Bash v PHP review and preview

Created Tuesday 29 May 2018

We will go over this in much more detail, but for those who want to get a head start.

The biggest conceptual difference between Bash and PHP, in my view, has to do with the "assumptions" Bash makes, and how most languages don't make those sort of assumptions (for good reasons.) Broadly, Bash presumes that you are usually working with "files" and "lines of text." As a result, there's a lot that you DON'T have to think about on this level when using Bash.

PHP, by contrast, is a more "general purpose" language — which means it will need things "spelled out" for it more often. Note that most languages are like this. A good example is "newlines." In Bash, when hit enter (either in a script or the command line) — this means "I'm done with this command." You can OPTIONALLY use a semicolon as well to mean the same thing.

In PHP, on the other hand, you ALWAYS have to put the semicolon, because whitespace is not significant. This also explains handling text and variables — often when you use Bash, and you feed it a string with spaces, it will presume that you want to chop up that string and use each bit individually. Again, in PHP in most languages, you have to be explicit about this (and also use "abstract" variables and types to explain what you're doing to the computer.)