📜 ⬆️ ⬇️

UNIX-like systems contain a bunch of crutches. The collapse of the "UNIX philosophy"

UPD from 2017-03-04: someone completed the English translation . Discussion on Hacker News .

In the first part of the article I will list a bunch of UNIX crutches, and generally various shortcomings. In the second - about the "UNIX philosophy". The article was written hastily, I don’t want to further “polish”, say thank you for writing. Therefore, I cite many facts without references.

Crutches in UNIX began to emerge from the moment UNIX appeared, and this was even before the appearance of not only Windows, but even Microsoft DOS (it seems, I’m too lazy to check, check it myself). If you are too lazy to read, at least look through all the items, you will find something interesting. This is not a complete list, these are just the shoals that I wanted to mention.


« UNIX». , UNIX . (« », « » . .) « UNIX». , , . « UNIX» . : , , .


. , . UNIX, . , « ». shell. , shell. ( , , « » shell ). , . , , . , .

. UNIX. . . UNIX . , , UNIX . , UNIX, « UNIX». , UNIX, . «UNIX Style, or cat -v Considered Harmful». . , , , cat — ( «» , , cat, ?). , « UNIX». cat-v.org, , .

, , , , , . , , ? . . «Systems Software Research is Irrelevant» , . , UNIX ( - ): «New operating systems today tend to be just ways of reimplementing Unix. If they have a novel architecture — and some do — the first thing to build is the Unix emulation layer. How can operating systems research be relevant when the resulting operating systems are all indistinguishable?»

: «The Good, the Bad, and the Ugly: The Unix Legacy». , , , : «What makes the system good at what it's good at is also what makes it bad at what it's bad at. Its strengths are also its weaknesses. A simple example: flat text files. Amazing expressive power, huge convenience, but serious problems in pushing past a prototype level of performance or packaging. Compare the famous spell pipeline with an interactive spell-checker». : «C hasn't changed much since the 1970s… And — let's face it — it's ugly». , , .

UNIX . , , UNIX. UNIX, UNIX. IDE. . , , .

, UNIX, : Plan 9. , . UNIX. Plan 9 . «Systems Software Research is Irrelevant» Plan 9, .

James Hague, ( ) : «What I was trying to get across is that if you romanticize Unix, if you view it as a thing of perfection, then you lose your ability to imagine better alternatives and become blind to potentially dramatic shifts in thinking» (). «Free Your Technical Aesthetic from the 1970s», . (, , , , , ).

, , UNIX — . , , . « UNIX» , , . UNIX GNU/Linux. .

UPD 2017-02-14: , UNIX shell PHP . , ! UNIX shell , , . . UNIX shell . . , UNIX shell cmd. , Windows Powershell. , , - UNIX shell.

UPD 2017-02-14: sshikov:

— , « , bash, ...» — unix way . .

, - ! , UNIX way. UNIX . - UNIX .

UPD 2017-02-14: , Windows UNIX- . UNIX, , UNIX , Windows. , Windows. UNIX. , , . « UNIX», . UNIX . . UNIX , « UNIX» . « UNIX», C Shell , , Web-. , Web- , , C ( C , ). - quirks , , C. , , . , , . , , . Windows ( - , Windows UNIX?). - Windows UNIX ( Powershell). UNIX. UNIX , , . UNIX. UNIX , .

UPD 2017-02-15: habrahabr.ru/post/321652/#comment_10070776.

UPD 2017-02-15: habrahabr.ru/post/321652/#comment_10071096.

UPD 2017-02-15: habrahabr.ru/post/321652/#comment_10071714.

UPD 2017-02-16: : habrahabr.ru/post/321652/#comment_10066240.

UPD 2017-02-16: , UNIX . , . . GNU/Linux :) . UNIX. , UNIX. UNIX , . James Hague, :

Enough time has passed since the silly days of crazed Linux advocacy that I'm comfortable pointing out the three reasons Unix makes sense:

1. It works.
2. It's reliable.
3. It stays constant.

But don't--do not--ever, make the mistake of those benefits being a reason to use Unix as a basis for your technical or design aesthetic. Yes, there are some textbook cases where pipelining commands together is impressive, but that's a minor point. Yes, having a small tool for a specific job sometimes works, but it just as often doesn't.

