I keep wondering about what seems to be the most important component of Unix philosophy: write many small programs that do one thing well and interface using text streams! 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 stru…
Recently I've been exploring the idea that small programs should consist of two parts; a "backend" that you can communicate with via a strict message protocol like protobuf. It can handle multiple requests because it is a mini server, the message format is locked to a "type" and you communicate with it via RPC. The second part is a "frontend", a command-line client that does all the unixy stuff with text streams etc;…
The Unix Philosophy
161–170 of 269 posts
Re: The Unix Philosophy
#162Earlier quoted context omitted.
Additionally, it's not a religion. Every programmer should be exposed to Unix style programming just like every programmer should be exposed to functional programming. 100% purity in either case is just creating unnecessary problems.
Amen. Extremism in programming, as in religion, is evil.
When the reality is that you can't take an opinion as the whole thought. But people do. Almost always. Regardless of the subject, people will think you're a fanatic for your position, no matter how temporary or experimental it is, unless you pay your dues in apologies and waffle terms.
Re: The Unix Philosophy
#163> The ‘Unix philosophy’ originated with Ken Thompson's early meditations on how to design a small but capable operating system with a clean service interface. Except that a program-to-program interface based on formatting and parsing text is anything but clean.
What do you mean by "text"?
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.
Re: The Unix Philosophy
#164Earlier quoted context omitted.
Python's support for closures is perfectly fine. Its anonymous function support is crappy, but it doesn't stop you from doing what you want, it just looks as ugly as sin.
Python only lets you have one line in a lambda - the return line. In languages with nicer anonymous function support I can make an anonymous function span multiple lines and branches eg. in C# you could assign to a delegate something like myObj.stringToHash = (s) => {int x = 0; foreach(var c in s) x += ... ; return x;} I find python's restriction in this case fairly strange. If I wanted to do that in python I'd have…
def some_method(...):
avar = aval
.... (some code)
def throwaway(x, y):
....
something_else(avar, x+y)
some_obj.somefunc = throwaway
The major difference is you do the function definition just prior to the assignment. The "namespace pollution" is literally limited to the scope of "some_method", so you have an extra local var in a function somewhere. The semantics of python mean that the function is created on the stack, and a closure is created each time the some_method is called, and the closure is later GCed as any other object would be, so there is nothing fundamentally different about the "named" function, and the "anonymous" function in you example, except a single local variable.Re: The Unix Philosophy
#165Earlier quoted context omitted.
The big problem I've found is serialization of sum types. thrift (or protobuf or any number of similar systems) is very good at serializing most of the data one tends to work with, with declarations that are suitably strict but easy to write. But it doesn't have a good way to represent "this field is an A or a B".
Thrift has unions, so does Apache Avro. Afaik Protocol Buffers is the only one where you have to string together one yourself with a required tag and a bunch of optionals.
Re: The Unix Philosophy
#166This should be taught in any programming class. > 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 ce…
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
Re: The Unix Philosophy
#167Earlier quoted context omitted.
Recently I've been exploring the idea that small programs should consist of two parts; a "backend" that you can communicate with via a strict message protocol like protobuf. It can handle multiple requests because it is a mini server, the message format is locked to a "type" and you communicate with it via RPC. The second part is a "frontend", a command-line client that does all the unixy stuff with text streams etc;…
Surely a lot of that could be done with a commandline switch? 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:80…
Re: The Unix Philosophy
#168I wonder how relevant is it nowadays. Many good things we can't have, like systemd, if we have to follow strictly to the unix philosophy.
Sure you can. See 'launchd' on OSX. 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.
Re: The Unix Philosophy
#169I keep wondering about what seems to be the most important component of Unix philosophy: write many small programs that do one thing well and interface using text streams! 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 stru…
Recently I've been exploring the idea that small programs should consist of two parts; a "backend" that you can communicate with via a strict message protocol like protobuf. It can handle multiple requests because it is a mini server, the message format is locked to a "type" and you communicate with it via RPC. The second part is a "frontend", a command-line client that does all the unixy stuff with text streams etc;…
Re: The Unix Philosophy
#170Earlier quoted context omitted.
What do you mean by "text"?
Semi-rigid, informally specified output meant for easy inspection by humans. The output of `ifconfig -a` for example. (That's the worst offender, most other commands have a better-formatted output.) 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 formatte…