353 points · by dorsatum · 11y ago · 256 comments
Yes, modularity is important. However, in some cases, this philosophy has resulted in the "tangled mess held together by duct tape" kind of systems architecture that no one dares to touch for fear of breaking things.
I think Unix philosophy is struggling with a fundamental dilemma:
On one hand, creating systems from programs written by different people requires stronger formal guarantees in order to make interfaces more reliable, stronger guarantees than interfaces within one large program written by one person or a small team would require.
On the other hand, creating systems from programms written by different people requires more flexibile interfaces that can deal with versioning, backward and forward compatibility, etc, something that is extremely difficult to do across programming languages without heaping on massive complexity (CORBA, WS-deathstar, ...)
I think HTTP has shown that it can be done. But HTTP is also quite heavy weight. It doesn't exactly favor very small programs. Handling HTTP error codes is not something you'd want to do on every other function call.
In any event, I think Unix philosophy is a good place to start but needs a refresh in light of a couple of decades worth of experience.
Pretty much, just as Booch's philosophy has given us tangled messes of class hierarchies with cross references pointed every which way. And just as The Gang of Four gave us AbstractedTangleMessFactorySingleton.
The distinction with the Unix-style pipe mess is that it exists and works an order of magnitude faster than other examples of bad code.
I think we have actually made progress with HTTP and all the REST. But I feel that the great failure of distributed object systems in the 1990s and 2000s has left a great void when it comes to new thinking about more fine grained sort of interfaces between programs.
Functional programming has influenced so many things but hasn't really arrived in the systems corner of the world yet. Also, looking at the sort of query capabilities of online streaming databases and complex event processing systems I get the feeling that there may be a lot of potential in combining that with Unix pipes and text streams.
Publish-subscribe ala zeromq is also something that could be a core part of modern Unix.
Sorry about the half-baked mess I'm dumping on you here :)
The Gang of Four didn't give us that. An army of OOP novices who were overwhelmed by all of the new choices and only skimmed Design Patterns gave us that.
If you actually read the book (which surprisingly few people have, given the number of people who have strong opinions about it), you'll see the Gang of Four are actually quite clear on the limitations or and ways to abuse the patterns.
The GUI-oriented 90's vibe, meaning zero examples that anybody would ever bother learning. The bizarre stuff nobody ever uses (Flyweight? Bridge?). Singleton -- 'nuff said.
You're left with what, maybe three usable patterns? Factory, which favors opaque, magical return-type polymorphism. Visitor, which is a solution in search of a problem, and also gets confused with trivial tree-walking operations. Interface, which rocks, and became part of Java, but really just shows how much inheritance sucks.
The resulting confusion is the proud sponsor of an AbstractStrategyFactoryBuilderDelegate near you.
The main issue that most of the common programming languages in use notably Java and C++ have very poor support for composition thus forcing developers to have to extend things.
Hey, not funny. I actually googled that pattern just to make sure it was a joke.
The second part is a "frontend", a command-line client that does all the unixy stuff with text streams etc; but is just another RPC client to the backend.
This provides flexibility; for quick duct-tape situations you use the front end and pipe anf ilter to your hearts content. Then when stuff needs to get serious, you can bypass the command-line front end and connect directly over RPC using a strict message format which has the ability to handle a couple (doesn't have to many) of concurrent requests.
Of course this is early doors yet, but I think it might have legs in the flexibility in the text streams/hard message format debate, for very little additional work.
The difference is that in what I've described, the ABI is the common interface and an RPC server would be just another consumer of the library.
Well there was an implementation of something like that, see https://en.wikipedia.org/wiki/DCE/RPC
or DCOM, https://en.wikipedia.org/wiki/Distributed_Component_Object_M...
then there was dcop, dbus, and a bunch of others and now nobody remembers what the goal was
tape_robot start -tapeid=1
as the quick hacky version, and: tape_robot --protobuf 'msg:start;tapeid:1'
(replace the 'single:quote;string:thing' with your protobuf message.), or tape_robot --protobuf_file filename
The filename could be a fifo or socket, of course. Then use a general purpose server which runs the programs: proto_serve tape_robot 127.0.0.1:8080
or whatever.This (to me) is closer to the unix idea - one server program, one actual processing app. Why should my tape_robot program actually have a server embedded in it?
If in the future, I want to add authentication, I only have to add it (once) to the proto_serve program, rather than to every single application that is a 'server', for instance.
It would also allow a version which 'pre-forked' the processes, and left them waiting for the data on the socket/filehandle, or whatever.
You could do a bunch of this already using nc or similar, I suspect.
But nowadays lots of things only come for the GUI.
In this case the 'library' is often the base programming language it's self, as the shipped parts are entirely glue and configuration.
Personally, I enjoy the
nix philosophy of using small programs that do one thing well. Also, I prefer text to proprietary binary formats that _I_ can't do anything with.As a *nix and Windows developer, I've never understood the mentality of wanting to build huge monolithic applications. But, I do think the tide is turning. I think more and more developers are allowing themselves to be influenced by ideas outside of what they are used to and that's a great thing.
Personally, I think the LLVM project shows what the Right Thing is here: package most of the real functionality into libraries while putting the user interfaces into runnable programs. Everyone who wants to communicate with the functionality can just link the library.
And if we want to do it statefully, well, handling global state across a large system is basically the unsolved problem of programming.
The one downside I found when trying to use it was that the 3rd-party C# Protobuf libraries didn't yet support it.
See: https://developers.google.com/protocol-buffers/docs/proto#on...
It's always going to be a good place to start because it embodies a realistic, documented, proven and actionable compromise between engineering purity (the "formal guarantees" you describe) and just shipping something.
For a collection of related thoughts, not limited to traditional unix philosophy but still unix philosophy-centric, check out my ansified fortune clone @ https://github.com/globalcitizen/taoup
I think it's not an accident or historical vestige that Unix philosophy uses the word "program". It has technical as well as social implications that have barely changed in the past 50 years.
Functions and programs are certainly not an either-or kind of thing but making them one and the same would require a very different kind of operating system than we have ever seen. Say, emacs OS :)
Insightful.
It's also free online:
http://www.catb.org/esr/writings/taoup/html/An example "Reading it, it looks like a total hack job by a poor programmer."
A better example might be this post, where ESR is implied to be racist when his actual post is a reflective one about correcting irrational racist reactions: https://news.ycombinator.com/item?id=6884767
On the other hand, someone's political opinions change what they're likely to write, so if you don't know whether it's "true" or not, knowing their political opinions can justifiably alter your beliefs about the text.
I think people tend to overweight the second consideration, and it seems particularly irrelevant in this case.
(Scare quotes because it's rarely as simple as true-or-false, e.g. "literally true but horribly misleading".)
Many programmers / writers / programmer-writers may well have equally strong political views in one direction or another, with which others may strongly agree or disagree, but they just don't say much about them in public.
Normally this would just be a quirk, but the fact is that a lot of technical people here on HN and other places would happily throw the baby out with the bath water just because they disagree with somebody's politics.
It's stupid and unprofessional. With so many companies focusing on such technically boring problems, image management is perhaps legitimately more of a business concern than having the best tech available.
So, unfortunately, we have people with dissenting opinions but excellent work slandered or ostracized...even if their opinions are actually worth considering. Then again, that just means that those of us who are more genuinely tolerant will have an edge during hiring. :)
Also, on ESR in particular:
You have to understand that, rightly or wrongly, his worldview is long-term Culture War. Literally anything which prevents The Right People from breeding faster (homosexuality) or defending themselves (attacks on the 2nd amendment) or arguing (kafkatraps) is suspect. Because he's playing for keeps, he'll do whatever it takes (including, perhaps, being less than perfectly equal in presentations on things) to further his agenda. That's just how it is, and it doesn't reflect on his technical contriubtions or aptitude at all.
Hell, the bitch of it is, he's even arguably correct on some of his cultural points, if he himself (much less his detractors) didn't spend so much time sounding so disagreeable and grumpy and wingnutty.
Anyways, it's just a sign of the times, as I said. It seems that most people are unable to handle a mental model which accounts for biased or unreliable narrators while still allowing the work of those narrators to be taken advantage of.
A better title would have been the Art of Linux Programming or the Art of Open Source Programming.
Except that a program-to-program interface based on formatting and parsing text is anything but clean.
As a general rule of thumb: if you have a command pipeline that would break because programs in it handle locale differently, it's most definitely text-based program.
I like the idea of Power shell: programs pipe formatted (binary) objects between them, and there exist commands to print them out in a nicely formatted way to the terminal. But it's objects. I can extract information through named fields instead of through magic indexes and regexpes in awk/sed/perl oneliners.
IOW, proper object (meta)model, not sucky text streams. Text is great for long-term storage, but awful for data in flight. UNIX ignored this distinction and decided to use text for everything.
The alternative - binary structures - require complex data definitions where you have to care about stuff like exact byte lengths when you have to convert between big/little endian. Some people like to claim that binary is faster, but your bottleneck is not going to be strtol(3). As for advantages in parsing - you still have to parse the binary structure you just read. I suspect most people that think "parsing text" is difficult are confusing the parser with lexer; the latter is the only part that changes when you switch between text and binary formats.
In the long run the initial investment in a text interface can be cheaper than wasting time debugging binary structures. Even more important when thinking long-term: it is a lot easier to inspect a text interface from the outside without the consent or availability of the original author. If you have an old program binary that was used in production for years and no source code or documentation, which would you rather try to debug? An opaque binary file? Or something in JSON or INI format?
[1] however, this is not an excuse to skip proper documentation
Anyway, I've been with my company for a few years and soon my contract expires and I'm going to study the field our company is in and get a degree in that, then I'm going to apply for a position doing our core business. I would still like to be involved with the software my current position is touching on, though, if possible. (Our company has 1000+ employees and several different sub-sections, so even though I might get back into the company, it's not a given that I'll be working with the group of people I am now even though I'd like to.)
I also sometimes think that if possible, perhaps I'd like to work for that other company in our neighbouring country for a few years and be on the dev team of the software. After all, I have experience from the user side which the dev team has not and the dev team has seen some of the tools I've made and a couple of the guys seemed to think that some of that stuff was pretty decent.
> Rule of Diversity: Distrust all claims for “one true way”.
Although, does the python rule "There should be one-- and preferably only one --obvious way to do it." contradict this one ?
> Rule 5. Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming.
I wonder what rob pike has to say about OOP or java, I wish I could listen to it.
Also it says that text is a good representation of data, but I think he meant it as intermediary. I don't think xml or html are really good choices when you see all the CPU cycles spent parsing those.
> Rule of Economy: Programmer time is expensive; conserve it in preference to machine time.
I prefer this rules versus the "no premature optimization" rule.
“object-oriented design is the roman numerals of computing.” - Rob Pike (http://harmful.cat-v.org/software/OO_programming/)
Some other gems from that page:
“Object-oriented programming is an exceptionally bad idea which could only have originated in California.” – Edsger Dijkstra
“The phrase "object-oriented” means a lot of things. Half are obvious, and the other half are mistakes.“ – Paul Graham
“I used to be enamored of object-oriented programming. I’m now finding myself leaning toward believing that it is a plot designed to destroy joy.” – Eric Allman
“The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.” – Joe Armstrong
Which is weird because Pike's Rule 4 is one of the fundamental principles of OO design.
The irony is that Python has more ways of doing things in general and often the choice is very much non-obvious, compared to a language like Ruby which is supposedly embracing TIMTOWTDI. In other words, that Python rule doesn't match reality and I've always found it funny.
The statement in question is from The Zen of Python and is more of a guiding principle for the design of Python than a rule.
The usual observation with Python is that it can have many libraries and frameworks which are quite similar and choosing one can be hard (e.g. web frameworks). This is a function of popularity and not something which can fairly be subject to that principle.
On a different note: missing is the Zen of Python's following line:
Although that way may not be obvious at first unless you're Dutch.The language itself is a prime example of a language with features that aren't orthogonal. For example count how many features in Python are solved in other languages just with proper support for anonymous functions.
https://talks.golang.org/2012/splash.slide#55
https://talks.golang.org/2012/splash.slide#56
https://talks.golang.org/2012/splash.slide#57
From this talk: http://www.infoq.com/presentations/Go-Google
12 minutes where Pike talks about a few things, that seem to be wrong in our software world: https://www.youtube.com/watch?v=5kj5ApnhPAE
I don't think so. To me Python's design rule implies there should be one way clear path to solve a specific problem and generally you'd also want to stay as consistent as possible with other similar solutions.
The "one true way" argument is to force everything to fall into a pattern even when it's a less than ideal way to solve a problem. An example would be trying to force everyone to use the same language/database/framework combination in a company for everything. Sometimes you want to be flexible and use the right tools for the job (while also accounting for the cost of deviating from the general accepted standard in making that decision).
Nope, that's a design guideline, it's not taking choice away. A rule like "Python is the only language you'd ever need" would contradict it.
If you exclude one person because they disagree with X and don't know Y, then you must equally disregard all who agree with and disagree with X, because they don't know Y. Otherwise you're just cherrypicking :)
However, it has become quite trendy to bash OOP itself, especially here on HN, without acknowledging that there are less awful ways of doing it that just aren't mainstream. Try making similarly blanket criticisms of FP here using Python (Why, it has lambdas and list comprehensions after all--isn't that enough?) or some other impure language and see what happens.
I'd argue that the unix way is to make it JSON until it becomes a performance problem by which time the format is so entrenched in so many programs and since there's no real central coordination, you just get to live with it.
Which means that no program is more un-UNIX-y than Emacs...
Emacs also interfaces with external processes (e.g. using comint mode). It's the ultimate bottle of glue.
Where it butts against contemporary practice is in places like threads where it is still not proven that YAGNI doesn't apply.
But yes, it's funny.
Saying that these are modern UNIX principles might be more fair. Yet, Kemp's article inspires doubt in even that:
For example, being able to draw a shape in a a graphical editor and then paste the shape directly to a window as the shape that window should take was rather cool - and this was in the early 90s!
The Single responsibility Principle (SRP), interfaces, cohesion and coupling are all relevant patterns and techniques that also describe the same design ideas.
The UNIX philosophy is simply one example of the above principles implemented at a user interface level, but they apply equally well in low-level embedded code, and device drivers just as well as in desktop and server land.
Software complexity grows exponentially with the number of internal interactions. by reducing the scope of any given module, you greatly simplify it. Thinking about, designing and implementing fixed interfaces between small cohesive modules helps this process and you get much more simple (as in the Rich Hickey sense) software as a result.
These same principles pop up all over the place in software, the Unix Philosophy, SRP, Microservices... they're all manifestations of the same thing.
The reason that 'systemd' is the ball of mud it is that Linux being just a kernel does not provide the basics for systemd to build on so it has to provide them itself.
The broader tools that systemd also provides (stub DNS/LLMNR resolution, network management [DHCP, PPP...], container registration, message bus introspection and library, event loop library, EFI stub loader, device and mount management, hardware database, TTYs, NSS plugins, session and seat management, SNTP client, time/date control, dynamic configuration population, etc.) exist mostly for philosophical reasons of being a one true toolkit/middleware that sits between GNU and Linux.
launchd isn't Unix-y at all, anyway.
Here's an LCA talk by a dude what works on X and Wayland: https://www.youtube.com/watch?v=RIctzAQOe44
Hell, the X primitives are so outdated, all the toolkit developers do client side rendering now.
Wayland is the bits of X that people actually use.
If all the developer thrust is behind toolkits that "badly misuse the protocol", maybe the protocol is a really shitty fit for app development?
Welcome to why Wayland is the future and X is deprecated. Daniel Stone's talk should be required viewing before anyone speaks on the X vs. Wayland issue: