15 ms·
> Linux is 15+M lines of code....But at only 9,000 lines, Unix v6 was tractable, people continued to study it (and maybe still do), and the famous comment lived
by brundolf 6y ago
> Linux is 15+M lines of code....But at only 9,000 lines, Unix v6 was tractable, people continued to study it (and maybe still do), and the famous comment lived on.
> Reading real programs is a part of learning computer science that should be emphasized more. As an undergraduate, we mostly programmed in BCPL, a local Cambridge language that is the fore-runner of C and C++. We had access to the full source code of the compiler and reading it was as valuable as the more theoretical aspects we learned in our compiler-writing course. Today, with open source, it is easy to read the source code for many systems actually in use (Linux, the Apache web server, Hadoop, TensorFlow, and thousands more) but these are hundreds of thousands, if not millions, of lines of code. As I said above, Linux is somewhere between 15M and 20M lines of code, depending on just what you include.
This is an interesting problem. Modern software is so huge and complicated that it's not feasible to go read it just as a learning exercise. Linux devs can probably spend years contributing to the project without having even visited all of its dark corners, much less understanding them.
Not sure what can be done. Though I am tempted to go see what a 9,000 line OS looks like.
- qsort 6y ago>Modern software is so huge and complicated (...) Not sure what can be done. Nothing. Any sufficiently complex system or body of knowledge is too large for any one person to understand. Does any physicist know ALL physics that was ever done? Does any one engineer know how to build a Ferrari? Let's be honest, we take for granted a lot of stuff that we don't fully understand, Linux is a major piece of infrastructure, it's natural nobody can fully wrap their head around it. > Reading real programs is a part of learning computer science that should be emphasized more. I had never thought of this in an educational sense, but I definitely agree. I sure wish I was taught more of that, toy problems get boring quickly.
- kevincox 6y agoThis. The strength of modern civilization is the ability to abstract. This means that you can let Joe deal with the frobnicator and Jane design with the fritzer and you just need to trust them enough that you can plug the two together and it works. Joe and Jane don't need to understand what you are doing, and you don't need to understand what they are doing. Of course partial understanding, especially for related technology is helpful, but the farther away you get the less you know, and the more you need to rely on others.
- lemax 6y agoAhh... labor alienation. One of the great drawbacks and geniuses of our primary modes of production in modern society. As we become more and more separated from the things we actually work on, what are the drawbacks though? The general trend becomes if we want to do more, we create more separation. The social impact, for one, is in general a large extent of estrangement from our human essence. Tangibility is intuitive, abstraction, not so much.
- Polylactic_acid 6y agoThis comment feels like something written by GPT-3. What are you actually trying to say here?
- User23 6y agoGP is saying that hyper-specialization is intrinsically fragile.
- Polylactic_acid 6y agoWhat is fragile? We have had specialized roles for the entire history of society and it hasn't caused anything to crumble. I suppose you could say many things have failed due to no one seeing the big picture among all the tiny details but without people focusing on the details none of that would have been possible to begin with.
- grp000 6y agoAs things are getting more complex, more people become specialized, and there are a lot more interfaces between specialties that need to be properly defined so things don't break. The more interfaces mean a higher likelihood of a system going wrong. That, and I feel that as long as you have a good big picture, you have a higher fault tolerance because there is a general goal you can identify to strive towards when something does go wrong to correct it. Certainly, I feel that in any field that has become sufficiently complex, there is a practical human limit for a single person to understand the field as a whole. Even if someone can claim to understand a field as a whole in a general sense and how it's major components interact, they will still lose information because of how much they have to abstract.
- trilinearnz 6y agoThere are some people with a massive capacity for holding the entire system in their head. John Carmack only reached the point of "too much" during Rage, for example. Pretty impressive!
- sokoloff 6y agoSince childhood, I have periodically tried to reason about when the latest moment in time was that a single human could have substantially all the knowledge that humans collectively possessed. As a kid, it was an easier thing to reason about (wrongly). As an adult, I’ve concluded that it was never possible to both have something we’d think was civilization and for one person to know substantially everything humans knew.
- indigo945 6y agoYou don't need civilization for this to be unfeasible. People tend to underestimate how much nomadic people know about things like animal behaviors, medical use of natural substances or about geography, especially with regard to the change of seasons. Arguably, it was never possible to know the entirety of human knowledge.
- mrmonkeyman 6y agoThe thing with software though is that it's untethered to reality. It answers to no physical law. Monstrosities have been built and are still built which should not exist. More complexity != improvement. Also, 15M lines consists of drivers. The core of an OS is way, way smaller. And actually yes, physicists know all of physics pretty well. Not deep expert level no, but it's not like they don't even know whole fields exist which definitely happens in computing. There are definitely engineers that know how to build a full car. What makes you think it is impossible? You don't know all the details by heart no, but you know where to look, you can have a pretty deep broad understanding of things. Let's not kid ourselves into complacency, throwing our hands in the air saying "it's complex".
- orbifold 6y agoA good physicist has the ability to grasp a large fraction of all physics that has ever been done. And there is a pretty good directed knowledge graph. The action principle and some ideas from quantum mechanics are enough to anchor almost all other results.
- person_of_color 6y agoThere is so much driver and feature spam in the Linux codebase. I really wish a beautiful, minimal microkernel approach would have won out. Why can't distros be a package of microkernel + drivers?
- someguydave 6y agobecause nobody is willing to pay alot extra for software of high quality
- core-questions 6y agoIt's not even guaranteed to _be_ of high quality, is the thing. The same arguments play out all over CS: monolith vs microservices, distributed vs. centralized. Pick a poison and do it well - there's no 100% argument that says one side is absolutely better than the other here.
- galangalalgol 6y agoBecause a monolith is easier to get working on a quick timeline and it will generally outperform code that makes compromises for the sake of its' developers sanity. At least as long as you can keep the insane developers from eating each others eyes.
- pferde 6y agoI feel obligated to point out that there is a notable lack of eyeless developers in Linux kernel developer community, even after many, many years of development.
- gnulinux 6y agoWhy does it matter? If you want to read scheduling code of linux, no one forces you to read 5M+ lines of driver code. If linux was just a microkernel, and distros shipped drivers, you'd still have to read roughly the same number of lines to understand linux scheduling. If you want to read the entire linux code, you can still do it, just ignore the driver code if you're not interested in them; otherwise in your scenario you'd be reading driver code in distros as well.
- throwaways885 6y ago> > [...] at only 9,000 lines, Unix v6 was tractable, people continued to study it (and maybe still do), and the famous comment lived on. Wow, Unix is a work of art. I have hobby projects at 2x SLoC which are literally just small web services :(
- flubert 6y agoI wonder how many lines of code were behind the QNX demo disk? http://toastytech.com/guis/qnxdemo.html http://toastytech.com/guis/qnxdemo.html
- bluedino 6y agoI wonder the same about the GeoWorks DOS version of America Online
- jacquesm 6y agoKernel + include files: about 10Kloc File system: about 15Kloc Network driver + IP stack: about 10 Kloc Task manager, posix compatible libc odds and ends, maybe another 50Kloc, Graphics driver: 10Kloc, window manager 2500 lines. So not that bad, you could do it by yourself in about 2 years of hard work, probably less than that if you use a VM instead of actual hardware if you're a halfway competent programmer. I've done it.
- amelius 6y ago> Linux is 15+M lines of code (...) Modern software is so huge and complicated (...) Not sure what can be done. Perhaps we need something more modular, like a microkernel architecture :)
- mikeyjk 6y ago'The jury is in, the monolithic kernel has lost'
- jacquesm 6y agoWe do actually. Not that it will happen, but we do. We need a hard real time micro kernel based OS for our personal computers, and not having it is a major blocker for a lot of applications that would then be trivial.
- yjftsjthsd-h 6y agoOkay, I'll bite: what would this enable, and why do you think we all need hard real time?
- jacquesm 6y agoHard real time implies that you get to choose what runs and when. It allows you to treat user input and output (arguably the most important aspect of using a computer) as a high priority affair and to guarantee that the user will never have to wait for their computer to respond to them. If there is one thing that irritates me about modern day computing then it is that it is in many ways slower (in spite of having 100 times the clock speed of a machine from the early 90's) than the box I had on my desk back then (which was running QnX). There are exactly zero reasons why this is the case other than a stupid ego war between Andrew Tanenbaum and Linus Torvalds who was gung-ho on recreating an OS from the 70's.
- indigo945 6y agoBut that's just wrong. There are a lot of reasons for those input delays that have absolutely nothing to do with the kernel. A bloated Electron app will not suddenly be blazing fast just because it runs on a real-time kernel. The true issues with the modern software stack lie in userspace.
- crdrost 6y agoViewpoints Research Institute claims that they did all of personal computing (including antialiased graphics needed to do SVGs, TCP/IP and an office application which could run both word processing workloads and PowerPoint) in under 20,000 lines of code. (Usually TCP/IP itself is 10k LOC so this is pretty impressive.) The basic idea that Alan Kay has presented in his many similar YouTube presentations (most of which run with that office application) is what we call today domain-specific languages, you write the rules for antialiasing a pixel in whatever the ideal language would be for those rules: you just imagine that you have a dream language and "wishful think" the solution: then you go and you reimplement that DSL in another language that you are wishfully conjuring, a language-language, and that final one can become self-describing and can compile and optimize itself. This is also a method of programming advocated in MIT's old SICP lectures, which will also cover the implementation of Lisp in itself, which is sort of a prerequisite for it. That all said, I would love to read the source code someday but I can't seem to find it anywhere, the software product may be the KSWorld that was described in [1]. [1] http://www.vpri.org/pdf/tr2013002_KSonward.pdf http://www.vpri.org/pdf/tr2013002_KSonward.pdf
- deleted 6y ago[deleted]
- cjameskeller 6y agoFinal report (2012, released 2016) of the STEPS project, which has some more info, but sadly no reference to the source code... http://www.vpri.org/pdf/tr2012001_steps.pdf http://www.vpri.org/pdf/tr2012001_steps.pdf Did some digging and found this site with some code, but I haven't looked closely enough to determine what it is specifically for... http://tinlizzie.org/dbjr/ http://tinlizzie.org/dbjr/ And it is not exhaustive of what the PDF describes. Maybe someone is able to contact one of the original group working on this?
- renox 6y agoWhat is amusing about the VPRI project is that, even though the number of lines is low, nobody managed to replicated what they did.. Or more precisely, nobody was able to build something which work with the pieces of code they left. An impressive research but a poor software project, apparently they hadn't hear about SCM..
- flubert 6y ago>Not sure what can be done. Though I am tempted to go see what a 9,000 line OS looks like. I think you are going to like STEPS: >The overall goal of STEPS is to make a working model of as much personal computing phenomena and user experience as possible in a very small number of lines of code (and using only our code). Our total lines of code target for the entire system -- from user down to the metal is 20,000, which we think will be a very useful model and substantiate one part of our thesis: that systems which use millions to hundreds of millions of lines of code to do comparable things are much larger than they need to be. http://www.vpri.org/pdf/tr2012001_steps.pdf http://www.vpri.org/pdf/tr2012001_steps.pdf
- scroot 6y agoOr Oberon, which is a top-to-bottom system that is described in a single book
- jacquesm 6y agoI put this up for someone on HN who asked about it: https://jacquesmattheij.com/task.cc https://jacquesmattheij.com/task.cc 3500 lines, micro kernels can be much smaller than that even.
- rstuart4133 6y ago> Modern software is so huge and complicated that it's not feasible to go read it just as a learning exercise. I can't agree. Linux is certainly huge, and yes it's size means it's beyond any newbie's capacity to understand it all. But nonetheless lots of newbies contribute to it regularly. Most of them build up the understanding they need by reading the kernel code. Obviously, that means you don't have to understand all of it to get a lot of benefit from just reading a small subsection. So it is indeed possible to go read the Linux kernel just as a learning exercise. The key point is you don't have to read all of it to get a benefit out of it. Reading just a small subset works just as well as reading the entire source of a small project.
- indigo945 6y agoYes, this is what some people seem to be missing here. Much of the Linux code implements drivers or subsystems that you might not be interested in to begin with (such as the network packet filter). Kernel code is highly modular. The code that implements trivial things like context switching is still much more complex than in an '80s Unix, but it is not millions of lines.
- andrewf 6y agoA profiler will often reveal an interesting cross-section of the code that you can read first. Any way to get a stack trace can be a rudimentary profiler, just keep looking at stack traces until you see what comes up most commonly. If you've got good tools, you can get a map of the code you want to read first. Here is an old MySQL executing some queries: http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html#FlameGraph http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html#... A debugger can also help. You can step through code as it runs. You can also often identify which code is associated with a feature, by putting breakpoints in likely places (dispatch functions!) and triggering the feature.
- v33p 6y agoIt's interesting to think about how modern languages help you squeeze more functionality into those 9000 LOC.
- Reelin 6y ago> modern languages Lisps are hardly a modern invention. "Modern" languages do seem to be ever so gradually working their way towards full compile time metaprogramming though, gaining a great deal of expressiveness in the process.
- userbinator 6y agoThough I am tempted to go see what a 9,000 line OS looks like. Here you go: http://v6.cuzuco.com/ http://v6.cuzuco.com/ I believe most of the Linux kernel source is actually drivers, or otherwise code for which you don't have the hardware to use on, so the actual relevant amount of code in the Linux kernel to e.g. a typical x86 PC might be an order of magnitude less.
- RMPR 6y agoI've found the series of books The Architecture of Open Source applications very helpful in this regard.
- dep_b 6y ago> "Linux is 15+M lines of code" But how much of it is the actual OS versus device drivers and other "extensions" of the main kernel? I assume there is somewhere a core that everything plugs into that has more or less the same functionality as what was done in the 9000 lines of the original Unix v6 code and only uses a fraction of all of the code of the kernel.
- rcxdude 6y agoIt's almost entirely (80%) drivers. Next heaviest is architecture specific code, then filesystems, networking, sound, documentation, and then the actual core of the kernel. A minimal build of linux uses about 300k lines of code. https://unix.stackexchange.com/questions/223746/why-is-the-linux-kernel-15-million-lines-of-code https://unix.stackexchange.com/questions/223746/why-is-the-l... So it's still substantially heavier than would be easy to study, but you could probably still fit the core into your head (I've been able to deeply understand systems with similar LOC counts, though there's probably substantial differences in 'density' between codebases)
- wisty 6y agoApparently Minix3 is 6k and can run a lot of NetBSD on top. https://en.wikipedia.org/wiki/MINIX_3 https://en.wikipedia.org/wiki/MINIX_3