Live data from Hacker News

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

twitter.com

701–710 of 929 posts

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

#702
post #534

Earlier quoted context omitted.

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…

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

Does it really need to include ?

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

#703
post #400

Earlier quoted context omitted.

I see you do not have much contact with Rust evangelists.

"Hey C++ developer, you should use rust instead" is very different than "Hey C++ developer, I don't want you to have a job". Do you not see the difference?

I do. "New programs should not be in C++" means, exactly, "You should be laid off so they can hire me instead". If you had something that could do what I need, I would be using it already. It cannot. But you want to bypass me and fool managers, instead, with FUD about memory faults I don't code and have not in years.

I have spent strictly more time in the past five years filing compiler bug reports than chasing memory faults. Yet you say I should trust the compiler to make errors impossible. Are you able to see the flaw in your reasoning, here?

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

#704

Earlier quoted context omitted.

bizarre. not even sure what that linked comment is supposed to do for your argument here. The idea that rust is some plot by "companies" to "prevent jailbreaking" is ..... rough, man.

They're not trying to burn the frog but boil it slowly. This is just another one of a series of small steps.

You're not crazy. The attacks that Microsoft (and others) are most worried about are attacks from their own customers.

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

#705
post #514
post #400

Earlier quoted context omitted.

I see you do not have much contact with Rust evangelists.

What issue is there for the C++ developers to transition? Rust is a simpler language, with better characteristics. Memory safety is the a big selling point for the business people, but there is also a better module system, dependency management, better generics, no hidden memory allocation, etc. etc.

Rust is not, in the end, a simpler language, in the same way C is not. It is able to do less, which leaves me needing to do more.

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

#706

Earlier quoted context omitted.

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…

Why would you design a list this way? So many things are wrong here; to name just a few: 1. Pointers work fine, you're not solving any problems here. 2. You can't rebind references in C++, so you wouldn't be able to delete nodes 3. Even with this insane approach, why would you use inheritance over a sum type? 4. Extra allocations or statics are needed to hold sentinels. As for why this wouldn't work in Rust, in addit…

I was just wondering how to do that without using 'unsafe' rust.

1. Dereferencing raw pointer is unsafe; but maybe not necessary? 2. `int main (void) { int a = 1; int b = 0; int &ref = a; ref = b; return b; }` 3. union access is unsafe 4. the cost of not having nullptr or similar

Obviously a linked list is trival to implement with pointers; but at least in C++ a naive linked list implementation can easily produce lots of suffering (read: UAF or DF) with a `delete list.getPointerToElement(i)` (in practice it will be a more convoluted variant of that, maybe introduced by dozens of people working on a badly documented code base over a decade or two). I'd expect if programmers already do that in C++ there isn't much that prevent them doing that in unsafe rust?

> insane approach

I can assure you my mental health is pretty good, thanks. Though I made a comment regarding a thought experiment in a rust thread, I can see why you would think that.

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

#707

Earlier quoted context omitted.

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…

Why are spaces randomly omitted for language constructs like if and for, and reference type &s left aligned?!

What's wrong with left aligned & and *? I prefer it because for me it makes more sense; it is not a , it is a reference (or pointer). This involves different semantics than just a , so it makes sense to me for the extra information to be with the type.

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

#708

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 compara…

> People learn Rust because they love their craft.

We're exchanging opinions here without any kind of data to back either claim, but let me offer a contrarian view: people who learn niche-language-X because they love their craft are mostly younger folk with little experience in programming. My reasoning for this is that you get less and less time to pursue your love for a programming language when said love competes with love for your SO, your kids, and all the other things that happen to most people later in life.

It's anecdotal, but in my experience people who learn niche languages because of love or fashion are not the kind of people who will help write high-quality libraries for the ecosystem. For that, you need a stable, sizeable "middle class" - people who already know what their doing, who were able to evaluate the tool objectively, and who found a real value in it. Such people are not easy to come by: IME by the time they have enough experience, they mostly lost the eagerness to evaluate every shiny new thing that comes along.

> The hiring market is way better for Rust because it's not mainstream.

I would like to see the statistics you base this opinion on. In my experience (also 20+ years of programming here) this effect is more than offset by the small pool of applicants.

> Languages are tools, try to be impartial and pick the best tool for the job.

Yes. But you need to account for more than just technical features of a tool, like hiring or the opposition from the existing team to learning the tool. Choosing Rust when you have 20 seasoned, experienced C++ devs just because cargo is better than CMake... might not be the greatest of ideas.

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

#709

Earlier quoted context omitted.

Ok, now I see the semi-colon. So rust has heavy memory allocation implicit in the syntax (not meant only for the stack). I remember now I did not want that (like those horrible c++ new/delete). Thx to have refreshed my memory about rust syntax.

It's very unlikely you would ever have to use something like C++'s new/delete in Rust unless you are doing something like re-implementing the Vec class.

In c++, it is not only with new/delete, heavy allocations do happen implicitely everywhere. Now, I recall I did not want that.

thx anyway.

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

#710
post #672

Earlier quoted context omitted.

I mean the argument is made that Rust is not mainstream, but if you were to pull in e.g. Java or Javascript apps in that comparison I'm confident it would make C++ look like a non-mainstream language too. edit: numbers say I'm wrong, C++ is more mainstream than C#, C is more mainstream than Java: https://www.tiobe.com/tiobe-index/ . I mean I doubt this source (it seems to indicate objective-C, which is all but supers…

That doesn't really change the fact that the only job you can really get is in cryptoshit markets.

Or working for Azure, apparently, or Cloudflare, or Amazon, or ...

This doesn't change the argument about scarcity in general, but it isn't true that the few jobs that are out there are only in crypto.

Post reply on HN