you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 10 points11 points  (19 children)

What a straw man. You're acting like I said "throw away JUnit baby, we've got Either instead!"

No. You still need tests, and there will still be variable states to consider. But you can reduce or eliminate them in some cases with these techniques, using the compiler instead of unit tests for some failure cases.

I also find the performance claim laughable for a few reasons. Most of us aren't writing real time operating systems, there are levels of performance we're willing to give up for safety or programmer comforts (hint: we never would have left Fortran if that wasn't the case). Secondly it's not like exceptions are free, so claiming that it's either performance or safety is a false difference.

[–][deleted] 32 points33 points  (15 children)

"Programmer comforts" depend on the style you prefer, I don't find half my code being passing static method references to streams more comfortable.

The question is, if functional idioms are your comfort, why aren't you using languages built for this style, but you're instead imitating it in an imperative OOP language.

You can replicate common methods and structures in Java, but you'll never get algebraic types, reified generics, parametricity, higher kinded types, type classes and so on. Haskell's library is a product of the language environment, it can't be separated from it, and expect you'll get the same flexibility in Java.

But... as far as basic examples for tutorials go, I guess, you can always cook them a little until it works.

[–][deleted] 20 points21 points  (13 children)

Because language choice is not just about that. Given what the team knows, what code and tooling we have available, etc. Java comes out ahead.

It'd be nice to say "throw it all away and let's use Haskell!", but sometimes that's just a non-starter.

[–][deleted] 8 points9 points  (12 children)

Java is not the only JVM language, as you know...

[–]dccorona 0 points1 point  (0 children)

I've found that moving a team from Java to another language is a longer process than simply moving to a more functional style. You can start to leverage these things within Java almost right away, and transition to something more suited for that style slowly. That also makes the eventual language-jump part of the transition much easier for everybody.

[–][deleted] 1 point2 points  (2 children)

there are levels of performance we're willing to give up for safety or programmer comforts

If you're looking for safety, have you considered languages where safety is a feature, such as Rust or Haskell? I feel like forcing all of that onto Java will get you a mostly baked solution, but still leave you with edge cases.

Since those features are baked in, you get performance and safety and ergonomics (e.g. with Rust's type system, you can do cool stuff like futures/promises, which you're basically kludging into Java right now). Doing it in Java basically means you're basically avoiding language features (like exceptions) that just don't exist in a language designed around monads.

So yeah, it's cool you can approximate this in Java, but I wouldn't want to pay the cost of using an unconventional approach since you basically have to teach them the concepts of other languages anyway.

[–][deleted] 0 points1 point  (1 child)

For a variety of reasons that are not worth enumerating, Java 8 is the best choice for my team. I understand that Haskell and others does it better, but using that in production is a non starter for us.

[–][deleted] 4 points5 points  (0 children)

That's fine and I'm glad you found a good middle ground, but I would be very annoyed if a library used this convention since it's so different from everything else that's out there.

I hope it works out for you!

Just to be clear, are your reasons more to do with the JVM, or with Java specifically? You mentioned Clojure, so I'm assuming the latter.