Which way is more beneficial and productive?
I think you need both. You have to focus on your core competencies and improve your understanding of them, but at the same time it's beneficial to look outside and see what else is out there. Exposure to other approaches and other languages is very important to make one a better developer overall. There are many ways to skin a cat, as it were, and knowing as many of them as possible will make you
a psychopath better at picking the right tool for a particular task.
So, spend most of your time getting better at your chosen proficiency and spend some of your time on learning something new.
Someone said "A language that does not change the way you think about programming is not worth learning".
So, if you know Java, there's little gain in learning C# (or vice versa). If not for pragmatic reasons (i.e, you need it to solve a problem), i would suggest stick to one Language per Paradigma, and your schedule is still full enough ;).
Specializing, on the other hand, is in my experience mostly achieved 'in the field', i.e, when working on a project, so it comes naturally.
There are a lot of really good arguements on both sides. Many years ago I was presented with that exact question... concentrate on my primary language and be attempt to become an "expert" OR pick up a new language and broaden my marketability. I chose to concentrate on one language.
There's really not going to be a wrong answer. Both have merits, it's really going to boil down to which one fits better for you and where you want your career to go.
Learning new languages is mostly a means to get new concepts and increasing your efficiency with programming. Learning programming in itself is very different from learning a new language to program in.
You should concentrate on making your programs better (and there are a lot of metrics for measuring that, many subjective; does not matter, take your pick on the metrics and refine them over time, use them for your education).
Having said this, learning 'newer' languages (say,
Python) over your older list (like, say '
C' and many such) will help you think more efficiently and focus on those core concepts that should be made better. Taking the example further, it may not appear immediately but you might find your
C programming getting better because you have been thinking in Python. You might even start writing Python instead of psudo-code for
C. Now, that is a much more readable and verifiable psudo-code.
Which brings us to summarize on the primary question:
Yes, you should focus on languages you already know and increase your knowledge in them -- as long as they are still in use for you. And, you should also dabble in newer languages to give your brains newer tools to think (maybe even faster) solutions for your programming needs.
Learning a New Language
It depends on the purpose for which you are learning the language. If you are learning the language because it uses a different paradigm or is suited for a particular problem domain. However, if it is a language very similar to the one you already know and all you plan to do is rewrite all of your existing code in that new language, there probably isn't that much value (for instance, rewriting a python webapp in ruby) in it.
Deeper Knowledge in Current Language
If you already feel very comfortable programming in a language, are familiar with all its idioms, and can write programs in it without having to look in the documentation for every single library call, there probably isn't much more to learn about it. If, on the other hand, your knowledge of the language is not that deep, there may be some value in learning more. Some good ways of gauging whether you are in the former or latter camp for language X are
- How many programs have you written in language X?
- If you go on Stack Overflow and look at the questions tagged X, how many of them would you feel comfortable giving an answer to?
- Do people come to you for help with language X?
If your answers to these questions are somewhere along the lines of "a lot", "most of them", and "yes, and it's getting annoying", it's a good indication that you've mastered the language and should move on to something new.
If you are already good enough with the language you are familiar, there's no good to learn very detailed, specific tricks for a little cool... it'll be totally a waste of time. However when you're quite uncomfortable with a language the suggestion is to master that language first.
Besides languages there's frameworks, patterns... to learn a framework you must know a language, so for very similar languages learning them helps nothing than bring some not so funny fun.
My personal opinion is you should always develop your capabilities to make faster, securer, more robust software, for more platforms, and make the time taken shorter, for that aim you may need to learn a new language, a new framework, a new IDE (that's just as important as a language), and only when you are for that purpose your investment is worthwhile.
At least don't learn a new language to increase the number of languages you know.