TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why Java? Tales from a Python Convert

75 pointsby soofaloofaover 9 years ago

17 comments

mattdlondonover 9 years ago
Just a spin on this: as a java developer that recently started doing a lot of python, what has really annoyed me (apart from the utterly woeful IDE functionality compared to typed languages) is the extra &quot;boiler plate&quot; thinking you need to do with python because of the dynamicness meaning you have to keep the types and classes you&#x27;re using for your codebase in your head, rather than letting the computer deal with that.<p>e.g. you have a function with a &quot;database&quot; parameter ... it could be a string, it could be a dict, another class, or even a number. There is no way to know apart from back-tracking through the code (or run it and wait for it to fail with a TypeError when that code gets hit). With java you just read the type off the screen and you can get on with solving the problem at hand without extra thinking, and even if you do screw up your IDE tells you right away with a nice squiggly red underline, or if you&#x27;re not using an IDE during compile time. With Python you might not find out about that TypeError until that 3am pager call.<p>People have suggested that the answer to this is forcing strict naming conventions and&#x2F;or strict docstring conventions ... but if you are going to go with that level of extra work of typing &quot;database_string&quot; or &quot;&quot;&quot;Lots of long docstrings explaining exactly what type the database parameter is.&quot;&quot;&quot; (and maintaining it!!!),you&#x27;re not saving any boilerplate (biggest complaint I&#x27;ve seen levelled at java) so why not just use a statically typed language ?<p>tl;dr - for me, python adds cognitive load of keeping the minutiae of the code in my head on top of solving the actual task at hand.<p>That said, I like the &quot;pick up and go&quot; prototyping feel of Python for quick jobs - java sucks for that.
评论 #10700523 未加载
评论 #10702580 未加载
评论 #10700340 未加载
评论 #10700503 未加载
评论 #10700242 未加载
pkaover 9 years ago
&gt; Java’s type system, while verbose at times, allows you to write code that largely “just works”.<p>NullPointerException would like to have a word with you about that.<p>In all seriousness, it feels unreal that people can be <i>that</i> impressed by Java&#x27;s safety or lambdas. Makes you shudder to think about what they&#x27;ve used <i>before</i> that.
评论 #10700050 未加载
评论 #10700048 未加载
评论 #10700078 未加载
sytelusover 9 years ago
OP is glossing way too many things.<p>1. Desktop users are tricked in to installing Ask toolbar crapware. Which other language tricks users in to doing that?<p>2. Java development actually have languished for very long time and it is very recent that it started to catch up with C# and other modern languages. Java forums are filled with cries and screams for adding these improvements for years on.<p>3. Java is built on language concepts that are now 20 years old. Back than people wanted every language look like C++. The millennials think outside the braces. They expect language to infer types instead of repeatedly being specified all over. They expect REPL. They don&#x27;t want everything modeled as object and so on. Mature language does not equal modern language.<p>3. Java is not truely &quot;open source&quot; or &quot;free&quot;. Ask Google and Apache Harmony for the legal battles they had to fight with Oracle.<p>4. If Microsoft had done what it&#x27;s doing with C# and .Net back in 2000, I highly doubt Java would be as popular as it is now. In other words, things can be popular even while being technically legging behind. This is not to say C# was initially just a Java copy cat but it did grew up fast while Java folks set on their laurels.<p>5. Java is owned by Oracle. Enough said.<p>I think modern languages should not have obligation to look like C&#x2F;C++ and it should use advances in automatic type inference, functional paradigms etc. Anything 20 years old would have great libraries and VMs, but then mainframes and Cobol were also very safe, &quot;reliable&quot; and had great libraries and infrastructure at some point. It&#x27;s ok to use mature tools to get shit done <i>now</i> but proposing them as new frontier doesn&#x27;t make sense.
评论 #10699969 未加载
评论 #10703073 未加载
评论 #10703586 未加载
评论 #10702224 未加载
评论 #10702583 未加载
ubercowover 9 years ago
The one thing keeping me away from Java still is the awful experience around modeling data.<p>Compared to something like a case class in Scala or even autoproperties in C#, writing classes with a bunch of getter and setter methods just to keep state is really tedious.
评论 #10699921 未加载
评论 #10699699 未加载
评论 #10699714 未加载
评论 #10699719 未加载
评论 #10699746 未加载
评论 #10699816 未加载
评论 #10700001 未加载
评论 #10704601 未加载
评论 #10699723 未加载
评论 #10699735 未加载
评论 #10699736 未加载
benedictpover 9 years ago
Take a look at Kotlin <a href="https:&#x2F;&#x2F;kotlinlang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;kotlinlang.org&#x2F;</a> I know there is also Scala and other JVM languages. But I&#x27;m also an Android developer and Kotlin works really fine with Android-Studio (both from JetBrains).
评论 #10699837 未加载
nikdaheratikover 9 years ago
I think the author has set an impossible task for the article: trying to sell Java without giving any specific use cases. Generalities don&#x27;t cut it, especially if you&#x27;ve already invested time learning how to do something in Python, which isn&#x27;t perfect, but can match the JVM in the areas that it does excel at (e.g. problems that need NumPy or Django).<p>Java is irritatingly pedantic about sticking to its idea of how OOP should work. It has that design by committee feel to it that enforces some idioms that please no one (like pushing object Factories). If you need to get a prototype out or want something that can let you automate a task quickly with little BS, you don&#x27;t want Java.<p>Java is good for enterprise developers as it tends to reign alot of the cowboy tendencies of some programmers and helps to force everyone on the project to use the same clearly defined, well planned (and less elegant) APIs and other systems. And the JVM keeps you from being tied into some specific hardware that may go away in the future.<p>It&#x27;s the difference between a toolkit to design and build a cool building, like the Space needle, or you need to coordinate a huge number of contractors because you&#x27;re building the Big Dig or Chunnel.
golergkaover 9 years ago
These examples look like C# 2.5 with a little bit of LINQ.
评论 #10699658 未加载
thothamonover 9 years ago
To me, the article doesn&#x27;t really sell Java the language. The big benefits are in the JVM and libraries, which support many languages far superior to Java. The only virtue of Java the language might be the programmers who know it, and even there, many programmers are not familiar with the new features of Java 8.
bsderover 9 years ago
java.util.concurrent is so much better than anything else mainstream that it&#x27;s ridiculous.
thinkersilverover 9 years ago
I love the jvm, I love the tooling and the ecosystem, but Java I do not love. The author presents many of Java 7&#x2F;8 features as a reason for Java&#x27;s greatness. The language features of Java 7&#x2F;8 are really not that compelling. Let&#x27;s consider that C# has had much a more progressive approach to language design for a while now.<p>Most places I&#x27;ve worked at recently have moved to Java 8 because 7 has been EOLed. It feels like we were pushed onto 8 rather than enticed by its shininess.<p>What makes Java great isn&#x27;t java it&#x27;s the jvm. It&#x27;s such a brilliant piece of engineering. What makes the jvm &#x27;meh&#x27; is it&#x27;s association with java. The arguments the author makes about Java being great are in my eyes really about the JVM, its tooling and its languages.
csenseover 9 years ago
Maven&#x27;s one of the most disgustingly over-engineered, obtuse, verbose, tightly coupled pieces of s...oftware I&#x27;ve ever seen. From <i>the project&#x27;s own 5-minute introduction</i> [1]:<p>If you have just installed Maven, it may take a while on the first run. This is because Maven is downloading the most recent artifacts (plugin jars and other files) into your local repository. You may also need to execute the command a couple of times before it succeeds...The POM is huge and can be daunting in its complexity...You executed the Maven goal archetype:generate, and passed in various parameters to that goal. The prefix &quot;archetype&quot; is the plugin that contains the goal... the second [command] is simply a single word - package. Rather than a goal, this is a phase. A phase is a step in the build lifecycle, which is an ordered sequence of phases. When a phase is given, Maven will execute every phase in the sequence up to and including the one defined. For example, if we execute the compile phase, the phases that actually get executed are [list of 6 items]...Although hardly a comprehensive list, these are the most common default lifecycle phases executed [list of 10 items]...<p>So in order to use this, I have to understand its own specialized non-standard vocabulary, like artifact, repository, archetype, plugin, goal, package, phase, lifecycle...the build configuration is in XML...it does a lot of stuff automagically, like executing five extra phases or downloading dozens or hundreds of executable files from the Internet.<p>People love Maven for some reason, but I&#x27;ll use shell scripts or Ant for my Java builds, because <i>when</i> the build breaks [2], I want to be able to understand what&#x27;s going on without having to read a few hundred pages of the build system manual.<p>[1] <a href="https:&#x2F;&#x2F;maven.apache.org&#x2F;guides&#x2F;getting-started&#x2F;maven-in-five-minutes.html" rel="nofollow">https:&#x2F;&#x2F;maven.apache.org&#x2F;guides&#x2F;getting-started&#x2F;maven-in-fiv...</a><p>[2] Anyone who&#x27;s ever worked with any build system knows the build <i>will</i> break.
je42over 9 years ago
I don&#x27;t see any valid arguments that make Java 8 strictly better than any of the alternatives. These languages are all in the same rough ballpark. Your particular use case&#x2F;environment will determine mostly which Language you should be pick.
js8over 9 years ago
&quot;the JVM has excellent support for production logging and production monitoring, allowing you to easily monitor performance metrics down to an individual thread&quot;<p>Is it &quot;excellent&quot; compared to z&#x2F;OS and mainframe (SMF and RMF, specifically)? I sincerely doubt it, but I would like to know if there is someone who can compare. I don&#x27;t think any platform can match z&#x2F;OS in the visibility into the system, but I am not enough expert in Java to really compare.
评论 #10699994 未加载
boultonmarkover 9 years ago
I can&#x27;t imagine you were ever really a Python programmer if you enjoy progamming in Java. It&#x27;s almost the anti-python
评论 #10700138 未加载
评论 #10700046 未加载
draw_downover 9 years ago
Every time you see &quot;it just works&quot;, run.
erokarover 9 years ago
Stockholm syndrome.
thefastlaneover 9 years ago
i don&#x27;t care what lipstick you put on that pig: when something as simple as writing to stdout requires that i first create a new class, i&#x27;m not interested.<p>Edit: i do consider this a legitimate issue with how Java &#x27;does&#x27; OO. i&#x27;d be curious to understand downvoters&#x27; thoughts.<p>One more edit: wow, tough crowd. for those not familiar, i&#x27;d suggest reading Steve Yegge&#x27;s essay &quot;Execution in the Kingdom of Nouns&quot;
评论 #10699972 未加载
评论 #10699995 未加载
评论 #10699855 未加载