It's the only compiler I've ever seen alert you if you're using a Greek question mark ; instead of an actual semicolon ;
Rust
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
I sometimes can't believe how helpful rustc is.
Yeah I think the reputation was probably deserved early in Rust's life, but as time has gone on it has gotten a lot easier to write, especially with the non-lexical lifetimes update 3 years ago.
Anyone here remember Pascal and its successor, Modula-2?
No, but if you want to write Delphi for a living, I can hook you up.
@vk6flab Pascal was my learning language!
For me it was 6502 assembly and Applesoft BASIC, followed by Commodore BASIC :)
Definitely! The only other language where I felt the compiler actually helped me was Haskell. C and C++ just go like "something is fucked, you figure it out".
I think the learning curve exists but it has been vastly overestimated by the rumours. I have many years of experience with Rust now, just ask if you are unsure of anything. Feel free to tag me in any post or PM me, then I'll definitely see it.
Currently I am trying to figure out how to access and change single characters in a string (I am coding a basic version of hangman to get used to working with rust). The main problem I have is, that I can not figure out how to change the value of a single character in a string based on its index. I have a string (that has the same length as my "word to guess") containing only underscores and whenever the user correctly guesses a character I want to replace the underscores by the guessed character to show the user how much he has guessed so far. I was able to turn the string into a char iterator, but I could not figure out how to change elements of said iterator (this can be seen at line 55).
The code is here: https://pastebin.com/kfSYWT42`___`
I was able to turn the string into a char iterator, but I could not figure out how to change elements of said iterator (this can be seen at line 55).
You have a few options here, but the easiest is to collect into a Vec<char>, replace the character there, then do a String::from_iter(chars) to get it back as a string.
You can also manipulate the original chars iterator directly through takes, skips, and so on and collect it into a string, but that's more complicated.
Also, "character" is such a complicated concept because unicode is not simple. If you can work directly with bytes though, you can convert the string to a Vec<u8> (which is the underlying type for String), manipulate that directly, then do String::from_utf8 (or the same method for str) to convert it back to a string.
This is simply not possible in rust, because strings are utf-8, so the size of a single character can vary. I think there might be a class for ASCII strings, but otherwise you can just use Vev and then convert to string
For bash scripting, shellcheck is your missing ingredient.
It's better than nothing but it really only drags Bash from "your code is definitely horribly broken" to "your code is probably broken". Nothing like Rust!
Haskell is also extremely picky about programs though GHC's error messages are notoriously confusing. Basically they say "error at line 123" with a bunch of incomprehensible spew saying what the error is. So you ignore the spew, look at line 123, and squint til you figure out what is wrong. In practice that method actually works once you get used to it. C++ is kind of similar IME.
You might also give Ada a try. Its goals overlap Rust's and I'd like to have some familiarity with both.
Based on your mentions of Python and bash, I'd say spend more time on languages with serious type systems. Rust, Haskell, Ada, ML, and maybe pointy headed languages beyond Haskell.