Live data from Hacker News

Ask HN: Why do you use Rust, when D is available?

news.ycombinator.com

161–170 of 262 posts

Re: Ask HN: Why do you use Rust, when D is available?

#161
post #151

As far as I know, D does not have ADTs (algebraic data types, a.k.a. tagged unions, a.k.a. Rust enums). I see that it has "enums" and "unions", but neither of these appear to be ADTs if I'm reading them correctly. And Rust's borrow checker can give very strong guarantees that aren't present in any other mainstream language that I'm aware of. In Rust, you can pass mutable references to large data structures between th…

> The cost of this borrow checker is huge: every reference in every program needs to be annotation with whether it's shared or mutable No. You need to "annotate" a mutable binding since bindings are immutable by default. But that also means that immutable bindings (ie the vast majority) does not to be "annotated". And even when you do need to, you literally just add the keyword `mut` as in `let mut foo = 42;`. > and…

Totally agree. I should have said "add sufficient annotations to distinguish shared references from mutable references", and "occassionally need to splatter confusing lifetime annotations all over the place".

EDIT: What's really relevant is that you can look at a Rust type, and tell whether it's shared, mutable, or owned; this is what Rust's borrow checker derives its power from. Likewise, Haskell's type system derives its (equally amazing) powers from the fact that you can look at a Haskell function's type signature, and tell what kinds of side effects it has. (Sometimes people think that Haskell functions don't have side effects in the sense that they never mutate anything. This is wrong; Haskell has mutable arrays in its standard library. Rather, it's that all side effects are reflected in a function's type signature.) https://hackage.haskell.org/package/array-0.5.4.0/docs/Data-...

I write Rust code for work, and we have a large codebase. We manage it pretty well, but there are definitely still innocuous looking changes that require adding lifetime annotations all over the place to avoid confusing error messages.

Rust is my favorite language by far (I get the impression you like it too and are defending it). I think the costs of its borrow checker are worth it, but they are significant costs.

Re: Ask HN: Why do you use Rust, when D is available?

#162
post #81

Earlier quoted context omitted.

I've been writing C++ professionally for 16 years. I'm doing it right now in fact, but snuck on to HN while a build is underway. OP is right, unfortunately. C++ is a dying language. Mozilla, Microsoft and Google are all looking at Rust. Why? Because it's probably makes more sense to rewrite a buggy C++ component in Rust instead of updating it to use modern C++ (where admittedly, you have to go out of your way to get…

C++ was a dying language in the 2000s. But they turned it around with C++11. Now it has iterative 3 yearly updates and it's getting pretty good. It's far too premature to declare its death. The pace of development of C++ is decently fast and there's many stakeholders with millions of lines of C++ who are interested in C++ not dying. C++ is taught in universities around the world so the chance of C++ developers becomi…

The C++ they teach in universities is either just C, or putting Java spin on C (C-with-classes). I've never seen a decent "modern C++" class taught in universities.

Re: Ask HN: Why do you use Rust, when D is available?

#163

The syntax is nicer. Granted, I'm not very familiar with D. I didn't even know it had a borrow checker. Rust took a lot of great features from Haskell, while keeping itself reasonably approachable from a C/C++/D/Java programmer's perspective. Rust put type names after variable/function/parameter names, which really cleans up the syntax nicely. Rust has very nice syntax for pattern matching, monads, and a slew of othe…

One of the reasons why I haven't approached Rust is its syntax. Subjectively ugly and polluted with punctuation symbols that tell you little about their semantics. D looks cleaner and more readable even for a person not familiar with the language. D's readability is on par with scripting languages. Rust is far away from that. Type names after variable or before? When you think about declaring a variable, do you think…

> Type names after variable or before? When you think about declaring a variable, do you think about its type of name first? I can't imagine you do the latter because "Hmm, I need an array of doubles to represent my tensor" is double[][] tensor; and not tensor: double[][].

You can just as equally think of it as, "I need my tensor to be an array of doubles".

That works much more cleanly with type inference, because the type is more of an annotation, and you can drop it without adding the boilerplate word "auto".

> Subjectively ugly and polluted with punctuation symbols that tell you little about their semantics.

Like what?

Re: Ask HN: Why do you use Rust, when D is available?

#164
post #135

Earlier quoted context omitted.

I got scared away by rust's syntax. I feel that people can learn rust faster if they know c++ beforehand. c++'s syntax is scary too. But there are different levels of c++. You don't need to use the scary part to make things work.

> I got scared away by rust’s syntax. I’m curious about what you find scary about Rust’s syntax. I always found it to be a fairly natural extension of the syntax from C and other ALGOL-derived languages. Its semantics , on the other hand, took quite a while to wrap my head around. I am reasonably productive in Rust these days, and I still sometimes can’t predict whether or not the compiler will allow something.

As a Rust newbie: macros, lifetimes, and (when I really first started), closures. All of that syntax just seemed so messy to me.

The borrowing model was actually my favorite part because it not only was interesting, but made sense! And the syntax was relatively clean :)

Re: Ask HN: Why do you use Rust, when D is available?

#165

Earlier quoted context omitted.

