views:

10935

answers:

37

I have been learning C and C++ for sometime now. But, they do not allow me to do a lot of things like writing a script/program to get a bunch of files from the Internet easily. So, I want to learn a scripting language which is fun and which is useful for everyday chores. Which one would you recommend, and why?

Other information that might be useful:

  1. References to tutorials / helpful information on how to learn the language.
  2. References to implementations of the language.
  3. Niches where you have found it to be particularly useful.

One language per response, please.

+6  A: 

Python

Python seems to be getting a lot of traction.

Joel Coehoorn
To add to this, you can choose the .NET flavor and go with Python.NET.
Jason N. Gaylord
Maybe you could explain why you would choose python and not just say "python, because its cool". :)
Node
And developer traction isn't important?
Joel Coehoorn
It supports multiple paradigms.(procedural,OOP,functional,...)
TheMachineCharmer
-1 Python is already listed, consider updating the existing answer.
mizipzor
@mizipzor - if you sort your answers oldest first, you'll see this was the first response to the question.
Joel Coehoorn
@Joel Coehoorn - Maybe I expressed myself in a bad way. The point was that there is no reason to list python twice. I downvoted this one because the other had a more developed answer. I still think they should be merged.
mizipzor
+1  A: 

Ruby is gaining ground

Maudite
+27  A: 

Ruby

I'd suggest Ruby.

johnstok
I started learning Python but after trying Ruby, I couldn't go back. Ruby is a happier, more elegant and doesn't feel as hacked together as Python (IMHO). The only downside is that it runs slower. That should change (for the better) with 1.9.
Kurt
Plus Ruby's support for Unicode leaves something to be desired imho. But that aside I do enjoy the language, its a really elegant and easier language for me to express my thoughts into code. It might not always be the fastest or best language for the job but its a nice one.
Pharaun
+1  A: 

PowerShell, VBScript, C#

If you are referring to a scripting language to write some quick admin things, there's always PowerShell scripts, VBScript scripts, etc.

But if you're looking to learn a language to do web stuff, I'd recommend learning C#. It's down the same path as C and C++ and you can write your applications for both the web and Windows. You can also take it a step further and learn XAML which could render an application as WPF (Windows) or Silverlight (Web).

Jason N. Gaylord
These should not be grouped together. Make them separate answers, and delete this answer.
Jay Bazuzi
C# is a **scripting** language?
Alix Axel
is C# a scripting language?
saurabh
Sure. It's a server scripting language. If you read the context of the item and not just the words, you'll see that they are looking for something that compares to C and C++, neither of which is considered a typical scripting language.
Jason N. Gaylord
A: 

If you want a good utility language, learn Perl. It's amazing, and wonderful.

Alex Fort
I don't care for Perl personally but I upvoted this because it's annoying to me that people are downvoting it just because Perl isn't popular. It's obviously a very capable language, and that is merit enough to suggest it.
eyelidlessness
I am throwing my hat into the ring for Perl as well. It's a fully featured language with a long history and a huge codebase/userbase outside of the .NET junkies.
Paul Nathan
Perl actually has some Lispish roots ( http://www.perl.com/pub/a/2007/12/06/soto-11.html look for "lisp"), and takes those roots more seriously than Python ( http://www.artima.com/weblogs/viewpost.jsp?thread=98196 ).
Max Lybbert
If I had the rep to do so, I would downvote — not because of any animus toward Perl but because the answer was of no help. I now know that the answerer likes Perl, but I don't know why. The answerer included no links to teach me about the language, nor any enumeration of Perl's features.
savetheclocktower
Puhliiizzze. Not perl. There's gotta be a more civilized scripting language than Perl.
jpartogi
perl is outdated, PHP is a "child" so to speak of perl, obviously perl has more libraries than just about any scripting language since its so old, but it has awkward syntax and IMO clearly shows its age compared to a language like python or ruby
Rick
+39  A: 

JavaScript

JavaScript (technically, ECMAScript or Standard ECMA-262; also known as JScript). With the increasing availability of many fully featured server-side/command-line implementations, it is becoming a great general purpose scripting language.

Edit: I want to be clear, I don't think this is the best scripting language to learn, as there is no best scripting language to learn. This is just one I'd recommend people learn if they haven't, because it's so useful.

References:

Implementations:

Niches: It's not the first place you'd think, but with Jaxer and Env.js/Rhino (see links above), JavaScript on the server is becoming more and more viable. And if you think about it, it becomes a natural choice as it is the de facto standard client-side language.

eyelidlessness
If I were responsible for a CS curriculum at a university, I would push hard to teach Javascript in the first year.
Max Lybbert
Any good place to start learning JavaScript (or is it Javascript?)
Shrivara
Isn't it technically ECMAScript?
Cristián Romo
Sure, and "Javascript" belongs to Netscape (I think; may now belong to Mozilla?), but it is the most common name, and is used by pretty much everyone except when discussing the standardization efforts specifically.
eyelidlessness
You would push hard to teach Javascript in the first year? Don't first year students have enough trouble making the compiler happy and understanding its errors? Do they really need to be confused by "undefined" errors and all the other subtle ways to mess up without proper feedback in Javascript?
BobbyShaftoe
I wonder if the single downvoter would care to explain their reasoning.
eyelidlessness
@eyelidlessness probably because JavaScript is neither "fun", nor "useful for everyday chores"?
Alex B
@Alex, I guess fun is subjective but I enjoy it , especially when compared to a lot of other languages I've had to write (including its much more verbose cousin, ActionScript), and quite a lot seem to agree. As far as utility for everyday chores, I don't see how that can be denied. I mean, obviously it won't wash your dishes, but neither will the other candidates. Which set of "everyday chores" may depend on implementation (the browser environment won't do a lot of what you could do in bash for instance), but those implementations do exist (and are proliferating).
eyelidlessness
The web is the new OS and JavaScript is its scripting language. JS also has many odd properties that make it very powerful and interesting as a language in general: first class functions, JSON, prototype-based object model. I wish I could use JS in more situations, I think it's a marvelous scripting language.
CodexArcanum
+5  A: 

