14 ms·
The Evolution of C Programming Practices: A Study of Unix (2016) [pdf]
- jxub 9y agoA really good read! Is there a repository to share papers related to source-code analytics like this one?
- irundebian 9y agoNot a repository but many references about source-code analysis focused on software security/safety: https://www.us-cert.gov/bsi/articles/tools/source-code-analysis/source-code-analysis-tools---references https://www.us-cert.gov/bsi/articles/tools/source-code-analy...
- drewg123 9y agoThere seems to be an oddity with their LOC for FreeBSD 2.0. At ~6M LOC, it is roughly 3x the size of the FreeBSD releases just before and just after it. The size steadily creeps up, but we don't see anything else that big until FreeBSD 5, so there seems to be something fishy there..
- klez 9y ago2.0 was when they revamped the code base because of copyright problems. Check this out: https://www.freebsd.org/releases/2.0/notes.html https://www.freebsd.org/releases/2.0/notes.html
- drewg123 9y agoSure, I initially though that might be it. Eg, maybe some of the non-x86 support from 4.4BSDL was not pruned out of 2.0, for example. But I checked, and 2.0 only has i386 support. What strikes me as odd is that the very next minor release (2.0.5) is listed as 2.1M LOC, while 2.0 is listed as 6.1 MLOC. That's a reduction of 66%. Looking at a diff between the 2 releases, I do not see anything to explain that.
- nurettin 9y agoThere is also a strange jump at 6.3.0
- jandrese 9y agoMaybe their tool got confused with the forks made around that time to fix the copyright issues? Basically the tool counted the codebase 3 times due to forks? It seems weird that an error like that would make it to publication though.
- bio_end_io_t 9y agoIt bothers me when "goto" is assumed to be "a maligned language construct". People who think "goto" is evil should also give up the other jump statements: continue, break, and return (and also switch, though its not listed as a jump instruction in the C standard, at least not in '89 or '99). You can see some contradictions in the paper regarding goto. For example, they state that deep nesting should be avoided, but goto should be avoided as well, even though one benefit of using goto is to limit nesting depth. From the Linux Kernel coding style doc: - unconditional statements are easier to understand and follow - nesting is reduced - errors by not updating individual exit points when making modifications are prevented - saves the compiler work to optimize redundant code away ;)
- haikuginger 9y agoAs a C novice, this makes me wonder - wouldn't templates/macros be able to serve a similar purpose to goto statements if the goal is to avoid nested calls but still share code? EDIT: Or, for that matter, trusting the compiler to inline small-enough function calls?
- Gibbon1 9y ago> wouldn't templates/macros A gcc extension that gets around macros is nested functions. > trusting the compiler 99.99% of the time you should just trust the compiler to do the right thing. That 0.01% of the time use a well tested and maintained library. Hating on goto in c is just cargo cult programming. goto in BASIC and FORTRAN are evil. Though back in the 1960's 1970's programmers often had no choice. Programmers used evil assembly goto hacks in order to get their programs to fit in memory/disk. Problem with Dijkstra was he was a academic mathematician who despised practical programming where the program needed to run on the hardware available. Hint back in the 1970's professors like Dijkstra had unlimited accounts on the schools mainframe where everyone else had extremely limited accounts.
- simias 9y agoYeah their take on goto is a bit odd given that it's probably the sanest way to do "cascading" error handling in C given that we don't have RAII or exceptions.
- pjmlp 9y agoSo no discussion about any positive evolution of security best practices or static analysis, other than single line remarks?
- dm319 9y agoDSTMT/statement density plot is nice to see. Although it wasn't my time, I've seen early code (or code from very memory-limited machines), and always been amazed out how tightly packed it seems to be. And remarkably unreadable too.
- jacksmith21006 9y agoI went to pick up my son at University studying CS recently. He had replaced Win 10 on his tower with Ubuntu and was writing a pretty complex program in C++. Doing some AI/ML primitives. Thought to myself I am old yet went to the same University and would have been coding in C++ on Unix (Ultrix or OSF or Solaris) at that point in my life. How in the world have we not moved on? BTW, his code was so, so pretty. Mine would have been ugly. Kids are far better coders than we were 30 years ago. I was crazy proud.
- jumpman500 9y agoSometimes tools are good enough that they don't need to change. People still use hammers and nails, even though we have awesome power tools and many different types of skrews. Coherency and ease of use are very important factors when building anything.
- mercer 9y agoPerhaps that BTW is what makes all the difference. I suspect that 'us' coders might overvalue the language or tools we use, and undervalue the progress that might take place in the context of them. Not just when it comes to the next generation(s), but also in our own work. For example, over the past decade or two I've 'improved' my toolage by learning vim and emacs, figuring out how to get Sourcemaps and live reloading working, and improving my command-line-fu. And yet, as a programmer, I feel all of these improvements pale in comparison to the stuff I learned that would be equally useful in Notepad as it would be in a decked out Sublime Text/VSCode/Emacs. This becomes evident when I work on one-off scripts in the Chrome developer tools, or editing stuff using vim on a server. I'm reduced to the most basic tooling, and yet I can get stuff done in a fraction of the time that I'd have needed a few years ago.
- jacksmith21006 9y agoWoops! Forget the best part. He was using Vim to write the code. That one really cracked me up as I am a Vi wiz and would never change as I am just so fast using. Never used Emacs.
- 9y ago
- badrabbit 9y agoThis helped me out a lot as a base guidline for writing good C code: https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Developing_Safety-Critical_Code https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Dev...
- jandrese 9y agoI wonder how many of those LOC are just support for more and more hardware over the years? The nice thing about drivers is that they're almost completely modular so they don't really bloat the code even though they shoot the LOC count through the roof.
- jradd 9y agoI know this title is not technically click bate, but it got me.
- shreyasetia 9y agoI have enrolled for CSE in http://www.thapar.edu http://www.thapar.edu college this year. Can I join this C programming course with engineering? I know basics of C and C++ !!