John Chamberlain |
Developer Diary |
Developer Diary – You Heard It Here First – Thursday, 18 January 2018 |
Another driver for the popularity of C is its use in Linux kernel and key support programs like Git. There are about 4,000 kernel developers and they exist at the top of the Linux food chain, so to speak. They represent a constant, driving force for C. Whether C is successful because of those programs or vice versa, is an interesting question. Linus Torvalds would argue that the reason Git works so well, and is so successful is because it is written in C. Wrote Torvalds, "...the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C." I agree with this. The more experienced I get, the more I tend to see things like object-oriented development as a crutch. In most cases, I can get whatever benefit C++ would have provided in a more direct, straightforward and reliable way by using the right constructs in C. Even so, the best programmers, judging from Google Code Jam, prefer C++. I checked the code of the top 25 performers in the 2017 Code Jam and 20 wrote in C++ and 5 in Java. None of them used C. By far the most popular features were vectors and streams. Most of the 20 used only those two features of C++. Since both features are easy to customize in C, I find it a bit puzzling. In some cases, there would be a guy with thirty macros in his file, and then he would use a vector. If you are going to have a library of thirty macros, why not customize your own list management as well? I think some of it is habit and custom, not a conscious decision. A lot of people forget (or don't know) that C++ was originally just a bunch of macros written in C by Bjarne Stroustrup. By the same method, a programmer can reconstruct C to do whatever they need it to do, at least in terms of higher abstractions. The functionality lacking in C which I miss most is the ability to return multiple values, a capability found only in Python among the principal languages. Without assembly language intervention, it is hard to see how that can be accomplished in C. The great thing about C is that it leads to very clean code that has the specific functionality needed without a lot of extraneous fluff. I also see explicit memory management as a big benefit. Using garbage collectors is sloppy and leads to all kinds of inefficiencies, artificial limitations and strange behaviors. Even using the default heap ("malloc") has problems. It's really not that hard to run a heap and you get much tighter control over memory when you run your own heap. It is funny that every student learns how to make a heap in school, but then promptly ignores that skill and resorts to garbage collectors when they start working. They haven't learned the advantages of cimplicity yet. |
return to John Chamberlain's home · diary index |
Developer Diary · about · info@johnchamberlain.com · bio · Revised 18 January 2018 · Pure Content |