Many Languages Don’t Have Exceptions

A very common misconception today is that languages that use the throw keyword are throwing exceptions. Often they are not.

Chris I think you have mistaken me for somebody else. I did a lot of my first C coding in DOS using Turbo C. I was dealing with the near and far pointer to access the frame buffer. I was calculating pixel positions with bit shifts and additions because multiplication was too slow back then.

I was writing self replicating computer viruses in x86 assembly code under DOS that hooked into the interrupt vector table to terminate and stay resident (TSR). So I am very familiar with low level coding. So don’t go all “back in my day,” grandpa mode on me.

Easiest question in years: C doesn’t have throw.

You might want to update yourself on the alternatives to C. It isn’t all Java you know. Plenty of languages don’t throw exceptions. Although several languages use the throw keyword without throwing exceptions such as Swift, Rust and Zig. In these languages throw is really just used to return an error code.

Your point that OpenSSL has bugs is not a criticism of C

OpenSSL is just one of many examples. This kind of things happen frequently because C simply isn’t a language that encourages safe coding practices. Sure blame the programmer, but that argument also works for assembly code. Lets blame all the problems on bad Assembly code on lazy programmers. You can keep shifting the blame indefinitely. But at some point you have to admit that the tool you are using is part of the problem.

Sure you can circumvent weaknesses in a language by strong engineering practice. But we are not all NASA or can afford to have meetings with 5 people going through every line of code, to make sure there are not mistakes. Sure you can code safe in any language including machine code if you simply build enough elaborate procedures and bureacracy around the development process. But who wants that, when a more modern language can solve those problems?

When a new processor or graphics chip is released it will have a C compiler.

That is not an argument to always pick C. And with toolchains like LLVM we now have quite a lot of languages that cover a broad set of platforms. You can find online accounts of people working on obscure microcontrollers who had a much easier time doing that using Zig than C. Unfortunately I cannot find the link now. There was a guy in Sweden programming microcontrollers on public transportation.

Written by

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store