Live data from Hacker News

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

twitter.com

791–800 of 929 posts

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

#791

Earlier quoted context omitted.

C++ the "language culture" unfortunately has a lot of gatekeeping as well. The fact that the gatekeeping generally revolves around "replace feature from n-5 years with the newer feature in the latest 0x00x release" is a bit tiresome. Yes, I'm exaggerating, a bit. As for the Microsoft whomever-he-is: I agree in theory, I disagree in practice. If there are a lot of C++ devs writing important code, then let them continu…

> "replace feature from n-5 years with the newer feature in the latest 0x00x release" Let me put a more pro-C++ spin on that sentiment. C++ is a language that's under long-term development. It might sound weird, but only with C++20 Bjarne Stroustrup felt that his vision for the language was now mostly-realized - and he had worked on it since the 1980s. With other languages, there's a lot of clearing-of-the-desk and s…

"but only with C++20 Bjarne Stroustrup felt that his vision for the language was now mostly-realized"

So... let me ask you given this statement. Let's say there is an uber smart super productive programmer who states: I can rewrite the entirety of the ecosystem of one language in 1 year....

Would you tell them to rewrite all C/C++ in C++20

or

Rewrite it in Rust?

C++'s only real advantage in the current language marketplace is an installed library base. But how much of that is C++0x2020? Is the barrier to entry of a new programmer in C++ not just 40 years of language revisions, but a massive massive map of libraries where JSON library uses features from v2016, while XML library uses v2005, while some multithreading thing uses v2020...

And then there's the STL, and mixed-in-C standard library, ye gods.

Will Rust turn into that? Well, I think it kind of will to some degree as they try to find dialects that perfectly describe borrower checker semantics. Rust is a syntax soup almost on par with C++, but I guess we'll see.

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

#792
post #205
post #181

Earlier quoted context omitted.

It makes as much sense to talk about a language named "Haskell/Ocaml" as about "C/C++".

What other people are saying about it being a shorthand for similar languages, but also... C/C++ is a coherent thing to write a single program in. You write some files with a .c extension and compile with gcc, some with c++ and compile with g++, and as long as you're careful in your header files everything works out just fine. People have actually done this , and because C isn't a subset you end up with C files that…

Haskell and OCaml both have FFI, and means exposing C function symbols, so can call one another.

It is not the same as between C and C++, but it is comparable. But more to the point, it is fully as absurd in the cited context.

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

#793
post #286

There are new programs being written daily in COBOL and Fortran, and I'm fairly certain that I see new PL/I floating around occasionally. C and C++ aren't going anywhere anytime soon. Love them, hate them, want to burn them with fire, they're here for a long, long time. Leaving that aside, I was still hitting Rust "oh look the developer of this crate on which the entire universe depends still assumes that everything…

> If Rusties want Rust to displace C... simplify your dependency chains. Get a build system that's easily workable without an Internet connection and recent TLS support. Make it easy for beginners to build out Rust infrastructure for OpenVMS on Itanium, Solaris on SPARC, z/OS, MorphOS, GNU/Hurd, and a 20-year-old budget PDA running a custom OS on an SH4 CPU. C is welcome to that niche IMO. The priority is getting peo…

> The priority is getting people to stop using C or C++ for regular applications that are exposed to the internet;

But I think this is already been taken care of by Java and others?

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

#794

Earlier quoted context omitted.

To what end? You’ve already stated elsewhere that your only point is that you can, under an increasingly strict set of conditions, write code that is (almost always) free of memory bugs. Great! Nobody is hiding around the corner waiting to take `gcc` or `clang` away from you if you want to keep using them. Nobody's threatening to take away your software engineering license if we catch you writing a memory bug. This w…

The RESF seems to want to take C away from me. They seem to think I am a bad person for using C. They seem to think I am a bad programmer for using C. To refute all of that, I point people at some code that they would probably struggle to break.

I'm sorry, but this is an entirely imagined persecution. Nobody is taking your C compiler away from you. Nobody thinks you're a bad person for using C. Nobody thinks you're a bad programmer for using C.

Many of us think there are better alternatives. We're excited about these better alternatives. We want people to use these better alternatives. We think these better alternative solve a lot of problems that many people spend a lot of time dealing with. We think these better alternatives prevent many of the types of bugs that regularly ruin people's afternoons, evenings, and weekends. We really think you should try it out, but if you don't like it, literally nobody is coming to take your compiler away from you.

We do think a lot of the common arguments against moving to these languages are bullshit though. "Rust can't do self-referential data structures" is one of them. "I have a ton of expertise in C and it would take more time than I'm willing to spend to get to that level in something else", "this project is already written in C and mature", and "I write code for unsupported platforms" aren't bullshit, but they are ones that naturally decay in how compelling they are over time.

