|
|
Why is shell script programming so fun?Dave, can you tell me, how come I enjoy shell programming more than other types of programming (Javascript, Java or C)? Well that's an interesting question! I've programmed in dozens of languages, ranging from the classics (BASIC, Algol, Fortran, Pascal) to more modern languages and even obscure ones (Ada, APL) and I have to agree with you, Scott, that there's something about shell script programming in the Linux environment that's easy, fast, and great fun. I think part of it is that since it's incredibly easy to access regular Linux commands from within a shell script, it's one of the few languages where you start out already knowing how to do the complicated things from just using the command line. Want to find out the hostname of the computer? Just use "hostname" as you would on the command line. Want to assign it to a variable? Easy: host=$(hostname)
(or you can use the older notation of `hostname` if you'd prefer) There's also almost no overhead, no declarations, no need to define variables in advance, so you can write shell scripts as short as one line: who | grep mary
Since it's an interpreted language rather than a compiled one, it's also really fast to work with and your development cycle is edit -> run -> edit -> run until you get it to work as you desire. Even better, as you learn more about Linux or add additional command packages like ImageMagick to your system, you gain lots more control and capabilities in your programming environment too. I've always referred to shell script programming as "lightweight" because it's really fast to get started, easy to use, and perfect for short apps and prototyping. Would I write a compiler as a shell script, or a GUI system? No, I think that'd be a huge amount of work and is going to be a pain in the booty. But would I write games, system utilities, and useful little 'bots as shell scripts? Heck yeah, I have a whole book about it: Wicked Cool Shell Scripts. Now, the honest other side of the coin: there are no debugging capabilities in the shell to speak of, and since you can do any command, you can also make grievous mistakes without it complaining, like deleting the file you're trying to parse. So it's not all milk and honey, proverbially or otherwise. Still, if you have a Mac OS X system or a Linux box, you might well want to spend some time playing on the command line, then jump in to writing a few short, simple shell scripts. You'll be amazed how little like programming it feels and how much faster and more fun it is than writing complicated C++ or Ruby functions!
More Useful Shell Script Programming Articles:
✔ Secretly capture screenshots on my Mac?
When I used to work on a Linux system, there was a utility we had that would let me take screen captures every...
✔ Parsing "id" strings in a Shell Script?Hello Dave. I need a Bash shell script that creates a directories with the group names automatically when user logs in to the...
✔ Copy and Paste from the Mac OS X Command Line?I am constantly running commands in Terminal.app on my MacBook and then copying and pasting the results into email messages or documents. Yes,...
✔ Script to test line lengths for Twitter compatibility?I've been tasked with writing a series of tweets for a Black Friday marketing campaign and am finding it a bit tricky because...
✔ Shell script to convert lowercase to title case?As part of a project I'm working on, I find myself deep in a Linux shell script, needing to have a subroutine that...
Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help
right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
Categorized:
Shell Script Programming
(Article 9339,
Written by Dave Taylor)
Tagged: ada, algol, c++, fortran, linux, mac os x, pascal, perl, programming, shell scripts Previous: How do I delete my Google Gmail account? Next: How Can I Comment On My Facebook Fan Page As Myself? Reader Comments To Date: 2tsolox said, on September 24, 2010 3:58 PM:
According to the German philosopher Friedrich Nietzsche, two forces must co-exist in a certain proportion. He calls it Apollonian vs Dionysian. The Apollonian,just like the greek god Apollo, is toward the tendency of form and order, of prediction and oracles and restraint, and preparation. This is just like Java or C#/C/C++ in which one's programming intent is properly prepared thru a compile-link steps and the language syntax elements supporting OOP and error exception handlers. The Dionysian, is from greek god of wine Dionysius, which has tendency toward chaos and disorder and the lack of restraint, all that is free flow like perl and bash.. no preparation, just pure kinetic energy. The proper proportion of these two, according to Nietszche, is the source of arts. That's why i learn Java/C#/C/C++/COM and then bash/linux/python embracing both Linux and Windows. A preference of one over the other is weakness.
I do have a comment, now that you mention it!Check This Out Too... |
Recent Entries
Look for Answers
Recommended
All Our Categories
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and Blogging Building Web Site Traffic Business and Management Computer and Internet Basics d) None of the Above Facebook Help Google Gmail Help Google Plus Help HTML, JavaScript and Web Site Programming Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Kindle Fire Help Mac OS X Help Pay Per Click (PPC) Advertising Pinterest Help Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help Find Me on Google+ ADT on G+ |
Dave, I have to agree with you....I've dabbled in Cobol, Fortran, PL1 and RPG before "discovering" UNIX shell scripting in 1995. I've moved into Linux and still really enjoy it.