views:

420

answers:

10

Background: Standard RIT computer engineering student. Took computer science courses (Java, then C++). I spend a lot of time on tech sites, so I constantly hear about scripting languages like Python, Perl, and Ruby. Besides them being scripting languages, I basically don't know anything else about them.

I have a lot of experience in "real" programming languages, but I recently rediscovered the joy of Bash scripts on my Ubuntu computer (my main computer is a Vista laptop).

Question: For a Java/C++ programmer, which scripting language should I learn first or focus on?

Reasons:

1) I need more co-ops, so I need to flesh out my resume. Does this mean I should work on becoming familiar with all the main scripting languages (and master of none), or would that be redundant?

2) I would like like to use the power of scripting languages to enhance my regular programming. Which language is best suited for what tasks and what can I do with scripting languages?

3) Lastly, as a small hobby. I have some ideas for personal projects to make my web browsing more efficient (which I guess would require web/data scraping) and automate certain tasks. Also, Google App Engine looks interesting, but I'm lazy and I would like to avoid the hard work I associate with Java.

A: 

Groovy - right at home coming from Java, Ruby sounds line fun - would be easy to deal with performance critical code needed to be written in C

vector
A: 

PYTHON...or may be Groovy...?

mshsayem
A: 

I'm biased, but I'd say Python: in my Python for Programmers talk, I point out the similarities with C, C++, AND Java that will help you get onboard. It's also currently the most popular "scripting" (hating that monicker is a different issue) language on Tiobe (below PHP, but that's not "general purpose"... above Perl, Javascript and Ruby anyway;-), for what THAT is worth;-).

Alex Martelli
What's wrong with the term "scripting language"?
Chris Lutz
@Chris, it erroneously classes general-purpose programming languages together with (e.g.) zsh or bash, somehow implying that they couldn't be used to program, oh, say, YouTube (probably the highest-traffic site entirely focused on Python), reddit.com (which switched to Python from Lisp...!), nltk, scipy, Twisted, ...!-)
Alex Martelli
I disagree - I think "scripting language" just means a high-level, high-abstraction, traditionally interpreted or bytecode interpreted language, particularly where execution starts at the first statement rather than in a main() function - but I do consider there to be a difference between "scripting languages" like Perl, Python, Ruby, etc. and "shell languages" like zsh or bash. I think the term "scripting language" just has a bad rap, as when I hear the term I think of something a bit more positive.
Chris Lutz
TIOBE is different from other popularity ratings, From them Perl is more popular than Python and Pyhton is more popular than Ruby.
Alexandr Ciornii
Who're "them" and when updated? Tiobe now has Python #6, Perl #8, Ruby #10; 4 years ago, it had Python #8, Perl way above at #4, Ruby way below at #25. How accurate, who can know!, but the trends seem true: in 4 years, Ruby way up, Python a bit up, Perl trending down (maybe Perl 6 will change the latter trend?).
Alex Martelli
@Alex Martelli: Are you implying that Perl 6 is going to be completed sometime in the next decade? ;)
R. Bemrose
draegtun
@R. Bemrose: Spring 2010 is in the next decade I suppose ;-) http://www.h-online.com/open/Perl-6-due-in-spring-2010-some-of-it-anyway--/news/113956
draegtun
Alex Martelli: for example, number of modules and number of new modules in repositories. In TIOBE, there is huge jump for Python - I don't trust such speculations.
Alexandr Ciornii
Alex Martelli: http://www.slideshare.net/Tim.Bunce/perl-myths-200909
Alexandr Ciornii
+18  A: 

For automation tasks, including web scraping, all of Python, Ruby, and Perl would be suitable. For Google appengine, you should use Python (as that is actually the first languge that was supported on that platform).

I recommend that you define yourself a specific project, and then ask here what specific libraries people would use, and try two out of three languages, to see which one you like more.

Martin v. Löwis
+1 It's very difficult to answer this without praising your favorite scripting language. Solid and unbiased advice like this deserves many upvotes.
Chris Lutz
+3  A: 

Try them all (do the tutorials) and use the one you like.

monkut
While it takes a while to really grasp the nuances of any language, spending a weekend with each in turn should at least give an idea of which works better for you (as opposed to the one you think you ought to like).
Steve Gilham
+3  A: 

I'll say Perl, because it has syntax most like C.

  • Python creates blocks by colons and indentation (not very C-like).
  • Ruby takes its queue from Python, but adds in some word-delimited blocks (kinda like Pascal)--although it just as often uses curly angle blocks as well.