I got scared away by rust's syntax. I feel that people can learn rust faster if they know c++ beforehand. c++'s syntax is scary too. But there are different levels of c++. You don't need to use the scary part to make things work.

Disagree. Sure rust has a notable syntax tax (not what it used to be) but that's the easy part! It's the concepts and mindset that are the biggest hurdle in Rust. Going to C++ first won't help you there. If you already know it, great but Rust is a different language and you'll spend a lot time trying to transfer C++isms over until you realize writing effective Rust is not like writing effective C++ and you go through…

> Rust is a different language and you'll spend a lot time trying to transfer C++isms over until you realize writing effective Rust is not like writing effective C++ and you go through a process of unlearning

Ding ding ding! However I do think that the combination of syntax with the brand new concepts just adds that extra layer of complexity. A similar thing is Optionals in Swift -- the syntax is so baked into the language that even if you really understand how optionals work, the syntactic sugar keeps piling up in different situations. (i.e., first the ? operator, then implicitly unwrapped optionals, then if lets, guards, guard lets...)

Re: Ask HN: Why do you use Rust, when D is available?

#166

The syntax is nicer. Granted, I'm not very familiar with D. I didn't even know it had a borrow checker. Rust took a lot of great features from Haskell, while keeping itself reasonably approachable from a C/C++/D/Java programmer's perspective. Rust put type names after variable/function/parameter names, which really cleans up the syntax nicely. Rust has very nice syntax for pattern matching, monads, and a slew of othe…

The elementary Rust syntax looks nicer. But once you start to do more intricate thing in Rust, then the syntax starts to look really ugly. I think this is where Rust falls apart. In things like C, more features requires writing more C code. In Rust, more features requires learning more syntax features.

How so?

My opinion is generally the opposite, that simple decisions like putting type annotations after names, etc. make it so each unavoidable complexity in syntax has its own home, instead of piling together like C++/Java/etc.

Re: Ask HN: Why do you use Rust, when D is available?

#167
post #33

Earlier quoted context omitted.

Why did go took off then?

It's impossible to measure how much impact just having Rob Pike and Google behind Go has had on its adoption.

You're saying "it's impossible to measure", but it sounds like you have an assumption about the answer...

Re: Ask HN: Why do you use Rust, when D is available?

#168
post #99
post #57

Earlier quoted context omitted.

1. Could you give a few examples of libraries that can’t be made in Rust due to lack of abstraction compared to C++? GUI libraries apart, I can’t think of anything offhand. 2. True, but growth curves are rarely linear. Here’s a rough proxy on users - the number of subscribers to /r/rust - https://subredditstats.com/r/Rust . Look at the growth between 2014-18 and 2018-2020. You’re extrapolating on current growth rate,…

1. Could you give a few examples of libraries that can’t be made in Rust due to lack of abstraction compared to C++? I'm guessing, but I think that something like Armadillo[1] would not be possible on stable Rust. Something like Catch[2] might also difficult to make ergonomic. I don't program in C++ anymore and I would personally live with the lack of expression/abstraction for a safer language though. [1] http://arm…

Can you elaborate on why Catch would be impossible or unergonomic? It's a test framework, right? Why would one even use it instead of the normal rust test framework?

Also, how is it ergonomic? I'd agree if you say that it's (one of?) the best for C++, and it's also my go-to option, but ergonomic?

Re: Ask HN: Why do you use Rust, when D is available?

#169
post #148

Earlier quoted context omitted.

The only language that one can honestly say that is dying (if not already dead) is VisualBasic. Perl and Delphi are probably going to continue to decline. Objective-C will be obsoleted by Swift some day, but is still relevant. Ruby's not too hot now, but far from dead AFAIK. Other than that it's nonsense to say that X is dying.

C++ is being blamed for allowing people to write buggy, insecure programs. In my mind, that's different to just becoming unpopular; it's dying because it's too dangerous and too complicated. Sure, it'll stick around for some years yet but all those jobs will become maintenance jobs. Very little greenfield projects will elect to use it outside of niche areas (games and maybe embedded - UK salaries for embedded dev are…

My company starts new programs in C++ because everyone knows C++ already, we write modern C++, our libraries are written in C++, and our bugs are mostly not memory safety issues.

Re: Ask HN: Why do you use Rust, when D is available?

#170
post #152

Because Rust is new and shiny. People who use Rust aren't using it to solve real world problems, they're using it to scratch a novelty itch. D is a tragedy in my opinion. It's an excellent language that just doesn't fit the political needs of any of the big players. We have Swift which is a worse version of C#, we have Go, we have Java. Why don't we have a single language so that we can do cross platform development…

> It's only a game developer of all people, Jonathan Blow, that's doing it and his creation is a C++ replacement for games, not general purpose software. Sigh. That would still be huge. C++ keeps being used because of games. There's little to no C++ software being written nowadays that's not games. And games are a gigantic industry, bigger than the film and music industries combined. Many game developers would love t…

> There's little to no C++ software being written nowadays that's not games.

You need to look around more, because you are totally wrong on this point. It's true that C++ isn't used a lot in web programming, and web programming is what a lot of people see these days. But there is a lot more software being written than web programming and games, and C++ is still in fairly significant use.

Post reply on HN