3 ms·
I think it's acceptable to leave details like character encoding in the documentation, so: msghead_to_xml() Are there any 53-character function names in the
by nitrogen 14y ago
I think it's acceptable to leave details like character encoding in the documentation, so:
msghead_to_xml()
Are there any 53-character function names in the multi-million line Linux kernel?
- jacquesm 14y ago> Are there any 53-character function names in the multi-million line Linux kernel? The linux kernel is actually only about 100 K lines. And its naming conventions are not what I'd call an example of elegance either, to put it very mildly (many of the names are quite cryptic and require extensive study of the code around it to understand what a function does). If low symbol length would be an indicator of code quality then we'd all be using fXXXX where X is a digit of your choice. The longest symbol in the kernel proper that I can quickly locate is 36 characters: timer_stats_hrtimer_clear_start_info It uses roughly the same convention that we use in our projects (a quite common one in large C projects): a module prefix (if possible the same as the filename) an action and a bit that specifies further details. Even with that simple convention it can add up quickly. And if you start linking against 3rd party libraries you're going to be looking at name clashes sooner or later, even if you're careful. Whoever at mysql decided to expose 'list_free', 'list_add', 'list_delete' and so on with global scope wasn't having their most lucid day. I wished I was kidding.
- nitrogen 14y agoThe linux kernel is actually only about 100 K lines. This is what I get from sloccount, which doesn't count blank lines or comments, for Ubuntu's old 3.0.0 kernel: Totals grouped by language (dominant language first): ansic: 9495321 (96.81%) asm: 241006 (2.46%) xml: 41486 (0.42%) perl: 13987 (0.14%) sh: 4117 (0.04%) cpp: 3486 (0.04%) yacc: 2987 (0.03%) python: 2770 (0.03%) lex: 1719 (0.02%) awk: 708 (0.01%) pascal: 231 (0.00%) lisp: 218 (0.00%) sed: 30 (0.00%) Broken down by path (top 8): SLOC Directory SLOC-by-Language (Sorted) 5474678 drivers ansic=5469921,yacc=1688,asm=1475,perl=792,lex=779, sh=23 1848085 arch ansic=1609109,asm=237452,sh=690,awk=470,pascal=231, perl=58,python=45,sed=30 693955 fs ansic=693955 518275 sound ansic=518092,asm=183 481158 net ansic=481062,awk=96 290060 include ansic=288348,cpp=1670,asm=42 118198 kernel ansic=117893,perl=305 53773 mm ansic=53773 Overall I think your naming convention sounds reasonable; C is also my primary language. Your example was just too easy to shorten to resist ;-).
- jacquesm 14y ago> 118198 kernel ansic=117893,perl=305 That bit is the kernel. File systems, drivers and so on are best though of as plug-ins to the kernel. Architecture dependent code would probably normally expose only one set of symbols rather than all of the code, probably should have included memory management. Likely if you include all that code you'll turn up a few more longish names, but the net effect is pretty much the same: really long names are rare when you've laid things out properly but 30 characters and up are certainly no exception.
- javajosh 14y agoThere's perl in the Linux kernel? Please God tell me that the Linux kernel doesn't have a perl interpreter built into it.
- jacquesm 14y agoThere isn't in the kernel itself but there is perl code in the build process. If you want to build the linux kernel without dependencies on interpreters then you're in for a rough time.
- javajosh 14y agoI figured; I was just being funny. Although actually the thought of embedding an interpreter of some kind in the kernel is very interesting. It would have to be an unusual interpreter, that's for sure, as it would have to operate without a kernel. I'm not sure if that even means anything though, as you'd probably end up implementing kernel-like behavior in your interpreter.
- jacquesm 14y agoI read somewhere - no reference handy - that windows NT contained a prolog engine to do network configuration. edit: found a reference: http://www.drdobbs.com/cpp/extending-c-with-prolog/184409294 http://www.drdobbs.com/cpp/extending-c-with-prolog/184409294
- 14y ago