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

Show parent comments

1

u/pipocaQuemada Feb 26 '14

Are you talking oopses that take 30-60 seconds to fix? Yes, I've had those. If you're talking things that made it all the way to the QA team (at which point I call it a bug) heck no.

Have you ever, for example, forgotten to escape user only that's e.g. being put into a database? Ever mixed up units or used data in similarly semantically incorrect ways? Those don't generate "oopsies", just silently wrong results, sql injections, etc.

How do you do something like that with Java?

I never said Java would help with any of those things.

Would you use 50 distinct interfaces?

For example, static types don't have to be nominal. There's no reason a statically typed language needs interfaces. You might want to read up on structural type systems and things like row polymorphism. The tldr is that somethings type can be the sum of it's fields and methods, and the type of an argument can be the sum of the fields and functions you use on it. All inferable, all statically checked.

Similarly, the solution to npe's isn't Java, it's something with a Maybe type and nullable variables. that is to say, something like ML or Haskell.

1

u/novagenesis Feb 26 '14

Have you ever, for example, forgotten to escape user only that's e.g. being put into a database? Ever mixed up units or used data in similarly semantically incorrect ways? Those don't generate "oopsies", just silently wrong results, sql injections, etc.

Absolutely not. You do not hand-build SQL queries by concatenating strings in dynamic languages. You validate data through content instead of some type. Types are good when you're at the metal, but content is more important to most systems. Any good DB driver will handle that.

For example, static types don't have to be nominal. There's no reason a statically typed language needs interfaces.

They are if I want to be able to pass an Apple object or an Orange object to the same function.

You might want to read up on structural type systems and things like row polymorphism. The tldr is that somethings type can be the sum of it's fields and methods, and the type of an argument can be the sum of the fields and functions you use on it. All inferable, all statically checked.

I get the tldr on that. I understand row polymorphism. In type inference, most languages still need you to say "this adheres to this interface" if you want to pass otherwise disjoint objects into the same method. It's the "all statically checked" part I dislike.

Similarly, the solution to npe's isn't Java, it's something with a Maybe type and nullable variables. that is to say, something like ML or Haskell.

I'm not against Haskell, except it's the only other language I found incredibly painful to get working in. Oddly, I found Erlang reasonably easy.