4 ms·
Rust is undoubtedly a step forward in correctness, but boy, the article's code is so thick that for me, that I am a C++ programmer, is almost unreadable, especi
by axilmar 4y ago
Rust is undoubtedly a step forward in correctness, but boy, the article's code is so thick that for me, that I am a C++ programmer, is almost unreadable, especially for a quick reading...
I skipped all the code and only read the text. I got to the point where it mentions that the language prevented them from storing a pointer to a stack object in a heap object, and that's really great, but boy oh boy, the code presented, and the error messages, where very difficult for me to grok even after the first few times...
It seems to me that the more sophisticated the safety a language provides is the more complex its error messages/code are. It would be so nice if we could solve both problems at the same time...
- dijit 4y agoFor whatever it’s worth: I think it’s harder to learn rust as a C++ programmer than it is for a new programmer. Reason being that you have to unlearn your paradigm before you’re able to learn the new paradigm; and it’s made slightly worse by giving the appearance of similarity (since certain concepts map directly, like flow control and loops).
- proto_lambda 4y agoOne big hurdle for C++ programmers learning Rust that I've seen time and time again in various community support channels is fixing their trust issues with the compiler. They are so used to compiler output being useless or worse than useless, they are unable to take advantage of rustc's stellar diagnostics (which frequently tell you exactly what you need to change to make things work) until they force themselves to actually read and internalise them. Once they realize that the tooling is actually working _with_ them, not _against_ them, they start to pick things up much quicker.
- lionkor 4y agoIn my experience only beginners have this issue, as a C++ programmer the compiler is my best friend.
- scoutt 4y ago> big hurdle Without going much further, to me it's the syntax. I can write some Rust lines of code, and I appreciate the compiler output to correct my syntax. But it's really difficult to me to read code written by others. I can't open a random file of a Rust project and have a minimal clue of what's going on After years of C and some C++, I have a parser implanted in my cerebellum, and it's hard to adapt it to Rust. To me, reading Rust feels like forcing an optical nerve to see something very small. Case in point, the code in this article.
- bilkow 4y agoOh yeah, I feel your pain, my brain is really used to Rust/Swift and Python syntax, and when I have to read Typescript/React, C++ or something like Nix, it gets hard for my brain to parse it. Loved the eyesight analogy!
- dgb23 4y agoI skimmed the code and there are a ton of language features in there that you might not be super familiar with: - pattern matching is quite expressive and ubiquitous in Rust, as in "stuff on the left" is almost always a pattern even in places that you might not expect at first - lifetime annotations, a form of generics, are quite unique and make the code more verbose/noisy if you are not familiar with them - Rust is expression based (a bit lispy) so you might not quite see the flow of the program as well if you are used to statement based syntax - traits are are an important part of the language and some of the methods and method chains you see there might look arbitrary, but many of them are very common. A more experienced reader can identify many of them and see the code very differently. - there is no syntax highlighting on the article's snippets so you already have to know how to parse them
- lawn 4y agoAs a Rust programmer I think the code could have been made much simpler and still get the point across. I think the author wanted to replicate the code as closely as possible, so it's more a case study than an educational piece if that makes sense?
- azakai 4y ago> It seems to me that the more sophisticated the safety a language provides is the more complex its error messages/code are. It would be so nice if we could solve both problems at the same time... That is incredibly hard, yes. But at least if you are ok with the overhead of GC or RC then this is a solved problem - the bug in question here wouldn't happen in Go/Swift/C#/Java/JavaScript/Python/Ruby/etc. And that is most software today. (But when you need maximal performance and maximal safety then Rust is an incredible option!)
- blub 4y agoAfter reading a good chunk of the Programming Rust book (minus concurrency, async and macros) I can understand that. My C++ experience helped a lot in comprehending and mentally mapping Rust concepts. As far as I can tell, that’s normal Rust code, but yes it’s unreadable if you come from C++ or another language and don’t know Rust syntax. The funny thing is that this kind of code is supposed to be the readable part of Rust :-)
- OneWingedShark 4y agoLook at Ada and its error-messages.
- TonyYayo 4y agoHello Axilmar. Incase you were unaware, a strong push for a DFUW relaunch is making strides, and team members are interested in having some discussion with you that include a possibility of being hired in some capacity. You can contact me on Discord as TonY#2011 and I can put you on direct contact with investors for more details. Hope to hear from you soon!
- adithyak 4y ago(Offtopic) Hey axilmar - I found your comment on a different thread[0] really interesting, and would love to chat with you about it. Couldn't find your contact details. Would you be open to emailing me? My email is on my profile. PS: Not a hiring / sales attempt. [0]: https://news.ycombinator.com/item?id=22288631 https://news.ycombinator.com/item?id=22288631