Question

I came from a C-Java-C# world... where the parentheses were VIP citizens and types were loved by everyone : )

Sometimes I need to develop some piece of code to automatize a repetitive task, convert some complex frame, order an input file, send programatic request to a server... you know what I mean?

But sometimes I wonder how easier could be write the same in some language like Python... or these DoItSimple languages : ) -with all respect.

So which language should I use for this kind of tasks?

Thank you very much in advance!

Was it helpful?

Solution

Why don't you just take a list of the languages you find attractive and write some small pieces of code. Then you'll be able to select the one that is "yours".

OTHER TIPS

You should really investigate one of the more popular scripting languages, like Python/Ruby/Perl. Any one of those will set you in good stead for what you're trying to achieve. Which one of those you should use is a matter for heated debate around the water cooler - or more likely, the coffee machine.

That said, there's something to be said for learning tools like 'awk' and 'sed', not to mention some of the extended capabilities in 'vim' for achieving day-to-day tasks

For a long time, you will always be faster with the languages you know. However, if you just want to experience something new and eventually have another useful tool in your belt, I'd try python. It's very handy, and is not too far of a jump from the C# world (if you've ever done BASIC, it feels VERY similar).

BTW - AlBlue's suggestion about awk/sed/vim(macros/etc) is A+. I will often hop onto a Linux box at work to handle any repetitive file tasks (on Windows you can get cygwin, we just don't have it available at work).

I love PHP and perl for these things (having grown out of sed and awk, for the most part), but if don't rule out the bash shell (I use Cygwin's on windows systems), and even the Windows scripting language (yes, batch files still exist) can do more than I once thought.

I Say Ruby or Python


My favorite is Ruby for its high-purity object model and generally awesome syntax and power.

However, Python has the same general capabilities and is about twice as popular.

Traditionally, Perl is used for sysadmin automation and other scripting tasks, plus obviously sed, awk, and sh.

But languages like Perl and PHP started as ad-hoc scripting interpreters, whereas Python and Ruby were real object-oriented languages. Perl and PHP have since grown object-oriented revisions, but now they have all the complexity of the first "nice try" coupled with the "oh we should make it a real language" extensions.

Ruby, in particular, is the product of a real language designer who combined the ultra-pure object model of Smalltalk with the populist syntax of Perl.

If you are coming from the C world, I would say Lua because not only is Lua a fine scripting language, but it also comes with a super API for binding it to C programs, which means in the long run you'll be able to use the same technology to script your C programs.

Lua also stands well on its own merits; I have written elsewhere about why I prefer Lua to Python.

Google for something like "perl vs ruby vs python" or "best general purpose scripting language" ... You should find some comparisons. I personally like ruby most cause it lacks the nasty $'s in front of all variables. If you're familiar with c# and the .net framework, IronRuby and IronPython would give you access to all the classes you already know.

I'll probably get downvoted for recommending this, but I suggest starting with "writing C in Perl", and working (or not) towards whatever level of idiomatic Perl that suits you.

My reason for suggesting this is that even if your Perl code is structured much like C, and even if you don't avail yourself of all of Perl's syntactic sugar, you'll still see an increase in productivity. Starting with C-style Perl just allows you to make use of idioms that you are already familiar with (ie C-style for loops vs Perl's foreach) while learning the language.

As I know, PHP is one of the scripting language to do tasks such as: order an input file, send programatic request to a server... and PHP is C-like syntax, and said to be the easiest to learn(you don't even have to learn before you using it, you just use it while learning it). But PHP is not a general purpose scripting language.

Python is a general purpose scripting language and has a strong type checking, bug it's not C-like, I'm afraid you would not like it.

I myself use PHP for the most time for text processing, network(socket, HTTP...) tesing. ^_^

These are all fine scripting languages, and IMHO it probably won't make a huge difference which one you choose. I hope I won't be downvoted for injecting a realistic answer in what is mostly a religious argument. It's basically like when you agonize over which college to go to, and someone points out that as long as they're both good schools, it's not likely to make a big difference in your life.

I use Perl for writing CLI programs because it's the first scripting language I learned (20+ years ago when it was the lingua franca for writing CGI scripts on the nascent WWW). I now use PHP for writing web apps because my last job used it for our intrantet web pages, and it has lots of nice built-in features for web and SQL programming; but I'm sure that with the write CPAN modules I could be just as productive with Perl.

If there's a language that's popular with other programmers you work with and respect, that's probably one of the best reasons to choose it, since you'll have a convenient support community. SO is nice, but even better is being able to learn from a local expert.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top