, , « UNIX». , . , . . . . . , . , , . , « UNIX» James Hague. , .

, «» UNIX . , . . . . , , . /usr make. , UNIX . , UNIX! Bell Labs Multics. : « Multics, - , ». . ? . . UNIX — . , .

, , , UNIX, . UNIX- , . , . , . , UNIX , . , UNIX . UNIX. ( !). C, UNIX shell, , « ». , C make, , UNIX. POSIX. : « IDE make». , , , , IDE — C, make shell.

, UNIX ( , ) . shell- — , . .

, shell, make , IDE, , GUI- . . :) - . . , , autotools , make. autotools, m4, make shell. , , , .

UNIX:

Write programs that do one thing and do it well.
Write programs to work together.
Write programs to handle text streams, because that is a universal interface.

, UNIX shell . , REST. ( , JSON). — , . universal interface . JSON XML. , , - , .

shell. , , find -exec xargs. , . , . , shell' . - . shell' quirks, . .

. :

iTWire: Systemd seems to depart to a large extent from the original idea of simplicity that was a hallmark of UNIX systems. Would you agree? And is this a good or a bad thing?

Linus Torvalds: So I think many of the «original ideals» of UNIX are these days more of a mindset issue than necessarily reflecting reality of the situation.

There's still value in understanding the traditional UNIX «do one thing and do it well» model where many workflows can be done as a pipeline of simple tools each adding their own value, but let's face it, it's not how complex systems really work, and it's not how major applications have been working or been designed for a long time. It's a useful simplification, and it's still true at *some* level, but I think it's also clear that it doesn't really describe most of reality.

It might describe some particular case, though, and I do think it's a useful teaching tool. People obviously still do those traditional pipelines of processes and file descriptors that UNIX is perhaps associated with, but there's a *lot* of cases where you have big complex unified systems.

And systemd is in no way the piece that breaks with old UNIX legacy. Graphical applications seldom worked that way (there are certainly _echoes_ of it in things like «LyX», but I think it's the exception rather than the rule), and then there's obviously the traditional counter-example of GNU emacs, where it really was not about the «simple UNIX model», but a whole new big infrastructure thing. Like systemd.

Now, I'm still old-fashioned enough that I like my log-files in text, not binary, so I think sometimes systemd hasn't necessarily had the best of taste, but hey, details…


UPD 2017-02-18: shell. , , find -exec xargs. , . , , , , -exec xargs — . « », UNIX shell.

, , , find -exec xargs.

touch'. « touch' foo ( )?» , touch' , grep' bar . . . file ⟦grep bar file > tmp; mv tmp file⟧. ? , , , . , :

find foo -print0 | while IFS="" read -rd "" A; do
	grep -- bar "$A" > tmp
	mv -- tmp "$A"
done

, , , foo, . , IFS . , , , foo — ⟦--⟧. , . . ⟦--⟧ : «, ». .

, xargs find -exec? touch', , . : grep , . , shell', ⟦sh -c⟧. ? , ?

find foo -exec sh -c "grep -- bar '{}' > tmp; mv -- tmp '{}'" ';'

, ! , . :

find foo -exec sh -c 'grep -- bar "$1" > tmp; mv -- tmp "$1"' dummy '{}' ';'

? . $1. - , $1. xargs. ⟦sh -c⟧ $1.

, , , , , - .

. . , find. , . . . , find sublanguage, . . find'. , , , find' . truth value, . . . - . , truth value find , descend (. . ).

, , . ⟦find -delete -name '*~'⟧ ⟦find -name '*~' -delete⟧ - . , , . . find . . , . , -name truth value true , . -name true, .

? , find sublanguage. shell. ( sed, — , awk — , UNIX' .) , find . . . find' , descend , callback. , UNIX shell . UNIX shell.

UPD 2017-08-01.

echo , . , , «Hello, world!», .

echo . , bash ⟦echo "Hello, world!"⟧. , . bash , .

UPD 2018-05-31. . , : ⟦-⟧, . , , . . foo.

Source: https://habr.com/ru/post/321652/


All Articles