Live data from Hacker News

Matt Godbolt sold me on Rust by showing me C++

collabora.com

631–640 of 675 posts

Re: Matt Godbolt sold me on Rust by showing me C++

#631
post #630

Earlier quoted context omitted.

The result type is obviously insufficient for writing nontrivial programs, because nontrivial programs fail in nontrivial ways that need exceptional control flow. The result type does not work because you have to choose between immediate callers handling failures (they don't always have the context to do so because they're not aware of the context of callers higher up on the call stack) or between propagating all of…

The Result type works for an awful lot of people. Be careful with absolute statements like "does not work." When it works for many others, they might just assume it's a skill issue.

When I say "it doesn't work" I mean that it doesn't allow you to write good code, not "doesn't work" as in the sense that people don't like it. That latter one doesn't make any sense, as languages like PHP "work" for many tens (hundreds?) of thousands of people.

I'm well aware of the tendency of Rust programmers to write bad code, constrained by the language, and then be deluded into thinking that that's good code.

Re: Matt Godbolt sold me on Rust by showing me C++

#632
post #444

Earlier quoted context omitted.

There should be a way to have the function/method document what sort of stuff can go wrong, and what kinds of exceptions you can get out of it. It could be some kind of an exception check thing, where you would either have to make sure that you handle the error locally somehow, or propagate it upwards. Sadly programming is not ready for such ideas yet. --- I jest, but this is exactly what checked exceptions are for.…

Honestly I'm not even sure that Java checked exceptions are so bad in general compared to Result . The amount of verbiage is roughly the same. Where Java failed is the inability to write generic code that uses checked exceptions - e.g. a higher-order function should be able to say, "I take argument f, and I might throw anything that f() throws, plus E1". But that, as you rightly point out, is a Java problem, not a ch…

I liked checked exceptions. I just think they were overused. Had a CS prof that summed up the optimal case like this:

Programmer's fault: runtime exception

Not programmer's fault: checked exception

Reading from a file but the disk fails? Not programmer's fault. IOException (checked). Missed a null somewhere? Programmer's fault. NullPointerException (unchecked).

Re: Matt Godbolt sold me on Rust by showing me C++

#633
post #53
post #8

The one thing that sold me on Rust (going from C++) was that there is a single way errors are propagated: the Result type. No need to bother with exceptions, functions returning bool, functions returning 0 on success, functions returning 0 on error, functions returning -1 on error, functions returning negative errno on error, functions taking optional pointer to bool to indicate error (optionally), functions taking r…

I like so much about Rust. But I hear compiling is too slow. Is it a serious problem in practice?

Yes, Rust compiling is slow. Then again, I wouldn't say that C++ is exactly speedy in that area either. Nor Java. None of those are even in the same zip code to Go's compile speed.

So if you're cool with C++ or Java compile times, Rust will generally be fine. If you're coming from Go, Rust compiles will fell positively glacial.

Re: Matt Godbolt sold me on Rust by showing me C++

#634
post #53

Earlier quoted context omitted.

I like so much about Rust. But I hear compiling is too slow. Is it a serious problem in practice?

Compile times are the reason why I'm sticking with C++, especially with the recent progress on modules. I want people with weaker computers to be able to build and contribute to the software I write, and Rust is not the language for that.

C++ compiles quickly? News to me.

Re: Matt Godbolt sold me on Rust by showing me C++

#635
post #630

Earlier quoted context omitted.

The Result type works for an awful lot of people. Be careful with absolute statements like "does not work." When it works for many others, they might just assume it's a skill issue.

When I say "it doesn't work" I mean that it doesn't allow you to write good code, not "doesn't work" as in the sense that people don't like it. That latter one doesn't make any sense, as languages like PHP "work" for many tens (hundreds?) of thousands of people. I'm well aware of the tendency of Rust programmers to write bad code, constrained by the language, and then be deluded into thinking that that's good code.

Lord, grant me the confidence of this man who claims objective understanding of what does and does not constitute "good code".

Re: Matt Godbolt sold me on Rust by showing me C++

#636
post #635

Earlier quoted context omitted.

When I say "it doesn't work" I mean that it doesn't allow you to write good code, not "doesn't work" as in the sense that people don't like it. That latter one doesn't make any sense, as languages like PHP "work" for many tens (hundreds?) of thousands of people. I'm well aware of the tendency of Rust programmers to write bad code, constrained by the language, and then be deluded into thinking that that's good code.

Lord, grant me the confidence of this man who claims objective understanding of what does and does not constitute "good code".

I note that you did nothing to refute my point about why error-handling-via-return-values is insufficient and instead resort to emotional manipulation and logical fallacies.

This seems to happen a lot in the Rust community when people point out flaws in the language.

Re: Matt Godbolt sold me on Rust by showing me C++

#637
post #635

Earlier quoted context omitted.

Lord, grant me the confidence of this man who claims objective understanding of what does and does not constitute "good code".

I note that you did nothing to refute my point about why error-handling-via-return-values is insufficient and instead resort to emotional manipulation and logical fallacies. This seems to happen a lot in the Rust community when people point out flaws in the language.

Why should I defend Rust? You haven't even defined "good code", which has eluded the best minds in the field for as long as the field has existed.

You are not a serious person.

Re: Matt Godbolt sold me on Rust by showing me C++

#638
post #8

The one thing that sold me on Rust (going from C++) was that there is a single way errors are propagated: the Result type. No need to bother with exceptions, functions returning bool, functions returning 0 on success, functions returning 0 on error, functions returning -1 on error, functions returning negative errno on error, functions taking optional pointer to bool to indicate error (optionally), functions taking r…

The result type is obviously insufficient for writing nontrivial programs, because nontrivial programs fail in nontrivial ways that need exceptional control flow. The result type does not work because you have to choose between immediate callers handling failures (they don't always have the context to do so because they're not aware of the context of callers higher up on the call stack) or between propagating all of…

> The result type is obviously insufficient for writing nontrivial programs

Counterpoint: there are many non-trivial programs written in Rust, and they use Result for error handling.

Re: Matt Godbolt sold me on Rust by showing me C++

#639
post #637

Earlier quoted context omitted.

I note that you did nothing to refute my point about why error-handling-via-return-values is insufficient and instead resort to emotional manipulation and logical fallacies. This seems to happen a lot in the Rust community when people point out flaws in the language.

Why should I defend Rust? You haven't even defined "good code", which has eluded the best minds in the field for as long as the field has existed. You are not a serious person.

I don't need to define "good code" for my argument.

You're not a person capable of using logic, apparently. As is characteristic of Rust zealots.

Re: Matt Godbolt sold me on Rust by showing me C++

#640

Earlier quoted context omitted.

Package managers per language are a (relatively) new endeavor. The oldest language I can think of that widely adopted it was Perl. Although, perl was quite ahead of it's time in a lot of ways, and php undid some the work of perl and went back to popularizing include type dependencies instead of formal modules with a package manager. C++ "gets away" with it because of templates. Many (most?) libraries are mostly templ…

C++ is _getting_ modules now? You must be kidding. How can this language, that adds more and more and more features every couple of years _still_ not have one of the most fundamental way to modularize code, splitting it into semantic units? Like ... what?! I did not think C++ would be that bad when it comes to foundational aspects of a programming language. This must be the result of silly obsession with OOP. The typ…

Modules were added in C++20, but it's taken them this long to be implemented. Right now, only MSVC has full support according to https://en.cppreference.com/w/cpp/20
Post reply on HN