You frequently hear you should learn a new language every year or so, or have a variety of languages at your arsenal to use in different situations, but won't that make you a jack of all trades and master of none?
I try to learn a new language every 2 years and learn the basic principles of at least 3-4 each year. I still have 1 or 2 languages I do almost all my work in, but knowing other languages has made me much better in those 1 or 2. You learn new idioms, new ways of thinking etc.
Most programmers come from an imperative background. Something in the Algol family. Learning a scheme/lisp, a functional language like Haskell, a stack based on like Factor or any of the numerous other types of languages is only going to make you a better programmer.
Think type languages are awful? Maybe its just the type systems you've encountered ( see haskell for a type system that I would call non-broken ).
Think OOP languages are garbage? Maybe encountering something like Self will give you a different view of OO than what you get from C++ or Java. Maybe encountering CLOS will open your eyes to a different way of doing OOP.
Another bonus via anecdote:
I don't use Ruby anymore, but I still follow the community because people are doing interesting things, things I might want to steal an idea from and use in my language(s) of choice.
You're not trying to be the master of a programming language. You're trying to make solutions happen in the best, quickest way possible.
Seriously. I could care less the order of constructor evaluation in a multiple inheritance language. If that becomes a problem, I'll look it up.
This isn't like school where you try to pick one subject and become the complete overlord of it. This is about building a toolbox: learning how different tools work and being able to switch instantly between them when the time is right. The meta knowledge of languages is infinitely more important than the abstract details of a particular one. If you're a good programmer, you'll naturally optimize the code you write.
Thinking about writing a solution in an imperative language is fundamentally different than thinking about one in a functional language. Thinking about a web solution in terms of Javascript/client-side/jsonp is fundamentally different than in terms of client-server, or in terms of post-response. It's the thinking about those problems, before you start hacking, that gets you the most mileage. And the best way to learn how to think using those paradigms is to write solutions using them.
You don't use the new language exclusivity, it's just an extra tool in your toolbox. You just use it to expand your horizons. Knowing even a little Haskell will show you that a little type inference can go a long way. Or that reasoning about correctness is easier in a purely functional language.
I think the primary advantage of knowing many languages is knowing when you're using the wrong tool for the job.
One new language per year is too fast a rate. And it's really about learning new perspectives, not so much about the language themselves.
It would probably make you a better programmer to master all of purely functional programming, syntaxic abstraction, pattern-matching and logical inference, distributed and fault-tolerant computation by message-passing, stack-oriented programming, etc.
It just happens that some languages are predominantly based on each of those principles so the act of learning those languages in depth make you master those useful principles for free.
Haskell = Purely functional programming
Lisp = Syntaxic abstraction
Prolog = Pattern-matching and logical inference
Erlang = Distributed and fault-tolerant computation by message-passing
Forth = Stack-oriented programming
(completely unexhaustive list of language/specialty mappings)
There's a difference between learning a language and mastering it.
Every little bit helps. Read one book and you've learned a new point of view. Read that book and build a sample project and you've learned more. To really understand a language or framework requires still more work. To master it might take years.
You should master one or two things (or more, if there are enough hours in the day or if you are superhumanly good at mastering languages). But that doesn't mean that you shouldn't also have lower levels of expertise in a broad range of other subjects. Half the battle in life is knowing what to master at any given moment, and the only way to figure that out is to sample a lot of things.
Some people have already mentioned that learning a new language often makes you a better programmer in other ones. I don't have any experience in improving skills that way (I started learning Haskell, but it's too early to see whether it's making my Erlang better or not), but what I've learned is that unwillingness to learn new languages makes you a fanboy of language(s) you already know. Being a fanboy of any language is what I'm actually afraid of (just because I know what it is to be a fanboy =)
Suppose, there is a guy (I will name him "Poluekt"), who is a master of Foo language (sounds like "a master of kung-Foo!"). Foo is a really good functional language having active community, excellent runtime and good libraries; Poluekt is good at writing in Foo but isn't brave enough to say "I'm not a Foo, I'm a programmer who wants to choose between languages when it comes to solving non-trivial problems".
What will happen with such a guy when he hear of nice features a new language (say, Bar) offers to solve problems in domain where Foo is (was?) the language of choice? Oh, it will be very offensive for our guy to hear that Bar beats Foo in some cases or even is press it. It will make Poluekt so unhappy, irritable...
Nobody knows how many Bars there will be on the Poluekt's way, but learning them seems a good way to become a good specialist.
Learning lisp or any other language in which closures are a common idiom should be a prerequisite for building anything of any size out of Javascript. An understanding of closures will aid in a big way in figuring out why your browser rapidly grows to 1 gig when running your applicatiion.
A language is a tool, not the end in itself. We need to be, or strive to be, masters of computer programming, not of computer languages.
Of course, a master knows its tools. He has many tools in his toolset and chooses the ones that better fit the task he is working at. Sometimes he may need to use a new tool, which he learns and adds to the toolset.
New languages rarely introduce substantially new concepts, mostly new ways to represent those concepts and put them together in a better way. However, if we are talking about new concepts, not just new languages, that is different. Other commenters have mentioned functional versus imperative programming style (enforced, or at least suggested, by the language) and so on. Learning new concepts makes us better programmers in older languages too.
If you mean by mastering that you never have to look at the API documentation, then more languages can have a negative impact. I'd concede that.
But that is comfortably offset by the advantages you gain from seeing through the syntax to the language concepts. It is not even the correct question to ask really. Because mastering of a language might be a secondary goal.
A more interesting question might be: do I know at all which language I should strive to master? And that will require you to look at a few.
This may be the case for natural languages, but is simply not the case with programming languages. A natural language is evolved over thousands of years and contains cultural nuances and hundreds of thousands of words in the vocabulary. A programming language is engineered to be simple and concise, containing a grammar that can fit in a few pages of BNF and at most a few hundred words in the vocabulary.
It's probably worth mentioning that the reality is that not every developer is of equal ability, nor has the same level of potential ability.
I've met many developers that clearly don't have the same capacity for learning and applying languages to problems as well as others. Do what works for you based on your own perceived capabilities.
I find learning each new language is easier than the one before it; the concepts of software development are largely the same from language to language and are often transferable from language to language.
Then again, I started out on C, so pretty much everything besides Haskell seems like a piece of cake.
Nonsense. Learning Python helped my JavaScript and PHP, and learning JavaScript in turn has helped my Python. Learning Erlang has helped both. PHP didn't help anything.
By making you approach the same problems in different ways, new languages make you a more versatile programmer less tied to a particular technology while improving existing skills.
Upvoted for "PHP didn't help anything". I'm pretty pragmatic about language selection (I've used Perl, Python, Tcl, C, C++, sh, and probably others over the years, and all have had their nice qualities), but I've been lightly working in PHP now for a couple of years for maintaining our company website, and I've never once thought, "Hey, that's neat! I wonder if I could do that in JavaScript/Perl/Python/Ruby."
It's a subtle but very depressing aspect of working in PHP. I just feel sad working in PHP, in a way that I've perhaps never experienced in any other language. Maybe I'm just getting too old to read more crappy code, and it would improve if I started working on better written code. And maybe I was lucky enough to mostly work with good code in the past in those other languages.
To be fair, there are some things about PHP that are surprisingly good and worth looking to for inspiration: Ease of app deployment, marketing for a "good enough" product, allowing a very large community to contribute without muddying the waters too much (comments on doc pages, for example, rather than a wiki), solving the right problems at the right time (even poorly), etc. None of these are aspects of the language itself, only the resulting full experience that is PHP.
I guess to be a master you need to focus a lot, so it takes much hard focused work. The time you spend with other languages could be used to go more deep in at just one. So the point is
HOW FREAKY ARE YOU READY BE TO GET THE POINT OF MASTERING 2 OR MORE LANGUAGES ?
Most part of programmers are good at some languages, but not masters ... being a master of one is difficult, what if master of two or three.
So the answerer is : depends of the freaky behind the try !
Most programmers come from an imperative background. Something in the Algol family. Learning a scheme/lisp, a functional language like Haskell, a stack based on like Factor or any of the numerous other types of languages is only going to make you a better programmer.
Think type languages are awful? Maybe its just the type systems you've encountered ( see haskell for a type system that I would call non-broken ).
Think OOP languages are garbage? Maybe encountering something like Self will give you a different view of OO than what you get from C++ or Java. Maybe encountering CLOS will open your eyes to a different way of doing OOP.
Another bonus via anecdote:
I don't use Ruby anymore, but I still follow the community because people are doing interesting things, things I might want to steal an idea from and use in my language(s) of choice.