Shell, Ruby, Python

For "getting" a bunch of files from the internet there are easier ways than to learn a scripting language. I'd suggest wget or curl. These can be combined with shell scripts.

For more advanced scripting more modern languages like Ruby and Python are most fun and useful for all kinds of stuff.

Ruby for example is easy to learn. You can even try it online interactively or learn it in 20 minutes.

Fabian Buch
+1  A: 

Groovy

Perhaps Groovy?

johnstok
I wouldn't recommend Groovy for scripting. It can eat alot of your memory if you are not careful.
jpartogi
yes, lots of libraries, very portable.
Ray Tayek
+64  A: 

Python

The reason this question is so subjective is that you didn't say much about what kind of scripting you want to do. Of course, you did mention downloading and processing files from the Internet, so I'll recommend Python.

Another Stack Overflow user asked a specific question about doing webpage scraping and asked which language would be best. The first answer outlines all the Python modules in the standard library which help accomplish this sort of thing, so you may find that helpful: http://stackoverflow.com/questions/86206/http-clients-programing-language

Since you already know C/C++ and thus are new to Python programming, I recommend the book Dive Into Python, which is written for people who already know how to program and focuses on how Python makes it easy to perform common tasks. The full text of the book is available online at http://diveintopython.org/toc/index.html

The "How to Learn Python" Stack Overflow question might also be helpful, since it contains links and descriptions of various Python resources: http://stackoverflow.com/questions/17988/how-to-learn-python.

Eli Courtwright
@Eli, if Python is your choice why not up-vote the existing answer and add a comment. As it is, you have split the vote for python so the most popular answer may not bubble to the top ;-)
johnstok
@johnstok: Eli's answer is better (more clear, more explanation, more detail) than Joel's.
eyelidlessness
+19  A: 

Perl

If you're familiar with C and Unix, Perl seems like a natural fit. The syntax is similar, but you get a lot of other "benefits" such as:

  • Regular expressions
  • Strings of unlimited size
  • Arrays of unlimited size and type
  • Easier file maniplation
  • Hash tables
  • CPAN
  • Flexible syntax
  • and more...

It's debatable whether you'll think features such as automatic type coercion, undefined values, and the sometimes-cryptic syntax are beneficial. I'll tell you this, however: with Perl, it was not uncommon for me to write a 100+ line program in a single sitting and have it work perfectly the first time I ran it. Not having to worry about declaring variables, overrunning arrays, and dealing with illegal null values allowed me to focus on solving the problem, not getting beat up by the compiler.

A lot is going to depend on what you need your scripting language for. I found Perl useful for the one-off programs I needed and for doing system administration tasks (chowing through log files, screen-scraping web sites, monitoring system resources, etc.)

My gut feeling, though, is that if you haven't had prior experience with Unix utilities such as grep, awk, and sed, you may not "get" Perl. In Perl-land, problems are best solved with hashes and regular expressions. They are far more productive (in terms of programmer time) than trying to shoehorn every data structure into arrays.

