Live data from Hacker News

Reflections on Rust, and the Sand Castle Metaphor

brandur.org

61–70 of 89 posts

Re: Reflections on Rust, and the Sand Castle Metaphor

#61
post #5

I do think the difficulty of Rust is brushed aside by its proponents. This week I wrote a little script to read an XML file, get a path from it, read a file at that location, do some regexes on it, and then update the XML and write it back to disk. I'd estimate it took me about 10 times longer to implement in Rust than Python. And I don't exactly know Python well - it wasn't just extra time Googling how to do things.…

> But that doesn't explain why I can't add two `String`s together using +.

Because that would consume both Strings, which doesn't make sense. The impl that exists only consumes the left string, reusing its buffer.

This seems like an odd thing to complain about since if you try it the compiler will tell you exactly what you should do instead.

Re: Reflections on Rust, and the Sand Castle Metaphor

#62
post #48
post #35

Earlier quoted context omitted.

Neither OCaml[1] nor Haskell[2] has performance competitive with Rust. It’s impressive how many high-level functional features Rust was able to include, but it’s ultimately a systems language—and it’s unique precisely because it’s a fast systems language that can give the sorts of high-level guarantees usually reserved for GC languages. [1] http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan... [2] https://b…

Depends what you're competing on. IIRC (can't view your link) OCaml/Haskell performance is much closer to Rust than it is to Python (runtime tends to like x for rust, 2x-5x for OCaml/Haskell, and 70x or more for Python) - if IshKebab's starting point was "my Python script is too slow, I need something an order of magnitude faster" then OCaml/Haskell would be competitive with Rust in that space.

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

stirner seems to mean something different by "competitive".

Re: Reflections on Rust, and the Sand Castle Metaphor

#63
post #5

I do think the difficulty of Rust is brushed aside by its proponents. This week I wrote a little script to read an XML file, get a path from it, read a file at that location, do some regexes on it, and then update the XML and write it back to disk. I'd estimate it took me about 10 times longer to implement in Rust than Python. And I don't exactly know Python well - it wasn't just extra time Googling how to do things.…

You need to type your Python code extremely fast to finish it 10 times faster than this Rust program:

    extern crate xpath_reader;
    extern crate regex;
    
    use std::io::prelude::*;
    use std::fs::File;
    
    use xpath_reader::Reader;
    use regex::Regex;
    
    fn main() {
      let mut contents = String::new();
      File::open("test.xml").expect("Unable to open the file").read_to_string(&mut contents).expect("Unable to read the file");
      //println!("File contents: {}", contents);
    
      let reader = Reader::from_str(&contents, None).expect("Cannot parse XML file");
      let files: Vec = reader.read("//file").expect("Cannot find file entries in XML file");
      //println!("Files: {:?}", files);
    
      for file in files.iter() {
        println!("File: {}", file);
        let mut contents = String::new();
        File::open(file).expect("Unable to open the file").read_to_string(&mut contents).expect("Unable to read the file");
        //println!("File contents: {}", contents);
    
        let re = Regex::new(r"foo bar").expect("Cannot compile regex");
        let replaced = re.replace_all(&contents, "baz").to_string();
        //println!("File contents: {}", replaced);
    
        File::create(file).expect("Unable to overwrite the file").write(replaced.as_bytes()).expect("Unable to write to file");
      }
    }

Re: Reflections on Rust, and the Sand Castle Metaphor

#65
post #31

Earlier quoted context omitted.

I had the same experience with any programing language with a rich set of libraries since the 16 bit days.

Oh come now, anyone who's worked with C or C++ knows there's a million pitfalls in porting code across platforms. Heck, C doesn't even guarantee that a byte is exactly 8 bits. The point I was making is that I was able to do this without a single ifdef/platform specific code without even planning for it(since it was the first time I'd cross-compiled for more than one other platform). While that's common in the VM lang…

There are more languages on this world that compile to native code, besides C and C++.

It not my fault not everyone bothers to learn them.

Re: Reflections on Rust, and the Sand Castle Metaphor

#66
post #20

I have a hard time believing that Rust's guarantees make it safer than easier statically typed languages like Java or Go. Rust is hard because it is solving a different problem, memory management without a garbage collector, not because it has the strongest correctness guarantees.

My experience would disagree with this. Features like enums, traits and newtypes make it easy to encode a lot more of your programs invariants statically, and in ways which naturally fit the problem domain (as opposed to Java where I often feel like I'm trying to squash my structure into a class hierachy which it doesn't really fit). In addition the explicit error handling (together with enum error types) allow the c…

Maybe Java is a bad example. But there are plenty of languages that have similar features to what you mention that are a lot easier to learn.

Re: Reflections on Rust, and the Sand Castle Metaphor

#67
post #55
post #53

Earlier quoted context omitted.

From the article > This is especially true when it comes to the more complicated ones like moves and futures, but also true for simpler ones like borrows. What I didn’t know when I wrote about it in frustration a month ago is that it doesn’t take a little longer longer to be effective in Rust compared to other languages, it takes 10 to 20 times longer. I think futures might be exacerbating the authors problems. There…

Too many articles about Rust talk about why the current language sucks, but some feature in progress will fix it. Rust started out with roughly the complexity level of C++, and it's become more complex from there.

I agree with both of your comments, I've noticed exactly the same thing. Every feature that fix something brings more complexity and have probability that will not interact nicely with some other features which means you need to make another feature that will fix that and then that feature...

Soon people will use different dialects of the language like in C++ and like in C++ only few will be able to say that they really know the language.

How will managing huge enterprise projects will look like in future? With average developers maintaining it and not language experts like in case of Mozilla Servo?

Time will tell I suppose. I am little bit pessimistic but I hope to be proven wrong.

Re: Reflections on Rust, and the Sand Castle Metaphor

#68
post #17

This is not at all specific to rust: OP is just grateful for the compiler to find lots of problems one would have to write tests for in dynamic languages.

It's not even specific to compilers; it's any type-checker. Compilers just happen to include one.

The advantage is that it not possible to forget to use it.

Re: Reflections on Rust, and the Sand Castle Metaphor

#69
post #36
post #17

This is not at all specific to rust: OP is just grateful for the compiler to find lots of problems one would have to write tests for in dynamic languages.

I agree with you if we replace "dynamic language" by "not as strongly typed". C is not exactly dynamic but its type system is prehistoric compared to Rust. For instance C's equivalent of Rust's enum would be tagged unions, however the compiler cannot enforce the semantics of tagged unions and will gladly let you access random members regardless of the tag. Same story with the borrow checker compared to C's "whatever…

I agree, just did not consider it worth anyone's time to go into details the OP does not even touch. The article compares rust with js and ruby....

Re: Reflections on Rust, and the Sand Castle Metaphor

#70
post #65

Earlier quoted context omitted.

Oh come now, anyone who's worked with C or C++ knows there's a million pitfalls in porting code across platforms. Heck, C doesn't even guarantee that a byte is exactly 8 bits. The point I was making is that I was able to do this without a single ifdef/platform specific code without even planning for it(since it was the first time I'd cross-compiled for more than one other platform). While that's common in the VM lang…

There are more languages on this world that compile to native code, besides C and C++. It not my fault not everyone bothers to learn them.

Yup, which you're happy to point out in every single thread about Rust. I can set my clock to a post from you about how another language did it first, it's about a useful as a comment saying "+1" these days.

Why not celebrate that these concepts are making it into more and more languages? Languages that have rich, vibrant communities and ecosystems.

Seems a lot more productive to me then yelling at the kids to get off your lawn.

Post reply on HN