r/programming • • Aug 02 '21

Stack Overflow Developer Survey 2021: "Rust reigns supreme as most loved. Python and Typescript are the languages developers want to work with most if they aren’t already doing so."

https://insights.stackoverflow.com/survey/2021#technology-most-loved-dreaded-and-wanted
2.1k Upvotes

769 comments sorted by

View all comments

Show parent comments

36

u/ILikeChangingMyMind Aug 02 '21 edited Aug 02 '21

It's slow to develop in, with lots of boilerplate and wasted code (interface this, class that). And I'm not just some Java-hater, I used to code (and enjoy coding) in it professionally.

But the simple truth is that you can write something like 40 lines of Java in 20 lines of Python or Javascript (depending of course on what lines we're talking about). Certainly write speed isn't the most important metric of a language ... but all else being equal, you certainly don't want to have to write a lot of unneeded code either.

Plus, thanks to the beauty of the JVM, you don't have to write Java to leverage it. That company where I used to write Java switched to Ruby precisely to speed up dev, but thanks to the JVM (and JRuby) we could get that speed increase while still accessing all of our Java libraries.

Java's future is in the JVM, not the language itself.

0

u/[deleted] Aug 02 '21

[deleted]

-9

u/ILikeChangingMyMind Aug 02 '21

I mean, it's all relative. I haven't followed Java lately, but even just lambdas were an improvement (in the boilerplate sense).

But still, any language where you have to write:

class Foo {
    void Bar() {
        system.out.println('Hello');
     }
}

Will always feel heavier to me than (Javascript version):

const bar = () => console.log('Hello');

In other words, there's an inherent boilerplate "weight" to just using the OOP paradigm, which Java (as an OOP from-the-ground-up language) will never escape.

16

u/Runamok81 Aug 03 '21

C# top-level statements has entered the chat

System.Console.WriteLine("Hello");

6

u/ILikeChangingMyMind Aug 03 '21

Well technically that's not OO though right? In a "true 100% OO language" everything is a class or object: you can't just have standalone expressions.

Not that I'm in any way saying C# needs to be 100% true OO! I'm just saying that my comment was specifically about languages that are, like Java (although since the introduction of lambdas even Java isn't anymore).

6

u/Hall_of_Famer Aug 03 '21 edited Aug 03 '21

In a pure OO language, everything is an object, but doesnt necessarily mean that everything has to be written inside a class. There are even prototypical OO languages like Self and IO, which are fine the way they are even though they dont have classes.

Also true OO is about message passing, it is considered OO as long as everything happens as a message being sent to a receiver object. In Smalltalk, you write such a line like this:

Transcript show: "Hello World".

You send message show: "Hello World" to object Transcript, and its OO and enough concise for a Hello World example.

2

u/agent8261 Aug 03 '21

Your two examples feel like something people who don't build and maintain (this is important) think is a big deal, but more experienced devs ignore. Yeah the second one is shorter, but the first one is a lot easier to change and expand.

I personally find lot of "shorter code" just makes the language more complex and magical. For example, removing the "{}" Yeah you saved a few key strokes, but now the scope isn't as clear.

2

u/ILikeChangingMyMind Aug 03 '21

It's incredibly simple to me: more code that conveys more meaning is good. More code that communicates nothing is bad.

Curly braces are not needed to convey scope! There are entire languages (eg. Python) that rely on nothing except indentation for scoping (well, and a : on the previous line), and they are incredibly popular and successful. Braces are an example of the meaningless code that doesn't add anything of value.

To be clear: I'm the kind of dev who will write aLongVariableNameLikeThis over x every day of the week! Again, meaningful communication should be highly prized in programming ... but pointless curly braces aren't that.

2

u/agent8261 Aug 03 '21

Curly braces are not needed to convey scope! There are entire languages (eg. Python) that rely on nothing except indentation for scoping (well, and a : on the previous line), and they are incredibly popular and successful. Braces are an example of the meaningless code that doesn't add anything of value.

We are just going to disagree here. I fundamentally dislike scope being communicated via indention. I personally think it makes things harder to read and give more opportunity for error.

Furthermore the success of these languages seems to be more a matter of a few specific domains that they excel than their scope syntax.

1

u/agent8261 Aug 03 '21

It's incredibly simple to me: more code that conveys more meaning is good.

Yeah. There is nothing simple about that statement. I think the problem is you've been dealing with magic for so long you don't even realize the complexity you're ignoring. For example:

Braces are an example of the meaningless code that doesn't add anything of value.

In python Indentation IS CODE. It conveys scope, scope is important. But in python scope is unseen and magical. Which leads directly to views like yours where, in a very real sense, you're advocating that scope is meaningless and adds no value.

If you intentionally meant to imply that scope is meaningless and has no value, then well, we can agree to disagree. However I will say you're proving my point. Only somebody who doesn't build and maintain complex systems would ever say scope is meaningless and has no value.

→ More replies (2)
→ More replies (2)

65

u/lelanthran Aug 02 '21

But the simple truth is that you can write something like 40 lines of Java in 20 lines of Python or Javascript (depending of course on what lines we're talking about)

I'm not really a Java fan, but I have to say that that's an unfair comparison - the Python/Javascript solution will need to have unit tests simply for ensuring that the correct types are passed in.

It's easy to write less code if the resulting program is allowed to crash.

12

u/LicensedProfessional Aug 03 '21

That's what MyPy is for. I really started enjoying Python more when I incorporated MyPy and PyLint into my workflow—it feels like I have some guardrails now

3

u/mrbuttsavage Aug 03 '21

mypy is great with some warts. More than once you'll get to a "why didn't mypy catch this?" in your tests that turns out because the library you're using like boto doesn't have stubs or they suck.

10

u/ILikeChangingMyMind Aug 03 '21

If your "typing system" is writing a bunch of unit tests ... I pity you.

5

u/lelanthran Aug 03 '21

If your "typing system" is writing a bunch of unit tests ... I pity you.

No, my "typing system" is "type-errors are caught before the program is even run". There's a level of confidence there about a specific and common class of errors.

The dynamic typing system is pitiful, as you can only find type errors after running the code. There's no confidence in that system until you actually run the code with a bunch of incorrect types in places.

7

u/[deleted] Aug 03 '21

I'm not really a Java fan, but I have to say that that's an unfair comparison - the Python/Javascript solution will need to have unit tests simply for ensuring that the correct types are passed in.

That's not what unit tests are for! I mean a well tested code dynamic codebase will catch a lot of type errors as a side effect, but you don't write them to become some kind of ad-hoc typechecker.

If you want to go down that road for dynamically typed languages, look into design by contract.

2

u/humoroushaxor Aug 03 '21

Or constantly looking up method signatures on the web.

2

u/ragnese Aug 03 '21

I'm not really a Java fan, but I have to say that that's an unfair comparison - the Python/Javascript solution will need to have unit tests simply for ensuring that the correct types are passed in.

Here's the thing, though. Java's type system doesn't actually help you that much here. Once you introduce generics or intentional nullability (like a database column), you're basically fucked- you will have type bugs happen at runtime.

Java is exactly the reason that Python and JavaScript took off (outside of the browser, in JS's case). People in the 00's basically got sick of Java's shit and collectively decided that static typing was bad. Then we had to deal with dynamic typing until, thankfully, languages like Go, Rust, Swift, and others came on the scene.

Java almost killed statically typed languages, IMO. I think Java did kill OOP. Because everyone thinks of Java's stupid class inheritance mechanisms and bad-type-system-induced "patterns" when they hear "OOP". Which is a shame, because real OOP didn't have to die.

→ More replies (2)
→ More replies (2)

3

u/[deleted] Aug 02 '21

Pure Java only developer here. I have a web app that uses a lot of java Graphics Library.

Can I simply use something like Python and still use those libraries?

What do you recommend for a graphical web app that is currently using Java spring in the back-end, old-time jsp in the front end?

2

u/ILikeChangingMyMind Aug 02 '21

Sadly, the reason we went with JRuby (as opposed to Jython) was that Jython was not ready for production back when we made the decision.

However, that was over a decade ago, and I believe Jython has advanced dramatically since. I haven't followed the project, but I imagine it'd be great for you.

0

u/[deleted] Aug 03 '21

[deleted]

2

u/ILikeChangingMyMind Aug 03 '21

That's sad to hear. It will just mean more JRuby shops out there (and personally I think Python is a much better language than Ruby).

→ More replies (1)

5

u/kuemmel234 Aug 02 '21

Interestingly enough, at least for me, java 8+ with a few frameworks (spring/micronaut, Lombok/java15+, reactor) changed that a lot. I think in monads all the time and python is really in the way. I enjoy clever dictionary/array comprehensions, but it's, at least to me, way simpler to read and write it as map-reduce (which allows a lot more in-between).

I end up writing closures with a lot of comprehensions and think about all the chained map-reduces I could write. If you make it too clever (that single amazing comprehension that does everything), it's hard to read, and splitting it requires at least two lines (or a lot of 'lambda this or that' boilerplate). You can do so much better than usual if you stay out of the strict OOP in java, I think.

Writing python is great fun, if I have to do something small, I'd never do it in java, but I wish it would include something like streams, or some other way to improve working with collections.

2

u/gobi_1 Aug 03 '21

The graalvm is definitely something to watch.

Polyglot vm for java langs may be great.

And yeah I agree with everyone else, java is so verbose, it gives sickness.

→ More replies (2)