r/Python•
zekel

self.python.ask('I am moving into a development position at my company and need to learn Java. Can you recommend a book that might appeal to a Python programmer and not make me want to kill myself?')

Posted Jan 4, 2009, 2:48 PM UTC

3078
tclark•

No. Suicide is your best option at this point.

49
zekelOPtornado, beautifulsoup, web.py•

So, you're recommending the nutshell book then? I'm pretty sure that would finish me off.

7
[deleted]•

And don't forget to put us in your will!!!

0
[deleted]•

Boo hoo, I have to program in an uncool language. What will my cool friends think of me now!?

Suck it up, wusses.

0
trpcicm•

1984 by George Orwell

22
zekelOPtornado, beautifulsoup, web.py•

First, sorry for posting this to pyreddit, but I thought this would yield a better recommendation for me than the java subreddit.

The Job - It's mostly a web development position, so a book that uses things like tomcat and struts might be helpful. Or maybe I just need a general (but not Programming101) book on Java and then jump into those topics after that. I see 'Java in a Nutshell' breaking bookshelves all over the office, weighing in at 1,254 pages. It offends my sensibilities to have a book with that title be that large; somebody is doing something Wrong.

I really, really love Python. I am an intermediate level Python programmer. I know almost nothing about Java. I know C and PHP, so the syntax should be familiar. Have any of you pythoneers come across a good Java book that doesn't agonize over the basics of programming and isn't so large as to dwarf the internet? I know there are probably some great PDFs or ebooks out there, but when I learn a new language I really like to sit in a chair with a good book (call me old fashioned that way.)

(And just to make this explicit rather than implicit, I am not giving up on Python one bit. I love the language and am really excited about dict-comprehensions. Moving into a development position, even at a java shop, brings me closer to being able to work where I want so I can program in the language of my choice and be ridiculously happy. I will also be able to have a better conversation about why I like Python better than Java and tempt some of the Javaheads in my office.)

Thank you in advance for any thoughtful or informative replies.

13
masklinn•

It's mostly a web development position

Wel development in Java?

If you've done web dev in Python before (or even in PHP 5), you're likely to want to kill yourself soon. Seriously, java is one of the worst web dev environment (and I've done it for a pair of years before quitting), I'm not even sure Cobol on Cogs would be worse, and it forced me to consider using PHP -- a language which I loathe -- instead. Have there been any mention of web frameworks? (a few recent java frameworks alleviate some of the pain through sensible defaults and annotation-based config -- Stripes for instance -- but older XML-based frameworks only worsens it, Struts 1.x is a prime offender)

You might want to read PJE's Python is not Java and Java is not Python, either...

Read the latter first by the way, if you start with Python is not Java, you're going to hang yourself right off the bat.

As far as books go, Thinking in Java 4th edition (java 5 support), just browse through it to get an idea of the language, and Effective Java 2nd ed (short book, enjoyable read and it will teach you how to think java in short bites).

PS: try to see if you can use Jython, JRuby Clojure or Scala instead, they run on the JVM and they're not java, 2 great advantages.

9
zekelOPtornado, beautifulsoup, web.py•

I have done web development in Python, and I know this won't be anything like that. I'm not expecting this position to be my dream job or even make me especially happy. But I'd rather move into Java development rather than stay in a non-development position. I am fairly certain I won't like Java and that I may hate it. But I'm willing to try it and find out for myself.

I probably should have made it more clear that this is an internal promotion and that I currently work for the company, and our desktop and web products are written in Java. Right now I build a lot of tools and web apps for internal use in Python. One reason I got the promotion is because I get stuff done so well and fast in Python.

6
Leonord•

how's moving to java a promotion ?

3
bjupton•

$$$

8
zekelOPtornado, beautifulsoup, web.py•

Going from a non-development position to a full time developer is definitely a promotion. =)

5
theatrus•

If you can buck the trend there, trying pushing for something like GWT. Its still Java, but a lot of the pain is reduced for you. Its hard to tweak when things go wrong, but depending on the application that may be acceptable.

I've also used OpenLaszlo. My recommendation is to stay far away. It can produce functional applications, but performance is horrendous and the JS backend is hardly mature.

2
masklinn•

Well good luck, but still once you're in place you'll probably ought to try to switch the language of the web frontend from java (as long as the chosen language runs on the JVM, the code shared between web and desktop will work and be useable)

1
bjupton•

I'm amazed at how many web dev jobs are in Java. Especially once you get outside the silicon valley and out into the "enterprise". They aren't always the outward facing things, sometimes they are the little apps used within organizations.

