Slashdot Mirror


Head First Java

honestpuck writes "Earlier this year I decided to learn Java. I'd spent some time using JavaScript without really getting my hands too dirty but I'd pushed it way to far and realized I needed a bigger hammer. Grabbing a copy of Learning Java, 2nd Edition from O'Reilly I started learning. First problem, I have to admit I've stayed away from object-oriented programming; after all, I've been writing software for nigh on twenty years without it - why make life hard? Sure, I understood the concepts and I'd done a little but never in a language so strongly committed to OO as Java." Read on for honestpuck's review of Head First Java, which he compares in style and content to Learning Java. Head First Java author Bert Bates, Kathy sierra pages 650 publisher O'Reilly rating 8 reviewer Tony Williams ISBN 0596004656 summary Good, offbeat Java tutorial with new approach to learning computer topics

The Good

Of course, you can't learn Java without a good understanding of object-oriented languages. I made fairly heavy going with 'Learning Java' until I decided to dive in head first. Head First Java, that is -- a new book from O'Reilly that has a totally different attitude to teaching than I've seen before in computer books. It also looks like this might be the start of a series from O'Reilly, the website an introduction seem to assume that there will be more 'Head First' titles and I hope so. The style is humorous, full of graphics, cartoons, puzzles, quizzes and crosswords. It reminds me of the textbooks that used to try and teach me geometry and algebra in high school or my daughter's elementary books on Roman and Greek history I purchased for her at the British Museum. The style didn't work to teach me much algebra and geometry, but I wasn't anywhere near as motivated. This time, it worked. In a couple of weeks I worked through the book and finally have Java skills where I can branch off and start coding the projects I had in mind (though something more advanced will be required soon.)

In the introduction the authors examine learning and explain why they designed the book as they did. To quote from one section: "Some of the Head First learning principles. Make it visual. Put the words within or near the graphics. Use a conversational and personalized style. Get the learner to think more deeply. Get -- and keep -- the reader's attention. Touch their emotions." They argue that our brain is tuned to novelty, and that their style provides the novelty to keep your brain turned on. They also provide ten tips for good learning. That's one thing that seems to set this book apart from most other computer books, they say they think of their reader as a learner and indeed that's the way you are treated by the book. You can start to get a feel for their ideas by visiting headfirst.oreilly.com, a site devoted to the series. You can also grab a couple of example chapters from the books web page, which also has the usual marketing info, table of contents and errata.

The Bad

When compared to Learning Java the coverage is not as good. Head First really only covers the basics, up to and including creating a GUI with SWING and then touches a number of others; Learning Java goes on to explore, with a fair depth, network programming, web programming, servlets, applets, Java Beans, XML and other topics that are only touched on briefly in Head First. If the style of learning does not suit you then this will be an incredibly irritating and useless book, I'd give it a try first, though. If it isn't for you then the style of Learning Java might be better.

Conclusion

When you get down to it, though, the only way to really decide on the worth of a tutorial is to decide how well it teaches. Head First Java excels at teaching. OK, I thought it was silly, I had a hard time making myself do the exercises, fill out the crosswords and solve the puzzles. Then I realized that I was thoroughly learning the topics as I went through the book. Learning Java was doing the same job, but the dry traditional method wasn't doing as well. Both books are well written, designed and constructed -- the style of Headfirst Java just made learning, well, easier.

It would seem to me that the 'Head First' approach is going to work wonderfully for the more 'beginner' topics, books for introducing you to a new style of programming, a new language or a radically different operating system or application. So if you're looking for a book to introduce you to Java then I can recommend Head First Java. Now if I could only find a book as good to introduce me to Common Lisp.

You can purchase Head First Java from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

