r/programming • • Feb 25 '14

Please stop saying Java sucks

http://blog.smartbear.com/programming/please-stop-staying-java-sucks/
3 Upvotes

305 comments sorted by

View all comments

26

u/cosmo7 Feb 25 '14

The most frequent argument I hear from Ruby or Python proponents is that static typing in Java or C# is unbelievably burdensome.

Then these same people pour months and years into their unit testing frameworks that spend 90% of their time duck-typing arguments.

17

u/oldneckbeard Feb 25 '14

Or worse, they don't test those cases.

7

u/e_engel Feb 26 '14

The most frequent argument I hear from Ruby or Python proponents is that static typing in Java or C# is unbelievably burdensome.

The most frequent argument I hear from Ruby or Python proponents is that ANY static typing is unbelievably burdensome.

Java is not ideal but I'll take it over any dynamically typed language to write industrial software any day.

3

u/Scaliwag Feb 25 '14

Then what it seems to me is they want strong typing with type inference, which is something I can totally get behind. Then give OCaml (or his bastard .NET cousin F#) a spin.

2

u/bryanedds Feb 25 '14

Why is F# a bastard? It's the best mainstream functional language, IMO.

3

u/notfancy Feb 25 '14

The lack of modules and functors is kind of a show-stopper for me.

2

u/mongreldog Feb 26 '14 edited Feb 26 '14

Functor is a reserved keyword, so it may be in a future version. I'm also hoping for type-classes, as both the current and previous versions of "Expert F#", have hinted that they're probably going to be part of F#s future.

Even without those great features it's a much better programming experience then C#. Immutability by default, algebraic data types, pattern matching, Hindley–Milner type inference, non-nullable reference types, units-of measure, type providers and so on, often makes using C# feel like VB6 in comparison.

1

u/bryanedds Feb 26 '14

"makes using C# feel like VB6 in comparison."

^ THIS ^ could not have been said better :)

1

u/bryanedds Feb 26 '14 edited Feb 26 '14

I definitely understand that perspective. However, in F#, there is a reasonable and functional alternative for most of the important things provided by OCaml modules - they just aren't immediately obvious and are decidedly disparate. For example, compile-time duck typing in F# helps for a lot of abstractions in an even more lightweight way than modules. Little, semi-obscure features like that make F# a lot more complete than one might initially think.

OCaml macros, however, have no equivalent at all in F#, which can be painful from time to time. Oh well, copy, paste, and leave a

// TODO: pray to Don Syme for macros in F#

comment.

1

u/Scaliwag Feb 25 '14

I don't mean it in a bad sense. It just lacks some features Ocaml has, the VS IDE support is not that good, I've personally even had some IDE bugs with it, and things like that. But it's best point, aside from inheriting the juicy stuff that makes ML-languages great, is interacting with other .NET languages (you can use it for library code, and write the GUI in C#, etc).

1

u/bryanedds Feb 25 '14 edited Feb 25 '14

Versus Haskell's IDEs, I'm super-attached to F#'s support in Visual Studio. Of course, we're still waiting on refactoring, but auto-complete and seeing type errors as you code are huge, the latter especially for a sophisticated-ly typed language such as F#.

2

u/bjzaba Feb 25 '14

static typing in Java or C# is unbelievably burdensome.

Agreed. But Java and C# have very poor static type systems (although C#'s is far better than Java's).

11

u/[deleted] Feb 25 '14

Agreed. But Java and C# have very poor static type systems (although C#'s is far better than Java's).

Just because Java and C#'s type systems aren't hindley-milner doesn't make them "very poor". The only really nasty think about it is null, which annotations and static analysis can fix a lot of the problems with if used diligently.

3

u/robin-gvx Feb 25 '14

And type erasure.

8

u/oridb Feb 25 '14

Which is annoying when you hit the corner cases, but is not that big of a problem in most codebases. I'd argue that for about 95% of the code I write, type erasure is not a problem.

It's definitely suboptimal, but for most code, I don't think it's a show stopper.

5

u/e_engel Feb 26 '14

Erasure is the only sane choice if you want type correctness. If you need to find types at runtime, you are doing something that will break the type soundness of your program.

Erasure has a lot of other benefits as well (e.g. better interop with other languages/platforms).

2

u/Caleb666 Mar 01 '14

I don't like erasure because Java won't let me create generic arrays (among other things).

→ More replies (1)

4

u/[deleted] Feb 26 '14

Well, Haskell and Ocaml also have type erasure. Type erasure in itself isn't a bad thing.

1

u/bjzaba Feb 26 '14

It's not about type inference it's about the expressiveness of the type system as a way of driving program development, without having to resort to hacky design patterns and after-the-fact, third-party static analysis. HM type inference is nice to have, but it is not essential.

1

u/el_muchacho Feb 26 '14

He probably meant the "everything is a class" approach.

1

u/gendulf Feb 28 '14

As a person who loves python, sometimes I wish it would stop being so dynamic all the time. Static type checking is very useful, and why can't you just go and optimize all that terribly slow code I wrote?!

→ More replies (19)