Akira1364How many times do I need to mention Free Pascal?•

Combines what’s best in other languages (be it old or new) and avoids their mistakes

No class-inheritance

lol doomed to an eternity of no gui

34
[deleted]•

unjerk Why do you need class-inheritance for GUI's?

18
Tysonzero•

You don't even remotely need it.

22
FluorineWizard•

You don't, it's just that the popular desktop GUI frameworks tend to be traditional inheritance-heavy OO, which causes a very annoying impedance mismatch with idiomatic Rust.

There are initiatives to provide an idiomatic Rust interface for those frameworks, like relm, but this part of the Rust ecosystem is not mature.

15
TheLastMeritocratOP•

What I find really hilarious is how the OOP propaganda from the 90's got to the GTK+ people on the design level, but not the language level. A mismatch that keeps giving.


I feel a lot of doors will open for Rust once this postponed RFC gets implemented.

18
slavik262Considered Harmful•

Who doesn't like to start their day by rolling their own vtables?

3
ArkyBeagle•

I may be misremembering which is GTK but the Tk GUI framework from Tcl seems to have been copied everywhere. It's not half bad, really. I say that as an essentially non-GUI programmer who has to write one now and again, so I'd defer to specialists for whom it might not be all that.

2
tpgreyknightnot Turing complete•

but this part of the Rust ecosystem is not mature

In the sense that it's still in nappies, yes.

7
[deleted]•

In the sense that it's an absolute dead end because Rust, while great for other things, is fundamentally incompatible in every way with GUI development, yes.

5
TankhouseAle•

not denigrating the work of the relm devs, but nobody wants to use GTK if they can help it. It looks like shit on Windows and Mac, making the whole library pretty much a non-starter on those platforms.

5
[deleted]•

[deleted]

2
Akira1364How many times do I need to mention Free Pascal?•

Well, you don't if your definition of GUI is just "using one specific framework by directly calling its methods in a procedural fashion via simple bindings for your language of choice." That's not mine though.

8
TheLastMeritocratOP•

Translation:

Well, you don't if your definition of GUI is just "Not what free Pascal does." That's not mine though.

18
Akira1364How many times do I need to mention Free Pascal?•

lol what would possibly be more desirable than having already implemented the cross-platform native GUI solution that people who don't know better are constantly complaining about not existing? That's exactly what Lazarus is.

Are you saying that if it were viable in the somewhat near future for someone to write a RAD IDE entirely in Rust that allowed for that kind of development, you wouldn't want them to?

7
tpgreyknightnot Turing complete•

Here we go again!

3
Tysonzero•

Jesus you don't need to do that at all in basically any non-OOP framework.

Is your head really stuck that far up Pascal's ass?

Have you ever used a non-OOP language or even used any non-OOP features in any language?

Did you know that inheritance isn't the only form of ad hoc polymorphism?

11
Akira1364How many times do I need to mention Free Pascal?•

lol not being able to comprehend the existence of a language that is equally good for doing procedural programming targeting embedded devices using zero classes as it is for full-on enterprise style desktop OO programming using nothing but classes.

And yes, I quite often use generics instead of inheritance in Pascal in places where it makes sense / is possible.

As far as other languages, I've worked quite a bit in C too (much to my chagrin honestly) as well as C++, although I guess C++ would be moreso categorized as another OO language.

10
idobaiI've never used generics and I’ve never missed it.•

Did you know that inheritance isn't the only form of ad hoc polymorphism?

Inheritance belongs to the class of universal polymorphisms, specifically: inclusion polymorphism.

Is your head really stuck that far up Pascal's Haskal's ass?

4
tpgreyknightnot Turing complete•

Is your head really stuck that far up Pascal's ass?

I didn't think that was still a point of debate at this stage.

1
[deleted]•

Any system that provides ad-hoc polymorphism could be used, not just OO.

Just having generic methods al a CLOS, even without inheritance, would be enough for that (or typeclasses, or traits...)

7
saddertadder•

wait wait wait

you cant do like

Class A extends B in Rust?

17
[deleted]•

It doesn't have classes at all. (It actually used to, but they were removed in version 0.4.) Now it just has enums (which are basically C enums combined with structs), normal structs, and unions. To add functionality you use traits.

28
snaketacular•

/unjerk

I guess this harkens back to the "what is a class" thing. In my very limited experience, you can implement methods and control member visibility on Rust structs, such that they resemble C++ classes closely, insofar as how you invoke them in day-to-day life (obj.method() syntax, RAII, etc.)

