I've just learned Rust and I think I'm in love
rskupnik.github.io/I-learned-rust-and-I-think...Posted Mar 30, 2018, 2:46 PM UTC
Posted Mar 30, 2018, 2:46 PM UTC
[deleted]
12x average performance increase
Only 12X?? Did you remember --release??
[deleted]
lol.unwrap().unwrap().unwrap()
Not enough unwrap.
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?
[deleted]
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.
[deleted]
[deleted]
Can we link this thread as a circle jerk? Jesus fucking christ.
Pcj is an extension of rustjerk and pascaljerk. You should get used to it.
I wouldn't really say pascaljerk, it's just one dude that likes it and everyone else taking the piss.
I wouldn't really say pascaljerk, it's just one dude that likes it and everyone else taking the piss.
This but unhilariously.
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?
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.
Forgot Haskell and Nim.
Love is fearless!
Rust features:
someone needs to help me come up with the rest
Fearless polygamy
intercourse without premature termination
Does Rust impose a specific form of polygamy?
No, you can just do something like fn fearless<P : Polygamy>(p : P); and bob's your uncle.
come up with the rest
with the Rust*
🎶 And suicide is painless. 🎵
Expected. People can't just learn Rust and then get on with their lives. They either love or hate it.
I’ve just learned Love and I think I’m in Rust
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?
I've just learned rust its time to annoy everyone.
[deleted]
[deleted]
[deleted]
lol doomed to an eternity of no gui
unjerkWhy do you need class-inheritance for GUI's?You don't even remotely need it.
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.
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.
Who doesn't like to start their day by rolling their own vtables?
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.
In the sense that it's still in nappies, yes.
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.
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.
[deleted]
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.
Translation:
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?
Here we go again!
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?
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.
Inheritance belongs to the class of universal polymorphisms, specifically: inclusion polymorphism.
I didn't think that was still a point of debate at this stage.
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...)
wait wait wait
you cant do like
Class A extends Bin Rust?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.
/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")
[deleted]
What is this the 90s?
I'll take a React-influenced library over manually mutating UI state any day.
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 onClicksure sounds a lot likeTButton.OnClickif you ask me.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 manuallyadd/removeUI 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:.
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.)
[deleted]
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.
[removed]
unjerkLol wut, do you live under a rock?
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?
pwned that redditor le epic style, nice.
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.
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.)
I think you need another translation:
Does it have to look native in any of those or you can use 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.
lol still using MVC instead of ECS
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.