35 ms·
Shell scripting (which will lead into Unix internals). A lot of programming is automation and yak shaving, and shell is often the quickest tool to get past tha
by chubot 9y ago
Shell scripting (which will lead into Unix internals). A lot of programming is automation and yak shaving, and shell is often the quickest tool to get past that. It lets you get to the meat of the problem you're actually solving.
Using the same tool for build, test automation, deployment, sys admin, refactoring, etc. is valuable. Otherwise you are stuck with frothy and immature domain-specific tools that clutter your brain.
Shell is sort of universal in that C/C++, Go, Python/Ruby/JavaScript, etc. programmers all use it.
It's sort of like the idea of mastering a single editor. You wouldn't want to switch editors every year. Likewise I think knowing shell and Unix really well pays off over the long haul.
- noir_lord 9y agoAgreed, I saw this posted the other day https://github.com/koalaman/shellcheck https://github.com/koalaman/shellcheck and it's been interesting. I like some of the features in the other shells but bash is ubiquitous.
- flukus 9y agoI agree, I knew how to "use" unix/linux many years ago, essentially knowing how to run things on a command line, but it's only in the last few years I've begun to really learn how to use it. For the last couple of years I've been focusing on doing more shell scripting and learning more of the unix tools available and I wish I'd invested the time a decade earlier because it's paid off more than anything else. It goes from simple things like being able to copy/view production logs in seconds (instead of fumbling through the file system) to writing DSL's in awk. I'd go as far as to say we'd be better off teaching kids how to write shell scripts than any of the current programming classes or the "mail merge with word" classes that they get taught today.
- chubot 9y agoYes I think that experience is common. Everyone uses shell, but many do it reluctantly, because it looks old and gross. My first experience with it was realizing that 'x=1' works but 'x = 1' does not. And also realizing that 'x=1' creates a GLOBAL variable. Who would design such a crappy language? Then you get past the surface ugliness and discover its power. I agree that shell SHOULD be a first programming language. But I don't think you can teach it to beginners with a straight face. There are too many sharp edges. I'm working on both a bash-compatible shell and a new language that aims to fix this: http://www.oilshell.org/ http://www.oilshell.org/ It would be great if the first thing you boot up to on a computer is a nice programming language with the capabilities to do practical things like send mail, scrape the web, talk to hardware, etc. I think of "apt-get" as the standard library for shell, and it is unbelievably powerful.
- flukus 9y ago> There are too many sharp edges. I wasn't thinking they should learn programming as such. More that they should learn some various unix tools (grep/sed/awk/etc), learn how to combine them with pipes and learn how they can save the workflows in a shell script. Maybe some functions and variables but not if statements or loops. Maybe even do that in awk instead of bash. I really love the blog by the way, any tips for putting one together like that? I'm currently replacing my node based abomination with a similarly minimalist one built with make, a couple of awk scripts and pandoc. I was thinking of going even more minimalist and putting a link to firefox reader mode on the page.
- chubot 9y agoYeah I think learning pattern matching like regexps before learning control flow and state with variables could be a good thing. I can imagine a curriculum where you go from HTML (data) -> regex (patterns) -> full source code. One thing I noticed is that a lot of people who want to learn to program aren't that proficient at using a text editor and generally using a computer, and doing HTML first will solve that. But I also think that regexes have the obvious problem of syntax too. I have taught regexes along with Python to non-programmers, and it works OK, but the material didn't demand too much. I think it was basically \d+ and one or two other constructs. FWIW one of my goals is to combine bash, awk, and make, although this is sort of far off: http://www.oilshell.org/blog/2016/11/14.html http://www.oilshell.org/blog/2016/11/14.html Awk is an OK first language but honestly it's worse than JavaScript, because you can't even return an array from a function. Also, functions can't be used as parameters or return values to other functions. Although I suppose it has the advantage of being very stable and immediate, and not requiring NPM and what not. However JavaScript has the advantage of integrating with the web. --- As far as the blog, it's a bunch of custom shell, Python, and CSS that I cobbled together over the years, and then wrapped in a Makefile. I use markdown.pl but I'm thinking of switching to CommonMark. I've made several static websites before so I copied the best bits, with not too much cruft. It also evolved over the course of the blog. It looks really simple but there are some details that I spent awhile on. (And honestly I wish Oil existed so I could write it all in one language, not shell + make + Python!)