Live data from Hacker News

How could the early Unix OS comprise so few lines of code?

retrocomputing.stackexchange.com

1–10 of 170 posts

Re: How could the early Unix OS comprise so few lines of code?

#2
Answer: smaller target to cover! Modern Linux has most code in device drivers to support so many different devices. Then, it supports many targets for other subsystems, like file systems.

The original Unix provided one implementation for each subsystem. They relentlessly simplified the problem they were solving to make it doable.

Re: How could the early Unix OS comprise so few lines of code?

#3
It was essentially a "time-sharing" system that multiplexes interactive sessions of multiple users on teletype terminals. The "shell" handles such a session by waiting for user input on the terminal, interpreting it and starting external programs as a sub-hierarchy of user processes. On a teletype terminal, you couldn't even have a cursor-oriented editor like vi, but had to rely on line-oriented editors like ed and sed.

Re: How could the early Unix OS comprise so few lines of code?

#4
I think mindset plays a role as well. Back in the day, there was a restraint on adding features, at least when they would make the logic more complicated for only a tiny or imagined benefit. Part of that was memory/storage limitations. But I think the pursuit of an abstract idea of elegance was equally important. After all, these systems were primarily written for other computer people.

This idea is completely gone from the world of software engineering. Systems become overloaded with the implementation of every crappy idea under the sun -- if a PM in a fever dream can think of it, and an overworked dev can hack it together, it goes in.

Re: How could the early Unix OS comprise so few lines of code?

#5
post #4

I think mindset plays a role as well. Back in the day, there was a restraint on adding features, at least when they would make the logic more complicated for only a tiny or imagined benefit. Part of that was memory/storage limitations. But I think the pursuit of an abstract idea of elegance was equally important. After all, these systems were primarily written for other computer people. This idea is completely gone f…

Not in open source. Projects with the attitude of allowing any feature that some rando comes up with die quickly when the manpower to keep it up simply isn't there. The projects with maintainers that gatekeep are the ones that survive, and they survive for a long time.

Re: How could the early Unix OS comprise so few lines of code?

#6
post #4

I think mindset plays a role as well. Back in the day, there was a restraint on adding features, at least when they would make the logic more complicated for only a tiny or imagined benefit. Part of that was memory/storage limitations. But I think the pursuit of an abstract idea of elegance was equally important. After all, these systems were primarily written for other computer people. This idea is completely gone f…

In the case of Unix, it was deliberately a KISS/stripped down successor to Multics. The simplicity was originally intended for faster development and running on minicomputers rather than mainframes. In the end the simplicity also meant hackability and portability which is probably why it was successful and has had so much staying power.

Re: How could the early Unix OS comprise so few lines of code?

#7
post #2

Answer: smaller target to cover! Modern Linux has most code in device drivers to support so many different devices. Then, it supports many targets for other subsystems, like file systems. The original Unix provided one implementation for each subsystem. They relentlessly simplified the problem they were solving to make it doable.

They also didn't care nearly as much about performance.

Or to be more precise, they had very different trade-offs to make. Back then, you could have a system call and context switch for every read and live with the overhead.

Today we have something like io_uring.

Re: How could the early Unix OS comprise so few lines of code?

#8
post #2

Answer: smaller target to cover! Modern Linux has most code in device drivers to support so many different devices. Then, it supports many targets for other subsystems, like file systems. The original Unix provided one implementation for each subsystem. They relentlessly simplified the problem they were solving to make it doable.

With virtual memory and demand paging, memory management (done efficiently) becomes a much harder problem, too.

Re: How could the early Unix OS comprise so few lines of code?

#9
post #2

Answer: smaller target to cover! Modern Linux has most code in device drivers to support so many different devices. Then, it supports many targets for other subsystems, like file systems. The original Unix provided one implementation for each subsystem. They relentlessly simplified the problem they were solving to make it doable.

Latest Linux kernel source:

      39,000  certs     0.0%
      40,000  usr       0.0%
     164,000  init      0.0%
     240,000  virt      0.0%
     250,000  ipc       0.0%
     459,000  io_uring  0.0%
     664,000  rust      0.1%
     980,000  samples   0.1%
   1,885,000  block     0.1%
   2,850,000  scripts   0.2%
   2,953,000  security  0.2%
   3,609,000  crypto    0.3%
   5,165,000  mm        0.4%
   7,156,000  lib       0.5%
  12,420,000  kernel    1.0%
  33,047,000  net       2.5%
  39,916,000  include   3.1%
  43,224,000  fs        3.3%
  45,001,000  sound     3.4%
  54,988,000  tools     4.2%
 107,971,000  arch      8.3%
 943,527,000  drivers  72.2%
Based on rough byte count (total 1,306,548,000 bytes in the above).

Re: How could the early Unix OS comprise so few lines of code?

#10

It was essentially a "time-sharing" system that multiplexes interactive sessions of multiple users on teletype terminals. The "shell" handles such a session by waiting for user input on the terminal, interpreting it and starting external programs as a sub-hierarchy of user processes. On a teletype terminal, you couldn't even have a cursor-oriented editor like vi, but had to rely on line-oriented editors like ed and s…

In a way it became the complete opposite of how it started. At first one OS for many users, ea with many processes. Now, with containers, micro services etc. we have an OS per service/process. Still the original abstractions work surprisingly well though makes it me wonder how a complete redesign of would look like aimed at modern usage.
Post reply on HN