Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?

32,232

Solution 1

A lot of times some quick task comes up that isn't part of the main software you are developing. Sometimes the task is one off ie compare this file to the database and let me know the differences. It is a lot easier to do text parsing in Perl/Ruby/Python than it is in Java or C# (partially because it is a lot easier to use regular expressions). It will probably take a lot less time to parse the text file using Perl/Ruby/Python (or maybe even vbscript cringe and then load it into the database than it would to create a Java/C# program to do it or to do it by hand.

Also, due to the ease at which most of the dynamic languages parse text, they are great for code generation. Sure your final project must be in C#/Java/Transact SQL but instead of cutting and pasting 100 times, finding errors, and cutting and pasting another 100 times it is often (but not always) easier just to use a code generator.

A recent example at work is we needed to get data from one accounting system into our accounting system. The system has an import format, but the old system had a completely different format (fixed width although some things had to be matched). The task is not to create a program to migrate the data over and over again. It is to shove the data into our system and then maintain it there going forward. So even though we are a C# and SQL Server shop, I used Python to convert the data into the format that could be imported by our application. Ultimately it doesn't matter that I used python, it matters that the data is in the system. My boss was pretty impressed.

Where I often see the dynamic languages used for is testing. It is much easier to create a Python/Perl/Ruby program to link to a web service and throw some data against it than it is to create the equivalent Java program. You can also use python to hit against command line programs, generate a ton of garbage (but still valid) test data, etc.. quite easily.

The other thing that dynamic languages are big on is code generation. Creating the C#/C++/Java code. Some examples follow:

The first code generation task I often see is people using dynamic languages to maintain constants in the system. Instead of hand coding a bunch of enums, a dynamic language can be used to fairly easily parse a text file and create the Java/C# code with the enums.

SQL is a whole other ball game but often you get better performance by cut and pasting 100 times instead of trying to do a function (due to caching of execution plans or putting complicated logic in a function causing you to go row by row instead of in a set). In fact it is quite useful to use the table definition to create certain stored procedures automatically.

It is always better to get buy in for a code generator. But even if you don't, is it more fun to spend time cutting/pasting or is it more fun to create a Perl/Python/Ruby script once and then have that generate the code? If it takes you hours to hand code something but less time to create a code generator, then even if you use it once you have saved time and hence money. If it takes you longer to create a code generator than it takes to hand code once but you know you will have to update the code more than once, it may still make sense. If it takes you 2 hours to hand code, 4 hours to do the generator but you know you'll have to hand code equivalent work another 5 or 6 times than it is obviously better to create the generator.

Also some things are easier with dynamic languages than Java/C#/C/C++. In particular regular expressions come to mind. If you start using regular expressions in Perl and realize their value, you may suddenly start making use of the Java regular expression library if you haven't before. If you have then there may be something else.

I will leave you with one last example of a task that would have been great for a dynamic language. My work mate had to take a directory full of files and burn them to various cd's for various customers. There were a few customers but a lot of files and you had to look in them to see what they were. He did this task by hand....A Java/C# program would have saved time, but for one time and with all the development overhead it isn't worth it. However slapping something together in Perl/Python/Ruby probably would have been worth it. He spent several hours doing it. It would have taken less than one to create the Python script to inspect each file, match which customer it goes to, and then move the file to the appropriate place.....Again, not part of the standard job. But the task came up as a one off. Is it better to do it yourself, spend the larger amount of time to make Java/C# do the task, or spend a much smaller amount of time doing it in Python/Perl/Ruby. If you are using C or C++ the point is even more dramatic due to the extra concerns of programming in C or C++ (pointers, no array bounds checking, etc.).

Solution 2

Let me turn your question on its head by asking what use it is to an American English speaker to learn another language?

The languages we speak (and those we program in) inform the way we think. This can happen on a fundamental level, such as c++ versus javascript versus lisp, or on an implementation level, in which a ruby construct provides a eureka moment for a solution in your "real job."

Speaking of your real job, if the market goes south and your employer decides to "right size" you, how do you think you'll stack up against a guy who is flexible because he's written software in tens of languages, instead of your limited exposure? All things being equal, I think the answer is clear.

Finally, you program for a living because you love programming... right?

Solution 3

I don't think anyone has mentioned this yet. Learning a new language can be fun! Surely that's a good enough reason to try something new.

Solution 4

I primarily program in Java and C# but use dynamic languages (ruby/perl) to support smoother deployment, kicking off OS tasks, automated reporting, some log parsing, etc.

After a short time learning and experimenting with ruby or perl you should be able to write some regex manipulating scripts that can alter data formats or grab information from logs. An example of a small ruby/perl script that could be written quickly would be a script to parse a very large log file and report out only a few events of interest in either a human readable format or a csv format.

Also, having experience with a variety of different programming languages should help you think of new ways to tackle problems in more structured languages like Java, C++, and C#.

Solution 5

One big reason to learn Perl or Ruby is to help you automate any complicated tasks that you have to do over and over.

Or if you have to analyse contents of log files and you need more mungeing than available using grep, sed, etc.

Also using other languages, e.g. Ruby, that don't have much "setup cost" will let you quickly prototype ideas before implementing them in C++, Java, etc.

HTH

cheers,

Rob

Share:
32,232
szabgab
Author by

szabgab

I help improving engineering practices by providing training, mentoring, coaching. Implementing techniques and technologies. Introducing Unit, Integration, and Acceptance testing Continuous Integration (CI) Continuous Deployment (CD) Software and System Configuration Management Version Control Systems (e.g. Subversion, Git) Build system Perl, Python, JavaScript Linux Basics for Power Users Database integration (SQL, NoSQL) Web Application Development Test Automation and Quality Assurance (QA) Adding telemetry to products and services Chief editor and publisher of the Perl Weekly newsletter. Author of the Perl Maven site with the Perl tutorial on it. Also the Code Maven site.

Updated on July 08, 2022

Comments

  • szabgab
    szabgab almost 2 years

    I wonder why would a C++, C#, Java developer want to learn a dynamic language?

    Assuming the company won't switch its main development language from C++/C#/Java to a dynamic one what use is there for a dynamic language?

    What helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?

    Update

    After seeing the first few responses it is clear that there are two issues. My main interest would be something that is justifiable to the employer as an expense. That is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the employers are usually looking for some "real" benefit.

  • Sunilsingh
    Sunilsingh over 15 years
    Even though my workplace is all c++ or embedded c, I use Ruby for exactly this kind of stuff. Log file processing, quick prototyping, test stub stand-ins for the other end of a TCP interface, etc.
  • Karthik Rao
    Karthik Rao over 15 years
    true 30% of the time...
  • neo2862
    neo2862 over 14 years
    Agreed. I was programming almost exclusively in C# before one day seeing a Perl tutorial and trying it. I could not believe how fun it was!
  • cwallenpoole
    cwallenpoole over 14 years
    I've actually recently come across the exact problem you're describing. I was given a PDF and needed to convert the contents to an XML syntax. I was able to do it in PHP in less than an hour, and I ensured that there were no typos. Far easier than copying and pasting.
  • Bruno Feroleto
    Bruno Feroleto almost 14 years
    +1 for the link on the Python Paradox.
  • Martin Ueding
    Martin Ueding about 13 years
    I tried Python from a Java point of view. It is just awesome :-)
  • svlada
    svlada about 11 years
    You left comment in 2008 year, now is 2013, and puck is still on Java, C# side.
  • Kris Welsh
    Kris Welsh almost 11 years
    I feel like this chart is relevant to your answer