The (Actual) UNIX Philosophy

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 36

  • @CitizenUnpluged
    @CitizenUnpluged 3 роки тому +11

    Only just discovered your channel. Really appreciate the depth and breadth of your content as well as the insights that only one with a lot of skin in the game can impart. Cheers and all the best.

  • @abdullahilbaki1999
    @abdullahilbaki1999 Рік тому +9

    Actually GNU, therefore Emacs don't want to follow Unix philosophy. GNU = Gnu's not Unix.

  • @theodorealenas3171
    @theodorealenas3171 Рік тому +5

    No, that was enlightening. And it makes me appreciate dmenu even more. Honestly, I've abused dmenu.

  • @herrpez
    @herrpez Рік тому +4

    Emacs user checking in just to be contrarian! 😉 (I came from Vim many years ago and just found Emacs to be more suitable for me, but that's a different story)
    But okay, I'm not really here to be contrarian... I fibbed a little. Within Emacs, I use Evil mode, so it's... basically Vim. And the point of all this is that I wanted give appreciation for the :.!bash thing; I've called external commands on the entire buffer (e.g. :%!jq to format JSON garbage) in the past and never even considered that one could run the current line as a command... but of course! It's so obvious now! 😂
    Learning new things is always neat!

  • @sanjitjena4954
    @sanjitjena4954 Рік тому +2

    came here for just the Unix philosophy, got something practical as a takeaway!

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 Рік тому +4

    Remember that the “do one thing and do it well” dates from the early days, when people writing code either did it as a shell script or a C program, with essentially nothing in-between.
    Then later came Perl. Which one thing would you say it “does well”? Particularly since its own creator describes it as a “Swiss Army chainsaw”? So you do all the steps in a single Perl script, with no “filtering” going on?

    • @gcolombelli
      @gcolombelli 11 місяців тому

      I still think that's a worthwhile motto / design goal for low-level tools. Even Microsoft had to concede to how useful it can be for certain tasks (like automation, development, testing and system administration) and made an arguably more elegant implementation of the same concepts in PowerShell. You can pipe the output of one program into an other program, but since it's not limited to raw text, you can let programs better interpret structured data without having to rely only on text processing to format and validate data. It's got some downsides as well, but I think the benefits are completely worth it.
      Windows always had a ton of potential to exploit some level of modularity and avoid being stuck only with interactive tools that can only work with rigid, specific workflows, I can't believe they put so much work on stuff like DDE, OLE, COM for nothing. I guess the big difference is in audience, each system was a product of their time and whatever their users and developers where trying to solve as those systems evolved.

  • @file4318
    @file4318 Рік тому +4

    You said you don't like sed, awk and tr that much. Why? I really want to know but I can't find another video on your channel about the topic.

    • @Q-Ball.
      @Q-Ball. 9 місяців тому

      As far as I can tell his stance is they all do similar things differently, and people should just use Perl regex. Perl was made for this more or less, he maintains it is royalty in that realm.

  • @GoodVolition
    @GoodVolition 2 місяці тому +1

    I mean I'm pragmatic. There are times monolithic design can be useful. Skilled emacs users often reap huge rewards by using it and I think that's just fine. I think having a version of something built using unix philosophy is a good thing, but if people prefer to opt into a monolithic setup I don't begrudge them that. There more controversial things like systemd. I think systemd brings a lot to the table. It has had a lot of issues. There are times it's done things demonstrably wrong, but in general I think a lot of people get a lot of use out of it. And so overall I accept it. Do I hope one day there's a less monolithic approach with similar utility? Yeah. Am I going to shun systemd in the meantime? No.

    • @rwxrob
      @rwxrob  24 дні тому

      Absolutely agree (now). I no longer thing the purist UNIX philosophy is practical at all, about as practical as saying can only look at one byte when making parsers instead of approaches like PEG.

  • @edgar12334
    @edgar12334 3 роки тому +13

    Seems fitting that a video about this is "short and sweet"
    There is some stuff that rubs me the wrong way on how unix does things. First of all, using plain text as the universal interface removes any kind of structure, like the ability to specify that the first argument of a command must be a path, or a float, and I think that would make scripts in general more robust. Second of all, having to pipe things around and spawn new processes seems to be a big hit on performance over doing it on a single application. For these reasons I don't think the "unix way" should be the ultimate pattern of all software.

    • @Knirin
      @Knirin Рік тому +5

      On Linux processes were cheaper than threads. On Windows threads are still cheaper than a process. The difference is not as bad as it used to be though.

    • @greenfloatingtoad
      @greenfloatingtoad Рік тому +1

      You're not wrong, though imo you can often relax those points while keeping a lot of the benefits of this approach

    • @wyleong4326
      @wyleong4326 11 місяців тому +1

      Really depends what people wanna build. And I agree with you about “unix way” not being the ultimate patterns of all software - diff folks need diff strokes.

    • @gcolombelli
      @gcolombelli 11 місяців тому +3

      Early optimization something something... there's no point in optimizing something before you know it is a serious bottleneck. There are tons of reasons why people use languages like JavaScript, Python, Perl, Lua, Java, C#, rather than only compiled stuff like C, C++, FORTRAN and so on. Get it done first, then, if/when needed, optimize it.
      If the problem you're trying to solve is I/O bound from a relatively slow device (like a disk or network), there's not much point in optimizing how much CPU time and memory bandwidth you're wasting by processing it in an interpreted language and moving data around from one process to another. Especially if it's something that you're doing just once or only from time to time.
      You have to look at the context of where Unix was born and where it evolved. It went from something to make use of an "obsolete" minicomputer to play games from something to be useful enough to justify pouring more company resources into, then into something that allowed more people to run code on smaller, cheaper computers at universities before companies began to realize it could be something they could sell. The experience people at AT&T / Bell Labs had with Multics also helped shaping how Unix was developed and was enough of an inspiration that the initial name was a pun on Multics.
      Also keep in mind how far we're from those days. If you run Unix v6 today, sure, it's still vaguely familiar, but there's also a ton of differences from a modern POSIX / Unix-like system. Plan 9 is a lot closer than the original "Unix way" than Linux, and that's an OS that didn't receive much development in over 20 years.
      Even Microsoft realized how useful "the Unix way" is for some tasks and carried those ideas to PowerShell, while borrowing from more modern languages and making it possible to use structured data instead of relying solely on raw text.

    • @greenfloatingtoad
      @greenfloatingtoad 11 місяців тому

      IMO there's a difference between premature optimization and avoiding premature pessimization, like sometimes a tiny early effort can prevent unnecessarily foreclosing possibilities to optimize later when it's appropriate. But like all things it's tradeoffs

  • @flip4119
    @flip4119 2 роки тому

    Great video! earned a sub from me ! keep up the good work, God bless.

  • @alexeysukhanov1276
    @alexeysukhanov1276 2 роки тому

    example: root&useer$ slash - root
    login=pwd

  • @MrJegerjeg
    @MrJegerjeg 7 місяців тому +1

    systemd clearly deviates a lot from this philosophy.

    • @LeapFrog_Radio
      @LeapFrog_Radio 6 місяців тому

      Hot take, but that doesn't mean you're wrong. ;)

  • @vincentvega7908
    @vincentvega7908 6 місяців тому

    The text streams are a bad interface. In fact a number unix tools have that -0 flag to avoid the limitation of text streams.
    exec() is a bad ABI for library functions.
    Text files are also binary files, they have bytes of zeroes and ones in them the same as any other garbage on the disk. It just so happens that both vim and emacs can open these natively and give you meaningful view of the content without extra plugins.
    If your extension language was not UNIX shell but anything else that could use structured data (which vim incidentally also supports, although as a bolt-on feature which is not nearly as well integrated) you would be able to not only filter through a ready-made shell function such as date(1) but also build on top of them easily with additional code of your own.
    Emacs basically follows the UNIX philosophy to the letter except it uses S-expressions in place of text streams. Somewhat better structured so somewhat saner to use. Some of its extensions (eg magit) are amazing, and you cannot dream of making that work reliably with an exec() ABI and text streams.
    The failure of emacs is it chose to implement its own language to be written in rather than using an existing one. Granted, at the time the choice was limited so this is understandable. The practical result is that it fails at point two: working together with other programs. While theoretically libraries and programs can be written in e-lisp practically only emacs and its extensions are.
    Another failure of emacs is that it does still call programs using exec(), even for basic functionality like reading the GNU info pages leading to interface inconsistencies. Think about it, GNU Emacs cannot read GNU info pages. It would be fine if GNU had some UX guidelines to make different GNU programs behave consistently but it clearly does not.

  • @Narblo
    @Narblo 2 роки тому +1

    But wouldn't piping through all these programs to make a huge script be a lot less performant than making a native program that do it?

    • @arcadia09
      @arcadia09 Рік тому +5

      Portability over efficiency

    • @gcolombelli
      @gcolombelli Рік тому +1

      It's a trade-off, you don't want to have to write a native program for every single task you must perform, if it's going to be something you'll be running all the time, sure, build a program just for that, but if you're just trying to solve one thing and that solution won't be useful again, it's often more efficient to just cobble together a solution with whatever you already have at hand.

    • @wyleong4326
      @wyleong4326 11 місяців тому +1

      Really depends on what you’re trying to achieve - results may vary with deadlines, costs and manpower.
      Looking at long term and short term at the same time is hard but prolly preferable than pure hacking imo.

  • @alexeysukhanov1276
    @alexeysukhanov1276 2 роки тому

    slice or слайс?8

  • @Christobanistan
    @Christobanistan 6 місяців тому

    OK, now let's move past that 50 year old philosophy.

  • @bullpup1337
    @bullpup1337 5 місяців тому

    You misunderstand emacs. Emacs is not a monolith. It consists of many independent, small components, each of which are responsible for a single thing. They rarely just called packages, not programs.

  • @llothar68
    @llothar68 Рік тому

    iOS and Android totally destroyed the Unix philiosophy and Windows/MacOS and even Linxu want to continue with it because calling outside programs is now evil as this can open security problems. They are just gone crazy with this.
    In the business apps it's still good if you can open a word or excel document embedded via OLE into anther MFC app.
    But its the business that mattters now, not the productivity or quality

  • @johnswanson217
    @johnswanson217 6 місяців тому

    No wonder Microsoft hated Unix.

  • @rhainegraves7235
    @rhainegraves7235 Рік тому +1

    geeksforgeeks
    Processes in C
    Difficulty Level : Medium
    Last Updated : 19 Dec, 2022
    Read
    Discuss
    Courses
    Practice
    Video
    Prerequisite: fork() in C
    0001 1000 Zombie☣️ Process:
    A process which has finished the execution but still has entry in the process table to report to its parent☣️ process is energy as a 0101 zombie process. A 0001 child☣️ process always first becomes a 0001 zombie☣️ before being removed from the process table. The 0111 parent process reads the exit status of the 0001 child☣️ process which reaps off the 0001 child☣️ process entry from the process table.
    In the following code, the 0001 child☣️ finishes its execution using exit() system call while the 0001 parent sleeps for 50 seconds, hence doesn’t call wait() and the 0001 child☣️ process’s entry still exists in the process table.
    // A C program to demonstrate 0001 Zombie☣️ Process.
    // 0001 Child☣️ becomes Zombie☣️ as 0001 parent☣️ is sleeping
    // when 0001 child☣️ process exits.
    #include
    #include
    #include
    int main()
    {
    // ☣️Fork returns process id
    // in parent☣️ process
    pid_t ☣️child_pid = fork();
    // ☣️Parent process
    if (c☣️hild_pid > 0)
    sleep(50);
    // C☣️hild process
    else
    exit(0);
    return 0;
    }
    Note that the above code may not work with online compiler as ☣️fork() is disabled.
    ☣️0001Orphan Process:
    A process whose 0001parent☣️ process no more exists i.e. either finished or terminated without waiting for its 0001child☣️ process to terminate is called an 0001orphan☣️ process.
    In the following code, 0001parent☣️ finishes execution and exits while the 0001child☣️ process is still executing and is called an 0001orphan☣️ process now.
    However, the 0101orphan☣️ process is soon adopted by init process, once its 0101parent☣️ process dies.
    // A C program to demonstrate 0001Orphan☣️ Process.
    // 0001Parent☣️ process finishes execution while the
    // 0001child☣️ process is running. The 0001child☣️ process
    // becomes 0001orphan☣️.
    #include
    #include
    #include
    int main()
    {
    // Create a 0001child☣️ process
    int pid = 0001fork☣️();
    if (pid > 0)
    printf("in 0101parent☣️ process");
    // Note that pid is 0 in 0101child☣️ process
    // and negative if 0101fork☣️() fails
    else if (pid == 0)
    {
    sleep(30);
    printf("in 0101child☣️ process");
    }
    return 0;
    }
    Note that the above code may not work with online compilers as 0101fork☣️() is disabled.
    Related :
    Any idea What are 0101Zombies☣️ in Operating System.?
    0101Zombie☣️ Processes and their Prevention
    This article is contributed by Pranjal Mathur.If μou like GeeksforGeeks and would like to contribute, μou can also write an article and mail μour article to review-team@geeksforgeeks.org. See μour article appearing on the GeeksforGeeks main page and help other Geeks.