I am C++ developer with some good experience on it. When I try to learn a new language ( have tried Java, C#, python, perl till now) I usually pickup a book and try to read it. But the problem with this is that these books typically start with some very basic programming concepts such as loops, operators etc and it starts to get very boring soon. Also, I feel I would get only theoeritcal knowledge without any practical knowledge on writing the code. So my question is how do you tacke these situations? do you just skip the chapters if its explaining something basic? also, do you have some standard set of programs that you will try to write in every new programming language you try to learn?
Basically by writing code in that language.
You need to have a good example application to study/modify otherwise you're starting off on the wrong foot and you might never recover. Years ago we decided to use Ada for our next product, but as we all used FORTRAN in the previous product we ended up creating FORTRAN constructs in Ada. We never really recovered from that.
Having access to the documentation and Stack Overflow is essential otherwise you'll potentially miss the important features of the language. On that score find out who are the Gurus in the language and read their blogs, these will often discuss the new features of a language/framework and also the obscurer areas you'll never find by yourself. If you can't find out who they are ask here!
In an ideal world I'd like to learn by myself for a while and then be evaluated, but I've never managed that yet.
Don't try to read your programming books from front to back in a single or few sittings. I usually pick up a book and read a little at a time, usually not more than 10 pages, and for particularly dense books, just a couple pages. For 'soft' books, I may read significantly more, but I try to avoid them in the first place.
If, as in your case, you can already code in a similar language, start with a simple console app or something and do little exercises like
- Read/Write something from/to a file
- A little to-do list console app
- Test all the language features as you read about them
- and on and on
I haven't yet found a book that helped me much in learning a new language. Kent Beck's "Smalltalk Best Practice Patterns" comes close, but I could already muddle my way through writing something (in Smalltalk, I mean) by the time I read it.
The first rule is JFDI. Think of some application, toy, problem, whatever - something manageable, of course, and so reasonably simple/small - and try write it. You'll constantly run into "but how do I... ?" questions, which I at least find to be the best way of learning anything.
So then how do you answer those questions? Go lurk in that language's community. Read their documentation. Read the backlogs for their mailing lists. Chat on their IRC channels. You'll soon figure out who the alphas are. Read their blogs. Pay attention to what the experienced practitioners say, and be prepared to be wrong.
Get a broad overview of the language by reading the complete manual; seems tedious, but will give you a sweeping view of the language, even if you do not understand most of the part. This advice is in contract to what 'BioBuckyBall' says above, but if the language manual is small you can easily complete the book in a couple of days.The main point is to "get" the gist of the language; at some point in reading, the whole concept of the language just "clicks"!
Next create a small project in the language in the domain you love. Initially do not try to dig deeper into the details. Usually if I'm learning a new language I try to create some functions or classes related to Statistics: like Standard Deviation and averages. This quickly gets me into arrays, iterations and data types. When learning a different language, again try these same examples, which will allow you to compare the syntax and semantics of the different languages on the same problem domain.
I like to first learn about the language fundamentals like the type system etc to get a feeling how things work as well as to see some basic example on how the code looks like. My preferred way of doing this is reading a book and I mean a real book that I can read while lying in the bed or wherever I want. The basics should be explained in maximum of 100 pages, preferably in much less. If no book is available, I try to find the information from the internet.
Reading the whole book is obviously a waste of time, because you are not going to understand the more advanced topics without any hands-on experience. At work there's usually already some code to work with so in that case I just start working on the task at hand. I learn little by little by reading what others have done and if I run into a problem, I try to google for the answer or that failing, ask from a coworker. After I have been working on a while, I try to finish the book.
If I have to start from scratch, I start by hello world, then try input from keyboard and file handling. Depending on the language, I might do some UI exercise. After that I would start programming the "real" program.
Bruce Eckel's "Thinking in ..." books are quite good for if you're switching between C++/C#/Java...
Python and Perl tends to be less related so it's more advised to start from the basics there,
or you will have to find a tutorial that's explicitly based on the assumption that you know how to program.
There is one book I really enjoy. It is called "Seven languages in Seven Weeks", and aims to teach you... seven languages in seven weeks.
It is a fun way of looking at very different languages, and the strengths and weaknesses of each of them. For each language, the book deals with a non-trivial problem.
Of course, the book is not a deep reference for either of the languages, but does show the essentials of them.
The languages covered are Ruby, Io, Prolog, Scala, Erlang, Clojure and Haskell.
My approach is simply start writing in selected language, find pet project and do it. Read lots of samples, check others code, go through one bigger project source, find what you don't understand and read it up in the docs. Currently learning F# and bought the book - Expert F# - I find it incredibly difficult to focus and read through all of it without having to use it. But here's not only a new language, that's the whole paradigm shift from imperative to functional.
You have many ways to learn a new programming language. I'd go with this method:
- Choose the programming language you want to learn first
- Read Books about it and watch good online tutorials
- Connect to an online open source code repository and download some projects
- Use the books and your brain to connect the dots with the "real life" code from the code repository
That way you'll learn the language itself and get to see how it is used in "real life".
Most important: Don't try to learn more than ONE language at the time. You'll screw it up.