Thursday, December 4, 2008

When to write a script in a language you don't know

Sometimes there is a long, repetitive task that you know would be much better off if done by a small script, but the problem is that you don't know how to use the tools available at the moment.

One of my problems is that I never remember anything about a language or system if I'm not using it often. It's like I do a brain dump in order to make room for new stuff when I switch from one technology to the next. That means that even though I *have* done considerable shell scripting in the past, I can't remember a darn thing when I need it for a one off project. So, I know that I'd be better off writing a script, but I end up doing the job by hand anyway because it would take longer to look up language bits than it does to hit arrow up, back, back, back,... delete, delete,... paste.... a few times through.

The whole time I'm doing that, though, I'm thinking, "I could solve this like this in PHP or like that in Perl" and none of it matters, because at the moment I'm working in a very limited embedded linux system with neither of those languages on board.

So, what do YOU do in a case like that? Do you go look up the language ref for what IS available to you, even if it will take longer than the cut-and-paste for the task? Or do you just do the task manually?

3 comments:

Anonymous said...

The nice thing about shell scripting, is that you don't have to know anything to do it.

If by "manually" you refer to shell commands, then all you have to do is list them one by one, and you got yourself a shell script.

If this works for you - good. If not, refactor. This is the way software development should be done anyway :)

Lisha said...

There's more to shell scripting that *just* writing a string of shell commands. There are variables and loop and conditional structures. Those are the parts of scripting that you actually have to look up if you don't remember them and need to write a script.

Anonymous said...

Sure there is more to it. My point was that you can have the first script pretty easily set up. You can then begin to look up the parts you want to refactor, but you already have a working code, which is a lot.