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:
One language per response, please.
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 client's programming language [1]
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.net/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: How to learn Python? [2]
[1] http://stackoverflow.com/q/86206/1694JavaScript (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.
I'd suggest Ruby.
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:
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.
Ruby is a great language for "everyday chores" and webscraping (see hpricot [1] and Mechanize [2]).
Googleage should provide plenty of tutorials and things for learning Ruby. See also this SOF question on learning Ruby [3].
[1] http://code.whytheluckystiff.net/hpricot/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.
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
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 [1] for example is easy to learn. You can even try it online interactively [2] or learn it in 20 minutes [3].
[1] http://ruby-lang.orgPython seems to be getting a lot of traction.
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...
Go try Falcon and Scala, both are amazing!
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 [1] (about half way down) why than I feel I can advance myself without being a bit too hypocritical. Quoting from there:
[1] http://news.jeelabs.org/2010/05/12/there-is-a-reason/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.
How about Lua [1]? 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 [2].
[1] http://www.lua.orgPHP
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 [1] 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!!
[1] http://en.wikipedia.org/wiki/There%27s_more_than_one_way_to_do_itit's great from beginner to expert, it's fast, and you can do anything you need to do... if you need a breath of fresh air after a while on Python try Ruby(my favorite)... and if you want to appreciate Python/Ruby's simplicity try Perl... cough
Perhaps Groovy?
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.
Heavy on HTML, less heavy on DB, heavy on DOM/XML/XPath
Learn PHP. It has a whole lot of quality third-party libraries.
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.
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.
Massive concurrent network processing
Python. The powerful network library Twisted runs on top of Python. Python looks beautiful compared to Perl.
Ruby is gaining ground
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).
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
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.
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.
+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 [1]
[1] http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=lua&lang2=yarvWhy 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
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).
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...
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
I think the problem with this question is the platform of execution. PHP is invaluable these days for web development. But PHP won't help you if you are looking to script OS events.
For Web: PHP & Javascript (and jQuery is the best framework)
For Windows: - VBScript should be a highschool course. It's on all windows boxes by default. You should know the basics (pun intended) - Perl is probably the biggest, probably because it is cross platform. But the syntax is strange IMO (if/elif/elsif, etc) - Python is highly regarded but much less popular - Tcl was my first automated scripting language and it was very good. Learned it in about 6months with the help of the big black Tcl/Tk reference book - Lua I only know from the Grand Theft Auto addon for "Multi Theft Auto" used it. It seemed easy enough to use, but again, not very popular.
I use vbscript in most cases when scripting windows events simply because its just "there" on all boxes. No other software to install or screw around with. vbsEdit is a great debugger but you can use the msscript debugger from microsoft with any popular editor (notepad++, ultraedit, etc). Additionally, learning vbscript is like learning the piano.. it helps you grasp the concepts of programming with other languages if you learn it first.
If you know C/C++, python has the advantage of relatively painless integration with those languages via Pyrex [1]. 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."
[1] http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/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++.
If you want a good utility language, learn Perl. It's amazing, and wonderful.
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! ;-)
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.
PYTHON
To learn this language go make an account at the ncss challenge website its cheap and makes it easy to learn.
Perl has the best Libraries and packaging system. Python has the best syntax.
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!
I'd suggest you to learn JavaScript...