I just published a new version of front end vs back end comic and it went viral again. More than 100k views in 2 hours and accelerating. Hooray for viral marketing!


Front End vs Back End

Until next time.

I was watching videos about my favorite topic, UNIX history, and found a talk by Hendrik Jan Thomassen. He's the UNIX pioneer in the Netherlands and has worked with Thompson and Ritchie in the past. He says the real reason why UNIX commands like ls, cp, mv, etc., are short is because PDP11 console keys were super hard to press. You'd get knuckle pain if you typed too much. So to save your fingers, all the commands were designed to be as short as possible. True or not, that's a fun story.

Here's the fragment from the video:

Video URL: https://www.youtube.com/watch?v=h5-DRLfzqD0

Here's the full video From UNIX to Linux, a time lapse of 45 years, with a bunch more fun facts.

Video URL: https://www.youtube.com/watch?v=boahlBmc-NY

Until next time!

Here's the next cartoon in the series about famous computer scientists. Here is John McCarthy. The creator. Inventor of Lisp and the father of modern artificial intelligence.


John McCarthy - The Creator

In case you're joining just now, here are the previous comics:

Like this? Subscribe to comic and/or follow browserling and/or me on Twitter and/or do nothing.

Until next time!

Here's something you didn't know about bash functions. Usually when you write a function you do this:

function name () {
  ...
}

Right? I know you do, because that's how everyone writes functions. Well, here's the thing. In bash { ... } doesn't mean "function's body" or "function's scope" as in JavaScript or C. It's actually a compound command. You can do all kinds of fancy things like this:

function fileExists () [[ -f $1 ]]

No need for those curly braces! Function is the test command itself. Or you can do this:

function isEven () (( $1 % 2 == 0 ))

Here function is an arithmetic expression. Or you can do this:

function name () (
  ...
)

This will spawn the function in a subshell rather than execute it in the current environment.

Or you can use while, if, case, select and for. Here's an example:

function sleep1 () while :; do "$@"; sleep 1; done

This one creates a function sleep1 that runs a command every one second forever. You can do things like sleep1 df -h to monitor how your disk changes.

Not only do these tricks make your code nicer and let you write quick bash one liners, but they also are super useful. It's especially useful if you need to create a temporary environment for your function and temporarily change variables or shell options. Here's an example I found somewhere in my code:

function caseInsensitiveMatch () (
    shopt -s nocasematch
    ....
)

Here funtion caseInsensitiveMatch executes in a subshell and sets nocasematch option and its scope is just this function. Similarly for IFS and other variables you often need a temporarily change. No need to save previous values, then restore them.

This was my quick 5 minute shell tip. Look up compound commands in bash man page to find all the possibilities. Once you master this, you'll start writing some next level shell code. Until next time!

This article is part of my upcoming book Bash One Liners (freely available on my blog.)

Success happens!

I just hit 700 days of commits to Browserling's private repo on Github:

The more I commit, the more Browserling grows. February was another record month for my company:

I'm on a mission to build a great company. Until next time!