26 of 327 comments (clear)

  1. Misconception by shaldannon · · Score: 2, Informative

    It appears our reviewer has fallen under a common misconception.

    Java != JavaScript

    The two are not even related. Yes, you can use them together, but the only thing they have in common are the four letters "J-a-v-a". It's bad enough when normal people fall under this misconception. We don't need supposedly technically savvy people succumbing to the same thing.

    JavaScript was developed by Netscape as a dynamic browser language, and "extended" by Microsoft. The W3C "standardized" it, and then both Netscape and Microsoft went about with their own proprietary versions.

    Java is owned by Sun Microsystems and was originally an embedded systems language. Sun took the language, renamed it "Java", and added web functionality.

    --


    What is your Slash Rating?
    1. Re:Misconception by M-2 · · Score: 4, Informative

      The current W3C approved release of it is, I believe, currently referred to as ECMAScript, in an attempt to separate the two. (The ECMA is a European governing body on standards, and I do not recall what it stands for at this time).

      I wouldn't mind seeing them separated like that - it would make more sense and minimize confusion, as well as the interleaving of books in bookstores. "Java... Javascript... hell, they must be the same thing!"

    2. Re:Misconception by Ranx · · Score: 2, Informative

      The W3C "standardized" it, and then both Netscape and Microsoft went about with their own proprietary versions.

      The W3C has not much to do with JavaScript.

      ECMA is the organization who made JavaScript into an independent standard (ECMAScript).

      --

      Me
    3. Re:Misconception by haystor · · Score: 2, Informative

      If you people would actually read the review its quite clear that he had outgrown JavaScript and was moving on to Java (Java being a bigger hammer than JavaScript).

      He also never staid that JavaScript has not object system, just that he's never done much with objects. Thus he needed a good basis in how to programm OO, something you don't have to have to use JavaScript.

      --
      t
  2. Don't know about Head First Java, but ... by UTaimSRC · · Score: 3, Informative

    The Java Cookbook is the way to go for beginners.

    http://www.oreilly.com/catalog/javacook/

    1. Re:Don't know about Head First Java, but ... by BFKrew · · Score: 3, Informative

      The Cookbook is a great little book, but it only really provides snippets of code and little examples of how to achieve basic tasks. It does not teach you about Java, about OOP, how to build programs or anything about the differences in things like Applications, Applets or Server Applications etc.

  3. Get the Tremendous books Free by MarkWPiper · · Score: 2, Informative
    I agree, Thinking in Java is a great book. Check it, and Bruce Eckel's other works out for free at:

    mindview.net/Books

    You'll be glad you did!

  4. Try Thinking in Java 3rd Edition by nih · · Score: 4, Informative

    best book on java imo, and its free to try out
    http://mindview.net/Books/DownloadSites

    --
    I'm a rabbit startled by the headlights of life :(
  5. Re:EWD 696 by pheared · · Score: 2, Informative

    http://www.cs.utexas.edu/users/EWD/ewd06xx/EWD696. PDF

  6. OOP for the procedural programmer by djrisk · · Score: 4, Informative
    I too had some problems w/understanding object-oriented programming. I was strong w/procedural languages, and your standard top-down programming style, but I struggled grasping the concepts of OOP.

    I found "The Object-Oriented Thought Process" to be a great jumping-off point in helping me familiarize myself with how to think in-terms of OOP.

    The intro to OOP chapters that are in most introductory books are OK, but they just didn't do enough for me.

    1. Re:OOP for the procedural programmer by Jucius+Maximus · · Score: 2, Informative
      "I too had some problems w/understanding object-oriented programming. I was strong w/procedural languages, and your standard top-down programming style, but I struggled grasping the concepts of OOP. I found "The Object-Oriented Thought Process" [amazon.com] to be a great jumping-off point in helping me familiarize myself with how to think in-terms of OOP."

      If you're going to do Java, OOP is essential IMO.

      I'm working on a project right now at work (in MSAccess VBA, ugh) where Java would be a godsend. Using overloaded constructors for objects, polymorphic programming and OO techniques would probably reduce the quantity of code for this project by a factor of 10.

      So if you're learning java, make a point of learning how to build those basic abstractions like nodes, linked lists, stacks, queues, binary trees, AVL trees, etc as object oriented structures. IMO it's way easier than doing it in C with structs and pointers to the moon and back. (Don't get me wrong, C has its strong suits. For example you get to create a celebration dance to perform when you eliminate all memory leaks.) In the end, however, if you build the basic abstractions it will help you both in creating efficient alogrithms in all languages and in learning how OOP really should work.

  7. The best way to learn Java... by barcodez · · Score: 4, Informative

    if you want to learn a particular Java aspect look at Sun Java Tutorials. (they are excellent a free).
    If you want to leatn OO programming and Java I would suggest Think In Java (it's the best and it's free).

    --

    ----
    1. Re:The best way to learn Java... by FortKnox · · Score: 3, Informative

      I have to second the 'thinking in java' suggestion, by Bruce Eckels. I learned java by that book, even though I already knew OOP. If you want a good C++ book, "Thinking in C++" by the same guy is the way to go.

      In fact, any book by Bruce Eckels is a great read. It reads like a book, and teaches you in easy terms. It isn't like reading a math book, which most programming books tend to do.

      --
      Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
  8. Common Lisp by Lemmy+Caution · · Score: 2, Informative
    Now if I could only find a book as good to introduce me to Common Lisp.
    What's wrong with the Paul Graham books on LISP? On Lisp can even be downloaded for free, and ANSI Common Lisp is a great introduction to the language.
  9. Re:I'd like to take this oppertunity.. by wik · · Score: 3, Informative

    Most modern JVMs compile Java bytecode to optimized native machine code. If you spend most of your execution time in your application (not the JVM), Java is quite competitive with C.

    If you're interested in seeing how this really works, I'd suggest downloading the IBM Jikes RVM (Research Virtual Machine), which is a JVM/JIT compiler that is almost completely written in Java (it actually can recompile itself at runtime, in addition to your application). Since it's written to be a platform for compiler research, it's not the fastest JVM on the planet, but it has reasonably well-documented code and it certainly does what you described.

    --
    / \
    \ / ASCII ribbon campaign for peace
    x
    / \
  10. Learning Java by StarCat76 · · Score: 2, Informative

    I read O'Reilly's Learning Java (1st Edition) and really liked the way the book is written. Its no-bs way of shwoing the concepts is useful for beginners who want to learn the structure of the language, and for experts, who use it as a reference for the advanced concepts. All in all, I'd recommend it thoroughly. -Neil

  11. Re:I'd like to take this oppertunity.. by mydigitalself · · Score: 4, Informative

    well considering you opted for the coward route, how is anyone going to take you up on that one!

    plus, i entirely disagree with you, i have php applications that pull data from mysql faster than an equivalent java application.

    the JAVA advantages, for me, are:
    - OO through and through
    - scalability in the form of J2EE
    - well writen java is a pleasure to read and understand
    - cross-platform
    - fantastic package library and 3rd party packages
    - sun screwed up and gave it away!

  12. Re:I'd like to take this oppertunity.. by 955301 · · Score: 2, Informative

    I'd like to take this opportunity to point you to IBM's SWT if you still think Java is slow as a client side app.

    Just because Swing got into a politically driven quagmire, doesn't mean the language or runtime itself is hosed.

    It's just a matter of your choice of libraries.

    --
    You are checking your backups, aren't you?
  13. Re:Stay away from it..... by botzi · · Score: 4, Informative

    This is far, far, too far away from being the best book on Java.

    I'll even argue that this is not a good book at all. As always Mr. Eckel is going on and on with a 2-3 pages of reflections and a small piece of programming practices(everyone who've tried to read the C++ thinking, know for what I'me talking about), so my point is :

    1) The book will be confusing for a beginner programmer.

    2) It'll be useless for the most part to a person with some general programming culture.

    Anyway, the best book to start with java is "On to Java", I don't even remember the authors but it's everything: Short, explicit and well structured. A problem may be that it should be a bit outdated.......

    Of course, all one really need to start programming in Java is here

    --
    1. No sig. 2. ???? 3. Profit!!!
  14. OO techniques are seldom fully understood by boster · · Score: 5, Informative

    The majority of developers do NOT fully understand OO principles. There is a difference between learning the syntax and the basic features and understanding how to leverage them. Most OO developers can write and use simple classes, use inheritance and basic polymorphism. This is generally all that is taught in courses and language books. This is also sufficient to get most things done. :) However, most people this level of knowledge do not understand just how much more can be done. A good example of more powerful OO programming is in the Gang of Four book. The conceptual leap from procedural to basic OO programming is but the first step. I guess what I'm getting at is that once you're at this point where you're using basic OO techniques, then there's still a lot more you can learn (even if you know each and every language feature and its syntax). Just be aware of that and look into it someday.

    --
    Madness takes its toll. Exact change please.
  15. Online docs by Hard_Code · · Score: 2, Informative

    Don't forget that Sun has a excellent set of Java tutorials online for free:

    Tutorials & Short Courses

    These are essentially the contents of the Sun press line of books.

    --

    It's 10 PM. Do you know if you're un-American?
  16. Re:Best Series For Learning Java by JoeWalsh · · Score: 2, Informative

    I'd tried Java back in the 1.1 days, but had no real use for the language at that time so I let it drop. Earlier this year, though, a project dropped in my lap that really needed what Java provides, so I started looking for good books on the subject. After browsing through the tremendous amount of Java books at my local bookstore, I settled on the Core Java series.

    By reading the two volumes you mention, I was able to come up to speed quickly. In fact, I finished the project just one month after buying those books.

    I highly recommend the Core Java series to anyone who wants to learn the Java programming language.

  17. Eckels' Books are Downloadable by goodviking · · Score: 3, Informative

    Here here to the Bruce Eckels sugesstion. He is far and away one of the best authors on the topic of OOP. Further, he does a lot of training, etc... and has made most/all of his books freely downloadable.

  18. Re:EWD 696 by TheWanderingHermit · · Score: 5, Informative

    "The habit of using pictorial aids, like any habit, is very difficult to get rid of. If, however, we take any responsibility for the effectiveness of our thinking habits, we should try to get rid of the habit as quickly as possibile, for it is a bad habit, confusing and misleading up to the point of being paralysing."

    Anyone who would say that obviously has no knowledge of how people learn and how different people learn with different styles.

    As someone who spent 10 years with learning disabled and emotionally disturbed students, I can say one of the most effective teaching aids for ANYONE is finding out how they learn and presenting material in the style in which they absorb it the best. Since I worked with those who had the most difficulty learning, I had to learn as much as possible about how we ALL -- disabled, "normal", or gifted learn.

    In a nutshell, anyone who can make a statement like the one above is ignorant. It has the sound of someone who is so busy showing off how intelligent he or she is that he has yet to realize how little he knows about people.

    Perhaps it was written by someone who does well with the style of learning he describes because he spends all his time in books and on the web and has not yet learned how to deal with the real world yet.

  19. I never get sick of hearing that... by the-build-chicken · · Score: 2, Informative

    I decided to learn Java. I'd spent some time using JavaScript

    ok...they're really nothing alike, except for the word 'java'. By the way, if you want to learn anything java, why waste cash on books...just head over to java.sun.com and go through their doco section...they have full documentation on almost every api, and have been keeping it up to date for as long as I can remember (the java trail is an excellent peice of work)

  20. Re:I'd like to take this oppertunity.. by swillden · · Score: 2, Informative

    I think the point is often made, at least in C++ circles, that a mandated GC in standard C++ would be non-real-time, because a real-time GC has worse average performance (like you said) and is very OS-dependent.

    Were such a thing to be mandated in C++, I suspect the standard would simply specify the APIs and semantics without touching on performance, just as they do with new/delete and malloc/free. However, I don't think making GC part of standard C++ would be a good idea, anyway. The language isn't well suited to GC, mainly because the programmer can play all kinds of pointer tricks, which means that any GC for C++ must be conservative (has to assume that any pattern of bits that might be a pointer *is* a pointer) and non-copying (meaning it's not allowed to move stuff around in memory, because tracking down and updating all of the references would be slow and error-prone).

    I think GC is a useful add-on to C++, though, and it's not really necessary to make it part of the standard for it to work. The relatively small performance degradation you're likely to get from a conservative, non-copying collector vs. malloc/free is often well worth the savings in programmer effort and the increase in reliability.

    I'm not sure you could implement a real-time GC for current Linux 2.4 for example. It would require kernel support, and so it is fair to compare malloc/free vs. non-real-time GC because that is realistically what developers would face.

    I don't think there's any difference between GC and malloc/free in that regard. Kernel support isn't necessary at all for GC, although I have to wonder if there's anything that could usefully be done... Normally, though, a GC-based system requests large chunks of memory from the OS (via sbrk(), etc.) and then parcels it out as needed, just like malloc does. This is a good thing performance-wise in both cases -- switching to kernel mode for every memory allocation would be tremendously expensive.

    Anyway, if you need hard real-time guarantees on Linux, you'd better get a Linux patched up for real-time, and you'd better use a real-time memory manager, whether malloc/free or GC.

    Even on 64-bit architectures? Even with lots of allocations (hand-written lists, etc)? I guess it's possible but non-trivial, and a search is always at least O(log N), right?

    I can't really see why a 64-bit architecture would matter at all. In fact, I'd think a conservative GC would end up being less conservative, since the space of potentially valid pointers would be such a small fraction of the total 64-bit space.

    As to the cost of a search... in the worst case I think it's linear with respect to stack size + size of reachable heap objects. In practice, however, people have come up with all sorts of really clever ways to reduce the effort required. I'm no expert on this (though I have a casual interest that used to motivate me to read papers), so I can't really describe the techniques. There's some good information here.

    One that I think is cool, though, is generational copying collection. Basically, it exploits the fact that most objects are allocated and then die very quickly, with only a few being retained "long-term". So, what they do is allocate all new objects in a "young object" pool. When a GC happens, they move all of the objects that are still live into another pool and then just mark the entire "young object" pool as free. You can see how this makes allocation and deallocation of short-lived objects very, very cheap, since the young object pool has no real structure -- just a pointer that indicates where the free space begins; allocation always grabs memory from there, with no worries about finding a block large enough, or updating lists or flag bits or anything. The copying is a bit of overhead on the deallocation side, of course, but it's usually dominated by the savings of not having to examine all of those individual chunks, update free l

    --
    Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.