4 ms·
Yes 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 reali
by chubot 9y ago
Yes 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!)