Of course, this might also be the reason you don't want to learn Perl, because you want a totally different type of syntax. But Perl has the following similarities.

  • All blocks are delimited with { ... }.
  • Statements are separated with ; (Ruby uses ':')
  • C logic operators ==, !=, ...
  • C ternary operator:
      my $result = $test ? $true_value : $false_value
  • OO Perl uses -> for method dispatch:
      $my_object->do_method()
  • Classes are named This::That::TheOther and methods This::That:do_that
  • Printf format specifiers (as well as plain old printf)
      printf "Your string is=\"%s\"\n", $your_string
Axeman
As one Perl fan to another, syntax is a rather poor reason to pick a language. Learning a new language syntax or three is easy, but writing idiomatic code in multiple languages is difficult. I would suggest trying to sell some nice features of Perl that you like, like syntax-level support for regular expressions, variable sigils ($var, @var, etc.) allow variables to be easily nested inside strings, the defined-or operator (`//`) for defaults, or other things. Of course, all of these are subjective, but no more subjective than the relative aesthetic appeal of syntax.
Chris Lutz
@Chris Lutz: I wasn't trying to "sell Perl". He asked "as a C++/Java Programmer" and somebody said Python has "similarities", and on that basis, I think Perl has more. There are other threads for "Neat Things about Perl". I'm not sure of what besides similarity would be the issue *as* a C/Java Programmer.
Axeman
+1  A: 

It all depends on what you want to accomplish.

For simple (or advanced!) day-to-day sysadmining/automation etc. I use bash.

For application development, I'm very partial to ruby (and ruby on rails for web-applications). But wouldn't mind python either. My view on perl is that it tends to be a write-once-hopefully-never-touch-again language. Don't get me wrong, it really is a nice language, but I find that it is way to easy to produce unreadable code in perl.

A different allround, nice language is lua. It is ridiculously simple to embed in C/C++ applications. It has a lot of nice libraries and is still very light-weight. I've used lua as the logic layer in a distributed C++/java-based 3D application (yes, 3 languages in a single product!?), and my xmpp-server of choice is currently prosody which is lua all the way.

Both ruby and lua (and presumably python and perl) behave nicely on windows as well as linux/unix. Bash is most definitively more at home in the linux/unix-world.

olemd
"I find that it is way to easy to produce unreadable code in perl." I agree. Perl relies a lot on "magic" which makes it harder to read. For example, the uninitiated person to perl would have no idea what the shift in "my $blah = shift;" is doing.
R. Bemrose
R. Bemrose: Same for other languages. I remember reading example published by someone who said that this example, in difference to Perl, can be read by person who does not know this language. For me (I studied many computer languages, but not this), this example was not readable.
Alexandr Ciornii
+2  A: 

Given that you are already familiar with Java, I would suggest learning Groovy first. Groovy is a dynamic language (the less pejorative term for scripting language) that targets the JVM. Because it targets the JVM, you have complete access to call of Java classes you are familiar with, but without the pain you associate with Java. This should smooth the learning curve a little.

Once you are feeling comfortable with Groovy, I would suggest Scala. Scala also targets the JVM. It will likely break your brain, as it is a functional language and up to this point you have only used imperative languages. Note, breaking your brain is a good thing. When you put the pieces back together you wind up with a better brain.

Chas. Owens
+2  A: 

You may try playing with ruby, python, they are both great languages and very close to each other. Perl is just another thing. If your coming from a C background you won't be spending too much time understanding its syntax and once you map the similitudes between the two language you'll find yourself doing C almost all the time.

In addition, Perl community, packages, resources, .... is just immense !

Remeber that the main goal behind Perl creation, is to achieve a lot while writing less.

ZeroCool
A: 

Since you go to RIT, you might be interested in the fact that the computer science department is switching Computer Science I and II from Java to Python and Computer Science IV from C++ to C. This means that there are going to be more Python resources on campus - more people are going to have some knowledge in it, meaning it will be easier for you to get face-to-face help if you need it.

In reality, all of the different scripting languages have some things in common, and some things that they excel at. I'm learning Python now - it's not that bad, coming from a mostly Java background. Ruby was my first scripting language, and I liked how I could make things happen quickly with it (and with Rails, for web-based development).

The best advice I have is to look at the major scripting languages and see which one you like the best. It shouldn't be that hard to take what you learn in one and quickly pick up another. And as you learn more languages, it will be easier to pick up other languages.

Thomas Owens