Live data from Hacker News

It's time to halt starting any new projects in C/C++

twitter.com

541–550 of 929 posts

Re: It's time to halt starting any new projects in C/C++

#541

As much as I like rust, I feel the statement is a bit premature. Rust has only one real compiler and no independent language standard. Rust is also the only alternative that is really being discussed most places. For an idea as major as "deprecate C/C++" you really want a couple solid alternatives. Rust is not perfect for everything, and so its easy to pick on the weaknesses and say "that's why we're sticking with C/…

Having a standard is overrated. What you usually want is clearly defined behavior and a good backwards compat story.

Standards only make sense to me in the presence of multiple compilers or formal verification. There is ongoing work on supporting the second use case. I don't understand why people want multiple compilers.

Re: It's time to halt starting any new projects in C/C++

#542

Earlier quoted context omitted.

Seriously, just use unsafe. “Welp, can’t write a doubly-linked list in safe Rust so I might as well use C” is throwing the baby, the bathtub, and the rest of the greater metro area out with the bathwater.

Not a rust dev, but shouldn't this be solvable using generics? At least I'm pretty sure I could construct a double linked list with a sane API using only references in C++ with templates. I would have used inheritance to create a "ListBaseType" with a "ListElementType" specialization (with all the data required to wrap some element) and an empty "ListNullType" to use as begin/end elements. A quick Google search resul…

Not really. The fundamental issue is ownership, what is responsible for freeing resources when they are no-longer needed? In that example, owning references are used on the "next" pointers and weak references are used on the "previous" pointers. Then there are no ownership loops, and everything is fine.

In a GC language, the runtime has ownership over memory allocations. The "owner" is actually outside the application code, so the application code can have as many reference loops as it likes, as none of them are owning references.

Re: It's time to halt starting any new projects in C/C++

#543
post #534

Earlier quoted context omitted.

The implication is that he's mostly writing C despite the file extension suggesting they contain C++. C++ changed a lot over time, and the way modern code is supposed to be written is very distinct from "C with classes", but you still can do that if you want.

Wut? Makes no sense to me.

Here's an example of C++ code written intentionally with all the latest C++ features:

https://gist.github.com/caiorss/c7db87df674326793431a14006aa...

It looks pretty much nothing like a C program doing the same job.

A lot of those features were made to make C++ a safer language to use. Eg, with a construction like:

    for(const auto& it : ast){
You can't accidentally walk past the end of the array by going one item too far. But C++ still allows you to write code the way you'd do it in C.

Re: It's time to halt starting any new projects in C/C++

#544
post #534

Earlier quoted context omitted.

The implication is that he's mostly writing C despite the file extension suggesting they contain C++. C++ changed a lot over time, and the way modern code is supposed to be written is very distinct from "C with classes", but you still can do that if you want.

Wut? Makes no sense to me.

They’re claiming the CTO of Azure doesn’t know enough about modern C++ to make the statement that we’re discussing.

Bold claim.

Re: It's time to halt starting any new projects in C/C++

#545
The management ecochamber will push rust until their faces turn blue.

Until they rewrite mrustc in rust everyone using rust is one dependency up.

The truth is we don't need rust, either you are making a server and then Java is the language to use.

On the client where rust has a good chance to compete with C we're looking at electricity cost problems and then C is an easy choice.

You need to compile things to be productive.

Re: It's time to halt starting any new projects in C/C++

#546

> For the sake of security and reliability. I just read a few C++ vs Rust comparisons online yesterday and didn't see anything about a significant difference in security or reliability. Mind you the articles weren't very technical. How is Rust so much more secure and reliable than *modern* C++?

The type system can express thread-safety.

If you try to touch a data structure from a wrong thread, it will stop you at compile time. You don't need to fuzz such problems under a sanitizer. You have a compile-time guarantee for your entire codebase and even your dependencies. If you try to use a thread-unsafe library from a parallelized code, it won't compile, and it will show you exactly which field of which struct needs to be wrapped in atomic or mutex to work (at this point people say "but what about deadlocks!?". They are very easy to track down compared to heisenbug memory corruption.)

This makes parallelization of code relatively easy and way more reliable. Rust markets this as "Fearless concurrency".

Re: It's time to halt starting any new projects in C/C++

#547

I’ll controversially go a step further and say we need to even begin requiring this via regulation for certain applications, at least for those that involve the personal or financial data of customers. From working with security at a large tech company, it’s abundantly clear that C/C++ should not ever be used for processing sensitive information (it’s fine to keep around for high performance computing or processing n…

In not sure we need to regulate for or against specific languages but we absolutely need to hold companies more accountable for their cybersecurity. Once meaningful fines for data leaks and compromises start raining down the market will quickly shift to safer technologies.

Re: It's time to halt starting any new projects in C/C++

#549
I'm just a programmer who's been doing this for 20 years. I don't have the credentials of Mark, who is a legend. But I fully agree with him. There will be specific exceptions, but if you have the choice between Rust and C++ you would be making a big mistake to not choose Rust. The language is simpler, cleaner, safer, and more enjoyable to work with. The build tools are far more pleasant. The IDE experience is comparable. The hiring market is way better for Rust because it's not mainstream. Programmers currently using Rust are superior to programmers using C++, statistically speaking. There's a vast difference between individuals, but with only that one data point you can tell quite a lot. People learn C++ in college. People learn Rust because they love their craft. I stopped using C++ after I learned Rust. I still use Go sometimes, when appropriate, and I use other languages in my day job. I have a lot of experience in C++, much more than with Rust. The borrow checker still drives me mad. I've worked in over twenty languages over the years. Languages are tools, try to be impartial and pick the best tool for the job. Your personal tastes don't matter unless it's your personal project.
Post reply on HN