As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Many programming languages introduce themselves with a simple "Hello World" program.
As a programmer, I must admit that this does not give very good insight into the strenghts and capabilities of the language.
What kind of problem would you suggest to use when providing a demo of a programming language?
I think the "Hello World" program has its uses. It says a lot if you can run that program:
You have your IDE/Tools setup correctly
You can write a class and or main method in that language
You can call a function in that language to print
You can edit a file and format it correctly for that language
Your compiler is working and you know how to use it.
So, for those reasons I don't find any better alternative to "Hello World."
However, in terms of a good intro to languages in general, I'm a big fan of coding challenges like Python Challenge. You are given a set of challenges/puzzles you have to complete with the language. They start out extremely basic (the first one is easier than writing a hello world).
They quickly progress into more difficult and advanced tasks, and usually are tasks that are intended to show off a particular aspect of the language.
I only wish every language had such a fun programming challenge. I think a LISP, Haskell, C++, C, Java, etc Challenge would be a fun introduction to the languages for people. They could be tailored to the languages.
The C++ challenge could quickly start having challenges involving pointers and other commonly misunderstood aspects to help drive home those difficult bits while the LISP/Haskell challenges could start to ask some questions that are more tailored to functional languages.
If you are worried about the scope of a "hello world" program, you can always upgrade to "hello universe"
IMHO, the purpose of the hello world program is to show a very simple program in that language, not to show the strengths and capabilities.
It would be hard as each language has its own strengths. Comparing a standard set of functions for each language might be asking for trouble, especially for an intro book.
Larry O'Brian wrote three very good blog posts on exercises to familiarize yourself with a programming language.
Part 1: Basics
Part 2: Data Structures
Part 3: Libraries, Frameworks and Mashups
"99 bottles of beer" is a slightly more involved example than "Hello world", so it can show the things that differentiate one language from the others.
Check out http://99-bottles-of-beer.net/ .
Depends on what core feature of the language sets it apart from other languages out there. The Haskell quicksort comes to mind.
With that said, hello world does show how to immediately produce some sort of output.
Personally when I start out in a new programming language I attempt to re-write a piece of code that I have already written in a different language so that I can get a feel for the language and see how it relates back to what I have already learned in my previous programming experiences.
People suggest programming simple stuff like binary search trees, and other data structures along with a simple way to test that it works. The other thing is to not give up on the programming language when things start to get complicated or do not fit in with your previous experience.
As for looking for the strengths in programming languages? Well, start out by writing a small application and then once you have a feel for the language look at open source projects written in this language. See what it does very well, look at mailing lists found out where the difficult parts were for that project, where they had to work around some idiosyncrasy in the language that caused them issues.
Certain languages you know right off the bat that they were meant for a certain task and using them outside of that task is not recommended. For example, PHP is a web programming language, the fact that you can write big programs in it and run them on the command line does not mean it is a language that should be used for those tasks.
I was very favorably impressed by Bjarne Stroustrup's choice to make a quite powerful calculator, including parsing. I expected that it would be too difficult as a first project, but he does an excellent job step by step. And the final application is not a toy.
All in his new book, Programming Principles and Practice in C++.
I some cases "Hello world" may be non-trivial.
See for example Struts 2 "Hello world". To have it working you'd need to have server set up, environment set up, your app deployed, etc.
Well a "blinky" is a good alternative, but that is more in the embedded world that this is relevant...
For you who have misses out on blinky, it is just to get a LED to blink on/off at steady pace. Kind of shows how to work with gpio.
/Johan
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
i was thinking learn a more low level language like C, but before it i'd like some opnion about:
what's the second language do you recommend to learn?
learn a low level language will make me a better programmer?
it's really necessary learn a second programming language?
Going backwards:
(3) Absolutely - you'll increase your ability by orders of magnitude by learning multiple languages.
(2) A low level language will make you a better programmer - alternatively a functional language will help as well.
(1) Low-level: go with C. Functional, try Scheme or Haskell. C also gives you the ability to write extension modules to Python if you ever have the need.
what's the second language do you recommend to learn?
Something imperative (i.e. same paradigm) but different. Python is dynamically typed with significant whitespace, so something statically types without significant whitespace: e.g. Java or C#.
These would also make a nice stepping stone towards C. The benefit of C is you really know what's going on, but with the disadvantage that you have to control it all. This level of control is not need for most business problems.
it's really necessary learn a second programming language?
Really subjective, but most good developers know many (consider for a web app: Python, Ruby, C#, Java on the server; SQL on the database and JavaScript on the client; and then the mark-up...).
You benefit from being able to see other approaches to problems and thus create better solutions. So once you have covered more imperative languages move into other paradigms like functional.
I agree with your choice of C, which leads on to C++. If nothing else, learning C will teach you why people these days tend to prefer languages with automatic memory management - but it will potentially also give you a feeling of programming "close to the metal" (without the pain of programming in assembly language), and help you to understand how a processor actually works. Not always useful knowledge but it's nice to know.
Whatever you choose, I recommend a statically-typed language - C, C++, Java, and some functional programming languages fit this bill. Java might be a good choice if you find C a bit tough at first.
I'd say learning any new language makes you a better programmer. However, will learning C make you a better Python programmer? Probably not; why should it?!
Define "necessary"! By a strict definition, no. But you're missing out on the experience of having to think about things in a different way (even if it's only a slightly different way).
I would stay with the same paradigm, but leave options open for another paradigm (functional programming). Probably C# is a good choice, because
If you decide to learn C/C++ later, it'll become a bit easier.
If you decide you want to learn functional programming later, you can switch to F# but still use existing code written in C#, because you stay within .NET framework.
Python is not known to be a remarkably fast language. You should consider learning a language which allows better computational performance. But good old ANSI C is probably too low level, despite you can write very fast programs with it. C# has OK performance for a just-in-time compiled language, and if you need more performance later, you can still extend your knowledge towards F# or C.
Although I don't use Microsoft Windows privately and advertise Linux and Open Source frequently, it's probably a good idea to offer some knowledge about Microsoft technology in case you intent to earn money with programming.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
As the question states, is it better if a student diversifies or explores when learning programming languages or should they focus only on 2-3 languages and really get to know them well?
Example of what I mean by diversifying:
Functional -> Scheme
Procedural -> C
Object Oriented -> Java
Dynamic or scripting -> Python
Other -> C++
I have a few breaks in between semesters sometimes (up to 3 months) and I'm thinking of either learning a new language or "master" those that I know right now. Which would benefit me in the future? I know some(about 3 months of self studying each) Java, C, and C++ already . If I'm not mistaken, where I live, the industry is heavy on Java, C++, and C#.
Mastery takes ten years. But if you were my student, I would advise you to develop a good working knowledge of four kinds of languages:
Functional
Object-oriented
Machine-level
Scripting
These categories are pretty loose, but if you have a good working knowledge of all four, you score well on diversity.
If you want to aim for mastery, study C as your machine-level language and Lua as your scripting language. Lua is definitely small enough to be mastered, and C is not too bad if you avoid odd corners like the true meanings of const and volatile. I don't know if a functional or object-oriented language that I would say is susceptible of mastery.
Summary: build carefully targeted diversity and allow mastery to come with time.
Do both. Master at least one language (probably Java or C# since those are most common in industry) and learn others languages for what they can teach you so that you can bring back to those you are forced to work with.
You can't master a language per se, you can master programming. In the end, it will rarely matter if you have to learn a new language, as you have all the basic knowledge from other projects, you just have to get used to the specific stuff of the new language.
I believe that a good programmer doesn't know every thing but he can learn every thing.
when you master a language and master "the programming" it won't take more than a week to learn another language.
but it is a good idea to take a look to new languages and be able to read and anderstand codes in many languages.
It is hard to master a language unless you are actually using it for real, this means that during your holidays you would have to write real projects - not many people can achieve that (finishing a real project in a short amount of time, while on a break from learning).
I would advise to diversify first. You will find that once you know a few different languages then any new lenguage becomes a lot easier to learn. Different types of languages also introduce you to new concepts, and may well help you decide what type of programming you really want to do. Once you have decided what you like, then work on mastering it.
It depends on where and what your intentions are (for me at least).
A student in varsity is somewhat bound to the curriculum and the course will surely lead them and bind them to the predefined learning path.
For someone in my situation (Self taught and takes Vendor certifications), the goal is employment and income and thus learning a language with the goal of finding employment is (or was) my highest priority.
It is not common to work as as a developer on a full 3 tier systems as roles are usually fragmented into at least 2 ends (front and back) so I would focus on on what you're good at out of these. (If you're an artist and graphical guy/gal focus on front end and if you're mathematical and a problem solver, focus on back end and possibly scripting).
I have thoroughly enjoyed learning Java (even with an orange sized brain tumor lurking in my brain) and found it a good enough language to take you to other languages as it has some commonalities to general programming like: functions (methods), can be written procedural (like hello world app), has standard variable declarations, has logical operators and conditional operators found in many other languages.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Question 1: How exactly do modern computer language come into being and why? How do they get their start and who is behind them?
Question 2: If any, what languages currently in their infancy are showing promise?
How exactly do modern computer language come into being and why? How do they get their start and who is behind them?
It's a multistage process:
Pointy-headed type theorists and other professionals are continually proposing new language features. You can read about them in places like the Proceedings of the ACM Symposium on Principles of Programming Languages (POPL), which has been held annually since 1973.
Many of these proposals are actually implemented in some research language; some research languages I personally find promising include Coq and Agda. Haskell is a former research language that made it big. A research language that gets 10 users is often considered a success by its designers. Many research languages never get that far.
From research to deployment I know of two models:
Model A: A talented amateur comes along and synthesizes a whole bunch of existing features, maybe including some new ideas, into a new language. The amateur has talent, charisma, and maybe a killer app. Thus C, Perl, Python, Ruby, and Tcl are born.
Model P: A talented professional make career sacrifices in order to build and promulgate a new language. The professional has talent, a deep knowledge of the field, and maybe a killer app. Thus Haskell, Lua, ML, Pascal, Scala, and Scheme are born.
My definition of a professional is someone who is paid to know about programming languages, to pass on that knowledge, and to develop new knowledge in programming languages. Unfortunately this is not the same as designing and implementing new languages, and it is not the same as making implementations that many people can use. This is why most successful programming languages are designed and built by amateurs, not professionals.
There have been quite a few interesting research languages that have had hundreds or even thousands of users but yet never quite made it big. Of these one of my favorites is probably Icon. I have argued elsewhere that nobody really knows why languages become popular.
Summary: Languages come into being because people want to make programming better, and they have new ideas. Languages get their start when somebody takes a whole bunch of ideas, some new and some proven, and synthesizes them into a coherent whole. It's a big job. The person behind a new language might be a programming-language professional, but historically, most languages that become widely used seem to have been created by talented amateurs.
Answer 2: Fortran 2008 looks very promising.
Come on, bring on the downvotes you humourless Java-teenies, Pythonettes, Rubes and Haskellites !
1) Most development environments these days are built to abstract a lot of low-level/inner workings of an platform to speed up development and cater for new user-interfaces and plaform technologies. There are a both open-source projects and corporates behind these changes... For instance an example would be jQuery is a newish Library that just wraps a lot of javascript making things easier and cross-platform...
Bjarne Stroustrup wrote a book on the history of C++, called "The Design and Evolution of C++".
The genesis of a programming language is always a different story. I'm currently reading "Masterming of programming", which is a series of interview with authors of popular languages. They explain what problems they tackled and how the language was born -- a really cool book.
The TIOBE index can give somehow a trend amongst the programming languages, including the emerging ones. I bet that the future lies in language that will run on top of the JVM or CLR (Notably due to the effort invested in the VMs which are now really great). Concurrency seems to be one of the hot problem of today; so I guess we will see some interesting moves in this area (e.g. Clojure).
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I already have a few languages under my belt (in a rough order of expertise): Python, C, C++, PHP, Javascript, Haskell, Java, MIPS, x86 assembler. But it's been almost 2 years since I learned a new one, and I'm starting to get the itch. I have a few criteria:
Must (repeat: must) have a free Linux implementation
Should be different from the languages I already know. In other words, it should have features that get me thinking about solving problems in a new way.
Should have some potential for practical use. It doesn't need to be the next Java, but this rules out Brainf* and Shakespeare :) I don't really care how many job postings does it have, but real-world apps and libraries are a plus.
Should have at least just enough free learning materials to get me started in it.
I was thinking Lisp (CL? something else?) or OCaml. I already have some experience with functional languages with Haskell (yes I know that Lisp/OCaml are multi-paradigm). I'm not an expert - e.g. parts of code from Real World Haskell can still contort my brain, but I understand the basic concepts and some advanced ones (functors, monads).
Which one to choose? Any other languages that I have overlooked? Also, could you please include some useful links to good books/tutorials etc.
Neither Lisp nor OCaml is super far afield from what you already know. Here are four suggestions chosen partly for intrinsic interest and partly to stretch your horizons.
A logic programming language, probably Prolog. I haven't found good materials online, but the book The Art of Prolog by Sterling and Shapiro is excellent. The more basic textbook by Clocksin and Mellish is also good. The main point of interest is programming with relations, not functions.
A pure object-oriented language, either
Smalltalk or Self. If you've only used hybrid object-oriented languages you'll be amazed how beautiful pure object-orientation can be. I've linked to the Squeak implementation of Smalltalk. I personally would recommend learning Smalltalk before tackling Self; there's a very large and active community and the software is well developed. Self stands on Smalltalk's shoulders and is an even more inspiring design, but the community is much smaller. For those who have access to the ACM Digital library I recommend the excellent talk by Dave Ungar at HOPL-III; the paper is also pretty good.
The Icon programming language has two great things going for it; a powerful and unusual evaluation model with implicit backtracking, and a user-extensible model of string processing that beats regular expressions all hollow. I'm sorry to say that Icon has never quite kept pace with the times, and of all my recommendations it is the least practical. In fact I fear the language is moribund. But it will stretch your mind almost as much as Haskell, and in wildly different directions. Icon is still very useful for string-processing tasks of modest size.
You can read about Icon string processing in an article by Ralph Griswold from Computer Journal.
The Lua programming language is my last and least radical suggestion. Its interest is not so much in novel language features or paradigms but in the superb engineering of the language and its implementation. Lua occupies a number of niches, including scripting, gaming, string processing, and lightweight functional programming. But its main point of interest is its seamless integration with C, and to get the full benefit, you should bind a C library into Lua.
The HOPL-III web site also contains an excellent talk and paper about Lua.
Both Common Lisp and Ocaml are certainly useful to learn. If you already know Haskell, CL might be the more different experience.
SBCL and Clozure CL are both very useful implementations of Common Lisp on Linux. (Overview about various implementations: Common Lisp survey.)
As a starting point I would recommend to use Peter Seibel's excellent book Practical Common Lisp, that is both available online and printed.
Community pointers are here: CLIKI.
Prolog may be what you are looking for.
Edit
The first commenter is right, my answer was pretty short and not very useful, so:
My preferred implementation is SWI-Prolog. I personally learned from Prolog Programming for Artificial Intelligence. It's style is pretty clear and it contains many examples, but I don't own any other book on logic programming (it's a shame, really :) so I have no basis for comparison.
Erlang is pretty interesting to learn because of its super efficient concurrency model, and the ease with which you can write distributed systems (for an example of this, CouchDB was written in Erlang). It's a dynamically typed functional language, but you can also write code in a procedural fashion. The tutorial I learned it with is called "Getting Started with Erlang", which covers just about every part of the language.
If you want to make use of your Java and functional programming knowledge, and you want to learn a Lisp, then try Clojure.
The implementation is free and cross-platform including Linux, because it runs on the JVM. Being a Lisp, it's different enough (in useful and wonderful ways) from most other languages to make things interesting. Some features such as immutable data structures, multimethods, metadata support, focus on safe concurrency, etc. are fairly novel compared to the languages you listed. Clojure is geared heavily toward being a practical and useful language rather than an academic one. It's a functional language but not "pure", which is arguably a good thing. You can also trivially make use of any Java library from within Clojure.
Clojure is a new language, so the only book out so far is Programming Clojure, but it's a pretty good one. There's also a wiki which may not be entirely up-to-date, because the language is still evolving very quickly. The mailing list and IRC channel are very friendly, welcoming places to ask questions. The official website is also a good resource, of course.
I'm going to recommend something that I haven't yet tried, but plan to, so you have to judge for yourself this one. There's this language, called IO, which is particular in that its prototype-based, like JavaScript, but also borrows concepts from many other languages. Its job market it's probably nonexistent, but I thought I mention this language.
Otherwise, a language from the Lisp family may be pretty different from what you already know. In that regard I'd recommend Scheme, which is, in my opinion, more elegant than Common Lisp. The new concept that you might found interesting in Scheme is continuations.
If you take the Scheme path, make some time to watch these videos from 1986. They're amazing.
Have a look at Smalltalk ! Either Cincom VWST or Smalltalk/X - dont bother with Squeak as the interface is terrible). VAST is good also but really only Windows centric. And dont bother about the sceptics that pore scorn on Smalltalk -- they arent using it and are stuck in the morass of edit-run-debug cycle languages and multiple dispirt linked libraries. :-)
Why these Smalltalks - well, they come complete wth excellent IDE, GUI tools builtin, best debugger you will ever see, online help, and is totally independent of the underlying OS. Eg a ST/X programming running under Linux can be transfered ( source code) to Windows ST/X and it should execute.
ST/X is free with only a very minor licience restrictions, Cincom offer a free NC ( Not Commercial ) version that is NOT restricted. I use ST/X as I prefer the default look & feel
it offers. Their IDE interfaces are very similar.
Languages without a IDE & GUI tools are just wasting your time as the world is really GUI, no matter how terrific the underlying language is. Eg Ruby is great, but with no IDE or easy GUI tools its really frustrating.
Smalltalk is not easy to get into, and its not perfect,(what language is?) but very satisfying to learn & use. And now that the hardware and operating systems have finally caught up with Smalltalks needs . very efficient.
I second Rainer's Common Lisp recommendation.
CL has all the things you're looking for and will provide a genuinely novel experience that will also make your coding efforts and approaches in other languages better.
But bring patience and persistence, you will have to grasp a lot of concepts that will seem alien at first.
You could try Tcl. It was sufficiently different to provoke an adverse reaction in my brain, so I can't really tell you how I found it different, but there's been a lot of good stuff written in it (maybe less nowadays than earlier).
C# has a free implementation in Linux under the Mono project, and it arguably is a very marketable skill unless you're completely anti-Microsoft.
My favorite C# book is Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition.
If you're really want exotic, F# is an OCaml style language that runs on the .NET platform and mono, and is getting a lot of attention these days.
http://msdn.microsoft.com/en-us/fsharp/default.aspx
Books for F#:
http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Daps&field-keywords=f%23
Of the suggestions I've seen so far, I like Lisp (see Secko) and Smalltalk (see brett), as both will give you another view of languages. Prolog even more so.
Another language that is different is Erlang -- I haven't had a chance to learn it yet, but it handles concurrency in a different way. The best link I can give you is the main website.
In terms of recommendations, Lisp is good both because it is currently used and because it is very old. The others you will have to look at sources and see which one appeals the most.
Try FORTRAN, then? I hear it's still actively used by the scientific and mathemematical communities, plus it should be dissimilar enough to be a learning challenge.
Compilers:
http://gcc.gnu.org/wiki/GFortranBinaries
http://www.g95.org/
http://www.fortran.com/compilers.html
http://www.thefreecountry.com/compilers/fortran.shtml
IDEs:
http://www.eclipse.org/photran/
http://force.lepsch.com/ (FORTRAN 77 only)
Tutorials:
Introduction to Modern FORTRAN: http://www-uxsup.csx.cam.ac.uk/courses/Fortran/
FORTRAN 90 Tutorial: http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/fortran.html
You could also learn Visual Basic.NET, in case you ever get forced to maintain that. Evidently mono has a working Linux implementation of it:
http://www.mono-project.com/Visual_Basic
Factor is pretty radically different from everything you said you know, and also everything else listed. It's stack-based, like Forth, but has a fairly comprehensive library and a lot of interesting features.
Ada is very practical -- there's a compiler based on gcc -- but also quite different from the other imperative languages you know. I find the type system a bit stifling, but it was worth learning something about.
Lisp is a great HLL, it has everything that other languages lack. In my opinion, this is a very good language that can "satisfy" any programmers needs.
Perl is also a HLL like Lisp, it's interesting and fun at the same time. It derives from C so you can pick it up as you go. It can be hard sometimes and some people tend to get lost while learning, but it's worth knowing.
Both languages are free of use and come with Linux.
Links
Lisp:
If Lisp is so great,
An Introduction and Tutorial for Common Lisp
Perl:
PERL -- Practical Extraction and Report Language
Books
On Lisp - Great book by Paul Graham on the Lisp language. It's free and you can download it here.
Scala has been very good for making me see programming in a new light. I haven't used it for anything worklike yet, but it's still affected how I write code in other languages - not just Java, but PHP. I recently wrote a simple parser for a WordPress plugin, and the code is vastly more functional and immutable than it would have been six months ago, and better for it, despite the lack of enforcement in PHP.
The only other language to have affected the way I work so dramatically is Perl, nearly a decade earlier. Perl has contributed a lot to the way I pseudo-code, even if I never touch the language itself.
Many people compare the functional aspects of Scala to Haskell. You may even imagine that knowing Haskell means you already know all Scala could teach you, but I don't believe that. The way Scala combines OO and function has a way of making it seem like that's actually the truest form of both of them.
Like you, I have over a dozen languages under my belt. While shopping for something to play with for writing a cross-compiler, I ran across ML and family. Many very good ideas there, and they have taught me to write code is a much different way; for example, my JavaScript now has a decidedly functional bent.
After toying with OCaml under Windows a while (and getting frustrated with stability issues), I ran across F#, an offspring of OCaml. The two are quite similar (can cross-compile a lot of code), but OCaml apparently has a really good macro system (P4) and type-classes (in support of writing "strongly typed" operators against generic types), while F# has excellent support for asynchronous and parallel operations, monads, units-of-measure for numeric types, as well as cleaner OO syntax and awesome IDE integration (VS2008 & will be released in-the-box with VS2010). I much prefer F# these days, since I have access to the whole .NET runtime and loads of 3rd party libraries. In fact, I write most of my one-off and utility code in F# now; for me, its generally much more productive than C++, JavaScript, C#, PowerShell, or anything else.
F# works fairly well under Mono on Linux, and has a good following there. The compiler and runtime will be open sourced once stable (released with VS2010), and the developers consider Mono support enough of a priority for it to be seriously considered for non-Microsoft use.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I have read numerous time that learning a language such as Haskell, Lisp or Smalltalk will somehow make you a better programmer while you program in other languages.
Is there more than just anecdotal evidence for that claim?
Or is it just the way people rationalize having spend a lot of time learning a programming language that they will never use?
IMHO, it is all about learning a new programming paradigm. If you know Java and then C#, there's not much gain, once both of them have almost the same "type of programming".
But if you get to learn a functional language or dynamic, for instance, you're forced to think another way, and that will probably help you to program better in your favorite language.
It is something like: "It is so easy doing this in {different language you learned}. There must be a better way to do this in {language you already know}". And then you rethink, and build up a more elegant way to do this in {language you already know}.
I don't have any hard evidence, but I have really appreciated the different way of looking at problems that I have since learning lisp (the same goes for python and c).
The key isn't necessarily learning different languages though, I believe that the key is actually the different viewpoints that you gain by learning different programming styles.
Good examples are functional, imperative, object-oriented, etc. Also, there are common design differences is interpreted vs compiled languages; static vs dynamic typing, etc.
Although most people do a majority of their programming using a single style (most commonly OOP over the past few years), I think that all programmers should know multiple styles so that they are better able to see the shortfalls of their own style.
Can't shed much light on this in terms of programming languages, but it seems very similar to the "why learn a dead language?" argument that surrounds Latin, and much of the reasoning there can be applied here.
Programming is a way of thinking, not writing code in programming language X: that is "coding", not "programming".
By knowing at least something about more than just one programming language - preferably across different paradigms, so imperative/OOP/functional/logical - you train that way of thinking about problems outside the context of the specific details and quirks of language X.
I think this always improves your abilities to be(come) a better programmer tremendously.
A great side-effect of learning new languages is the potential for application in your existing language.
For instance, I'm a Java programmer and I took the time to learn my first functional language (Haskell). I was recently asked to learn Scala for an upcoming project. This is extremely easy since I understand the comcepts of guards, recursion, etc. from Haskell.
Deeply learning language just for learning language has too little benefits. If you have a lot of tasks and you don't know language that ideal for solving it then it is make sense to learn that language. Otherwise it is make sense to spend the time to become expert in languages you already know.
I don't know that there will have been much rigorous study regarding the benefits of multi-programming language exposure on overall programming ability, but I would argue that the studies regarding why learning a foreign human language (which you may never use in practice) is beneficial would in general hold equally well for studying foreign programming languages. The benefits ascribed often include improved cognitive abilities as well as improved understanding of one's native language.
here's some links to studies
anecdotally, I complained a great deal about taking COBOL, and have never really used it but was able to apply things I learned in that class at my first job.
If you give any credence to the Pragmatic Programming guys, consider their advice from page 14 of their first book:
Learn at least one new language every year. Different languages
solve the same problems in different ways. By learning several
different approaches, you can help broaden your thinking and avoid
getting stuck in a rut.
Some examples that come to mind:
Knowing C and having to deal with memory management and do-it-yourself data structures can help you understand performance issues when programming in a higher level language where those details are hidden from you.
Conversely, learning an OO language can affect your C programming - with, for example, the concept of Polymorphism prompting you to use function pointers in ways you might not have otherwise.
Learning a language where functions are first class objects that can be passed around can make you think of similar techniques in other languages, even if, in those other languages, you have to make the functions methods in objects that get passed around.
Learning about the way Erlang handles concurrency can make you rethink how much shared state you use between threads in other languages.
Any language that has a built-in feature you find useful can prompt you to implement your own version of that feature in another language that doesn't have it, and thus allow you to solve problems in ways you might not have thought of if you hadn't been exposed to the feature in the language that has it built-in.
Learning about Interfaces in Java can make you think about the benefits of precisely specifying your (small "i") interfaces in other languages that don't have them as a formal construct in a type system.
No doubt there are others.
Learning a language is not a binary event. If you are a decent programmer, you should be able to trust your own instincts as to whether a language offers you a new take on your craft.
Virtually every language worth considering these days can be downloaded and test-driven in a couple of minutes. So do it -- pick one and try it out.
There are a limited number of cases where this "laissez-faire" approach falls short. If you're a complete beginner, of course it doesn't work. When I first learned C, I had to have it beaten into me, but it did turn out to be worth it because it made me understand pointers, memory reference and dynamic allocation in a way I hadn't previously.
But if you know that much already, just poke around and look for a language that makes your lightbulb go on.
Different languages have different ways of implementing the same ideas. By learning new languages, you get a different perspective on how things can be accomplished, and can then use that knowledge to approach how you program in your current environment. Think about object oriented and functional programming. OO Programmers can learn a lot about parrellization from languages like C.
Learning a language, especially one that practices a new paradigm, is very beneficial for every programmer. For example learning Scheme will help someone understand functional programming. The programmer can later practice what he/she learned with other languages like C#. She can think of new ways of doing things.
Also, as languages evolve, it's high likely that the language you use will adopt some features of other languages. Having taught myself Ruby, I was able to grasp the changes in C# 3.0 much easier.
I think learning languages will always benefit you even if you don't use them again. I started playing with Ioke as an attempt to learn something experimental and because of it my JavaScript has improved because certain ideas have been cemented.
learning a new language will possibly give you new insights that you will try translate to your main language.
I don't think there will be any hard evidence--I think this is more of an intuitive thing. Learning a totally different language will help you look at things totally different. Or maybe it won't. In any case, what's the harm in learning something?
It's entirely subjective, but way back when, after taking an undergraduate course in Haskell, I did notice that my programming style in C became more 'Haskell-like' for a while; I used a lot of simple, recursive functions. I also noticed that this programming style seemed to yield some of the same benefits programming in Haskell had; bugs were fewer, code was easier to understand (albeit slower).
So, while learning another programming language may not make everyone a better programmer, it definitely was a learning experience for me, personally.
What are the benefits of learning mathematics or physics that you won't use, or the benefits of studying philosophy or dead tongues?
It's the intellectual achievement and the enlightenment what matters, you will be a wiser person with any new thing that you learn, no matter if they are programming languages, literature, role playing games... of course if it's related to your working field, then you'll actually find a use, sooner or later :-)
I spent some time studying clojure even though I knew I wouldn't use it in the near-term (mostly because I can't really deploy on the JVM).
It has concepts that aren't supported by the languages I use (C#/C/C++/Python/Perl) and I wanted to know what I was missing and also if it would be worth looking into libraries that purport to add these features.
Specifically, I'm very interested in understanding Lisp-style macros and the direct concurrency support. I also spent some time reading the implementation, specifically the datastructures, which was very educational -- good to see a quality implementation of persistent datastructures to learn how they work (and give you immutability without sacrificing much performance).
Bryond what has already been said, I really like new languages just because it can bring new interest to programming. You learn different ways to approach problems and the strengths/weaknesses of certain languages. It is something new to learn and any good programmer should be striving to always be learning new things. It mixes up your daily routine of possibly programming in the same language for years.
I also like what everyone has said about programming perspective.
Some good points have been made.
I would add that learning languages you won't use in production work can be of value
To better appreciate and absorb the arguments and methods in texts and papers that will improve programming ability in languages I do use for production work (e.g. MIX/MMIX for Knuth's Art of Computer Programming; RATFOR for Kernighan and Plauger's Software Tools; I still use some ALGOL-based syntax for some pseudocode although I never wrote runnable code in ALGOL outside University)
To be able to check or prototype programs that will be written in a different language (e.g. some routines for numerical computing in C can be quickly checked or scaled using languages that have appropriate functionality built in such as Fortran, Python or Haskell)
Learning a new language can give insight as to how it could be used to more easily solve problems that were put to one side because of time or complexity constraints.