News for hackers. Stuff that matters.
Re:Sayonara, C++, and Hello to Rust by CyberRabbi on Tuesday December 07, 2021 @01:39AM (#29469639)
> I plan on writing several posts about Rust features, why they’re an improvement upon C++ features, and why Rust is a better, more modern programming language.

I’m always impressed that Rust turns people into such devoted evangelists after relatively little experience with it. This is a testament to its quality.

Re:Sayonara, C++, and Hello to Rust by jstx1 on Tuesday December 07, 2021 @03:01AM (#29470066)
When I see someone very devoted to a programming language, I see it as a sign that they might have problem with their perspective, not as a testament to the language's quality.

Rust might be great (I don't know) but this aspect of the community makes me less likely to try the language, not more.

Re:Sayonara, C++, and Hello to Rust by xondono on Tuesday December 07, 2021 @05:56AM (#29471142)
I think a lot of people don’t realize that for people at the bottom of the stack Rust is almost a revolution.

We’ve had basically no alternative other than C, with a lot of failed attempts at half supported C++. A lot of us suffered the horrible experience of working with severely lacking C++ compilers in the embedded space. Unless you were working with ARM or on top of linux, C++ was a bad idea.

Re:Sayonara, C++, and Hello to Rust by gmueckl on Tuesday December 07, 2021 @08:59AM (#29472493)
C++ on bare metal microcontrollers works quite well. I've done that. You have pretty much the same restrictions as C or rust in that space, even though they look a bit different due how C++ works. But then again, you also need learn which parts of C or rust you can use in that environment.
Re:Sayonara, C++, and Hello to Rust by xondono on Tuesday December 07, 2021 @11:18AM (#29474263)
Let me guess, you’ve done it with ARM microcontrollers.

Pretty much until ARM, support was terrible.

Re:Sayonara, C++, and Hello to Rust by gmueckl on Thursday December 16, 2021 @06:39AM (#29577227)
The codebase was originally written for V850 and quite mature by the time I joined. It was ported to ARM.
Re:Sayonara, C++, and Hello to Rust by gefhfff on Tuesday December 07, 2021 @03:14AM (#29470148)
Why?

( I didn't care a bit about this aspect when I approached Rust )

Re:Sayonara, C++, and Hello to Rust by gmueckl on Tuesday December 07, 2021 @03:44AM (#29470313)
Because a community with a strong devotion to a new tool is evidence of a strong reality distortion field and the reality is then decidedly less rosy than the followers of the new creed proclaim.
Re:Sayonara, C++, and Hello to Rust by gefhfff on Tuesday December 07, 2021 @05:45AM (#29471066)
> is evidence of a strong reality distortion field

How so?

Re:Sayonara, C++, and Hello to Rust by mgaunard on Tuesday December 07, 2021 @04:07AM (#29470433)
The reality is that programming with a language like Rust or C++ takes a higher level of expertise, those are more sophisticated tools than web technology.

You need to invest a lot more to use the tool well, but then the tool can do a lot more.

Re:Sayonara, C++, and Hello to Rust by jstx1 on Tuesday December 07, 2021 @04:18AM (#29470501)
That just sounds like snobbery; why even compare them at all.

> but then the tool can do a lot more

Can it? How do you measure that Rust/C++ do more than JS/TS given that they're used to solve completely different problems?

Re:Sayonara, C++, and Hello to Rust by mgaunard on Tuesday December 07, 2021 @04:56AM (#29470750)
Rust/C++ are not specific to certain types of problems, they can do anything.

That's a whole paradigm shift from using languages that are only fit for a given application domain.

Re:Sayonara, C++, and Hello to Rust by rmnclmnt on Tuesday December 07, 2021 @01:58AM (#29469737)
When reading the Rust Book and coming from a C++ background, it feels like every chapter brings a solution to an issue you have encountered previously. So yeah I think this gives C++ programmers hope to not lose too much hair anymore! (C++ made me bald the first 5 years!)
Re:Sayonara, C++, and Hello to Rust by usrnm on Tuesday December 07, 2021 @01:47AM (#29469679)
If JavaScript frameworks taught us anything, it's that people tend to fall for "new and shiny" much more willingly, than for anything related to quality.
Re:Sayonara, C++, and Hello to Rust by ioseph on Tuesday December 07, 2021 @02:01AM (#29469763)
I'm not too sure that's still the case in the javascript world. React is coming on to 10 years and still remains the most beloved framework.
Re:Sayonara, C++, and Hello to Rust by jayflux on Tuesday December 07, 2021 @03:33AM (#29470253)
That’s not really what was happening in the JavaScript world though.

It was a new ecosystem trying to figure itself out, and it takes quite a few attempts to do that. Both react and vue are near 10 years old, express is over 10 years, so it’s not “new and shiny” chasing.

Rust will go through the same thing before the dust settles.

Re:Sayonara, C++, and Hello to Rust by rapsey on Tuesday December 07, 2021 @02:07AM (#29469787)
Rust is not that new and shiny anymore.
Re:Sayonara, C++, and Hello to Rust by nindalf on Tuesday December 07, 2021 @02:24AM (#29469876)
Maybe that’s why they named it Rust. It sounds old and boring.
Re:Sayonara, C++, and Hello to Rust by FridgeSeal on Tuesday December 07, 2021 @03:27AM (#29470220)
For a bit of trivia, I believe it’s named after a fungus.
Re:Sayonara, C++, and Hello to Rust by nlitened on Tuesday December 07, 2021 @02:13AM (#29469812)
It has a new edition every year though :)
Re:Sayonara, C++, and Hello to Rust by rapsey on Tuesday December 07, 2021 @02:16AM (#29469829)
No it does not. 2015, 2018, 2021. With the 2021 changes so small few projects actually required any changes to be compatible from 2018.
Re:Sayonara, C++, and Hello to Rust by nindalf on Tuesday December 07, 2021 @02:35AM (#29469933)
The 2021 changes could be applied with an autofix tool - “cargo fix --edition”.

Most of these changes are small paper cuts that make sense to fix, but they’re breaking changes so they need to be opted into explicitly.

For example, earlier use a field x of struct b in a closure would capture the ownership of the whole of b. In rust 2021, the closure will only take ownership of b.x. This makes sense, but it’s a breaking change and therefore it needs an opt-in.

The Edition system is one of Rust’s biggest strengths IMO. Some languages never make breaking changes be enough if they’re small because it would break too much code. Other languages make breaking changes but expect users to migrate, placing a burden on them. The Rust edition system leaves it up to the user, on a per-crate (package) basis. Staying on the old edition is perfectly acceptable, as is moving to the new one.

Further reading - https://doc.rust-lang.org/edition-guide/rust-2021/

Re:Sayonara, C++, and Hello to Rust by GolDDranks on Tuesday December 07, 2021 @02:17AM (#29469831)
*every three years, actually. The current one is 2021, the one before that was 2018 and the (implicit) first one 2015.
Re:Sayonara, C++, and Hello to Rust by MaxBarraclough on Tuesday December 07, 2021 @02:28AM (#29469897)
I think that's at least somewhat particular to the web, though.

Plenty of 'C++ people' have been doing C++ for decades.

Re:Sayonara, C++, and Hello to Rust by tialaramex on Tuesday December 07, 2021 @06:45AM (#29471421)
It's the first new language I've learned (in let's call it 30 years of programming, not counting Turtle Logo or self-taught BASIC) which made me want to rewrite my programs.

I quite like several languages I learned, Java, Python, even C# is rather nice in some ways, others didn't make a dent, Scheme I had actually forgotten until I was asked about old Scheme code I wrote, ML was nice but too abstract for me... I am learning PowerShell at the moment for some reason, I can't say I'm fond.

However I never had any inclination to go back and rewrite software. The software already works, why change language? But I've already spent a bunch of time doing that in Rust because it's so much nicer than the C I wrote a lot of software in previously.

It's not just the language itself, which is pleasant, the tooling is excellent as well. I spent part of Sunday pair-debugging a friend's Perl AoC solution (it worked for the test input but not real inputs, that's a fun story) and they lamented that early on they'd forgotten to have revision control. When you ask Rust's cargo for a new project, it automatically creates you a git repository (if git is available) for the project, and if you didn't say you're making a library it gifts you a "Hello, world." example program to start with.

The error messages are excellent. The developers actually put effort into further refining the already excellent error messages. After a long day writing SQL Server queries for which the response is typically "Syntax error" if you got anything wrong like this is still 1975, it's really nice to write a line of Rust that's wrong and have the compiler explain why it's wrong.

The documentation is lovely. The official documentation for the standard library is in the exact same style as auto-generated docs for your own code. Because why wouldn't you do that? Java more or less did this and I appreciated it then, but writing such docs for Java is much more painful, and yet the results are less useful. C# is similar. I believe Swift got nice documentation behaviour in a recent version but I don't know Swift.

Re:Sayonara, C++, and Hello to Rust by flyinglizard on Tuesday December 07, 2021 @01:53AM (#29469709)
That’s a very kind interpretation.