And as much as I believe you personally can write memory-safe programs in C, I would be willing to bet this guarantee would go out the window the moment you add a second maintainer who can push and release code without you vetting every commit.

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

#795

Speaking of Microsoft, it's time to halt starting any new projects in Windows and use Linux for those scenarios where an OS kernel is required. For the sake of security and reliability. the industry should declare that OS as deprecated.

get back to me when there's equivalents of KPP/Credential Guard/a stable driver API/etc

tbh i was mostly being facetious and I don't actually think everybody needs to immediately drop Windows (although i do actually hate it). The OP has the exact same problem that you highlighted with my post, which is the assumption that since rust is a viable replacement for C in his line of work, C must be obsolete across the board for everyone, which is a ridiculously arrogant statement.

Rust's tier 1 platform support is woefully inadequate (https://doc.rust-lang.org/beta/rustc/platform-support.html), and even the tier 3 platform list is missing some important targets. And even the platforms that it works on aren't necessarily platforms where it works well enough to be a viable alternative to C. But this guy from Microsoft's Azure who probably only ever writes software for x86 and ARM says C should be considered deprecated because Rust works really well in his specific domain.

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

#796

Earlier quoted context omitted.

Because it is. And it is because you all say things that imply people like me are terrible, awful, evil, no-good, very bad people for not using Rust. We are not. We just have different preferences. You all have also implied that we are negligent for using C. I don't know about others, but I have not been. That's why I have the challenge to break a release of my `bc`. I actually have not been negligent because I do pu…

> You all have also implied that we are negligent for using C. I don't know about others, but I have not been. I’m sorry that people have implied that, but I feel most of the time when Rust people say languages like C should be retired or deprecated, are doing so because your skill and attention to detail does not scale. Maybe you personally have advanced enough to write safe code, and you have the requisite skills a…

> I’m sorry that people have implied that, but I feel most of the time when Rust people say languages like C should be retired or deprecated, are doing so because your skill and attention to detail does not scale.

This is a fair argument.

On the other hand, I wish we had less software so that attention to detail did not need to scale.

For example, I run a Gentoo machine with the Awesome Window Manager and no systemd. The end result is less than 50 processes running after I login.

My machine is powerful, but if I were running Gnome, it would still feel laggy. With this minimal setup, my machine is snappy even when running an update and compiling Rust, Chrome, Firefox, or anything else. (I did have to make my update script renice Portage to the lowest priority to make that happen, but it works.)

Nevertheless, it is good when less attention to detail is needed.

I'm making my own C replacement, and I'm going to rewrite my current project in it when it's done. It will be about as safe as Rust, if not safer because it will not have async/await.

> Maybe you personally have advanced enough to write safe code, and you have the requisite skills and insight to avoid any and all memory bugs, such that your C code is just as safe as what Rust would compile. That’s great.

Thank you.

> But there’s always someone starting out and they will not have your skills. They will make the use after free, null pointer deference, buffer overflows, and other issues that the C language not only allow but encourage.

Yes, they will. But I view this argument as equivalent to "roll your own crypto."

If no one actually rolls their own crypto, then we as an industry will lose the ability to do so, even when we need to. If nobody uses C, then we as an industry will lose the ability to do so, even when we need to.

When I started writing `bc`, I sucked at C. `bc` was so full of security holes.

So what I did was spend enormous amounts of time on the test suite and asserts and then hooked those up with sanitizers and Valgrind. Patterns of bugs repeated over and over.

But I eventually got to a point where I started to get good. I didn't release a 1.0 before that point; I waited until I was good and had done thorough checks with as many tools as I could learn.

I'm currently learning and implementing crypto. I am following the same process, except that I'll add in professional code audits by actual cryptographers, which I have to pass before I release the code.

I'm doing this because someone has to.

> So the question is: how long do we tolerate new programmers making these mistakes in production code, leading to bugs and exploits for all, when other languages are readily available that would have caught those mistakes before reaching production?

We should not tolerate this in production code, but this is a failure of the industry. Why are beginners writing production code in the first place?

This industry grew too fast for its own good. It would have been better if it had had a master and apprentice model. The best programmers would be "masters" (in the sense of master and apprentice), and juniors would be apprentices who would write code under the master until the master thought them good enough to be journeymen (moving up from junior), and over time, such journeymen would themselves come to be recognized as masters, and the cycle would repeat.

If the industry does not do that, we may soon lose the ability to do things we need to do.

