views:

316

answers:

13

I have just started learning Java (referring Head-First book).

I just wanted to know what's the best way of learning any language?

How to get most out of the book?

Should one have to study the book's matter and then try that code later on computer or do that simultaneously? (learning concept and try that on the computer at the same moment)

In my case I am referring the book and taking help of the forums. Also I want to know when to start answering here on Stack Overflow :) Since I am new to the language so I don't know much.

(I just read other's answers here regularly)

A: 

When I want to learn a language, I set myself a difficult task, like Huffman Coding, or Facebook Puzzles, and start punching away at it with the help of this site.

You might want to use a book to get the basics of the language, though...

piggles
+7  A: 

The "best" way depends on you - my own approach can be summarised as:

  • read a book
  • write some code
  • repeat

but some people don't learn well that way, and prefer something more formal, like going on a training course, something I can't sit still for, though as an ex-instructor I used to be glad that many people feel otherwise.

anon
A: 

I have gotten into new languages by coming up with a project. Maybe something you have already done in another language or something you would find useful(like a programming tool). Then try to write it in the language you wish to learn, at first using just what you understand about the language and can glean from books and websites. As you get the project to completion start asking in the community for someone to look at your code and ask questions for what appear to be problem areas.

It is important to realize that a language is usually very general while a problem will give it context. For instance I may know how to develop Java applications, but that does not mean I know how to develop J2EE applications. Same language, different context; so you may wish to think about that while coming up with the learning project or projects.

I also highly recommend building the project with very heavy unit testing. Writing unit tests is going to give you a solid set of tools that they will not be showing you in the books, your code will improve and more importantly any unexpected language idioms will stick out like a ... well like a failed test.

Gabriel
+1  A: 

This is a duplicate, as I remember answering this not that long ago, but for me it depends on the language and whether I need to learn just the languages or completely new ideas as well.

With a language like Haskell, which I considered hard given that it was quite different to what I was used to, I started with book learning. Practical experience is however essential, but rather than trying anything ambitious from scratch, I concentrate on small modifications to existing code.

With easier languages like Ruby, or indeed Java, I may do a tutorial, then I would try and write an app from scratch. When I come up against any walls, I just surf around for answers, or ask here, and the learning comes with experience.

Actually doing stuff is the key regardless.

Kurt
A: 

The most important thing for me is always to find something I really want to do with the new language I intent to learn. Otherwise its difficult to be really motivated. But once I have an idea for something I go read tutorials and articles on the language and start building my project learning as I go.

I used to read many books but today with stackoverflow and the tutorials everywhere I find my self needing them less and less.

Iznogood
A: 

I usually google for the best book possible (a one with most recommendations) and I scan through it very fast, just to get the general idea of the language, good practices etc. Then I either think off or google a program which would be able to cover everything you can possibly do with that language (well OK not everyting, but as much as possible). Like when I was learning JEE (JSP, Servlets, JPA) I decided to write a simple hangman game, first I'd do the basics, then I would add the database etcetc. - first I did a very basic program, then I added more and more. Of course I while writing it I would always google for good practices, because you can code something and it will work, but it might be hell to maintain it in the future etc.

I think that writing stuff in a language you're learning is the most efficient way if you execute it right.

Zenzen
+1  A: 

I usually first read the books and do the exercises after each chapter, trying to understand the basic concepts and be familiar with its features

ladyfafa
A: 

I personally still have a copy of the NetflixPrize dataset that I write algorithms in said language to solve or just goof off with it, in general. Unfortunately, the dataset is no longer publicly available (at least officially from Netflix themselves).

Regardless, find a fun project that you have a good idea what you need to do to complete it and solve, and then learn that language and platforms facilities and best practices for solving it. Once you've gotten your feet wet, then branch out and start new projects with the language/platform you are learning.

whaley
+2  A: 

I've done something interesting and tried to rewrite my IRC bot in the new language. This allows me to learn several things including

  • Using whatever GUI framework the language uses
  • Using things like sockets, streams, etc
  • Synchronization
  • OOP style (if the language is OOP)
  • Multithreading
  • Do things dynamically (for plugins)
  • If I'm doing it correctly when I solicit a code review.
  • How to use other frameworks

In java, this is pretty much the extent of any SE desktop application. In PHP (yes, I did this in some awful looking PHP that I abandoned), I learned many interesting things, mainly that PHP was not made to do that.

Using this can give you great insight into the many features of the language. It can also be fun sometimes.

TheLQ
A: 

For me: I learn a language by just starting a project. I learned C#.NET this summer by starting a web project on C#. When I get stuck on something, I either google it or just benefit from stackoverflow!! If you don't feel confident: start a mini project with Java and see how it goes!

Saher
A: 

If you're in the very early stages of learning to program, then I think it's more didactic to play with what you've learned as you go through the book. Don't wait until you finish reading it to get some practice. You can understand the knowledge, but being able to apply it adequately takes a lot of practice. And it's easy to forget what you learned a week ago, if you don't exercise it.

So what I usually do when I'm learning a new language, is to try to solve some problems with it. That helps me a lot to evaluate how far my understanding of the language is, and also helps me discover the in-depths of the language. Examples of problems I try to solve when I'm learning a new language:

Pedro Rodrigues
A: 

If you never had any experience programming, I don't think it's a good idea to start a project where you'll find yourself getting stuck most of the times and requiring the assistance of google or stackoverflow.

Rather, get a book, go through each example, try some end of chapter questions, type the code from the examples and think of creative ways to modify the program according to your needs. You can also supplement your learning by watching the video lectures provided by Stanford's Engineering Everywhere or MIT's OCW. In your case, Stanford's first free video lecture series starts with Java, goes on to C++, then deeper to MIPS and some scripting languages.

Check it out: http://see.stanford.edu/see/courseinfo.aspx?coll=824a47e1-135f-4508-a5aa-866adcae1111

As far as start answering beginning questions, you can always say what are your favorite TAGS and set it to "beginner" so that StackOverflow will show more "beginner" questions.

chiurox
Thanks chiurox :)
Chankey Pathak
A: 

I often do followings:

  • read book that talks about same thing (ex Java intro, Java for beginner, Java head-first etc)

The reason is they talk about same thing but use different examples and different coding style sometimes so it helps me understand the varieties of way of coding. Also often one example is not really enough to fully understand what's really going on when you get stuck.

  • read codes that other people write.

Go online and search for the code you looking for, they write in different way and you will find which approach has what pros and cons.

  • join forums and get involved in discussion.

Make sure to spend sometime before you post questions. People don't like easy solution seeker. I usually spend couple hours searching for answers and if I can't figure out, then start asking online with as much detail as possible so I get the precise answers.

masato-san