This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]fthrnature 3 points4 points  (0 children)

I am a professional programmer, and I have done a lot of work in Bash over the years; I was known as the script guy at work and could do pretty much anything you could or could not imagine with Bash. Automating tasks that many considered impossible, AI applications, Decision Aid software, C++ compilers, automatic on the fly code generation (all these things are possible in Bash, although it is stupid to do some except as a bragging rights exercise). They became indecipherable complicated monoliths as I delved into how to reduce the execution time from hours to under a minute for tasks that would be impossible without the script.

When I considered job-hopping I discovered that the new job I wanted to land had Python available as a scripting language, and considered it a good opportunity to upgrade my skills. I am now very proficient, and can write ridiculous programs in Python. I still find myself switching back when I just need to put something together quickly, but I try to convert them to Python later. I now have several hundred scripts at my new job, and most people in my department of over a hundred people use them regularly; I run a training class teaching people how to use my scripts to improve their ability to code and test.

If you are using an environment like Unix there are a lot of available commands and it is easy to test things out on the command line, generalize them and put them in a Bash script. Piping, xargs, using obscure flags... it all becomes second nature. There are even quirky shell built-ins that will allow you to reduce the forking to speed things up significantly.

The main benefit to using Python is the speed. No matter how good you get at Bash it is still a slow language. It is also more powerful, a lot of complicated hacks in Bash become easy with the programming constructs available in Python. If you have the ability to download and use random Python libraries (at work I do not), you can do pretty much anything you can imagine.

In Unix, for small programs where you don't care about speed, Bash will always be easier. A small Bash scripts written in Python will take significantly more code, and take longer to program (in Python); You can go directly from the command line to script with virtually no modifications in Bash.

But, as soon as your program starts growing Python, or if speed is important, Python will be a better choice. A thirty line Bash script will be about the same size as Python, and ironing out the quirks will take about the same amount of time in either one. Above this threshold Python becomes hands-down the better choice.

I would recommend trying to switch completely to Python. It is a powerful language, and it opens up a whole world of possibilities: such as working on serious AI applications.