Skip to content
HomeVideosBooks
AllTopicsTrends
BlogsPodcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    Cover of Java puzzlers

    Java puzzlers

    Joshua Bloch · 2005

    Based on Bloch and Gafter's standing room only Java Puzzlers talk at JavaOne, the heart of the book comprises over 100 Java programming language puzzlers: brainteasers that challenge the intellect while alerting programmers to the traps, pitfalls, and corner cases that lurk in the nether regions of the Java platform. All the puzzles from the authors' popular JavaOne presentations are included, as are many puzzles never before seen in public. There are two major types of puzzles in the book. Most of the puzzles take the form of short programs that appear to do something but actually do something else. Readers will be encouraged to predict the behavior of the program before running it. After running the program, readers will be encouraged to figure out why it behaved as it did before consulting the solution. In a second type of puzzle, the reader will be asked to write a short program that performs some specific task. Most of the solutions will contain a "moral," a rule that reader can follow to avoid the problematic behavior demonstrated in the puzzle. The puzzles are grouped into chapter based on the primary platform features they exercise and to maximize readability, fun, and pedagogical effectiveness.

    Programming
    Open LibraryAmazon
    Stats for nerds
    12recommend
    21mentions
    20people
    2008–2025years
    57% recommend43% neutral

    Mentions per year

    2008201020122014201620182020202220242025

    What Hacker News says

    1. 0xmarcinDec 2022
      Have you got a chance to read "Java Puzzlers: Traps, Pitfalls, and Corner Cases"? Java is a very surprising language with a lot of strange corner cases (a lot of them related to reified generics and wrapper types).

      There is also a lot of magic going on in JVM e.g. there is one optimization that causes stack trace to be omitted if the exception is thrown from a given place a lot of times. Beginners then see an exception without a stack trace and are stuck. SO rel: https://stackoverflow.com/a/3010106/1779504

      Spring can be a source of confusing problems when defining beans (especially when you have to use Qualifier's). Most of the juniors that I had a change to work with had very hard time getting used to Spring bean model. And I am not mentioning here strange Spring Proxy behaviour that can defy even programmers with 10+ years of exp

      thread
    2. cratermoonMar 2021
      My favorite books about languages are the ones that point out where the language is ambiguous or otherwise has surprising, e.g C Traps and Pitfalls and Java Puzzlers: Traps, Pitfalls, and Corner Cases, . It would be great if there were programming languages with no surprises, but I don't think that it's possible. Every language has to compromise on some things in order to solve the problems it was designed for.
      thread
    3. denormalfloatOct 2018
      Java Puzzlers by Joshua Bloch and Jeremy Manson are pretty entertaining. For a pretty bog standard language, Java has some more exotic corners: https://www.youtube.com/watch?v=wbp-3BJWsU8
      thread
    4. kjeetgillJun 2018
      Java can get into some weird cases with generics, super classes, and overriding. Joshua Bloc has some interesting ones in the fantastic (and horrific!) book, "Java Puzzlers: Traps, Pitfalls, and Corner Cases".

      For what it's worth, I think python's case is fairly simple and easy to remember.

      Python objects can define two different methods for operator * : __mul__(self, b) and __rmul__(self, b). When you see A * B, try A.__mul__(B) if A has a __mul__. If the call throws NotImplemented (usually due to B's type) of if A did not hava a __mul__ call B.__rmul__().

      I think that's actually much simpler that relying on types for dispatch since operators tend to be more "flexible" in their operand types than normal functions.

      thread
    5. emmelaichFeb 2018
      All in no particular order....

      As a Unix systems engineer, I would choose

          1. W.R. Stevens books on Unix and Tcp/ip.
          2. Rochkind's Advanced UNIX Programming.
          3. Most of the Unix/Linux manual pages.
          4. Bash FAQ
      
      As a Unix systems programmer I would choose

          1. Mythical Man Month
          2. Jon Bentley's Programming Pearls.
          3. K&R C and Stroustrup C++
          4. A recent Java reference and Bloch's Java Puzzlers
          5. a reference and cookbook for the language of your choice -- Python, Ruby, Perl, etc.
          6. Google's style guides
      thread
    6. noxTokenFeb 2018
      Java Puzzlers[0] has a few entries similar to this. Some of the entries are things that would trip you up (but logically makes sense) rather than oddities, but it's an interesting read. Note that the book is from 2005 and uses Java 5.

      [0]: https://www.amazon.com/Java-Puzzlers-Traps-Pitfalls-Corner/d...

      thread

    Related

    Cover of Effective Java
    2007–2026

    Effective Java

    Joshua Bloch
    172 recommend · 287
    Cover of Java Concurrency in Practice
    2009–2026

    Java Concurrency in Practice

    Brian Goetz
    53 recommend · 82
    Cover of Programming Pearls
    2007–2026

    Programming Pearls

    Jon Bentley
    158 recommend · 315
    Cover of Game Programming Patterns
    2012–2026

    Game Programming Patterns

    Robert Nystrom
    120 recommend · 161
    Cover of Code Complete
    2007–2026

    Code Complete

    Steve McConnell
    393 recommend · 894
    Cover of Refactoring to Patterns
    2009–2026

    Refactoring to Patterns

    Joshua Kerievsky
    15 recommend · 25
    Cover of JavaScript
    2008–2026

    JavaScript

    Douglas Crockford
    72 recommend · 104
    Cover of Introduction to Algorithms
    2007–2026

    Introduction to Algorithms

    Thomas H. Cormen
    274 recommend · 880