Barry Brown
I take issue with Perl sytnax being similar to C.
Joel Coehoorn
@Joel: Why? Its syntax is based on C. That it diverges is part of what makes it a different language, but that doesn't mean its syntax doesn't come from C. As is the case with most languages.
eyelidlessness
When I learned Perl, I had a similar background as the OP, plus I had some shell scripting experience. For the most common things, Perl syntax is very similar to C: the use of braces for code blocks, = for assignment, brackets for arrays, etc. I was learning Perl 4 at the time, which was simpler.
Barry Brown
+6  A: 

If you just want to play, why not try some out?

Personnally, I'd favour Ruby or JavaScript (I've not quite figure Boo out yet), but there's no reason why you might not find that you like other languages more, or that other languages suit are more suited to different problems.

One thing you may find, however, is that the cross-language querying features (like XPath and Regular Expressions) are more useful to learn that the individual languages themselves...

David Kemp
++ for cross-language features like XPath/regex
eyelidlessness
A: 

I recommend JavaScript simply because it's in line with C# which is more in lines of the language you are currently using (thus if you switch back and fourth a lot). My main reason for learning C# was because writing VB.NET then JavaScript seemed unnatural.

There are too many good JavaScript places online to list, any quick Google search will give you more than enough, but I say if you have particular issue, YOU POST IT ON HERE because this thing rocks! ;-)

schmoopy
+15  A: 

Ruby

Ruby is a great language for "everyday chores" and webscraping (see hpricot and Mechanize).

Googleage should provide plenty of tutorials and things for learning Ruby. See also this SOF question on learning Ruby.

Pistos
+3  A: 

Lua

How about Lua? It is a fast, light-weight, embeddable scripting language. I'm not saying that it's THE BEST (it is subjective), but open your mind, try it out and be happy.

rodfaria
+7  A: 

Lua

What about Lua? I've been learning it for a while and I've found that you can develop/prototype applications fairly quickly and there is a lot of flexibility with it. The only thing that standard Lua doesn't handle very elegantly is object oriented programming (OOP). It can be done, but it can be tricky. There are also several versions of Lua which have different features... such as one specifically for making OOP much more easier.

If not Lua then I would suggest, as others have, that you take a look at Python. I find though that Pythons syntax rules are very annoying. If you have a particular indentation style that you use for C and C++ then you'll probably have to make a few modifications to it if you're planning on taking up Python.

Dalin Seivewright
A: 

If you know C/C++, python has the advantage of relatively painless integration with those languages via Pyrex. This is incredibly useful if you need to interface a C/C++ library or you need to speed a python application up. In fact, for my purposes, elevates python from "scripting language" to "general purpose language."

fivebells
A: 

Of all of the scripting languages mentioned here, I believe Ruby is the best choice. I learned Ruby after having learned C/C++, C#, VB, VBS and a little javascript and to me Ruby has the easiest to learn and cleanest syntax, the fewest surprises when coding and things that just make sense.

For example, Python uses whitespace as a programming construct and those namehere methods, perl is way to easy to write "write once" code and favors global variables. Javascript supports a lot of metaprogramming facilities that ruby and python have but they are not as cleanly implemented and it feels almost like template meta programming in C++.

Raindog
You are bashing Perl and Python without having taken the time to learn them?
postfuturist
I learned a little about them and found other things to be easier to use while provide the same, if not more language features.
Raindog
+6  A: 

Powershell

If you use Windows, make it PowerShell.

Good

PowerShell combines a rich, relatively sensible syntax with .NET, COM, and WMI integration. It also offers a novel (and very cool) pipeline of objects.

It is both a great scripting languange and a great shell, so your knowledge is useful in both contexts. (Compare to CMD which is a fine shell but a crappy script language, or CScript/WScript, which are fine scripting languages, but no shell.)

Bad

If you're not on Windows, it's not much use to you.

If you hate Perl syntax, you'll mildly dislike PowerShell's syntax.

http://en.wikipedia.org/wiki/Windows_PowerShell

ScottStonehouse
+1  A: 

