Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@olback yeah, me too! I can't go back now.. using anything which allows null pointer dereferences just seems unreasonable now.
-
Also really liking it, but haven't done anything bigger than basic stuff.
I'm always riddeling when to use str and when string (and why).
Also due to some changes you always have to look out which version (e.g. stable, nightly) of Rust you have to use for some libs. -
@KnutKnutsen yeah, it is kind of fiddly at the beginnig.. Strings are basically objects stored in the heap, while str's are basically only a view into a utf-8 encoded string, so they are only references basically. so you can't copy their memory into an object, unless you use a String object.
And the only real disadvantage of Rust (that I see) is that many libraries are still work in progress, and there are very few frameworks to use. Generally Rust has a "bottom up, but correctly" approach, so there are few libraries, but the good ones are.. godlike. They can be extremely powerful, because they are efficient, safe and generic. -
@heyheni that's hard to say, because Rust is not exactly aiming to be a better Java. Rust has a different approach to object orientation and is more focussed on efficiency than on simple conceptualization, although designs in Rust tend to be simpler because they are more explicit and robust.
I think they are a different niche. But I can definitely see Rust replacing C++ and maybe even C in large parts. -
@fuckwit Where do you work? :) I want too. My project manager decided to use Go for backend instead of Rust 😩 we could have even used Rust for frontend using WASM, but he was not sure if the technology is mature enough yet.
-
fuckwit12165y@simulate well I am the only one that uses rust in my company :D for our normal backend tasks it's mostly ruby or php (I luckily don't have to touch php :D)
And I would agree with your boss that rust and wasm front end is not mature enough. It's getting there but even wasm itself is missing a lot of stuff. -
@fuckwit Yes that might be true.. I just believe it would be worth it to invest time into it and contribute to the language. It is a much better long term investment compared to Go, in my opinion, because Go is just so much more prone to bugs. But of course my company mostly wants to get results as soon as possible, and believes Go will provide that. I don't see it, in the long run.
-
fuckwit12165y@tague hey that doesn't look bad. Some more error handling and fewer unwraps(except in tests) and that's it.
-
@tague Oh I don't think it's that bad. I really like the err_type macro! I just can't wrap my head around the macros 😂
What I would improve here is to use the assert! macro in tests, which will output useful information and takes less code, and I think you could make more use of iterators and functional functions like map and fold. These usually take less code and make the code easier to understand and edit. Also they are safer because they usually work with the Option and Result types, so that there is less implicit meaning in the code, as is the case with using a bool to indicate the result of the operation. Usually it is best to return an Option or a Result if an Operation can turn out empty or fail, respectively. -
@heyheni I'd like to say that D would be more likely, but D doesn't really have any major corporate backers, despite having really good mindshare on the core team.
-
@tague Yeah it can become hard to remember the types when working with them.. but check out things like Option::flatten and Iterator:: flat_map. They will take away one level of nested Options.
-
I use rust at work unfortunately, its the least flexible, most annoyingly handholding piece of crap ive ever seen
-
@tague absolutely
@yellow-dog it takes a while to get comfortable with it, you can't be impatient. It is called "fighting the borrow-checker" for a reason 😅 but once you learned all the rules it really makes sense and you will barely ever have run time crashes anymore.
In rust I can make extremely complex additions and when it compiles, it just runs, and most of the time, it does what I want. -
@simulate been using it for a year now. Guess what, i dont have runtime crashes in ocaml nor scala, because i know what im doing. Rust is cool if you are a beginner in low/er level programming but a pain in the ass if you try to do anything remotely complex.
And just for the record, i dont mean making a rest api, i mean heavy maths, encryption, parsing, networking, the things its supposed to be good at. -
@yellow-dog check out the nom crate. I don't think parsing can get any simpler.
Here I use it in one of my projects:
https://github.com/mankinskin/...
Some parts are admittedly a bit ugly, but it handles a lot of cases. -
@yellow-dog but as I said, Rust is focussing on efficiency a lot. It is not meant to replace Java or scala or anything. If you want performance close to C, on par with C++, then you can't get anything better than Rust nowadays.
-
@simulate yeaaaah nope, thats just a weak imitation of what functional languages do out of the box.
Edit: i hate cpp but u would argue that rust is any better for that specific usecase than c.
@tague ill probably write a blogpost about it because its too long to fit in a rant -
@yellow-dog I have only used haskell as a functional language yet, and of course, many things are wonderfully simple in functional languages. But most functional languages are simply not fast enough or allow for such deep fine grained control as C or C++ do. Rust kind of meets the middle, with allowing deep control under strict rules, and providing functional style libraries. But it is still an imperative language.
-
Bubbles66125y@yellow-dog I’ve heard it can be really handholdy, is it that bad?
I love C and I thought of maybe trying Rust to see what it’s like. Not to replace C but just to add to my tool kit.
I’ve seen the syntax but I need to know the good parts along with the bad parts with no sugarcoating on either side so I can judge it properly so I know if I should give it a chance.
Related Rants
Have any of you already used Rust? And what do you think of it? :)
Personally, I love it.
rant
rust
emerging
programming languages