Hacker News new | past | comments | ask | show | jobs | submit login

I’m not sure if this is a critique or a question. If former, then I don’t understand why would that matter. Even at 4 times the length of the code, Rust is safer, more robust and better optimized. So why would the length matter?



This might be a preference that isn’t universally shared, but I really do find shorter programs easier to read. I don’t mean code-golf style short, but languages that don’t need a lot of boilerplate or ceremony. I’ve frequently used Python on personal projects for over 20 years because of its expressiveness.

Of course, correctness trumps almost everything in programming. Rust seems like a really nicely balanced programming language that can replace C++ and C and provide additional protection against some kinds of common errors made by programmers. So it’s definitely on my list of languages to try next for a project.


>This might be a preference that isn’t universally shared, but I really do find shorter programs easier to read.

Even so, 1300 vs 1000, or 1.3x is not really in the "so much more as to be more difficult to read" category.

In fact it can be in the "better worded and easier to read category" (e.g. a monolithic stream of code without functions and comments vs one with).


You’re right. Ada has come up in this thread and there was a time when I was excited about Ada (I actually worked in a group that was competing in the early Strawman—Ironman proposals that led to the design of Ada), but Ada really is too verbose for my taste.

Rust might end up being just right, not too concise, like Haskell or APL, and not too verbose, like Java or Ada; it could be a Goldilocks language.


One of Rust's selling points is zero cost abstractions which would normally imply doing more work with less code (as you would expect in a high level language like Python). So it is surprising that it takes that many more lines of code to achieve what C does without those abstractions.


1300 vs 1000 is not "that many more".

It's close to insignificant to comparing two languages. Especially when they boil down to things like:

  let ptr = unsafe {
        libc::mmap(
            ptr::null_mut(),
            len,
            libc::PROT_READ | libc::PROT_WRITE,
            libc::MAP_SHARED,
            file.as_raw_fd(),
            0,
        ) as *mut u8
    };
vs calling something like this in one line in C, etc.

The C version also crams every line together, the Rust version couples related statements but leave newlines between others (not sure if loc counts those too).


"zero cost abstractions" usually means you don't pay a performance penalty for abstractions you do not use.


Also means that the abstractions themselves don't introduce unnecessary overhead. It's taken from C++.

C++ implementations obey the zero-overhead principle: What you don’t use, you don’t pay for [Stroustrup, 1994]. And further: What you do use, you couldn’t hand code any better. – Stroustrup

https://blog.rust-lang.org/2015/05/11/traits.html




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: