Erik Engheim
2 min readApr 27, 2021

--

No you don't need to do rewrite. Lots of languages can interface with C today.

Rust, Swift and Go can all easily call C code.

If you need to mix C code directly with something else, then Objective-C is an excellent choice. Objective-C has the advantage that it can easily be called from Swift.

The problem with C++ isn't to learn the key concepts. I am 43, and I was fine programming C++ as a teenager. It is through my long professional career programming C++ for over 15 years in large 3 million line large programs that I started seeing what huge problems C++ creates.

C++ is fine when you write small programs. But as programs grow in size, C++ complexity starts to really drag you down:

1. C++ has terrible compilation time.

2. It access memory in very unsafe ways, which means you get a lot of nasty memory bugs which can be really hard to track down in a large program.

The languages I offered as alterantives to C++ where not interpreted. Objective-C, Swift, Rust, Go, D, Haxe etc are all statically typed and compiled languages.

They also offer much better type safety than C++. C++ actually has a rather weak type system. In fact many dynamic languages have much stronger typing. Sure they may not catch problems at compile time, but they catch many problems at runtime which C++ catches neither at compile time nor at runtime.

Try this in C++: for (int i=0; i; ++i) { ... }

Compiler will generally not catch that you are not using a boolean expression and produce an infinite loop. Lots of dynamic languages will catch that sort of problem. E.g. if I write this in Julia:

while 4

print("hello")

end

Then at runtime I get this error:

ERROR: TypeError: non-boolean (Int64) used in boolean context

C++ in contrast just ends up in an infinite loop causing it to hang, run out of stack space or something else.

--

--

Erik Engheim
Erik Engheim

Written by Erik Engheim

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

Responses (1)