It depends on the specific program you're writing, which means you have to learn Perl, Python, PHP, and Ruby, all of them. Unfortunately, I have no knowledge of Ruby. And, JSP is less like a scripting language.

  1. Heavy on HTML, less heavy on DB, heavy on DOM/XML/XPath
    Learn PHP. It has a whole lot of quality third-party libraries.

  2. Heavy on HTML, heavy on DB
    Learn Ruby on Rails. Its MVC framework will make your life happier, I heard. But this choice may limit the type of web servers. Ruby on Rails works like a charm with Apache, lighttpd? I don't know.

  3. Generic pipe(stdin/stdout) scripts, or heavy regular expression
    Perl. You cannot claim yourself as a shell script master without knowing Perl. You can easily install new modules with its CPAN repository.

  4. Massive concurrent network processing
    Python. The powerful network library Twisted runs on top of Python. Python looks beautiful compared to Perl.

yogman
+5  A: 

Falcon, Scala

Go try Falcon and Scala, both are amazing!

Wow, never heard of Falcon before but at a first glance it looks very promising. I've programmed quite some stuff with Lua but beeing a professional Java Developer I'm missing some kind of 'official' OO support there. Seems that Falcon has more to offer in that direction. Thank you for mentioning it here.
Ridcully
A: 

I'm just starting to jump into the world of web scripting too and I just finished learning PHP. I obviously can't recommend it over any of the other ones, since its the first such language I learned, but I can say that I've had a lot of fun with it and it has A LOT of functionality. I find it hard to believe that any of these other languages have the same horizontal scope as PHP.

But again, I can't say for sure ;)

Good luck!

yeah well believe it, LOL why make such a ridculous statement about PHP having superior functionality when you haven't learned any other languages
Rick
A: 

I'd suggest you to learn JavaScript...

Sakthivel
+2  A: 

PHP is pretty easy, but has a pretty awful syntax and it forces a lot of self discipline to be possibly used for designs with more than 10000 or 20000 lines (although is it possible, for example the wonderful WordPress blog package is written in PHP, or the HORDE email and calendar package for web servers is written in PHP).

Perl also somehow has the disadvantage of a syntax that can become pretty ugly if a lot of different programmers with different coding styles and shortcuts usage mindsets cooperate on a project: here their TMTOWDI design goal (there is more than one way to do it) can be a disadvantage (I personally love Perl a lot, though...)

Python seems to be more elegant and more consistent, although probably at the beginning you will need some time to get used to their indentation-based scope delimitation...

For Ruby, I've seen it shortly and I did like it a little, but not too much. For me is a little too extreme, and I would consider it only if to use Ruby on Rails.

As a whole, I think that, no matter which you decide, mostly you will not regret your choice anyway, because all of them are, for rapid prototyping and for small glue-logic scripts or text-based activities, REALLY GREAT!!

Alex
Wordpress is a lot of things, but I don't think "wonderful" is a word I'd use to describe it.
eyelidlessness
+1  A: 

+1 to LUA cause it beats Python and Ruby on CPU time and memory usage :-)

p.s.

Lua vs Ruby 1.9 benchmark (you can look also Lua Vs Python 3):

http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=lua&lang2=yarv

0x69
A: 

Perl has the best Libraries and packaging system. Python has the best syntax.

Blanford Robinson
A: 

PHP

Come on guys! PHP is the best! It is the most powerful!! It is the most used nowadays. Now JavaScript is important, but HTML is about 20 times more important.

HD
A: 

Go for Python...

nullpointer
A: 

I agree with the Lua one, it is one of the easiest programming languages to learn and I'm just 14 years old and I knew Lua since I was 9 years old. If a 9 years old could learn it, you could too and Lua isn't as much a memory hog as Python or Ruby.

You could also try using Pascal, it is an easy language too...

joseph
+1  A: 

Lua

It is easily embeddable, very fast, has a simple syntax and best of all it is very easy to earn points on Stack Overflow because there aren't that many active Lua users here (though the ones that are, are very skilled).

ponzao
+4  A: 

Tcl

While I'm very biased as a developer of Tcl, I think that Tcl's definitely worth a look. Others have put together better reasons (about half way down) why than I feel I can advance myself without being a bit too hypocritical. Quoting from there:

Why Tcl? Because there seems to be nothing quite like it, in terms of simplicity, expressive power, flexibility, robustness, portability, scalability, and deployment. I don’t mean in terms of each individual issue, but in terms of the combination of those aspects. As a package deal, Tcl embodies a surprisingly clever and effective set of trade-offs. I could probably dismiss Tcl on every single issue in isolation, and name another language which would be preferable – but no single language can go where Tcl goes.

Donal Fellows
+1 due to irrational bias
TokenMacGuy
I think Tclkit(s) are a compelling reason for learning Tcl: "a compact, single file executable containing a complete scripting runtime"; see http://www.equi4.com/tclkit/
George Jempty
+1  A: 

