
How should I learn Java Web Development? - amirexdev
I am a freelance developer doing most of my work with Laravel (PHP). However, I want to branch out and learn Java, primarily in the context of web development.<p>My main question is this. What would you say is unique to Java web development that I should focus on as I learn?<p>I understand that syntax is easily picked up, and design patterns can be translated from one language to another. But are there special paradigms that make Java development different than a language like PHP, Ruby, and Python?<p>In other words, what&#x27;s the 20 % investment that will get me 80% return to become a professional Java web developer?
======
wrmsr
Java is much heavier weight [1] than languages like PHP and Python, and that’s
not at all a bad thing - it just changes what the language is used for [2] and
what’s normal within it. As such the threshold for overengineering is
significantly higher than in most other languages. Dependency injection for
example is something that in the small looks like needless complexity but when
used well [3] makes things that would be realistically impossible without it
easy and routine.

Java is a very dumb language, and that’s also not at all a bad thing. What we
get from this dumbness is best-in-class tooling. I don't think I have to say
it but pick one of the 3 major IDE’s: IntelliJ, Eclipse, or NetBeans. If you
have no preference IJ tends to be the modern (and my) favorite. I frankly
switched from years of emacs to PyCharm for even my dynalang stuff due to the
quality. Java lacks [4][5] many of the powerful and dynamic features of other
languages like eval, code execution during class definition, the ability to
flat lie to the type checker, et cetera. In return we have an ecosystem of
tools that can nearly perfectly understand the intent of code statically -
things beyond simple templated code generation like 'go to definition’ and
'find all references’ work so well that automatic refactoring can usually be
done fearlessly. The downside of this is that I’ve yet to see a code review
system that can gracefully handle the giant diffs these tend to create, but
the end result has a vastly higher chance of success than for more expressive
languages, and it’s better than the alternative of accumulating technical debt
(and hey, nothing’s perfect :). Similarly get used to using the debugger. You
basically never have to resort to 'printf debugging’ in Java due to the high
quality tooling. To learn a codebase set breakpoints and poke around.

To your 80%/20% question: in my opinion Java’s killer feature is its unbeaten
ease at handling vast codebases, which unfortunately presents a barrier to
short-term entry. I think I’d say look for a Java-only library that interests
you and put a web interface on it. Due in part to Hadoop there are lots of
Java-only (or effectively so as a result of shoddy ports) systems that deserve
an HTTP wrapper so other languages can access them (a colleague of mine wrote
one for Kafka a while back as an example, and frankly things like
Elasticsearch and Solr are basically this for Lucene). This will get you into
exploring and getting familiar with not only the library you wrap but the
webserver (like Jetty) or framework you choose. Due to its tooling I find
learning large Java codebases easier than those of any other language [6] and
as above to me that’s what Java is 'for’.

[1] HotSpot more or less expects to be able to use all of its host’s cores,
which somewhat clashes with modern container-centric ecosystem. Containers
have always meant less to Java though as it’s had things like jar shading,
internal access control, and classloader isolation for many years. OSGi for
example has been capable of similar multitenancy through these features.
That's not to say docker isn't still remarkably useful to Java development, it
just tends to be less ‘amazing’ in the context.

[2] The amount time it takes to build a simple CRUD site will likely be higher
than in, say, Rails (although it’s getting better all the time), but many of
the things a growing site winds up talking to (Elasticsearch, Cassandra,
ZooKeeper, et cetera) are implemented in Java. Different tools and all that.
I’m not discouraging its use for even smaller projects but it does tend to be
more of an up-front investment than a lighter language all else equal.

[3] As a Guice fan I recommend checking out the Presto codebase (
[https://github.com/prestodb/presto](https://github.com/prestodb/presto) ) -
lovely and extensive (perhaps a tad too much :) use of Guice, and
extraordinarily high quality codebase in general. I’ve never used much of
Spring[Boot] myself but as with Java in general many of the criticisms aimed
at it are many years out of date and irrelevant.

[4] All of these things are ~possible~, just (as usual :) more involved and
verbose than in many other languages, and more importantly extremely non-
idiomatic (or at least considered 'big guns’). As an example in lieu of eval
many systems leverage runtime bytecode generation to do things like building
object proxies and computation pipelines at boot or on user input. HotSpot
dutifully jits, optimizes, profiles, and inlines this with 'normal’ code
resulting in usually impressive performance, but it also involves jumping
through a lot of hoops to make it work right as the vm spec mandates fairly
strict requirements.

[5] Notable though is Java’s extensive use of annotations - they’re used to
communicate to both tools and people (though primarily the former), and you
can stick them nearly anywhere. Annotations themselves do absolutely nothing -
they exist purely as introspectable markers (not to be confused with similar
looking Python decorators). Tools like serialization libraries, web
frameworks, dependency injection systems, and thread safety analyzers scan for
these and do things with them as they please. A lot tends to happen at boot
and during warmup in Java systems both in the app code and in the vm, and much
of it is powered by these otherwise-do-nothing purely-for-reflection
annotations.

[6] The only other equal to me is C#, which is basically Microsoft Java. There
are numerous differences (mostly more advanced static language features at the
expense of a dumber runtime - .NET has F# but Java has Nashorn and Graal) but
they share the spirit of dumb but extremely toolable 'heavy’ languages. I
haven't touched Mono in quite a while though so I can’t comment on its modern
usability.

~~~
amirexdev
Wow, thanks for your reply. That's exactly what I was looking for. I know
there are IDE's for PHP, Ruby, and Python, but it seems for Java it's
practically a requirement.

As I've been researching, it seems to me like newer versions PHP has borrowed
a lot of ideas from Java, which has made PHP better.

Thanks for the detailed reply, and I will definitely do some of those ideas.

