Skip to content

Comment on C versus C++: Fight

Comments

Having used both C and C++ they both have strengths and weaknesses and each is better suited for certain kinds of problems:

C: simple, ubiquitous, FFI with practically everything, practical direct access to the hardware; requires significant effort to build bigger things, feels more fragile at larger scales.

The power of C in a single page of code: https://www.jsoftware.com/ioj/iojATW.htm

C++: powerful, complex, efficient, builds upons C's strengths and C's weaknesses; can be difficult to debug, has grown immensely complex and difficult to "keep it all in your head".

"Why should I have written ZeroMQ in C, not C++": https://250bpm.com/blog:4/

But C and C++, while ubiquitous are not safe:

"A Guide to Undefined Behavior in C and C++": https://blog.regehr.org/archives/213

I resisted Rust at first and then I decided to try out Rust for Advent of Code. It was impressive. I read "Programming Rust, 2nd Edition" by Jim Blandy, Jason Orendorff, and Leonora F. S. Tindall (https://learning.oreilly.com/library/view/programming-rust-2...) and was more impressed by the design decisions and pitfalls that Rust avoids. We started using Rust at $WORK to replace a tool written in C and discovered many hidden bugs in the C implementation and gained maintainability and better performance.

Today, I view C and C++ as legacy languages that will be replaced with safer alternatives like Rust.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.