by cs702 · 9y ago · 0 comments
Yes, if you run the popular editor Atom on Linux, you're running an application built atop Electron, which incorporates an entire web browser with a Javascript runtime, so the application is using browser drawing APIs, which in turn delegate drawing to lower-level APIs, which interact with a window manager that in turn relies on X...
Yes, it's complexity atop complexity atop complexity all the way down.
But the solution is NOT to throw out a bunch of those old layers and replace them with new layers!!!
Quoting Joel Spolsky[1]:
"There’s a subtle reason that programmers always want to throw away the code and start over. The reason is that they think the old code is a mess. And here is the interesting observation: they are probably wrong. The reason that they think the old code is a mess is because of a cardinal, fundamental law of programming: It’s harder to read code than to write it. ... The idea that new code is better than old is patently absurd. Old code has been used. It has been tested. Lots of bugs have been found, and they’ve been fixed. ... When you throw away code and start from scratch, you are throwing away all that knowledge. All those collected bug fixes. Years of programming work."
[1] https://www.joelonsoftware.com/2000/04/06/things-you-should-...
The author of the article recognizes there's a problem, but is less clear on how to go about solving it. A clue is in this article by Erik Naggum: http://naggum.no/erik/complexity.html
Dan Ingalls once wrote: "Operating System: An operating system is a collection of things that don't fit into a language. There shouldn't be one." What he meant is we should migrate the functionality of the operating system into the programming language. This is possible if there's a REPL or something similar, so no need for the shell or command line. The language should be image-based, so no need for a file system. So, a bit like Squeak, or a Lisp with a structure editor.
There's still a gap between the processor and the language, which should be eliminated by making the processor run the language directly. This was done in Burroughs mainframes and Lisp machines.
Further up the "stack", software such as word processors and web browsers are at present written entirely separately but have much in common and could share much of their code.
I like the idea of an image based system, eliminating the need for the filesystem itself. I think the 'filesystem' and 'executable-process' ideas are so prevalent that they frame our thinking, and any new OSes tend to adopt these right away. But more interesting and powerful systems might emerge if we find a new pattern of operation and composition. Are you aware of any image based full stack systems that are in active development?
But, sometimes, that's exactly what you should do. It brings to mind OpenSSL after Heartbleed. I remember reading that the LibreSSL people were ripping out all kinds of stuff (like kludges and workarounds to support OpenVMS), and rightly so. You might call it "knowledge [and] collected bug fixes," but sometimes the crap is just crap.
Key word here is "Sometimes".
Reviewing code means you get to find out the reason these hacks were written in the first place, and then decide wheter to keep, rework or delete them.
Starting from scratch means you get rid of the worthless crap, yes, but you also lose all the valuable crap.
So, they weren't starting over. They forked, refactored and removed things no longer needed. Completely different thing.
It's three years later. What general-purpose OS other than OpenBSD is using LibreSSL?
https://developer.apple.com/library/content/documentation/Se...
https://opensource.apple.com//source/CommonCrypto/CommonCryp...
Neither is keeping everything as it is and keep pretending it's fine!
> When you throw away code and start from scratch, you are throwing away all that knowledge.
I disagree with Joel on here. There's lots to be learned from throwing everything away and starting from scratch, and if anything those innovations could make their way into the current infrastructure, as it has happened with Midori and Windows.
Related: "legacy code is code that doesn't have tests" not sure who said this but also very true IMO
Michael Feathers in "Working with legacy code" (A book I can highly recommend)
In the other words, the point is that you always have to do the cost-benefit analysis for any such endeavor and the history tells that rewriting is intrinsically very expensive.