Enterprise IT just seems to love java. I don't know why. It's expensive, and a pain in the ass to code. But, they of course already have a set of people in place that know it, and they are doing the hiring etc.

2
masklinn•

Enterprise IT just seems to love java. I don't know why. It's expensive, and a pain in the ass to code.

  1. Covering asses: just as nobody's ever been fired for buying IBM, nobody's ever been fired for going Java. In big corps, middle-managers first and foremost want to avoid the chance of being blamed. So they go for java because it's "the industry standard", and when the project is overbudget and/or late and/or a failure, it's not their fault.

  2. The python paradox: going for java ensures they have a huge pool of not-necessarily-qualified potential hires (see java schools & al). This also pleases middle managers.

  3. You saw point 1 about choosing IBM? Well IBM pushes java hard, so you buy overpriced IBM hardware (and software, hello Websphere), and then you code in java to top it off (Oh websphere, what a surprise!)

I'm sure we could find others, but that's a good start

9
laprice•

And you have to factor in the perverse organizational incentives that exist.

Some outfits budgets are allocated based on headcount, and depth of tree, so a two person team with a single layer counts less than a 7-person team with two layers; and a manager who is responsible for a team totaling 7 FTE doing Java, is better compensated than one who manages two programmers writing in python. Even if the two teams are producing equivalent functionality :P

3
[deleted]•

[deleted]

1
mikaelhg•

Enterprise IT just seems to love java.

It's because they care more about getting more bang per buck than their e-penis size, and Java gives radically bang when you look at the whole process of producing value with software in a large and complex environment, instead of just looking at the matter from an individual developer's immediate standpoint.

2
13ren•

and yet... java was not designed for the Enterprise. It was heavily promoted by Sun as an applet technology (in set-top boxes). Getting adopted by the enterprise happened by itself, and was kind of surprising and strange. The whole "application server" thing came about as a surprise too - BEA Systems came along and did that.

Java has something going for it... but what?

Familiar to C coders, but much safer, simpler, friendlier error messages and more reliable, was what Java offered I think (some argue that other C variants, such as Objective C had this too) - and a virtual machine. I'm not sure how important the whole OO thing was, except as one of Java's well thought-out supports for modules, You can load classes dynamically (making it a "component platform"); you have classes and packages. This support for modules makes it possible to write big systems.

"Components" and architecture dominate the big picture, but are invisible when writing specific code (forest/trees) - so, if true, decision-makers would love it, but coders wouldn't see why.

2
bjupton•

This is wrong. Completely wrong.

It has everything to do with what they are used to.

-2
amnezia•

Because its J2EE! its has enterprise in the name therefore its must be built for enterprise /sarcasm.

Seriously though most of the lead developers at the companies i've worked for don't have any experience with languages like python, its in their best interest to keep everything in Java.

1
mrsanchez•

Effective Java 2nd ed FTW!

2
[deleted]•

You might want to read PJE's Python is not Java and Java is not Python, either...

Read the latter first by the way, if you start with Java is not Python, you're going to hang yourself right off the bat.

Uh, so you want zekel to commit suicide?

1
zekelOPtornado, beautifulsoup, web.py•

I did post about Java on pyreddit. I'm sure some people will try to do me in for that.

3
masklinn•

Well of course it would be an acceptable side-effect of my post, but mostly no, Java is not Python highlights quite a few differences between java and python, just because they're seen from the Python side doesn't mean they aren't interesting when you go from Python to Java.

Just think of it as a smaller dose of the pain to be experienced later, to build immunity. Kinda like the guys who inject themselves daily with small doses of toxins/poisons to build resistance. In both cases, if you fuck up the dosage you might die, it's an accepted risk.

1
[deleted]•

No, that's not what I mean at all. I'm sure your logic is sound.

But you effectively said, "Read Java is not Python by the way, if you start with Java is not Python, you're going to hang yourself right off the bat."

This is the former word in the sentence, and this is the latter.

2
csdigi•

I did a course called Enterprise Computing (insert laugh here) as (a very easy part) of my undergrad in CS at Edinbrugh University. Basically this course turned out to be more like Enterprise Java, and works through quite a lot of the web java features such as JSP,Hibernate,Tomcat and some stuff like the Java logger. While it may not help you to learn the language much it might certainly help when you come to cover the stuff required for deployment (like the JSP and servlet compile pathway). There is also quite a good introduction to ANT which will save you from actually killing yourself due to the inane nature of java classpaths...

