5 ms·
Having recently kind of abandoned golang for Java, I've got to say I love the richness of the Spring ecosystem.
by nprateem 3y ago
Having recently kind of abandoned golang for Java, I've got to say I love the richness of the Spring ecosystem.
- lbhdc 3y agoWhat made you switch?
- nprateem 3y agoI want to create a load of rapid prototypes. With Go it seemed I was wading through treacle just to create a DB-backed REST server that basically just permitted CRUD on the DB with some extra business logic. With Spring, you just declare a model object and it can infer a data repository with a ton of convention-named query methods, so the number you actually have to write is far fewer. Spring is used by so many people there are loads of good libraries. E.g. I'm just adding permissions, and without needing to hunt around for a compatible library or litter my code with conditionals, it's pretty easy to use Spring Security to configure sane permissions with annotations. With Lombok there's no need to write the garbage you used to have to (loads of getters, setters, etc.) so the code is quite clean. Annotations also simplify DTOs with mappers - in Go I had this triplicate of model struct, DTO and mapper. Maybe there was a library I could have used to help, but the faff around setting up the DB (e.g writing SQL, configuring an ORM), updating DTOs and mappers was just crippling my velocity. Plus, for hiring, there are tons of Java devs around the world, while for Go rates are much higher. So yeah, several factors.
- lbhdc 3y agoThanks for sharing :)
- joncfoo 3y agoHave you come across sqlc? https://docs.sqlc.dev/en/stable/ https://docs.sqlc.dev/en/stable/ It gets rid of the crufty parts of DB interaction with Go.
- nprateem 3y agoI did, but didn't end up trying it. Being able to hire a Spring dev for $10 p/h vs several times that for a golang dev (plus time learning a particular codebase) just means it doesn't make sense to use Go if you want to outsource in future. I plan to run multiple experiments in parallel, keep working the day job and outsource the ones that take off. So the more standardised I can make the tech stack, the faster and cheaper dev work will be.
- sgt 3y agoBeing able to hire a decent Spring (or any good developer) at $10 p/h is HIGHLY theoretical.
- nprateem 3y agoAny with any sense will be using chatgpt anyway. It's how I've written most of it. And it's easier to just add to a working project than set one up. But yeah, we'll see...
- victor106 3y ago$10 p/h ? are you joking? if you can find good (I don't want really great) Spring devs for under $80.00 p/h let me know. You can hire at that rate and everyone I hired had faked their experience and could get through the interview but did a terrible job. So we ended up firing everyone and had 3 devs for above $110 p/h that were truly awesome who got the job done.
- nprateem 3y agoYeah I'll see how it goes. Tbh at the moment I expect those bottom end devs are worse than just using chatgpt directly. I'll probably have to spend more time explaining to them what I want. Once IDE plugins can scan the majority of a codebase it'll be easier to just write a bulleted set of requirements and let it get on with it. But anyway I was talking to a friend who's hired some great Ukrainians quite cheaply and I hear there are some good devs in the Philippines.
- nme01 3y agoPossible that I was using Spring in a wrong fashion but for me (project size around 300 KLOC) Spring dependency injection model with so much magic happening (all the auto configurations, guessing which classes to load etc.) was extremely hard to maintain and understand. I think I prefer Guice/Dagger style of defining dependencies which is much more explicit.
- dtech 3y agoIt's a fair point, although you can set it up to only do explicit defined dependencies which I definitely recommend.
- crdrost 3y agoWe had a similar sized project grow out of a 2-pizza-team and had the same problems. Kinda like how Java devs come to JavaScript and are shocked that this language doesn't have proper numerical types, I came to the Java ecosystem and was shocked that everything pivotally hinged on whether you had the right magic beans and especially if you had different beans vying to be the same sort of magic it was awful. My favorite bug we ran into was a short little RedisConfig.java file that got copy-pasted into a bunch of our microservices in the test environment. It appeared on a very casual glance to connect to Redis. But our tests did not run a Redis instance, so the configuration should have failed. Instead if you looked carefully at this file you could determine that the connection string was all broken but that didn't matter because it never implemented the Redis Connection Bean logic anyway and in fact you could replace it with a purely empty class and tests still pass. But, tests break when you delete this unused file, the file needs to exist even if it is the empty `class RedisConfig {}`, because now tests are trying to connect to a nonexistent Redis and not succeeding. Same if you try to rename it to like `class RedisTestConfig {}`, suddenly tests want to reconnect to Redis and they all break!! So, everyone has more important things to do, it gets copied to everyone, nobody understands what on earth it is doing since the code inside the file is clearly broken. Eventually, we start experimenting with Kotlin. When you copy this pattern over to the Kotlin repo, it starts to complain VERY loudly that you have two objects with the same name in the same namespace and it won't start because it is too confused. And that was the key hint. As far as Spring was concerned, this file, because it has the same class name in the same namespace, basically string-replaces that file. (Nondeterministically? Or maybe it was deterministic that "test" won over "main" because it was lexicographically larger?) So we were string-replacing to a RedisConfig that could never be used as a Redis configuration bean, which causes Spring's Redis Cache logic to say "oh I have no configuration, I should assume that I am unneeded", which disables Redis. But if you rename it, then Spring Redis says "oh I see two things, I can't use that one but I can use this one, let's connect to Redis with that. oh no!! Redis is DOWN!~ crash all the tests!!"
- ye-olde-sysrq 3y agoOne thing that bothers me about Spring is how it manages to use so much off-heap. I used it initially for a small project (hobby-tier) and was shocked to find it was using 200-300MB of offheap (or something in that range). To where my poor 1GB RAM digital ocean VPS was 20-30% just random Spring offheap crap. I ported my handlers from Spring to just using netty and their provided HTTP codecs (and I wrote my own http router implementation which was fun but also wish there was an easy one to just use, I didn't see anything I liked when I looked) and suddenly offheap was ~0 and I could've easily crammed 100 of these into this tiny VPS. (Not that I planned to, but I did want to use this VPS for other things too). I know "300MB offheap" is not something Spring will care about when they're probably normally running on giant ec2 instances, but for my case, while I would've liked to use the "django/rails but for java"-type tool, it did actually end up being too heavy in the most-constrained vector of cloud hosting (RAM).
- imtringued 3y agoI am sorry but RAM is the least constrained vector of cloud hosting. I have apps that need to do video encoding in real time with 100ms latency and those are always bottlenecked on CPUs. I have a micronaut app that uses around 350MB which is almost entirely JVM overhead.
- nunobrito 3y agoOf course that all depends on the context, for my cases I'll certainly keep my distance from either Spring or JBoss. Prefer to build faster apps with Java.
- frant-hartm 3y agoNot sure what you did wrong. You can easily fit whole spring web app including support for jpa and what not into 300 MB heap/native together.
- throwaway45391 3y agoI'm not an expert, but I think the memory used is not necessarily the memory it requires. I think Java tends to grow memory usage up to a point, rather than to try and release it at the cost of performance. That doesn't mean it would not be able to run on a machine with lower memory. It could run more expensive GC if it was needed
- sgt 3y agoWhat is wrong with Go?
- kaba0 3y agoThat it has the expressivity of Java.. from 20 years ago.
- sgt 3y agoIn theory it's a good Python alternative if you want more speed. But having done a bit of Go, I tend to agree. Developing in Go can be frustrating. Java these days is however looking much better.
- bern4444 3y agoit should have been named stop cause you have to stop at every function call to check for an error.
- mikro2nd 3y agoRealy? I saw "Spring", suddenly acquired a skin rash, and swore I'd never look at this again...