Solved Learn shell scripting or other language for simple utilities?

Greetings all,

On a different thread I inquired about support tools, for scripting. However, it appears that there is no debugger enabling setting breakpoints, stepping through the code, etc.

Thus, I am contemplating, whether I should not invest time in learning a different language. My goal is not to become a code writer, just to be able to write some simple utilities. A typical example would be to walk through a directory tree, calculate for each found file a check-sum, compare the check-sum with a previously calculated check-sum, and take an action based on the result of the comparison.

Any opinion/suggestion would be appreciated.

Kindest regards,

M
 
There are often debugger libraries like https://github.com/deivid-rodriguez/byebug for languages like Ruby. I personally would recommend just trying a few programming languages for some simple tasks and seeing how you feel about the different experiences (do not let yourself be biased by the ease with which you are able to complete the tasks after the initial attempt). A good language to start with would be Ruby IMO.
 
Many, many years ago I learned Perl. This was at a time when Perl was often used for web CGI applications. Perl is called "the Swiss army chainsaw" because there's very little you can't do with Perl. For admin type scripts I still think it's the best solution. If the script I need gets too complicated for a simple shell script I often fallback on Perl. Perl is almost always installed as there are many applications depending on it.

One thing I have realized is once you learn to program using a "proper" language it becomes a lot easier to learn a second or third language. The way programming languages work, conditionals, loops, etc, are the same, it's usually only the syntax that's slightly different.
 
Many, many years ago I learned Perl. This was at a time when Perl was often used for web CGI applications. Perl is called "the Swiss army chainsaw" because there's very little you can't do with Perl. For admin type scripts I still think it's the best solution. If the script I need gets too complicated for a simple shell script I often fallback on Perl. Perl is almost always installed as there are many applications depending on it.

Are you recommending Perl 5, or would you recommend Perl 6?
 
Are you recommending Perl 5, or would you recommend Perl 6?
Stick to 5. I haven't looked at 6 myself but I've heard it is quite different. Perl 5 is certainly more common and is the default Perl version for most systems.
 
Hi Preepal, SirDice,

I have done some reading based on your suggestions. and am currently favoring lang/python, due to the general consensus that it is easier for a beginner and with a more formal structure. Any comments/further suggestions?

Kindest regards,

M
 
I have done some reading based on your suggestions. and am currently favoring lang/python, due to the general consensus that it is easier for a beginner and with a more formal structure. Any comments/further suggestions?

You are not going to go wrong with Python (I just personally prefer Ruby as I work in that language as a web developer).
 
I'm quite fond of shell scripts (as such my nickname) but for everything else I often resort to Java, aka java/openjdk8.

Main reasons for me is that Java is very easy to use and learn; it has a logical structure and you can do tons with it. I also appreciate the fact that you don't necessarily need extra libraries in order to make it "do" something because many features are already part of the basic runtime.

Here is a very nice documentation overview and as you can see it supports networking (from HTTP connections to setting up sockets), encryption and other security features (SSL/TLS, crypography and limiting the privileges of the Java runtime through security managers), logging, databases and even GUI support when needed, all "out of the box" so to speak. One of my favorite features though is Javadoc. Just making sure that you document your classes and your methods is already enough to automatically generate API documentation which can then be used by everyone else to see how to use your program and/or code against it.

Of course it helps that Java is installed on all my servers :)
 
Any comments/further suggestions?
I you like to use GUI you should have a look at tcl/tk. The integration of tk with tcl is "natural". When I think of python the GUI stuff is like an alien. It does not integrate well. Personally I have no idea how someone can get used to python with tk without having experience with tcl/tk. As far as I remember the integration of tk in perl is much better compared to python, but this might be outdated. In my opinion there are two downsides of tcl. The syntax looks very ugly. And the integration of classes looks alien like. But I have not really tried that as much as I have done that with python.

Summary: Nothing beats tcl/tk in doing things extreme fast, even if a GUI is necessary. It is not as "hip" as python. I still have digging into the oo stuff with tcl on my todo list. Python is very good in making it easy to keep things clean. Without GUI things can be prototyped fast , too. If I remember correctly Perl has the most cute syntax.
 
Hi ShelLuser, chrbr,

thank you for your replies and sorry for my imprecise language. What I was asking was to inquire whether I did not misinterpret my understanding of python. The reason why I settled on python was that I found a utility that is very close to what I would like to implement written in python, and I must start somewhere.

Kindest regards,

M
 
The reason why I settled on python was that I found a utility that is very close to what I would like to implement written in python, and I must start somewhere.
Dear mefizto,
if you have found something written in python which is close to what you want do achieve, than you have a very good starting point. I suggest to follow that idea, and use python for that task.
 
Almost everywhere python,bash is using every day. Python is growing so fast. Look at Ansible where PlayBooks are generated to python, exploits are written in python. You can check job offers for DevOps (bash, python) :).
 
Hi Vermaden,

I have actually written a few scripts with POSIX /bin/sh, but the lack of more sophisticated debugging tool, made my last script pain to make to work.

Hi bryn1u,

I am not looking for the language from a job utility, I am in a different profession, but rather something reasonably easy to start with, but still usefull.

Thank you both for the replies.

Kindest regards,

M
 
Hi Vermaden,

I have actually written a few scripts with POSIX /bin/sh, but the lack of more sophisticated debugging tool, made my last script pain to make to work.

Hi bryn1u,

I am not looking for the language from a job utility, I am in a different profession, but rather something reasonably easy to start with, but still usefull.

Thank you both for the replies.

Kindest regards,

M

Bash and python are really good to start.
 
I personally think Perl is a little easier to get started with compared to Python. There's only one big downside to Perl, the syntax is so free it allows you to write utterly unreadable, yet functional, code. Python is much stricter and thus has much cleaner code but it also has a little steeper learning curve because of it.

Quick and dirty scripts: Perl
Learning to write proper, clean, code: Python

But note that one does not exclude the other. Techniques you learn for one language can usually be easily applied to another language. The structure of a program typically doesn't change much between languages[*], only the syntax.

[*] At least when comparing similar languages. Comparing procedural languages with object oriented languages is like comparing apples and oranges. But the differences between one procedural language and another procedural language are minor, same for one OO language vs. another OO language.
 
Hi SirDice,

There's only one big downside to Perl, the syntax is so free it allows you to write utterly unreadable, yet functional, code. Python is much stricter and thus has much cleaner code but it also has a little steeper learning curve because of it.

That is what I gathered, also in regards to the recommended Ruby. As my only well rusty experience is with FORTRAN, which is strongly typed, and a little FORTH, which really requires one to pay attention, I would prefer to start with more structured language.

Kindest regards,

M
 
Back
Top