What Rust won't give you is fine-grained const interior member variables that are set once during construction, method overloading, and, as already mentioned, inheritance. For the latter, Rust wants you to use traits (read: interfaces) and composition instead.

TL;DR that's correct, u/saddertadder.

(edit: also, going offtopic, Rust enums are closer in spirit to C++ "enum + std::variant" than "enum + struct")

10
[deleted]•

[deleted]

2
DoListeningnot even webscale•

What is this the 90s?

I'll take a React-influenced library over manually mutating UI state any day.

10
Akira1364How many times do I need to mention Free Pascal?•

lol it doesn't sound like you understand how Lazarus works at all.

What exactly do you think the major differences are between it and something like React (other than the fact that React is a web framework, as opposed to a RAD IDE that is built with itself and makes use of its own GUI component library that abstracts different native frameworks)?

button onClick sure sounds a lot like TButton.OnClick if you ask me.

3
DoListeningnot even webscale•

What exactly do you think the major differences are between it and something like React

Eh, I'll try.

The minor point is the web-based part, which results in a lot of flexibility (easy to build all kinds of layouts and designs, at the cost of not having any uniform "platform-native" look - think Spotify for example). But that's not what I'm mainly talking about.

The big difference is the that in 90s-style RAD tools (Visual Basic and the like), you can typically only design the initial state of the UI - how it looks when the program first starts - and then you either manually mutate it in code, or use some kind of data binding library (or a mix of both).

Say you want to display some kind of data that you fetch from a server, e.g. a list of users, and a bunch of buttons next to each user for actions, then you can "expand" each user to see their email addresses and you can do a bunch of actions on those as well. Something like this: https://imgur.com/HxP0ix7.png