(Funnily enough, this is another argument for less software because there will be less people to write production software, and they'll all be good at it.)

> C was released 50 years ago, and in the intervening time a lot has been learned about how to write programs, and what language features are desirable in enforcing those practices. We also learned that when practiced aren’t enforced, they aren’t followed. So “just write modern c++”, which is espoused throughout this thread, doesn’t work to make c++ code safer, because it’s not enforced. Not taking advantage of those lessons learned seems like folly, irrespective of how bug-free your particular C codebase is.

Surprisingly, I agree with you that it's folly. I really do. In my original post, I ended it by saying

> But seriously, use Rust if it's available for your target platforms, and you have no other preference.

People really should do that, even though I don't like Rust.

All I was doing was just to remind everyone that there is a time and a place for C.

By the way, the reason I don't use Rust is because I'm pretty sure I would actually write buggier code in Rust than in C. The reason for this is async/await: I just can't get it. I mean, I do get it, but the rules seem too complicated for my brain to do as safely as I can do threads and locks.

I think I am one of those people for whom async/await is dangerous, just like there are those that just can't get Lisp or Haskell.

I say this so people know I'm not some great programmer; I have my weaknesses like everybody else.

So it would be folly for me personally to write Rust.

At the same time, yes, it is folly to write anything but Rust if it works for you.

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

#797
post #315

Earlier quoted context omitted.

Do you have a tool that enforces the use of all of these macros and stuff? How do you know that, for instance, you didn't forget something? Seems like one slip-up is all it would take.

This is where C fails against Rust. I have to use static analyzers to find such problems. But I do use them, and I also use sanitizers against large and thorough test suites, with excessive fuzzing thrown in for good measure. And I mix all of that with crash-happy code littered with gobs of `assert()` calls that document as many of my assumptions as I can find. Those help me find about all I can find. But I'm still w…

> But I'm still writing a language that is as safe as Rust that I will auto-translate my code into when it's done.

Just curious, how do you intend to make it memory safe? By using a garbage collector, automatic reference counting, a borrow checker, or something else?

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

#798

Earlier quoted context omitted.

Because it is. And it is because you all say things that imply people like me are terrible, awful, evil, no-good, very bad people for not using Rust. We are not. We just have different preferences. You all have also implied that we are negligent for using C. I don't know about others, but I have not been. That's why I have the challenge to break a release of my `bc`. I actually have not been negligent because I do pu…

> You all have also implied that we are negligent for using C. I don't know about others, but I have not been. I’m sorry that people have implied that, but I feel most of the time when Rust people say languages like C should be retired or deprecated, are doing so because your skill and attention to detail does not scale. Maybe you personally have advanced enough to write safe code, and you have the requisite skills a…

[deleted]

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

#799
post #464
post #454

Earlier quoted context omitted.

In other words, not a problem.

Except for the use-after-free?

Look - can we just admit that most C++ apps don't have thousands of use-after-free errors?

Of those use-after-free bugs that exist, they are a large source/percentage of the exploitable security bugs in C++ apps for sure. But again, it's not like apps are usually just littered with use-after-free. Like you may find one in a several million line of code app. They are not that common of a mistake, and FWIW, 100% of them are catchable with things like MSAN.

So people make mistakes. C++ makes certain kinds of those mistakes easy. Rust makes them hard or impossible. I don't think you will find any disagreement about this.

Again - this sort of thing is not going to convince anyone to use rust that doesn't want to already, for lots of reasons, not the least of because they think they are unlikely to make mistakes that matter :)

All this sort of thing does it turn people off from considering it for real, when they should!

(and i say all of this as someone who is funding efforts to replace billions of lines of C++ - i have no love for C++ over rust or vice versa. I just think the current approach here seems very unlikely to result in increased adoption)

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

#800
post #551

Earlier quoted context omitted.

I find it hard to imagine the CTO of Azure has done enough C++ programming in the last few years to be fluent in C++20. Maybe as a hobby I suppose; it doesn't match my understanding of what a CTO of a big organisation does otherwise.

He doesn’t need to be fluent in every language to set technical direction as a CTO. You don’t question a general’s war strategy simply because they aren’t accurate with a rifle.

You should if the general came up during the flintlock era and now everybody is using machine guns. Plenty of people in World War 1 would have benefited anyways.

I could throw a bunch of examples further. For instance how the changes made to rifles because of what Generals thought their engagement ranges would be hampered the western forces who had to fight in Afghanistan.

You should also be skeptical of a General who suggests we go all in on Drone Warfare and not worry about rifles at all.

TLDR, person in a strategic role is rarely the best to assess tactical tools, and will often attribute strategic failures on their tactical tools.

Post reply on HN