4 ms·
> A lot must have happened since then. Yes. As others have said, 'java is stable' which means the old stuff still works. Which in turn means that a lot of peop
by rzwitserloot 6y ago
> A lot must have happened since then.
Yes. As others have said, 'java is stable' which means the old stuff still works. Which in turn means that a lot of people are still using it and still writing blog posts about it. That still makes these old things often obsolete, or needlessly complex and just 'lesser than'. They don't support certain nice features or support them very badly, or have other significant downsides - 25 years of experience does lead to insights, after all.
20 years ago, you loaded your JDBC driver with `Class.forName`. You _STILL_ see this in many examples (and it hasn't been necessary for 15+ years).
These days, you:
* Use a load balancer like hikari
* Consider raw JDBC as basically nuts as far as an API goes, and you use JOOQ or JDBI. Or JPA/Hibernate of course, if you don't want SQL/want DB independence and don't think you'll need to performance-tweak queries too much.
* You use serializable transaction levels and toss _all_ the code that interacts with DBs into a lambda so that the framework can handle retries for you.
And that's just DBs. As a general trend:
Libraries tend to wax and wane. Right now spring is _very_ popular. JSP is the kind of outdated crud that is just a straight up 'do not use this right now' (even if it still kinda works). For date stuff, use java.time. Libraries in general are more focussed on configure-via-java-code, and dip more into code generation and annotations (example: JOOQ). You don't use The JSONObject API, you use jackson or gson. The list is very long.
I have no particular advice on how to know all this stuff as someone not familiar with the (modern) java ecosystem, though. Just pointing out that 'stable' doesn't translate to 'not much new in the past 15 years'.
- scns 6y ago2 of 3 Gson maintaners say: "use Moshi". Source: Jake Wharton (1 of 3 Gson maintainers)
- pabl0rg 6y agoBaeldung has decently up-to-date tutorials. Try kotlin instead of Java, and if you must use java, read the book Effective Java. If you use kotlin, check out ktorm for db access, http4k for http api’s
- sk5t 6y agoBaeldung's content is IMO uniformly quite deficient. If you want examples of how to do things poorly, which examples may or may not compile, or if there's no other alternative, then I guess read the Baeldung article. Try Scala instead of Kotlin, it's much more powerful, and you can safely avoid the mad Scala libraries jam-packed with symbol infix notation.
- deepsun 6y agoWow, thanks for "JOOQ or JDBI"! I'm the perfect case of what you sad re. old devs -- I've been using various JVM languages for ~15 years, but still didn't think of replacing JDBC :) Will check those out!