Then you have fields on the page that display some aggregate data (total number of users). And the whole screen can also be in a "Loading..." state (https://imgur.com/tnwJC54.png) and a "Failed to load data from the server" state.

With traditional GUI libraries such as Qt, this is a major pain in the ass to achieve. You have to awkwardly wrap your data by subclassing base model classes such as QAbstractItemModel. Then you have to manually notify the model of changes whenever new data comes in, deal with sorting and filtering via additional models, etc. And that's in the better case - the more naive solution would be to manually add/remove UI widgets, manually call .show(), .hide() on the loading screen, enable/disable, setText, and all the other mutation methods, which pretty much guarantees you'll end up with your UI being out of sync with your data sooner or later.

In React, this is way more pleasant to work with. You simply write a render() function that returns how the UI looks in the current state, kind of like immediate-mode rendering, so you can just do:

// Top-level component:
return <Box>
    {props.loading ?
        "Loading users..." :
        props.users.map(user => <User key={user.id} data={user} />)
    }
</Box>

.

// User component:
const data = props.data

let emailView = <span style={styles.loading}>Loading data...</span>
if (!data.loading) {
    emailView = this.renderEmailView(data.emails, state.isEmailExpanded)
}

return <Box>
    <span style={styles.name}>{data.name}</span>
    <ButtonGroup>
        <Button enabled={!data.loading} onClick={() => props.onUserApproved(data)}>Approve</Button>
        <Button enabled={!data.loading} onClick={() => props.onUserRejected(data)}>Reject</Button>
    </ButtonGroup>
    {emailView}
</Box>

And you don't have to worry about "changing" anything in the rendered UI, ever - the library calculates all the changes for you.

You just write a function that answers the question "given this particular state, how does the UI look?". This approach is not a magic bullet - there are still other parts of the app you have to design properly, but it is overall way more pleasant to deal with than any "traditional" desktop UI library.

I even tried writing a toy library like that, and this is a gif of working with it (1.1MB), that I have on its github page.

Does Lazarus have anything like that? (If it does, I just wasted a good 20 minutes writing a long-ass post, lol.)

6
[deleted]•

[deleted]

5
Akira1364How many times do I need to mention Free Pascal?•

Of course it does? I don't really understand how else you think it would work. See here and here for a simple example of the designer and some event handler code. (Sorry about the aspect ratio, not using my normal computer at the moment.)

When the slider changes, so does the progress bar. It's also possible to use RTTI-aware controls that can have their properties directly linked together, if you want.

2
[deleted]•

[removed]

0
Tysonzero•

unjerk

Lol wut, do you live under a rock?

6
Akira1364How many times do I need to mention Free Pascal?•

If asked you to write a GUI component library in Rust that interchangeably abstracted native WinAPI, Carbon, Cocoa, GTK1, GTK2, GTK3, QT4, QT5 and more, and then write an IDE using that library which could then itself be built against/in any of the underlying GUI frameworks allowing it to run on every platform and be used to build applications that could be seamlessly cross-compiled from any of them to any of the others, how would you do it?

11
saddertadder•

pwned that redditor le epic style, nice.

13
Tysonzero•

You think that because not every single GUI toolkit in your arbitrarily chosen set can be coded against, that therefore Rust is unviable for GUI programming? How retarded.

Not to mention I don't use Rust nor half of those GUI toolkits so why would I know? Spewing out requirements for things to do isn't even close to a valid explanation for why you think there is exactly one viable way to do GUI programming.

7
Akira1364How many times do I need to mention Free Pascal?•

lol there's nothing arbitrary about what I was describing at all. Lazarus is a real thing.

(That repo is just a mirror by the way, if you're wondering why there's zero issues for such a large codebase.)

12
TheLastMeritocratOP•

I think you need another translation:

If asked you to do what I can do with Lazarus and fpGUI, how would you do it?

6
BufferUnderpantsGopher Pragmatist•

Does it have to look native in any of those or you can use Free Pascal?

1
Akira1364How many times do I need to mention Free Pascal?•

I'm not sure what you mean by this TBH. Of course the code is always written in Pascal. I explained how Lazarus worked pretty explicitly in this comment.

2
SelfDistinctionnow 4x faster than C++•

lol still using MVC instead of ECS

4
Akira1364How many times do I need to mention Free Pascal?•

lol not realizing those serve two distinctly different use cases, and that it's possible for a language to be perfectly suitable for both. The way the Lazarus component system works isn't really either of them, also.

6
[deleted]•

[deleted]

16
adwhit86•

12x average performance increase

Only 12X?? Did you remember --release??

11
[deleted]•

[deleted]

5
kurashu89•

lol.unwrap().unwrap().unwrap()

Not enough unwrap.

9
ProfessorSexyTimeSoyboy•

even with the overhead of the rust binary having to open a mysql pool.

using reddit::pcj::unjerk;

Maybe it's because I don't know Rust and I'm lol unemployed, but what exactly is the overhead with that? Or what about Rust contributes to that overhead?

3
[deleted]•

[deleted]

3
tpgreyknightnot Turing complete•

unwrap() calls littered everywhere

AIUI doing this means you're a bad person and should feel bad

"?"

You can use try!{} instead if that's easier on your habits.

2
[deleted]•

[deleted]

1
[deleted]•

[deleted]

1
_errata_•

Can we link this thread as a circle jerk? Jesus fucking christ.

16
senntenialwhat is pointer :S•

Pcj is an extension of rustjerk and pascaljerk. You should get used to it.

6
Tysonzero•

I wouldn't really say pascaljerk, it's just one dude that likes it and everyone else taking the piss.

5
defunkydrummerlisp does it better•

I wouldn't really say pascaljerk, it's just one dude that likes it and everyone else taking the piss.

This but unhilariously.

5
mistertenxCode Artisan•

From the HN comments

I understand the advantages of Rust over C or C++, but what are the advantages over OCaml, Standard ML, D and Go?

13
username223line-oriented programmer•

I am RUST thy Language, which have brought thee out of the land of C++, out of the fear of concurrency.

Thou shalt have no other languages before me.

14
TheLastMeritocratOP•

Forgot Haskell and Nim.

11
[deleted]•

Love is fearless!

9
Disolationlanguage master•

Rust features:

  • zero-cost affection
  • love semantics
  • guaranteed intimacy
  • trust-based dynamics
  • passionate mating
  • marriage in time

someone needs to help me come up with the rest

23
DC2SEADO NOT USE THIS FLAIR, ASSHOLE•

Fearless polygamy

20
saddertadder•

intercourse without premature termination

7
TheLastMeritocratOP•

Does Rust impose a specific form of polygamy?

2
tpgreyknightnot Turing complete•

No, you can just do something like fn fearless<P : Polygamy>(p : P); and bob's your uncle.

2
r2d2_21•

come up with the rest

with the Rust*

2
olleharGets shit done™•

🎶 And suicide is painless. 🎵

4
SelfDistinctionnow 4x faster than C++•

Expected. People can't just learn Rust and then get on with their lives. They either love or hate it.

7
samnardoni•

I’ve just learned Love and I think I’m in Rust

5
skulgnomeCyber-sexual urge to be penetrated•

How can you say you've learned a thing, if you've not even written a To-Do List App in it and published on the To-Do List App Store?

5
enchufadoonot Turing complete•

I've just learned rust its time to annoy everyone.

4
[deleted]•

[deleted]

1
[deleted]•

[deleted]

1
[deleted]•

[deleted]

1