http://www.inf.ed.ac.uk/teaching/courses/ec/

Now for my token effort to avoid another Java train wreck, why not write in python and use Jython to compile to java byte code, they need never know! Although on a serious note I would check out groovy, especially if you are just learning. It is basically the Java language with a little bit of python flair installed for good measure and is widely supported now!

http://groovy.codehaus.org/

Hope you don't end up doing something stupid, although I fear that ship sailed the moment you posted about learning Java to the python subreddit...

Enjoy.

2
zekelOPtornado, beautifulsoup, web.py•

Believe me, if I had the choice to write in Python I would, but it's a case of having to conform to my team's environment.

Thank you for the link Java link, that looks like it will be helpful.

2
amnezia•

well hopefully they have some kind of code review, its gonna be a little difficult to review byte compiled java.

1
csdigi•

Well obviously any code review would be done on the python side... The fact that it compiles to java byte code is only to satisfy any portability constraints on the system.

1
koko775•

This is slightly OT, but how does one define themselves as an "intermediate"-level programmer in one language or another (particularly in Python)? Is it about knowing the standard library? Understanding less popular parts of the languages (such as generators, list comprehensions, etc.)?

2
zekelOPtornado, beautifulsoup, web.py•

Well, I found myself to be an excellent audience for Expert Python Programming. (I highly recommend it.) And since I'm not a beginner, that means I'm probably somewhere in between. Although maybe that means I'm an expert now... hm, nope.

3
trpcicm•

If you're doing web development, look into the Google Web Toolkit. It lets you write all your code in Java, and basically converts it into JavaScript for you, and does a pretty good job of it too. The only downside I've ever run into (when I used to use it for work), was that at the time it was using a pretty old version of Java.

-1
amnezia•

how is that helpful? He doesn't know Java and hes developing in Java not JavaScript..

2
Wiseman1024•

Start with:

new QuestionAsker(QuestionMaker.getInstance(new QuestionWrapper(new Question("I am moving into a development position at my company and need to learn Java. Can you recommend a book that might appeal to a Python programmer and not make me want to kill myself?")))).askIndeed()
11
zekelOPtornado, beautifulsoup, web.py•

Where's the exception handling?

2
meltingwax•

Not to mention your line exceeds 80 characters, which is the industry standard's limit.

2
[deleted]•

http://www.leepoint.net/notes-java/index.html

Taught me all the basics of java.

10
[deleted]•

Ye gods, that's an ugly website.

0
iamnotaclown•

It's not as bad now that it has generics and collections. Eclipse is a godsend, since most of your pain will come from looking up API calls.

9
tofergregg•

I agree that Java isn't as bad as you think it will be. The language itself has a few quirks, but it is rather straightforward, and if you understand classes and inheritance well enough, you'll figure it out. Two tips:

  1. Bookmark the API reference now. For J2SE 5.0, it's here: http://java.sun.com/j2se/1.5.0/docs/api/

  2. Get used to Googling for code examples. There are about a zillion examples out there.

6
Leonidas_from_XIV•

It is not because the language is hard, it's because the language lacks about any advanced features and forces people to do stupid workarounds, "to help them not to shoot in their feet" or something.

3
masklinn•

It's not as bad now that it has generics and collections.

But the generics suck, and the collections don't have literal syntax (yeah you can approach it with anonymous classes tricks, but it's not exactly sexy), plus you need heavy libs (google collections) to use them non-imperatively.

Eclipse is a godsend, since most of your pain will come from looking up API calls.

I strongly preferred IntelliJ IDEA when I was coding in Java, though.

5
teaguesterling•

I Second that, using Eclipse makes Java quite a bit more bearable. Along with Google and Sun's reference you can do pretty well.

0
oneP•

Head First Java, but amazon's probably cheaper.

4
zekelOPtornado, beautifulsoup, web.py•

I took a peak at that in the bookstore. It looked littered with the 'for dummies' style. Pictures of giraffes and stuff...

1
namin•

At first sight, I also thought 'Head First ...' was just O'Reilly's '... For Dummies', but no! I can't speak for Head First Java, but I read Head First Design Patterns, and it's a pretty serious and insightful book in a very digestible format.

2
oneP•

Honestly, I don't feel the for dummies style at all. They explain in the preface that that they write the way they do in order to teach you the material and so that you retain the material with out having to put forth the effort to try to retain it. I like it. I would suggest giving it a try. If it's not for you, then it's not. Otherwise, it creates an atmosphere where minimal effort yields maximum retention, and who can argue with that?

