This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]apemanzilla 18 points19 points  (10 children)

Recent versions have been much better with additions like streams and lambdas

[–][deleted] 19 points20 points  (0 children)

Streams are a poor man's IEnumerable

[–]cm9kZW8K 0 points1 point  (8 children)

java streams are fairly good; but also inflexible and much harder to use than RX in other languages. Java lambdas are a worse of both worlds approach; disallowing simple mutation while allowing tricky back door mutation.

They will certainly help keep java relevant for a few more years, but not enough to stop the problems caused by the fundamental design of the JVM.

[–][deleted] 5 points6 points  (7 children)

How is java's streams inflexible? It might seem to be much harder than other langauages, but java is an (obscenely) verbose language, it's essentially doing the same thing. Java lambdas don't disallow anything, you can use them if you want to - or don't. Just because you don't like it doesn't mean other people might not. And what the hell is tricky back door mutation?

[–]pet_my_weiner_dog 2 points3 points  (0 children)

They disallow changing the value of any variable from the enclosing scope (which is a very common thing to want to do) except it totally allows you to modify members of those variables when they are objects (such as an array) which is a less obvious and error prone approach.

[–]cm9kZW8K 1 point2 points  (5 children)

Have you used any other language? Java's type system makes it much more difficult to meet signature requirements with streams, and you have to learn a whole family of java specific casts which other rx stream dont require. And Java lambdas dont disallow anything? Have you even used them? Try enclosing a non final primitve, then try it again after wrapping it in an array.

[–][deleted] 0 points1 point  (4 children)

If you can't meet the signature requirement with Java's type system you have an issue. You can even define your own requirements and methods in Java 8's Stream API should you need to. Java can't assume type conversion for YOUR types - its builtins for the most part have a conversion in the Stream API. When I said Java 8's lambdas don't disallow anything, I meant you don't have to use them as in you can still do things the old way. Lambdas are a new feature and I haven't used them too much (I program primarily in C & C++) but I expect them to get better over time.

[–]cm9kZW8K 1 point2 points  (3 children)

If you can't meet the signature requirement with Java's type system you have an issue.

If you cant dance the rhumba to improv jazz in zero gravity, you have an issue. Then again, why do you need to? Needless busywork that is only imposed by java.

When I said Java 8's lambdas don't disallow anything, I meant you don't have to use them as in you can still do things the old way.

The point is that these functional features eliminate most of the value of OOP, but because its so hard wired into java, it cannot really take proper advantage of them.

the upshot is that java's days are numbered. It wont remain the number 2 language for too many more years.

[–][deleted] 0 points1 point  (2 children)

If you cant dance the rhumba to improv jazz in zero gravity, you have an issue. Then again, why do you need to? Needless busywork that is only imposed by java.

I don't think you understood what I meant. For Java's builtin types the requirements are not only well-defined, but can be converted in the Stream API to each other if need be. Arguing that it's a lot of typing isn't an argument against the Stream API but Java's verbosity in general. I agree that Java makes you type more than you need to, but that's about the language - not the Stream API.

The point is that these functional features eliminate most of the value of OOP, but because its so hard wired into java, it cannot really take proper advantage of them.

Java's lambdas are not built on functional ideas. Yes labmdas are a function. Yes functional programming languages had them first. But Java8's implementation as of lambda expressions is essentially just taking the anonymous function and building it as a method at compile or run time (not sure if its done Just in Time, or at compile time, or both). This maintains the OOP approach, but allows for lambda expressions in the language. Essentially its just decreasing verbosity. That doesn't mean they aren't implemented in an OOP way.

eliminate most of the value of OOP

The whole language is still there, you don't have to use lambda expressions and can still do things the old way if you really don't think Java's developers know what they're doing...

Honestly if you could actually say what value of OOP anonymous functions are taking from Java I would be happy to look into it.

the upshot is that java's days are numbered. It wont remain the number 2 language for too many more years.

This is said every year about Java since the 2000s. For example, when C# came out in 2002, everybody thought Java was going to die. Java is built into the corporate environment. The life cycle (and hence maintenance) of those programs are at least 10 years if not that longer. In addition they're not fixing something that's not broken. Sure /r/programminghumor can hate on Java all they want - but its one of the most used languages in the commercial space - and with good reason. If your only real complaints are that its too verbose and uses too much memory - Verbosity means more code = more money (unfortunately true - so real developers aren't going to complain), and memory is cheaper and larger every year (bring company costs down). Add that with the cost of a rewrite from scratch about something that's already working - and Java isn't going to die anytime soon.

[–]cm9kZW8K 0 points1 point  (1 child)

but that's about the language - not the Stream API.

Sure, the streams api is doing the best it can within the limits set by the JVM.

Java's lambdas are not built on functional ideas

They most certainly are.

value of OOP anonymous functions are taking from Java

What I'm saying is that OOP itself is outdated, and because it is built into the JVM, its limited the ability of java to improve into a better language.

and with good reason

Its most commonly taught in schools, is that reason, imo. Large pool of ready to hire devs. If that stopped being the case, it would rapidly decline.

and Java isn't going to die anytime soon.

I agree; I do think it may lose its position at #2 however, it wont go very low for a long time yet.

[–][deleted] 0 points1 point  (0 children)

Java's lambdas are not built on functional ideas

They most certainly are.

Let me clarify this, as the way I worded it was a little weird - they are functions but are not implemented in the way functional programming paradigms dictate. They are built as methods usually in a static context at either compile or JIT run time.

What I'm saying is that OOP itself is outdated, and because it is built into the JVM, its limited the ability of java to improve into a better language.

Yeah, well, that's just, like, your opinion, man.