Originally posted by CommunityMember
View Post
Announcement
Collapse
No announcement yet.
Linux Developers May Discuss Allowing Rust Code Within The Kernel
Collapse
X
-
- Likes 2
-
Originally posted by lyamc View PostI saw the comments of "write good C code" but the whole point of Rust is that even with great coders, eventually your code will do something with memory that you never expected. If you hate seeing memory errors then maybe you'd like to hear what they have to say.
Also, the Rust compiler is amazing.
- Likes 5
Comment
-
Originally posted by Marc Driftmeyer View Post
The Rust compiler like all compilers is written by humans, thus the idea of `amazing' is relative. Fifty years of C Programming development and being the foundation language all these other languages draw from speaks for itself and why every major OS Vendor kernels are written in C.
- Likes 15
Comment
-
Originally posted by discordian View PostRust is particularly stupid for not following the dominant syntax type then name, but using something close but not similar to math statements.
ie.:
let i: u32 = "42".parse()- Without a variable declaration marker keyword like "let", you get a parser ambiguity (is this line of code a variable declaration or not?).
- If you tried to fix this with some kind of "let type var = value" syntax, you still couldn't introduce type inference without adding another parser ambiguity.
- C's universally reviled function pointer syntax and C++'s most vexing parse show that type-then-name isn't as intuitive as it is sometimes lauded to be.
Last edited by HadrienG; 10 July 2020, 02:42 AM.
- Likes 10
Comment
-
Originally posted by wswartzendruber View PostIt would be a lot easier to discuss this if you told us what those reasons are.Last edited by curfew; 10 July 2020, 02:37 AM.
- Likes 3
Comment
-
Originally posted by HadrienG View PostType-then-name is a bad idea.- Without a variable declaration marker keyword like "let", you get a parser ambiguity (is this line of code a variable declaration or not?).
- If you tried to fix this with some kind of "let type var = value" syntax, you still couldn't introduce type inference without adding another parser ambiguity.
- C's universally reviled function pointer syntax and C++'s most vexing parse show that type-then-name isn't as intuitive as it is sometimes lauded to be.
Comment
-
Originally posted by jaypatelani View PostI am wondering why not ada? It is more robust and readable than rust.- Some language features (e.g. exceptions, variable-sized returns, multitasking features...) have heavy runtime requirements. So a bit like with C++, you need to learn, through much poorly documented guesswork, what subset of the language is usable on the bare metal and what isn't. Except it's worse in the Ada case because there are more such features. This is handled better in Rust, where most of the features that require runtime support are standard library features, not language features, as in C. The biggest exception AFAIK is panics, and even there the fact that `panic = abort` is a well-accepted language operating mode and not something that requires fiddling with weird compiler flags is a nice touch.
- There is only one Ada compiler that is not in maintenance mode, and its economic model means that unless you have a lot of money to spend, you will only get compiler updates once a year. Waiting a year for a compiler bugfix to be released is no fun.
- Because of this de facto GNAT monopoly and the generally low popularity of Ada OSdeving, little effort has been expended into properly documenting and standardizing the language implementation aspects that one needs to interface with when operating at the bare metal. Basically you need to dive into the source code of the GNAT runtime, which isn't terribly pleasant to read, and hope that you will eventually make sense of it.
Last edited by HadrienG; 10 July 2020, 03:02 AM.
- Likes 6
Comment
-
Originally posted by llukas View Postdoes most vexing parse still occurs with auto?
- Likes 2
Comment
-
Originally posted by indolering View Post
I don't understand your objection.... I really like the `name:type`syntax, as this enables type inference (`let v = "hello world"`) and prevents namespace collisions between types and variable names. `"42".parse()` feels very natural coming from an OO background (which is the dominant form of programming).
let i: u32 = "42".parse().unwrap(); is syntactic sugar for the equally valid let i: u32 = str:arse("42").unwrap(); or let i = str:arse::<u32>("42").unwrap();
(parse() takes advantage of one of the few ways Rust allows for method overloading so, if you don't specify a type on the variable, you need to use the ::<> "turbofish" operator to disambiguate what type you want it to return... and yes, there has been a lot of discussion surrounding the turbofish. It's agreed to be the best of a bunch of bad options with the only more elegant solution being to not use <> for denoting generic type parameters. Rust devs are big on managing parsing complexity.)
...and if anyone knows how to disable emoticon conversion for inline monospaced text under vBulletin, please let me know.
- Likes 4
Comment
Comment