<story><title>Javapocalypse</title><url>http://jz13.java.no</url></story><parent_chain><item><author>StavrosK</author><text>This is irrelevant, but I just had my first Java experience yesterday. I decided to make an Android app, it&amp;#x27;s a simple remote control for hobby projects (Raspberry Pi&amp;#x2F;etc) that gives you a customizable UI with buttons that perform API calls. It&amp;#x27;d be pretty simple to do in Python, which is the language I am proficient in, but Android development sounds fun so I wanted to get started in that.&lt;p&gt;Creating the UI was easy enough, but making an HTTP response was hell. The simplest HTTP GET took around 30 lines of code, and the compiler kept complaining about unhandled exceptions (I know the URL is fine, it&amp;#x27;s a fixed string I can see, it&amp;#x27;s not going to throw MalformedURLException, I don&amp;#x27;t want to catch it, thank you. What? I can&amp;#x27;t compile without it?). Wrapping the calls up in try&amp;#x2F;catch blocks was easy enough (if a bit verbose), but now the variable only existed in that scope.&lt;p&gt;I know I&amp;#x27;m new enough that I can&amp;#x27;t form an opinion about the language, but I know that something that has as simple an interface as an HTTP GET call shouldn&amp;#x27;t take 30 lines of boilerplate to do. I&amp;#x27;m wondering how people deal with this issue (I&amp;#x27;m guessing it&amp;#x27;s a lack of a good standard library?). What attracts people to the Java world? Is it the tooling (Eclipse was, admittedly, very good about auto-fixing my mistakes). Is the verbosity just &amp;quot;the way it is&amp;quot;, or am I doing something wrong?</text></item></parent_chain><comment><author>RyanZAG</author><text>The standard method for getting around this in the java world is to create &amp;#x27;sane&amp;#x27; libraries (in the case of android http, something like &lt;a href=&quot;http:&amp;#x2F;&amp;#x2F;loopj.com&amp;#x2F;android-async-http&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;loopj.com&amp;#x2F;android-async-http&amp;#x2F;&lt;/a&gt; ) and then just use the library. The strong point of Java is just how many libraries there are - you often don&amp;#x27;t need to touch the actual built in Java APIs. On the server side (non-android) this has gone even further through the use of new annotation based libraries that generally autodiscover classes in your code, removing a lot of boilerplate.&lt;p&gt;One area in Java that is still incredibly annoying, however, is the ubiquitous getter&amp;#x2F;setter pattern that bloats all Java code for zero benefit to anyone.</text></comment>
<story><title>Javapocalypse</title><url>http://jz13.java.no</url></story><parent_chain><item><author>StavrosK</author><text>This is irrelevant, but I just had my first Java experience yesterday. I decided to make an Android app, it&amp;#x27;s a simple remote control for hobby projects (Raspberry Pi&amp;#x2F;etc) that gives you a customizable UI with buttons that perform API calls. It&amp;#x27;d be pretty simple to do in Python, which is the language I am proficient in, but Android development sounds fun so I wanted to get started in that.&lt;p&gt;Creating the UI was easy enough, but making an HTTP response was hell. The simplest HTTP GET took around 30 lines of code, and the compiler kept complaining about unhandled exceptions (I know the URL is fine, it&amp;#x27;s a fixed string I can see, it&amp;#x27;s not going to throw MalformedURLException, I don&amp;#x27;t want to catch it, thank you. What? I can&amp;#x27;t compile without it?). Wrapping the calls up in try&amp;#x2F;catch blocks was easy enough (if a bit verbose), but now the variable only existed in that scope.&lt;p&gt;I know I&amp;#x27;m new enough that I can&amp;#x27;t form an opinion about the language, but I know that something that has as simple an interface as an HTTP GET call shouldn&amp;#x27;t take 30 lines of boilerplate to do. I&amp;#x27;m wondering how people deal with this issue (I&amp;#x27;m guessing it&amp;#x27;s a lack of a good standard library?). What attracts people to the Java world? Is it the tooling (Eclipse was, admittedly, very good about auto-fixing my mistakes). Is the verbosity just &amp;quot;the way it is&amp;quot;, or am I doing something wrong?</text></item></parent_chain><comment><author>AYBABTME</author><text>Java is verbose.  Tooling is great, however.&lt;p&gt;For exceptions, there are two types.  Checked exceptions and runtime exceptions.&lt;p&gt;* Checked exceptions need to be explicitly handled in your code, or it doesn&amp;#x27;t compile.  
* Runtime exceptions can just happen, you don&amp;#x27;t need to check them.  I personally don&amp;#x27;t really like the runtime exceptions because they can hide in thousands of place and throw when you don&amp;#x27;t expect it.  However, you don&amp;#x27;t need to check them so it makes for less verbose code... but it&amp;#x27;s like putting your head in the sand.&lt;p&gt;To reduce verbosity of exception handling, I find a pseudo-solution is to just propagate the exception up the stack and deal with it later.  It depends for what exception, but for instance, a MalformedUrlException for which you KNOW the Url is fine, can be checked much higher in the call stack.  You will save yourself the local verbosity, which hides meaning, and really if the Url is malformed, you might not want the app to keep running; if it&amp;#x27;s hard-coded you should expect it to be right.  It&amp;#x27;s in the same spirit of Go&amp;#x27;s `regexp.MustCompile(string)` that makes a compile error if the hardcoded string you give it is not a valid regex.&lt;p&gt;That being said, Java is a daily pain, but the extensive tooling makes it usable.</text></comment>