4 ms·
First taste of Rust
- hiker 12y agoFunctional C version for comparison https://github.com/skaslev/catmull-clark/blob/master/obj.c https://github.com/skaslev/catmull-clark/blob/master/obj.c
- maikklein 12y agoI was pleasantly surprised by the combination of pure functions.. But Rust doesn't have pure functions.
- simias 12y agoWell, rust does have pure functions (as most programming languages) you just can't tag a function as such to have the compiler enforce the purity for you (it used to, though). That being said I'm not sure why the author mentioned that point in particular. Maybe he feels that having immutable-by-default semantics encourages writing pure functions?
- PudgePacket 12y agoYou've hit the nail on the head!
- PudgePacket 12y agoHmm, perhaps I was a little overzealous in my attribution, I'll amend that, thank you.
- hucker 12y agoIs rust very geared towards writing network applications (like Go is to some extent) and lacking in other areas, or would you recommend it as a general language? I'm always curious about new languages, but my needs are mostly in maths/scientific computing. Would Rust prove a good (or at least OK) match?
- swah 12y agoI guess so. Do you know if Rust has bignum? What do you use now?
- klibertp 12y agohttps://github.com/jsanders/rust-bignum https://github.com/jsanders/rust-bignum
- NkVczPkybiXICG 12y agohttp://doc.rust-lang.org/num/ http://doc.rust-lang.org/num/
- klibertp 12y agoJust give it a try - my guess is that it will fare similarly to modern C++, excluding libraries availability.
- nulldata 12y agoNice article though some of the code is less elegant than it could be, normally you would match the option to unwrap it and then match it's value, instead of doing a lot of 'Some( .. )' matches. let first_character = match line.chars().next() { Some( v ) => v, None => return } match first_character { '# => println!("Comment"), ... }
- PudgePacket 12y agoI played around with a few different configurations for that particular part, even having something similar to yours that looked like match line.chars().next() { Some(x) => match x { '#' => ... 'v' => ... _ => ... }, None => ... } But I felt that the current approach was fine. At this point it becomes more a decision of style and taste vs any kind of practicality.
- deleted 12y ago[deleted]
- nfoz 12y agoWhy don't experts write articles? Why do I see "my first experience with x" so much more frequently than "I've written large complicated systems in x, here's how I use it"? I'm in no way criticizing the OP, I just wonder why these sorts of articles are especially valuable.
- mattgreenrocks 12y agoThey do get written; you just don't see them on the frontpage as often. The crowd selects familiar things, like fixating on the syntax of a language, or the emphasis on the act of constructing a program (rather than the long-term maintenance). HN and /r/programming are pretty much mouthpieces for pop culture programming. Reinventing the wheel is perceived as newsworthy. Now, there's nothing wrong with pop culture programming! The only problem is when you stop growing in abilities and understanding. Personally, I tend to read: * lobste.rs (like HN, but more tech and less startup BS) * /r/haskell * Lambda the Ultimate At all three of these sites I am regularly confronted with material I do not easily understand, so I lurk and take in what I can.
- dictum 12y agoThey are especially valuable to HN because most HN users have not used Rust for a long time [0]; they're still approaching the language. — I know your question isn't specific to this submission, but Rust is a new language, built to support an ongoing research project. Very few people, if any, could have written a large complicated system (apart from Servo). Even if an expert were to write an article explaining how they use Rust, it would be of little use to most people using Rust at this point in time. Example: Nobody was explaining how to use JavaScript for large complicated systems in 1998: the language itself wasn't ready for this kind of usage, and adoption hadn't reached the critical mass required for certain discoveries (language quirks, unexpected ways to do things, ready to use libraries and frameworks etc.) to be made. [0]: Substitute Rust for any new language.
- steveklabnik 12y agoAnd in some ways, very few people have ever used Rust for a long time, because it's always changing. If you read the same article a year ago, it would have been different.