Java Puzzlers
Kylar writes "When you have spare time and decide to do something with a book (That's like an analog webpage, for the neuronauts among us), how often do you turn to a computer related book? How often has it happened in the last year? Right. The problem being that computer books are often either: a) boring, b) difficult to read, c) poorly written, or possibly: d) made of cheese." Read on for the rest of Kylars' review.
Traps, Pitfalls, and Corner Cases - Java Puzzlers
author
Joshua Bloch, Neal Gafter
pages
282
publisher
Addison-Wesley
rating
9 out of 10
reviewer
Tom Byrne
ISBN
0-321-33678-X
summary
95 Corner cases and traps that any serious java developer should be aware of (or entertained by.)
Java Puzzlers is none of the above(*), being well written, amusing, whimsical, and above all, informative. Bloch and Gafter have brought us a book that entertains us with corner-cases, one-in-a-million chances and other happenings that explore the ins, outs, and guts of the Java Programming Language.
Anyone who has been a serious java programmer in the last several years should know the name Josh Bloch, and more importantly, should have read his book Effective Java. Josh, acting as java's platform architect has been directing and guiding Java into it's current incarnation as a mature, robust (Cue the laughter from the peanut gallery) programming language.
This book primarily references the Java 1.5 programming language, and some of the puzzles are 1.5-specific, although a significant portion of the problems are applicable to previous versions. Also, this book is aimed towards people who are competent-to-expert java programmers, and although there is a lot of good information, people who are new to Java will probably be a bit lost. As it stands, I have 7 years of Java experience, and I was only able to figure out about 15% of the puzzles without resorting to code, or more frequently the answer. The reason that I didn't stop to try out most of these problems is that the book is eminently readable, and difficult to put down (unusual for a computer book, and doubly so for one that delves deeply into a language specification document.)
This book dives into a lot of esoteric bits of the Java Language Specification, also known as "The Big Paper That Sometimes Tells Us Why Java Acts Like That," and there are lots of bits in there that don't even make sense, let alone seem intuitive.
Divided into 10 parts, each part presents a series of different code problems that usually present a small method or class that looks innocuous, but in reality exposes a piece of behavior that is strange, spectacular, or, more often, completely confusing. The book exposes flaws in the language, including one of my personal pet peeves, their inability to have a consistent Date object, and this is noted in Puzzle 62 by my favorite line in the book: "The lesson for API designers is: If you can't get it right the first time, at least get it right the second..."
One topic that I found was a continually recurring theme had to do with handling primitives and what happens when they are cast into different types. Java provides a lot of ways to deal with primitives, and for the most part, they play nicely with each other. There are several occurrences that really surprised me. A perfect example is the following innocent statements:
byte b = -1;
char c = (char)b;
so c=-1, right? Wrong. Places like this are things that you could potentially knock your head against the wall trying to figure out why something doesn't do what it appears to do.
(In this case, byte is signed, char isn't, and the widening cast fills in bits, leaving c=65535.)
A good job is also done describing best-practices for API and library designers, as well as us, the more mundane programmers.
The only downside (from my background and point of view - that of an applications architect, and not generally as a language or API designer) - is that some of the amazing optical illustrations can cause dizziness and nausea - although I can't guarantee that won't happen by the loops and twists that your mind will be tied into because of the puzzles.
Lastly, Bloch & Gafter include an appendix that serves as a summary to all the pitfalls and traps that are introduced in the book, and almost could be an appendix to Bloch's 'Effective Java'.
The bottom line is that in reading this book I learned a fair amount about several edge cases and issues that I had actually encountered - and it increased my understanding as to HOW java does things - although I'm fairly certain that I'll never understand the WHY. And most of all - I enjoyed this book, from start to finish, and that's rare, and worth the time.
You can purchase Java Puzzlers from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Java Puzzlers is none of the above(*), being well written, amusing, whimsical, and above all, informative. Bloch and Gafter have brought us a book that entertains us with corner-cases, one-in-a-million chances and other happenings that explore the ins, outs, and guts of the Java Programming Language.
Anyone who has been a serious java programmer in the last several years should know the name Josh Bloch, and more importantly, should have read his book Effective Java. Josh, acting as java's platform architect has been directing and guiding Java into it's current incarnation as a mature, robust (Cue the laughter from the peanut gallery) programming language.
This book primarily references the Java 1.5 programming language, and some of the puzzles are 1.5-specific, although a significant portion of the problems are applicable to previous versions. Also, this book is aimed towards people who are competent-to-expert java programmers, and although there is a lot of good information, people who are new to Java will probably be a bit lost. As it stands, I have 7 years of Java experience, and I was only able to figure out about 15% of the puzzles without resorting to code, or more frequently the answer. The reason that I didn't stop to try out most of these problems is that the book is eminently readable, and difficult to put down (unusual for a computer book, and doubly so for one that delves deeply into a language specification document.)
This book dives into a lot of esoteric bits of the Java Language Specification, also known as "The Big Paper That Sometimes Tells Us Why Java Acts Like That," and there are lots of bits in there that don't even make sense, let alone seem intuitive.
Divided into 10 parts, each part presents a series of different code problems that usually present a small method or class that looks innocuous, but in reality exposes a piece of behavior that is strange, spectacular, or, more often, completely confusing. The book exposes flaws in the language, including one of my personal pet peeves, their inability to have a consistent Date object, and this is noted in Puzzle 62 by my favorite line in the book: "The lesson for API designers is: If you can't get it right the first time, at least get it right the second..."
One topic that I found was a continually recurring theme had to do with handling primitives and what happens when they are cast into different types. Java provides a lot of ways to deal with primitives, and for the most part, they play nicely with each other. There are several occurrences that really surprised me. A perfect example is the following innocent statements:
byte b = -1;
char c = (char)b;
so c=-1, right? Wrong. Places like this are things that you could potentially knock your head against the wall trying to figure out why something doesn't do what it appears to do.
(In this case, byte is signed, char isn't, and the widening cast fills in bits, leaving c=65535.)
A good job is also done describing best-practices for API and library designers, as well as us, the more mundane programmers.
The only downside (from my background and point of view - that of an applications architect, and not generally as a language or API designer) - is that some of the amazing optical illustrations can cause dizziness and nausea - although I can't guarantee that won't happen by the loops and twists that your mind will be tied into because of the puzzles.
Lastly, Bloch & Gafter include an appendix that serves as a summary to all the pitfalls and traps that are introduced in the book, and almost could be an appendix to Bloch's 'Effective Java'.
The bottom line is that in reading this book I learned a fair amount about several edge cases and issues that I had actually encountered - and it increased my understanding as to HOW java does things - although I'm fairly certain that I'll never understand the WHY. And most of all - I enjoyed this book, from start to finish, and that's rare, and worth the time.
You can purchase Java Puzzlers from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
...it took a long time to load the first page. On the other hand, if you drop the book on the ground, it automatically throws itself into the garbage can.
That's not expected??
I doubt that most experienced programmers would get hung up over the byte b example. I'm pretty sure that you'd get similar behaviour with C and a lot of other languages.
If the title of a puzzle book does not contain the letters s,u,d,o,k and u in it, I am not interested. Sorry.
A citizen of America will cross the ocean to fight for democracy, but won't cross the street to vote in an election.
yay. go java!!!
The problem being that Slashdot Headlines are often either: a) Dupes, b) boring, c) difficult to read, d) poorly written, or possibly: q) made of cheese
To the moon, Java!
Is there heaven? Is there Hell? Is that a Tuna Melt I smell?-Primus
I'm somewhat puzzled by the premise of the book. I thought C/C++ was full of puzzlers, and that Java was supposed to fix all that. Puzzlers may be cute, but they are definitely bad (except for job security may be). BTW, my little test shows that this example also applies to C, except that it isn't as surprising since you have to specifically declare the variable as unsigned, e.g.
int b = -1;
unsigned char c = (unsigned char)b;
Without "unsigned", char is -1, as expected.
See, to a C coder, this is non-obvious because both the types would be signed, and if you wanted it unsigned you would have to say so.
It has always diven me nuts how Java forces its own signed-ness on it's primitives. The fact that you can't have an unsigned int in Java 1.5 is a huge pain, because it is not like it is simpler to just use char everywhere, since then you lose all the autoboxing capability of Integer/int. So, you have to deal with it yourself. It's a big mistake IMO.
If that c != -1 example isn't obvious, it may be safe to assume that former VB programmers have started programming in Java! Run!
It is to expose a flaw in the language.
Why should a primitive byte be signed, but not a primitive char?
And why can't I have an unsigned int primitive in Java?
Primitives in Java are a real pain to work with compared to most languages.
1) Code readability.
2) Speed of development.
3) Lack of "cute" features that break easily.
4) Javadoc!!
5) Bazillions of pre-written, pre-tested source-available library functions.
No folly is more costly than the folly of intolerant idealism. - Winston Churchill
I think the whole notion of a "character" type being assigned a numerical value is dubious in the first place. That's not to say the idea of a character coding that translates between characters and numbers isn't sensible, but the character itself is not a number - it's a character. I like Python's approach to the solution - there simply is no "atomic" character type (defining such a thing when character sets have characters that aren't uniform size is questionable anyway)
So given that characters aren't numbers, is it really so hard to imagine that people see that code and can't readily guess what sort of number a character is? I guess one could say that the character set is indexed with non-negative integers, so the character type should be non-negative - but a logical derivation isn't the same as a plain fact, and other languages aren't so sensible in those kinds of decisions...
---GEC
I'm but the humble pupil, seeking to snatch the scratchbuilt pebble from the master's fully articulated hand
When you have spare time and decide to do something with a book (That's like an analog webpage, for the neuronauts among us), how often do you turn to a computer related book? How often has it happened in the last year? Right. The problem being that computer books are often either: a) boring, b) difficult to read, c) poorly written, or possibly: d) made of cheese
Being a computer science grad student... I imagine myself to be among the nerdy. Interestingly, I own an assortment of books, spend most of my time that isn't in a lab in a library, and read about 6-7 hard-copy academic papers a week, in addition to an assortment of books. When I have free time, I read books on AI.
Ya, no kidding right? Java==(tehsuxx0rz)++; Just remember who was in charge of Java development: Eric Schmidt, uber-billionnaire CEO of Google.
Unfortunately, real-life java problems are never very interesting.
Invariably the solution consists of editing an annoying xml config file, or perhaps correcting one of my daily misconceptions about some boring detail in whatever convoluted j2ee framework I am forced to work with.
Just to piss you off.
Why bother? I have 1 HTML/CSS book I keep on hand just because I've used it so much. Everything else, I use google. Its faster (for me) to find designs, references, and code samples online then it is for me to get a book, look up the index and flip through the pages. I even gave up on my old SQL bible as Google can get me syntax and samples faster then I can find them in the book.
-Rick
"Most people in the U.S. wouldn't know they live in a tyrannical state if it walked up and grabbed their junk." - MyFirs
I'm sure a book called C Puzzlers would sell at least twice as well as this.
~jennifer.k~
I'm curious as to why this user's post was marked "informative". There are many places to buy the book, and the story provided one. In fact, the only significant difference between this link and the story is that this person has apparently posted a referral link to make some money.
drool...
As far as I can tell, only 4 can qualify in favour of Java.
1, 2, 3 and 5, on the other hand, should drive devs towards Python or Ruby.
"The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
The problem being that computer books are often either: a) boring, b) difficult to read, c) poorly written, d) made of cheese or possibly: e) sex with a mare?
Is there an online version? This seems like the type of thing I'd do on my lunch break or when I need a diversion. Something along the lines of the Python Challenge, would be cool. To me, it seems more natural to do these puzzles in soft form.
Peoples, look at your desktop.
How many java apps are there?
How many C/C++/ObjectiveC are there? (hint: your browser, email, OS, shell, image editor, spreadsheet, wordprocessor are)
Now do you get it?
The purpose of Java is to have an object oriented version of Pascal for teaching freshmen some simple concepts. The real world doesn't use it very much.
Most technical books are: ...
E) Out of date before the ink is dry.
I was there, and I found it quite entertaining and informative.
The purpose of Java is to have an object oriented version of Pascal for teaching freshmen some simple concepts. The real world doesn't use it very much.
I was using an object oriented version of Pascal (Turbo Pascal 7) before Java existed. My high school didn't teach the Object Pascal features, but they were there.
Java is being used heavily, but more for information systems work than software you'd buy at a store.
Ok, so where are these books that are made of cheese? I'm hungry! Are any made of sharp chedar? Monterey Jack?
I dream of a better world... one in which chickens can cross roads without their motives being questioned.
Have any other more interesting/fun examples?
If you want some puzzlers, look for copies of the Sun Java Programmer certification exam. There's lots of "we're not testing to see if you're a good programmer, just testing to see if you can find the unexpected result in the insanity-pepper code" snippets there.
boxlight
Why would anyone use Java?
From now on? Just to piss you off.
1, 2, 3 and 5, on the other hand, should drive devs towards Python or Ruby.
They may be strengths of python and Ruby(i don't have much ruby experience), but can you give examples of how they do not apply to java?
"If they have both, tell them we use Linux. And if they have that, tell them the computers are down." -Dave Chapelle
My browser and email are actually written in Javascript with a small C core.
"The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
a book (That's like an analog webpage, for the neuronauts among us)
Books are just as digital as webpages, with the possible exception of illustrations.
I think you would have to title the book "GCC Puzzlers" or something of the sort. Different compilers give you different behavior for C. For example, how big is an int? Java is much more concrete.
ok. it's not the new pascal. it's the new cobol.
Let's see... ebay, autotrader, careerbuilder, cars.com and a huge chunk of newspaper classifieds just to start the list.
OpenOffice is java.
Why do many of the largest ecommerce sites choose Java? Because it's fast, efficient, solid and secure.
"byte b = -1;
...surprised you?
char c = (char)b;
so c=-1, right? Wrong."
Loading...
That's like an analog webpage, for the neuronauts among us
wtf? neuronauts???
made of cheese.
wtf?? cheese??
mature, robust (Cue the laughter from the peanut gallery) programming language.
W..T..F..??
"The problem being that computer books are often either: a) boring, b) difficult to read, c) poorly written, or possibly: d) made of cheese." I think the actual problems with computer books, are the readers. Example: The Bible (written by God)
Don't worry, no one is gonna take away your mainframe, grampa.
Enough Rope to Shoot Yourself in the Foot is an excellent example. It's a nice book that's easy to read. I keep a copy near the throne. It can be a bit preachy and I don't always agree with the author's stance, but it's still a good read.
The Exceptional C++ books are also easy reading.
It really just depends on what you want. Way back when I was first moving from C to C++, I bought the book Simple C++. While it was a good book that was easy to read, it took far too long for me to gleam the information from it. It's easy-to-read and simplistic approach was a notch or two down from what I was looking for information-wise. Likewise, I imagine most of the CS books sitting out there are for reference purposes. That's not the arena for books that are fun to read.
Didn't Microsoft fucking kill that guy yet?
Your broswer is written in C++
You are very confused.
The real world doesn't use it very much.
I see it most often used in combination with other languages, rather than standalone. It's more a professional language than public, you see it more for business/corporate work.
guiding Java into it's current incarnation --> guiding Java into its current incarnation
Some of us don't hate gay people, while still hating the word "Neuronaut."
I have freaks! I did something right...
If I need a book to understand this (being it JAVA or SNOBOL it doesn't matter), the first 200 pages will be about information technology.
Another 200 pages are needed for the basics of computer science and finally the remaining 200 pages are for JAVA.
Maybe Computers will never be as intelligent as Humans.
For sure they won't ever become so stupid. [VR-1988]
I bought the puzzlers book on a whim. Love it.
But the subject seems to be "computer books in general", and man is there a world of difference between computer books. Someone might pick up an Organization textbook, and come to understand twos complement numbers (and thus, not be surprised by the puzzler mentioned in the article), he might learn how a full adder can be made from NAND gates, and that might get him to the second chapter of a logic theory book.
It may be tempting to compare "computer books" to "computer books", but "PHP in 24 Hours" is NOT on the same shelf as Cormen, Knuth, Stevens, Hopcroft, Sipser, I think you get the idea.
A person might be very skilled and experienced in some areas, who would pick up one of these books and wonder "WTF?"
Works both ways. I know CS academics who would be hard pressed to function in a business software environment, and experienced business software devs who would not understand the theory expression to any depth, even those who ackowledge that theory is important.
There is no byte data type in C, only the char, which in terms of C is an integer of size depending on the most basic machine addressable unit (usually a byte). This example is probably most interesting to people who cut their teeth on C and then moved on to other C syntax style languages like Java.
You're right though, most programmers worth a damn don't make assumptions like this when it comes to data type conversion.
It should be at least a little bit interesting to all, however, since the code is valid and the result isn't intuitively obvious.
The correct value of is the glyph or other character corresponding to entry 65535 in whatever character encoding Java is currently using. (Assuming UCS-2, it's an invalid codepoint and therefore undefined.)
Yes, for purposes of demonstrating that is stored as a signed value and isn't the example is correct, but that's still a little more of an under-the-hood mentality that's more appropriate to C than to Java.
download this : http://ftp.mozilla.org/pub/mozilla.org/firefox/rel eases/1.0.7/source/firefox-1.0.7-source.tar.bz2
(mozilla source code).
unbzip it.
count the *.cpp files.
count the *.xul files.
(whaps idiot over the head)
Now do you get it?
I've been using Eclipse as my sole IDE for at least 8 hours a day, 5 days a week, for the last 3 years. But yeah, aside from that, very little of my time is spent using Java apps.
Well, maybe that's the intended purpose. But its semantics don't sit totally easy with that. What does this print? (from p.25)
System.out.println('H' + 'a');
It prints '169'. The book goes on:
From a linguistic standpoint, the resemblance between char values and strings is illusory. As far as the language is concerned, a char is an unsigned 16-bit primitive integer - nothing more.
Yeah, in practice this sort of thing is mainly irrelevant, because you wouldn't actually USE chars like that. Still, it's interesting stuff.
fud, notfud, yes, no, maybe
Kylar writes "When you have spare time and decide to do something with a book (That's like an analog webpage, for the neuronauts among us), how often do you turn to a computer related book? How often has it happened in the last year? Right. The problem being that computer books are often either: a) boring, b) difficult to read, c) poorly written, or possibly: d) made of cheese. Read on for the rest of Kylars' review.
I know slashdot is hardly the pinnacle of good reporting, but that summary is bordering on the idiotic. Were those daft little bits of meaningless fluffy non-humour put in there simply to up the word count?
C17H21NO4
System.out.println('H' + 'a');
It prints '169'. The book goes on:
The real problem is the overloading of the '+' sign. This is just more evidence that operator overloading is harmful in general purpose langauges. Sure, that '+' is convenient for putting strings together, but it does cost in clarity.
The reason for this behavior, BTW, is do you can do things like this:Being able to obtain mathematical deltas is extremely important when you're changing the forms of letters. Gosling wasn't looking to change those sorts of features when he created the Java language.
At least that's a more realistic example, though.
Javascript + Nintendo DSi = DSiCade
That's definitely closer, although VB was the new COBOL first.
5 most defintely does apply. I've downloaded the Java source code several times to dig out why something weird is happening with the Sun APIs. And then there is the Apache Foundation stuff and all the rest.
a) Print "hello hello"
b) Print "hello goodbye"
c) Compile error
d) Other
Some banter of my own, roughly:
Well, let's see. This seems like bad code, since why would you name a class String, but sure. So each bad.String has a java.lang.String inside it, and when you construct a new bad.String you get an object that contains the java.lang.String that you constructed it with. Of course, the toString() method just returns the java.lang.String that it stores. So first we make a String with "hello" and then we print it, followed by a space, and then we make a String with "goodbye", and print "hello" again. So I think this program should print "hello hello".
I'll post the answer later if nobody gets it, but you can always try it yourself. I do recommend thinking about it, though: it's cute. Note that everything I said in the banter, except for what I think the answer is, is true.
I can't really fathom the choices in Java's design. A lot of advanced-ish features like operator overloading, left out, *just in case they tempted you* to write non-obvious code. And yet it keeps lots of old C syntax which gives you plenty enough rope to hang yourself with (from which flows several of the puzzles).
anyhow, I recommend it.
fud, notfud, yes, no, maybe
Ah, there's nothing more productive than starting up the "your language sucks, you should code in [insert my language of choice here] because it's what real programmers use" argument. I've yet to meet a coder whose ability I truly respected that ever got into such an argument. But, hey, maybe this is really useful. Under that guise, let's run the entire argument here and anytime you feel like a language being discussed is for half-wits, you can reference this.
So, here's the argument in order from first salvo to coup-de-grace
> When we moved into millions of cycles per second (big big solaris servers) we had similar problems...
When we use big servers, Java 1.5, huge centralized clusters (offsite backup!), connection pooling, application level caching, big Oracle clusters, and pro (expensive) app servers (no tomcat) not only can we handle millions of cycles, we can handle a lot, lot, lot more at 6 sigma reliability and better.
I'm guessing your problem is a deeper architectural issue, not a "bug with Java".
Horns are really just a broken halo.
Hmmm, but proper (internationalized) case conversion is ridiculously more complicated than that.
:-)
Yes it is indeed.
The JavaDoc for the Character class actually bemoans this in detail. My only point was that the Java Language allowed the numerical operations for such purposes. Writing a proper Unicode case converter is something that Sun has already done for us. (Thank God.)
And yet it keeps lots of old C syntax which gives you plenty enough rope to hang yourself with (from which flows several of the puzzles).
That much is easy to answer. Java started its life as a new C++ compiler that didn't require a recompile of the entire project when just one class changed. To meet that goal, Gosling turned to using bytecode. That partly solved the problem, but he found he had to make several language changes to keep classes separate. By the time he was done, a new language had emerged.
Javascript + Nintendo DSi = DSiCade
Actually implicit casts are a bigger problem than operator overloading and less useful too.
Linux is not Windows
No, I won't teach you cause if they do start a gameshow..I'M GETTIN' PAID!!
0x09F911029D74E35BD84156C5635688C0
4) Javadoc!!
Java should be banned because of "cute" features like Javadoc that can easily be abused. For example, in the early days of Java, asshole Sun Inc. just spit out skeleton javadoc-generated API "help", like:
class Widget
void setDecomboobulation()
Sets decomboobulation.
But unless you already know what the fuck "decomboobulation" is, it doesn't fucking help!
Another obvious example is checked exceptions, which encourage you to just write an empty one to get the compiler to just shut the fuck up for one second so that you can think, and then forget to come back later and fill it in with something meaningful.
So, in closing, since the rule with you fucking Java airheads is that any language with easily abused "cute" features sucks, Java sucks. QED.
Thank you. I also do weddings and barmitzvahs.
Right on, brotha, anything not made for the dumb and lazy just isn't kewl.
It never ceases to amaze me how naive people can be when it comes to Java. The truth is, the underlying VM is a different technology than the "Manage it yourself" tradition of C/C++. While garbage collection is an additional process that occurs in a VM environment such as Java or .NET, there are peformance advantages to using such a process. (And no, I am not refering to the programmer laziness argument about not having to manage memory in Java... I am talking about the efficiency of allocation and deallocation that a Java VM affords)
y /j-jtp09275.html?ca=dgr-lnxw01JavaUrbanLegends
I do not plan on engaging in any arguments back and forth about the two types of memory management... But if you are truly interested in an article that means to show the reality of the "performance characteristics" of a Java VM, please read the article listed below. It is truly a well written article and worth the read.
http://www-128.ibm.com/developerworks/java/librar
The second one I'm not so sure of: double i = Double.NaN;
Disclaimer: I work on a Java JIT compiler for a living.
Patrick Doyle
I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
Gah... wrong button. Meant to hit "preview". The first one should of course be Integer.MIN_VALUE;
Patrick Doyle
I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
Are you a liscensed mathamagician? i've got a birthday party coming up and we need some entertainment.
"neuronauts"? You COMPLETE FAGGOT.
I agree, that word makes me want to punch something (I was talking about "neuronauts" btw).
Top 10 Reasons To Procrastinate
10.
If you want to use an unsigned short in Java, you need to use a char.
Which is a PITA since Java 1.5 autoboxing is useless now, you need to cast all over the place again just like in Java 1.4.
Which is why it is retarded. Why can't Java just have an "unsigned" keyword like in C++ and let the developer do what he/she wants?
I have Lucene in Action open on my desk at work at the mo. Great stuff. Other than that, i always look online.. there are few other computer books i've encountered as useful.
Last.fm - join the social music revolution
Of course. Generally, the requirement of a sudoku puzzle is that it can be solved using logic alone, without guessing, and that it has only one solution. It's not rocket science, it's a light brain-workout.
True confidence comes not from realising you are as good as your peers, but that your peers are as bad as you are.
No,(and no such thing as a "licensed" one) but if you're serious, I can probably find a magician in your area. I prefer mentalism(psychic entertainment without the delusional thinking that makes someone from NYC think they have a Jamaican accent) and what they're now calling "street magic"; I also dig running "short cons" but nothing that gets me anything more than a free drink every now and again.
0x09F911029D74E35BD84156C5635688C0
Overall, out of your list, only point 5 stands. Java is not the most readable out there (out of more or less mainstream languages, Python arguably is), not the most rapid development friendly (any scripting language beats it there), and Javadoc-like documentation system is usually the second thing after compiler/interpreter which gets written for any new language these days.
Personally, I find Python extremly difficult to read, as I do any loosly typed language. With a lot of C/C++/Java experience, I once tried porting some fairly simple algorithms from Phyton to C, and gave up becaues the code was too hard to follow due to loose typing.
Maybe its not so bad if you are used to it but from my perspective I'm amazed how any large project written with such languages doesn't get bogged down in bugs. Perhaps its just requires a bit of disapline or something, I don't know, I am nieve on the topic.
Since there is a String class that exists within the bad class, this prototype:
public static void main(String[] args)
is the same as this:
public static void main(bad.String[] args)
and java can't find any main to execute because it is looking for:
public static void main(java.lang.String[] args)
See?
I'm still not sure what static typing has to do with readability, but even out of statically typed languages Java is hardly the most readable. See Eiffel for a better example. This is, of course, because Java syntax is really just C/C++ legacy.
Imagine you want to do:
Quite useful really.
In this world nothing is certain but death, taxes and flawed car analogies.
It seems a bit odd that they made chars behave like integers if they didn't want people to use them as integers.
In this world nothing is certain but death, taxes and flawed car analogies.
Is that I figured it would generate some discussion :)
If you have a super fast solution to the sudoku puzzle family you should probably write it up. Sudoku is NP-complete... if you've solved it then you've cracked every encryption protocol known to man...
$you = new YOU;
honk() if $you->love(perl)
When jumping into the middle of a code segment of a loosly typed language, it can be extremly difficult to work out what is going on because you don't know what any of the types are. For example, if you look at a function, it can be tricky to work out what type the paramaters are. In a strongly typed language, it is obvious.
I can't say C/C++/Java are the easiest languages to read in general for everybody, but considering they are burned in to my mind, for me any language that doesn't make excessive use of currly brackets is hard for ME to read in comparison;)
Now, that is why one should use descriptic variable names. If you see a variable named count, you know it's a non-negative integer, and percentage is quite certainly [0; 100] (and whether it's int or float is really unimportant, if you think about it).
But of course, for formal code review and automated verification this is not enough. Some formal way to describe the constraints on input and output data (function arguments and return values, in our case) is needed. That is what Design by Contract for; but curiously enough, it does not imply static typing, even though it originated in a statically typed language (Eiffel): dynamically typed languages such as Lisp also have successful DbC implementations.
To sum it up: DbC covers all the readability and maintainability issues traditionally associated with lack of static typing, while peacefully co-existing with all the benefits of dynamic typing. Behold, the way of the future! ;)
I find where loose typing is most confusing when it comes to data structures, classes and arrays rather then simple inbuilt types where it isn't too bad.
I agree, descriptive variable names are greate and I don't mind a bit of design by contract my self. I'm sure there are ways to code with loosly typed languages that are safe and readable, however, I wouldn't discribe much of the loosly typed code I have seen as such (Attmitably I havn't looked at much).
Perhaps this is a good question, if you wanted to port code from an undisaplined, ans perhaps inexperienced team of programemrs, what language would you prefere? That would probably be a good measure of readability.
All in all, in the situation you described, I would probably prefer it to be in Eiffel. It's pretty hard to mess Eiffel code up.