7 ms·
> Basically your objects are data-only, so there's no benefit. This makes me wonder why most of us use Java at all. In your typical web app project, classes ju
by ejflick 10mo ago
> Basically your objects are data-only, so there's no benefit.
This makes me wonder why most of us use Java at all. In your typical web app project, classes just feel like either:
1) Data structures. This I suspect is a result of ORM's not really being ORM's but actually "Structural Relational Mappers".
- or -
2) Namespaces to dump functions. These are your run-of-the-mill "utils" classes or "service" classes, etc.
The more I work in Java, the more I feel friction between the language, its identity(OO beginning to incorporate functional ideas), and how people write in it.
- marcosdumay 10mo ago> why most of us use Java at all Java was the first popular language to push static analysis for correctness. It was the "if it compiles, it runs" language of its day, what meant that managers could hire a couple of bad developers by mistake and it wouldn't destroy the entire team's productivity. I'm not sure that position lasted for even 5 years. But it had a very unique and relevant value proposition at the time.
- javcasas 10mo agoOCaml would like to have a word with you. In 2005 it already had better static analysis and correctness on object oriented stuff than what Java struggles to approach today. But Java has better marketing.
- marcosdumay 10mo agoJava is from 1996... It got really useful by 1998.
- javcasas 10mo agoOCaml is also from 1996. And I say 2005 because that's when I started using it, not when it started being useful. By that time it supported parametric generics, multiple inheritance, named parameters, optionals instead of nulls everywhere, compile to machine code and quite a few extra things that I couldn't understand at the time.
- morshu9001 10mo agoJava is a waste of time for the reasons you said. People use it for legacy reasons. Back then, the alternatives like JS just weren't there yet in several spaces like backend. Your alternatives were even more cumbersome like C++.
- jpnc 10mo ago> People use it for legacy reasons This is so incredibly wrong it must be a troll.
- vips7L 10mo agoService classes are the thing I hate most. They’re just namespaces for functions. They’re a product of Java not being able to have top level functions.
- elric 10mo agoNot being able to have top level functions is a feature, not a bug. You can declare static methods on interfaces in Java, which means you could call things like Users.create("Foobar") if you wanted to.
- vips7L 10mo agoIt is not a feature. Every programming language since has decided this was a mistake.
- elric 10mo agoCan you provide an example of that?
- fmjrey 10mo agoHere is an example of a 2006 rant that qualifies: https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html https://steve-yegge.blogspot.com/2006/03/execution-in-kingdo... OO conflates many different aspects that are often orthogonal but have been conflated together opportunistically rather than by sound rigor. Clearly most languages allow for functions outside classes. It's clearly the case today especially with FP gaining momentum, but it's also clear back then when Java and the JVM were created. I think smalltalk was the only other language that had this limitation. Like others in this thread, I can only recommend the big OOPS video: https://youtu.be/wo84LFzx5nI https://youtu.be/wo84LFzx5nI
- javcasas 10mo agoNot everything can be associated to a single entity. Many operations work on two or more entities where none of them are the "master". Otherwise you end up with "coordinators". Users.create(...) is the easy case. Try transfer_permissions(user1, user2, entity) while retaining transactionality and the ability of either user to cancel the transfer.
- elric 10mo agoA lot of that is down to how people rely on frameworks that force them into "convenient" abstractions. Like Spring and Hibernate. But those are not the language. They represent a (vocal) subset of programmers. You don't need an ORM or an overgrown dependency injection framework to create a webapp in Java.
- 21asdffdsa12 10mo agoYou are so ready : https://fsharpforfunandprofit.com/rop/ https://fsharpforfunandprofit.com/rop/ The separation of functions and records..
- ejflick 10mo agoI've read his book "Domain Modeling Made Functional" without much prior knowledge of F#. He provides some compelling examples and some of it ended up inspiring how I write OO code. F# seems cool but it felt like it was close to being extinct.
- vips7L 10mo agoHonestly one of the best books I've read about programming. It's inspired me to try the language out just for fun things, think I'm going to use it for Advent of Code this year. I think it does benefit from being interoperable with C# so you can use it where it makes sense and still have C# to fall back on. Kind of like Scala/Kotlin with Java.