Why just one Language?

When I think scripting I think first Unix shell programmming where BASH is the common shell progam. Whatever your system is set up with though should be learnt to some extent. One can't reccomend BASH for major projects but it is well worth your time to at least learn a little.

Man does not live on bread alone so I'd strongly reccomend learning Python. Python is very cross platform so that helps a lot. Python is a lot like VIM, you can find it anywhere. Pervasive doesn't make it good but it does mean transferable skills.

To a some extent Ruby is in the same ball park as Python but not as mature. JavaScript is great but has severe limitations when inside a browserr.

Dave

David Frantz
A: 

Why you want to learn those and all, Rock the life man, enjoy your best!!!

Raju
A: 

Python for the simple reason that its syntax is a huge benefit, not a hindrance, you just have to break away from the mindset of brackets and after a little while you will not want to have to use them for anything, they serve no real purpose other than to muck up code, think, every bracket takes up a line in properly spaced code and this is done for no real reason... if you are writing code cleanly then you should be indenting anyways, so why the need for brackets, i don't get why this would bother someone

Rick
A: 

Perl

Perl is the best scripting language to learn for many reasons, but the two that might not spring to most people's minds are

  • Learning Perl is the best introduction to Scripting Languages ever written
  • The Perl community is very friendly to new-comers

If we're honest the actual language differences between Python, Perl and Ruby are all pretty small. This means that the reference material and support you get is really a good way to make a your decision.

Kaoru
A: 

Perl

I strongly respect the reasons given by several other people in favor of some of these languages. In some ways, you can make good arguments for some of them being superior to Perl as languages. However, you asked which one to learn as a scripting language. Perl was created for that purpose. It makes scripting easy. Perhaps more to the point, the Perl community has a long history of documenting Perl for scripting tasks and developing modules to support the needs of programmers using it for those tasks.

There was once a time when programming languages existed more in isolation than they do today. Now, you have to consider them in the context of the libraries or modules and communities around them. While the quality of those is excellent for several of the languages other people have mentioned, their focus is different. A good language with a wide range of modules specifically built for the purpose you have in mind is the way to go.

Dale Gulledge
A: 

OK.. This REALLY depends on the platform that you are writing for, and the purposes you are trying to accomplish. This being stated, here is my opinion of three of the leaders in this poll (I have no idea about Lua or Ruby... looked over Lua, its syntax seems weird... no experience with Ruby):

Perl is quite powerful, but its syntax is a mess. It hails back to the early days of Unix programming, and unfortunately, the syntax shows this badly. Imagine, as a previous poster stated, writing most of what you do as a regular expressions, rather than working with arrays and objects. It does boast a large, dedicated community, but this is mostly because it is as old as dirt, and a LOT of people grew up on it. Primarily, only really usable for Unix based environments.

JavaScript is a bit of a pain, but not as bad as Perl. The worst issue with JavaScript is that it can produce some maddeningly invisible errors... invisible, as in that when you run it? NOTHING HAPPENS. Right... nothing. No error code, no "You forgot a bracket on line 23"... nothing. This is especially problematic when there are multiple interpretations of JavaScript, depending on the browser and/or environment it is run in. Couple this with severe limits to its capabilities, such as not being able to write to the file system (at least on client machines... I have no direct experience with JS in server environments), and you have a non-starter.

Python is extremely powerful, especially for math. It doesn't use brackets (like C, C++, JavaScript, etc), yet the syntax is still pretty familiar for anyone knowledgeable in those languages. There are a few issues, here, though as well, such as picking what version to learn. Version 2.7 is the most widely supported, but is inconsistent, version 3.1 has corrected this, but is incompatible with many libraries, still. A more minor annoyance, which might not affect you, is the fact that there is no means in the language to declare anything private... you basically just label it private by a naming convention, and hope others respect that. Python is also available on many, many platforms, and is pretty consistent across them. You can pick up python 3.1 on a local windows machine, for example, and still be able to run the code with little or no modification on a Linux server (although path names may be a pain due to platform dependent file syntax).

As a general script language, Python 2.7 is my recommendation. You can pick it up, along with IDLE (its built-in IDE) from python.org. In the next year or so, expect version 3 to overtake it, but the differences, by then, should be easy enough to handle.

As for learning the language? No idea where to go... sorry. I learned it from the documentation included with Python, but its 'tutorial' is written more akin to a poorly indexed reference document. I would probably recommend something from O'Reilly or No Starch Press, but, again, I taught myself, so don't have any useful recommendations for specific books.

SilentThunderStorm