

First taste of Rust - PudgePacket
http://pudgepacket.github.io/rust/2014/07/28/first-taste-of-rust/

======
nfoz
Why 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.

~~~
dictum
They 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
And 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.

------
hucker
Is 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
I guess so. Do you know if Rust has bignum? What do you use now?

~~~
klibertp
[https://github.com/jsanders/rust-bignum](https://github.com/jsanders/rust-
bignum)

------
hiker
Functional C version for comparison [https://github.com/skaslev/catmull-
clark/blob/master/obj.c](https://github.com/skaslev/catmull-
clark/blob/master/obj.c)

------
nulldata
Nice 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
I 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.

------
maikklein
_I was pleasantly surprised by the combination of pure functions.._

But Rust doesn't have pure functions.

~~~
simias
Well, 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
You've hit the nail on the head!