2
naturalethic•

Some years ago I got one of my best friends, a very intelligent Java guy, to join the company I worked at and write web software in Python. He hated it. I've since left, but he now heads all development there, having converted the whole place to Java, and he loves it. So it is possible to have fun web programming in Java. Embrace the challenge if you must. You'll likely get something out of it.

4
mipadi•

Look at the hell you've wreaked upon that company!

7
Wiseman1024•

a very intelligent Java guy, to join the company I worked at and write web software in Python. He hated it.

So I take a very intelligent Java guy is still below average as a Python guy? :)

2
Poromenos•

I wish you hadn't added the method call...

3
frumious•

Maybe you can sneak by using jython.

3
zekelOPtornado, beautifulsoup, web.py•

It might make a good April Fool's, but I have to work on the same code base as my co-workers, so I can't dictate language or tools. Unfortunately.

4
rerb•

Java hurts. Thinking in Java, by Bruce Eckel is written well, by an intelligent man (who apparently prefers Python now). The 3rd edition is available for free, so you can check that out w/little risk. http://www.mindview.net/Books/TIJ/

2
mipadi•

For a second, I thought you were indicating there was a book called Java Hurts.

Come to think of it, that'd be a great title for a Java book...

7
namin•

I can't stand the verbosity of this book.

1
snookums•

Can you use Groovy? It'd be an easier jump for a pythonista.

2
epicRelic•

Jython would probably be better.

6
amnezia•

Read up on design patterns, i can bare just about any language as long as im developing elegant solutions. Frameworks like spring and [hibernate (ORM)](http://en.wikipedia.org/wiki/Hibernate_(Java) are a god send and you should feel comfortable with them coming from a python background.

By the way i'm a hobbyist python programmer who works in Java development, its not half as bad as people make out.

2
zekelOPtornado, beautifulsoup, web.py•

That's great to hear!

2
Wiseman1024•

Read up on design patterns

Instant downmod. Well, at least you're making OP kill himself with the Best Practice™ way. (Which is it BTW? Use the suicidal factory class to get an instance of a SuiciderBroker which uses an instance of SuiciderMethod to allow you to construct a SuiciderAction object to kill yourself? Will you recommend the free fall pattern for that?)

2
amnezia•

you do realize that there are several design patterns that are intrinsically built into python right?

1
Wiseman1024•

More than half of the book "Design Patterns" is bloated crap for "enterprise" and "best practices" software - patterns you're best not using because they lead to bloat in the code, verbosity, harder to use interfaces, and worst of all documentation hell.

Two popular useless patterns are singletons (use globals for globals!) or factory classes (use functions for functions!), but there are other less obviously useless patterns.

The more useful patterns are still a bad idea. First of all, they should occur naturally, without having to pull them from a recipe book, and they shouldn't be crafted more than once. We are not "web designers" copypasting JavaScript snippets. Programming is not about copypasta; it's about abstraction. As such, the programming language we use should be powerful enough to offer the abstraction capabilities to abstract any design pattern as a function.

Python is generally capable of abstracting such design patterns into functions since it features first-class functions, first-class classes, and closures. We don't need copypasta, and we don't even need to read Design Patterns to work properly. Once a pattern is obviously useful and repeats through the code, you need to abstract it with functions, just like you abstract blocks of functionality which repeat through your code.

The language is not free of design warts, however, such as the defect known as "statements" inherited from terrible languages such as Fortran. Because of them, and because of its syntax, but most importantly because of Guido's stubborn opposition to functional programming, Python doesn't have expression defs or statement-capable lambdas. Because of this, decorating functions would have been clumsy, so instead of fixing the underlying design and syntax problems, Guido added a Perlish hack known as the decorator feature ("@").

2
Wiseman1024•

The language will make you want to kill yourself. Better find yourself a good window.

2
zekelOPtornado, beautifulsoup, web.py•

It appears they already had and addressed this problem, as the windows and balconies are all sealed.

2
namin•

I recommend Java in a Nutshell. The first part of the book is an excellent concise introduction to Java as a second language.

Sun's Java tutorial respectably taught many of the early adopters how to program in Java.

1
zekelOPtornado, beautifulsoup, web.py•

Can you recommend to me the best 800 or so pages of Java in a Nutshell? I don't want to read too much unnecessarily, maybe I can just skim the other ~450 pages?

2
[deleted]•

I like your honesty.

0
zekelOPtornado, beautifulsoup, web.py•

Why thank you, you have good taste.

2
[deleted]•

[deleted]

0