Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^10: let Makefile.PL to do the Readme file for me -- new target?

by afoken (Chancellor)
on Jan 20, 2021 at 23:01 UTC ( [id://11127171]=note: print w/replies, xml ) Need Help??


in reply to Re^9: let Makefile.PL to do the Readme file for me -- new target?
in thread let Makefile.PL to do the Readme file for me -- new target?

This must be error prone.

Not necessarily. It is the Unix philosophy at work: each part of the chain just does one thing and does it well.

Understanding that is a little bit hard at first if you have a DOS / Windows background, or at least it was for me. DOS was a terrible environment.

Shelling out from any program larger than hello world ate lots of memory, because DOS could not swap out the now waiting program. It stayed in memory, and memory was a scare resource (no, you could not run programs from EMS or XMS). Yes, there were tricks to have more memory available from subshells, but in general, you avoided shelling out. You generally learned quite fast that almost all programs you tried to invoke from your program failed due to low memory. Unix shells out all the time, sometimes you don't even know. Unix also grew on memory-limited machines, but swapping out unused programs became standard very early in the development.

The command interpreter (command.com) sucked big time. Trying to do more than running a few programs in sequence requires a lot of patience, deep knowledge of the bugs in the command interpreter, and how to use them. Having a few spare chickens to sacrifice also was helpful.

Also, passing arguments to programs was severely limited - no more than 126 bytes for program and arguments, and all arguments are passed as a single string. So, if you need to pass more than a few options, you would write them to a file and pass the name of that file to the program. Again, Unix was and still has the better design: Pass an array of strings, and have the invoking shell prepare that array in the same way for all invoked programs, so that no program (except for the shell) has to worry about variable expansion, resolving * and ? in path names, and so on.

Oh, environment variables. 256 bytes by default, about half of that was needed for PATH. Memory size is fixed, set during boot from a parameter passed to command.com. You would not use environment variables if you did not have to. Unix uses environment variables all the time, and many shells allow to set them temporarily (e.g. PERLIO_DEBUG=/tmp/log perl test.pl).

And while pipes look like on Unix, they aren't anything like on Unix. DOS pipes are a feature of the command interpreter, not of the operating system, and are implemented as simple redirections to a temporary file. The real DOS also could not redirect STDERR, another limitation of the command interpreter.

So, you were effectively forced to do everything in one big program. At best, you could reuse some existing source code. You were effectively trained not to call existing programs (due to the memory limits).

Now imagine coming from that environment to Unix, a multi-user, multi-tasking, system with a real memory management and a powerful shell that can do tons of things you could not even dream of when using command.com. It is a culture shock.

Things don't seem that bad when you have a first look at Windows, at least you get a working memory management. And while no supported version of Windows is based on DOS any more, the NT-based Windows versions, like OS/2, still inherited a lot of concepts from DOS. Windows still has no fork() and exec() (instead, there are about 10 API functions with up to about 30 parameters), batch files still emulate bugs from ancient DOS versions, and add a lot of new quirks, program parameters are still passed as a single string, and so on.

Windows does not impose as much limits on programs as DOS did, but the DOS limits have survived as part of the DOS/Windows culture. You still rarely use the environment, you don't use pipes between programs to process a few megabytes of data (text or binary), and you rarely invoke other programs from your program.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re^10: let Makefile.PL to do the Readme file for me -- new target?
  • Download Code

Replies are listed 'Best First'.
Re^11: let Makefile.PL to do the Readme file for me -- new target?
by eyepopslikeamosquito (Archbishop) on Jan 21, 2021 at 01:48 UTC

    Interesting history lesson. Sorry I have no first-hand experience to offer (apart from .BAT being the worst (by far) programming language I've ever used ;-) ... but I've noticed that all the Windows guys at work seem to have completely abandoned .BAT for PowerShell. Anyone know if the Windows Perl world is similarly replacing .BAT with PowerShell?

      PowerShell is a very interesting and powerful language, which also borrowed many aspects from Perl and some from Haskell.
      • Interesting b/c instead of piping text, they are piping objects (in the first draft the language was named "Monad")
      • Powerfull because these object have deep access into the OS and .NET-framework.
      <update> Example:
      • if you do ls PATTERN | grep PATTERN in bash, you are piping a list of lines and you'll end in regexing relevant fields like file-size.
      • In PS you'll transport a list of objects , e.g. the file-size is just an attribute of one of the file-objects
      </update>

      But in my experience it's not an intuitive DWIM hack like bash, mainly because the syntax is lengthy with "Verb-Noun Thing -options" structure

      Example: To tail in PS you need Get-Content PATH.txt -Tail 10

      They try to compensate this "wordy" structure with aliases for common commands like:

      Standard Aliases for Get-Content: cat, type, gc

      Though it still doesn't feel like CLI scripting (to me)

      BUT: For many things PS is the only viable alternative.

      My current strategy is to write Perl wrappers shelling out to PS.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        PowerShell is a very interesting and powerful language, which also borrowed many aspects from Perl and some from Haskell.

        I never worked with PowerShell, except for casting a few magic spells copied from Google results to make Windows behave.

        • Interesting b/c instead of piping text, they are piping objects (in the first draft the language was named "Monad")
        • Powerfull because these object have deep access into the OS and .NET-framework.

        That should allow doing interesting things WITHIN the PowerShell/.NET walled garden. As long as you can use those objects, everything should be fine (except for bugs). But what about Unix-style interactions with other programs? Piping objects arounds surely is a powerful concept, but can I stuff binary data from STDOUT of tool A into a pipe, then filter it through B, C, D, and finally have E process the result of filtering? (In other words, what's the equivalent of a bash on Unix doing A -foo -bar | B -bla bla | C --what=ever | D ./magic ./stuff  | E +gnarf)

        What about networking? I often do things like this:

        tar -C /some/where -cf - subtree | ssh root@embedded.system tar -C /else/where -xvf - > copied.txt 2> problems.txt

        (Create a tar archive of subtree in /some/where and write to STDOUT, have ssh pass that byte stream to another tar instance running as root on embedded.system as STDIN, make that second tar extract the archive to /else/where, write STDOUT of the second tar to copied.txt on the local system, and STDERR to problems.txt on the local system.)

        What about quoting? Quoting the two redirections in the previous command would write STDOUT and STDERR of the second tar to embedded.system, because ssh implicitly invokes a shell on embedded.system:

        tar -C /some/where -cf - subtree | ssh root@embedded.system tar -C /else/where -xvf - '>' copied.txt '2>' problems.txt

        How to pass things like ", ', <, >, | as arguments? On Unix:

        echo '"' "'" \< ">" "|"

        Expanding variables, and passing parameters that just look like variable expansions?

        echo '$PATH' "expands to \"$PATH\""

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
        In PS you'll transport a list of objects , e.g. the file-size is just an attribute of one of the file-objects 

        that's interesting, I was not aware. Actually it sounds impressive but in reality is nothing more than a unix-like pipe communication passing a text-json-pojo-whatever or, as easily, binary-data to, e.g., represent serialized objects. Both can be and are achieved in unix. Text-pipes we are all aware of and for binary: an example is imagemagick's piping of binary images to its various converter-executables.

        This however poses some more interesting questions: for example are these objects allowed to have pointers to other objects? Surely there is inter-linkage. For example a file object with pointers to the object of its user-owner which in turn will have pointers to history-object and preferences-object and a myriad of other details? Often saucy and often remotely stored? Oh that's lovely, I can suck the whole M$-big-brother-brain with just an ls. and God said let there be ls. I can imagine that with just an ls I can suck each and every digital record ever existed.

        Further, when do these objects expire/die/cleared from memory? It seems that there is a gargantuan garbage collector larking at the bowels of the OS? And is very busy indeed. With each innocent find c:/*.*|grep which could potentially copy the whole hard-disk's contents into RAM and then back to disk-swap to feed back find. Here's a nice blue screen of death right there.

        Anyway, some thoughts. now, begin-trolling:

        Nah... M$ is thoughtless crap (disclaimer: If trump was voted in as USA president then I am allowed an aphorism for each of them votes).

        end-trolling

        bw, bliako

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11127171]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 23:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found