News for hackers. Stuff that matters.
Re:From Java to Go, and Back Again (2016) by thermodynthrway on Saturday June 23, 2018 @02:19PM (#17382570)
Java is crufty, but it's the best general purpose language I know. There's hardly anything you can't build in Java.

"Casual" Java programmers usually miss the most important feature, what really makes it possible to do almost anything in Java. Reflection and runtime code generation. Every time I look at Go this ends up being a problem, worse than lack of generics. A lot of Java libraries use these features under the hood to make things like JPA and JSON serialization work.

Nothing I'm aware of comes close to Java in this, where you can redefine the language and rewrite compiled code at runtime while still maintaining execution and memory safety. Java agents, annotation processors, and libraries like JavaAssist, ByteBuddy, and ASM make seemingly impossible things pretty easy to write.

This is why annotations are used for everything in Java. They're often just tags used to find targets for rewriting code at runtime.

I was trying to write a thin ORM for Go and quickly found out it was impossible to do what I needed without blowing a bunch of nasty generated source files into the build. In Java, I can give the developer a nice clean interface and just generate the code when the app starts. Go forces you to expose all this to the user of your library

Re:From Java to Go, and Back Again (2016) by StaticRedux on Saturday June 23, 2018 @02:34PM (#17382660)
> Nothing I'm aware of comes close to Java in this,

C#. No Type Erasure. More powerful reflection with less code. Not to mention the unbelievable power of Roslyn and being able to programmatically generate code with little effort.

If you love Java reflection, your mind will be blown by C#'s.

Re:From Java to Go, and Back Again (2016) by thermodynthrway on Saturday June 23, 2018 @02:40PM (#17382693)
I came from the C# world :). And yes, it's even more powerful, plus reified generics.

The huge problem is that it's not that much better than Java which has ~50X more open source software written for it. The day MS makes a bytecode transpiler so I can use my Java libraries in C# I'll never touch Java again. The languages are so similar I have no idea why they haven't done it yet

Re:From Java to Go, and Back Again (2016) by wpdev_63 on Saturday June 23, 2018 @02:54PM (#17382765)
"The huge problem is that it's not that much better than Java"

I always see the .net fanboys tout how much better C# is than Java with generics, await/async, etc. but at the end of the day it's not that much better when you can achieve the same thing in Java with better open source support and across oses.

I know there's .net core now but I am not going near it until it matures.

Re:From Java to Go, and Back Again (2016) by thermodynthrway on Saturday June 23, 2018 @02:59PM (#17382788)
I miss all that from C#, some of it a lot. But Java has a community so large that they've basically hacked these things into Java anyways.

LINQ -> streams, QueryDSL, RxJava, JOOQ etc

Async/await -> Comsat/Quasar

The type system is lightyears better in C# but it was rare that I needed those features. Usually you can hack around the limitations and end up with something (slightly cruftier) that does the same thing in Java. Mockito, Retrofit, and RxJava are good examples of hacking about the type system until you have something good enough. That said, there are definitely times I still miss C#'s stellar type system. Easily the best of any language I've touched besides maybe Typescript (which is designed by the same guy)

Re:From Java to Go, and Back Again (2016) by mercurial on Saturday June 23, 2018 @03:47PM (#17383055)
There is nothing particularly outstanding about C#'s type system. It has reified generics and some basic type constraints, but so what? No option type, no ADTs, no pattern matching... Working with Typescript at the same time, I feel crippled every time I need to do something in C#. Not that Typescript is perfact, but its type system (especially with `strict`) is considerably more sophisticated.
Re:From Java to Go, and Back Again (2016) by Latty on Sunday June 24, 2018 @01:10AM (#17385043)
It has basic pattern matching now, nullable is the option type, which is being extended to reference types in the next version. It's no Scala, but it's getting there.
Re:From Java to Go, and Back Again (2016) by wpdev_63 on Saturday June 23, 2018 @05:09PM (#17383465)
If you really care about all those features then you would just use kotlin. It works almost seamlessly with Java and has the best ergonomics of any language I have ever used. All those festures are in kotlin and then some.
Re:From Java to Go, and Back Again (2016) by guitarbill on Saturday June 23, 2018 @03:00PM (#17382789)
It's weird, I started in C# but haven't touched anything Microsoft for roughly 10 years. That's how long they've been asleep, maybe longer. I would have killed for official cross-platform C#, if only for a decent UI toolkit (Mono was too bigger pain), and I'm sure C# would have significantly dented the popularity of e.g. Python. Instead C# never outgrew Windows, while many developers and companies did. Meanwhile, Java has kept evolving and taking chances, so much so that Java 8+ is pleasant enough. Only now has Microsoft realized the error, but way too late.
Re:From Java to Go, and Back Again (2016) by thermodynthrway on Saturday June 23, 2018 @03:09PM (#17382840)
It's a damn shame really. MS killed the golden goose by tryiing to squeeze too much money out of it years ago. C# is an excellent langauge, the design and type system are just incredible. But they missed the open source boat by about a decade and it's yet to be seen if their attempt to rally is too late
Re:From Java to Go, and Back Again (2016) by RangerScience on Saturday June 23, 2018 @03:36PM (#17382991)
It's distinctly possible that Unity3D will "rescue" this aspect if C#, although from what I saw of the community it's not there yet. Probably the lack of a good package / dependency manager - oh, and the lack of up-to-date C# support (last I checked you were stuck way back with 3.5).

Yadda yadda, if I wanted to "fix" the lack of an open source community in C#, I'd start with the Unity3D community.

Re:From Java to Go, and Back Again (2016) by kamac on Saturday June 23, 2018 @04:28PM (#17383276)
In the latest Unity version (2018) you have access to C# 6 (stable) and .NET 4.6.
Re:From Java to Go, and Back Again (2016) by UnpossibleJim on Saturday June 23, 2018 @05:32PM (#17383560)
The problem with that is, there are now open source game engines coming on the scene that are promising (in the long run, and yes it's a BIG maybe) to upset Unity's stranglehold, that support Python and in the future C# to lure away Unity devs. I'm speaking of Godot. I'm not sure how successful they'll truly be but I, for one, am hoping they bring a solid rivalry.

Python as a scripting language makes sense, in this arena, anyways, as it's the scripting language for Blender. A single scripting language for 3D software and game engine in a game studio just makes sense.

Re:From Java to Go, and Back Again (2016) by pjmlp on Sunday June 24, 2018 @03:44AM (#17385462)
Only makes sense in modern game engines if it comes with a JIT.

I can go for a coffee when Blender does some kind of data transformation, I can't do that in a middle of a rendering a frame 60 times per second.

Re:From Java to Go, and Back Again (2016) by Latty on Sunday June 24, 2018 @01:13AM (#17385054)
It can also do .net standard 2.0, which is great for library compatibility, and the experimental (but working) incremental compiler is Roslyn based and can do c# 7.2.
Re:From Java to Go, and Back Again (2016) by RangerScience on Sunday June 24, 2018 @05:44PM (#17388545)
Oh, horray! I stopped working with Unity3D, and so haven't been in the loop
Re:From Java to Go, and Back Again (2016) by valeriob on Saturday June 23, 2018 @03:44PM (#17383038)
I don't think that's accurate, we use opensource .net dev stack since 5/8 years, and since 3 it can be deployed on win, linux and osx.
Re:From Java to Go, and Back Again (2016) by valeriob on Saturday June 23, 2018 @03:49PM (#17383068)
That's unfortunate, since ms opensource journey started 10 years ago :D Java as a language stagnated 10 years compared to anything (example lambda). .net has been the source of many technologies, CQRS/ES, Async/Await, Reactive Programming, etc.
Re:From Java to Go, and Back Again (2016) by guitarbill on Saturday June 23, 2018 @04:28PM (#17383279)
Woah there. I think a lot of these need citations. While it's true that .NET had async/await in 2007 (F#, AFAIK), Microsoft open-sourcing things isn't that old. From what I can see, their most popular open-source projects are TypeScript (Oct 2012, so 5 years ago), and VSCode (Apr 2015, so 3 years ago). .NET Core was Nov 2014, also 3 years ago. Cynically, you might say they released VSCode and .NET Core because VS and .NET were dying slow deaths, maybe the same can be said for TypeScript, because JavaScript/web dev cannibalized Microsoft's markets.

Meanwhile, the interesting technologies, especially relating to web development, ops/deployment, or data storage and processing are first-class citizens in Linux (and macOS gets a free ride, because POSIX and desktop). Most of them don't use Java , but enough do: Lucene/ElasticSearch, Cassandra (and probably DynamoDB, even if it isn't OSS), Hadoop, Neo4j, Kafka, and more.

It's not even close. Please understand I'm not hating on C#, or saying Java was why these things are successful (definitely not), but I think it helps to understand the eco-systems surrounding both C# and Java. C# may be a nice language, and may be able to run on Linux. In 2005 (C# 2.0) it was almost revolutionary, but now it's just another language. Meanwhile everybody else has been learning and using the other languages to build great things - distinctly without Microsoft.

Re:From Java to Go, and Back Again (2016) by valeriob on Tuesday June 26, 2018 @08:29AM (#17399992)
Yep you are right, i rounded too much, mvc is from 2009 : https://stackoverflow.com/questions/734892/asp-net-mvc-is-no... But the bulk of it started a bit later with the whole .net ecosystem.

I agree with all you said, but i'm referring to the previous comment where ms has been all but asleep in the last 10 years :D Anyway talking about language and dev-environment are two completly different conversations, and i'm not wrong saying that Java as language stagnated far too long. I never said the .net eco system thrived meanwhile :D

Re:From Java to Go, and Back Again (2016) by jcelerier on Saturday June 23, 2018 @03:27PM (#17382940)
> The languages are so similar I have no idea why they haven't done it yet

the languages are so similar because microsoft started with J++ and got a lawsuit from Sun (https://en.wikipedia.org/wiki/Visual_J%2B%2B).

Re:From Java to Go, and Back Again (2016) by pjmlp on Sunday June 24, 2018 @03:42AM (#17385457)
Re:From Java to Go, and Back Again (2016) by jsiepkes on Sunday June 24, 2018 @06:26AM (#17385917)
https://twitter.com/dibblego/status/419232648674828288?s=19

> It's funny when Java users complain about type erasure, which is the only thing Java got right, while ignoring all the things it got wrong.

Re:From Java to Go, and Back Again (2016) by vardump on Saturday June 23, 2018 @02:54PM (#17382768)
> There's hardly anything you can't build in Java.

I do bare metal/low level embedded, kernel drivers, and occasionally shared libraries. Java is useless for practically all of my typical use cases.

Re:From Java to Go, and Back Again (2016) by guitarbill on Saturday June 23, 2018 @03:04PM (#17382811)
I get the sense you're being contrarian. Op isn't saying it's the best choice, but being in that field, you should know that even those things people have tried to do and sometimes done with Java. For example, Java-based smart cards or Java Micro Edition.
Re:From Java to Go, and Back Again (2016) by pjmlp on Sunday June 24, 2018 @03:54AM (#17385494)
These guys think otherwise

https://www.ptc.com/en/products/developer-tools/perc

https://www.aicas.com/cms/

http://fiji-systems.com/

https://developer.android.com/things/

Of course it isn't suited when trying to fit something into PIC with 64KB.

Re:From Java to Go, and Back Again (2016) by repolfx on Saturday June 23, 2018 @05:00PM (#17383420)
Technically speaking you can build these things in Java. JNode is an OS written entirely in Java, including the drivers. You probably meant "drivers for linux/windows" though and yes, there it's not so useful.

You can also make shared libraries with Java these days. Look at SubstrateVM. It turns Java code into a .so file that doesn't depend on the JVM, compiled ahead of time, with a C API exported.

Re:From Java to Go, and Back Again (2016) by vardump on Saturday June 23, 2018 @06:11PM (#17383731)
Yes, there's very little in software development that's strictly impossible. Practicality is another matter.

> Look at SubstrateVM. It turns Java code into a .so file that doesn't depend on the JVM, compiled ahead of time, with a C API exported.

Thanks, will do. I've been mostly eyeing Webassembly for some "cross-platform shared object" use cases.

Re:From Java to Go, and Back Again (2016) by calgaryeng on Saturday June 23, 2018 @03:04PM (#17382810)
Your comment seems largely unnecessary.
Re:From Java to Go, and Back Again (2016) by alfalfasprout on Saturday June 23, 2018 @05:37PM (#17383591)
It's really a matter of preference, but Go encourages you to expose more to the user. It tends to discourage heavy abstraction. You don't really need runtime code gen (Go actually does have reflection) and it's certainly quite possible to write clean implementations of most things without it.

Java's real issues like in two aspects: 1) Bad Java programmers have built a culture of writing "overpatterned" enterprise code (with FactoryBuilderFactorFunctions) 2) Horrible GC/iffy performance for a modern language

#1 is reason enough to avoid Java like the plague. #2 makes it totally unsuitable for heavy numerical computation or systems level applications. Nothing like huge GC spikes to liven up your day.

Re:From Java to Go, and Back Again (2016) by KennyCason on Saturday June 23, 2018 @05:55PM (#17383662)
1) I mildlt disagree with this. There are lots of amazingly written Java libraries, and not all teams or people write “over enterprises code. I’ve seen dubious code quality on both ends of the spectrum in many languages. I do not think this is limited to Java, but more of a fact that Java is very popular and has been around for a long time, and thus has a lot of both good and bad history with it. I feel that modern Java practices have really improved.

2) Without a doubt native shines here. I’ve also been a victim of those massive GC spikes in the past. But I think saying the JVM has horrible GC seems a bit hyperbolic as it’s quite matured and more than adequate for most usecases.

Re:From Java to Go, and Back Again (2016) by sjellis on Sunday June 24, 2018 @03:12AM (#17385390)
> I was trying to write a thin ORM for Go and quickly found out it was impossible to do what I needed without blowing a bunch of nasty generated source files into the build. In Java, I can give the developer a nice clean interface and just generate the code when the app starts. Go forces you to expose all this to the user of your library

Speaking as someone moving from Ruby to Go, I actually like the strong stance that Go takes against magic. The original article acknowledges that Go works the way that it does by design, and acknowledges the reason very fairly: the language is firmly on the side of making code easy to read, even at the expense of making it less elegant to write.

Re:From Java to Go, and Back Again (2016) by captainbland on Monday June 25, 2018 @08:34AM (#17391843)
I think you're right, but for me Java lacks compile-time features sorely (JavaPoet looks alright, but suffers from not being an official component of the JDK). Thinking about the user I'd much rather have that processing done at compile-time than startup-time. I guess this is part of where the appeal of Scala and Clojure lies.

Rust and Nim provide the sort of thing I mean, hygienic macros - they're nicer than reflection because you keep type safety and you keep run-time performance without generating a bunch of transient source files. Nim's also got a nice RTTI interface, too.

Re:From Java to Go, and Back Again (2016) by beagle3 on Sunday June 24, 2018 @01:13PM (#17387292)
The biggest problem with Java is the culture. All modern languages are Turing complete and roughly equivalent in the their expressiveness (Lisp, APL and Forth notwithstanding). But only Java people seems to have an AbstractAbstractFactoryFactoryWidgetGadget fetish.

When I have to do Java, I keep recalling Brazil[0].

[0] https://www.imdb.com/title/tt0088846/

Re:From Java to Go, and Back Again (2016) by icedchai on Monday June 25, 2018 @10:58AM (#17392894)
More modern Java libraries and frameworks don't have this issue.

Sure, if you look at JEE stuff, you'll run into it...

Re:From Java to Go, and Back Again (2016) by drbojingle on Saturday June 23, 2018 @09:31PM (#17384467)
Reflection? Lisp dude
Re:From Java to Go, and Back Again (2016) by badrabbit on Saturday June 23, 2018 @02:28PM (#17382627)
I think it's the crappy jvm's that keep giving java a bad name. If only you could compile native executables independent of a runtime/jit/bytecode.

On the contrary java has been around since 1994. Who knows how mature golang and python will get after aging and maturing like java.

Re:From Java to Go, and Back Again (2016) by thermodynthrway on Saturday June 23, 2018 @02:38PM (#17382678)
The JVM is a double edge sword. It makes all of this possible. Not only can you generate code at runtime, Java will optimize it just as well as if it was originally compiled in the application.

I'm not sure why people harp on the JVM so much. JavaScript uses a runtime with even more magic that uses 5-10x as much RAM. I think the crappy JVM's of the past along with bad memories of Java Applets tarnishes its reputation unfairly

Re:From Java to Go, and Back Again (2016) by innagadadavida on Saturday June 23, 2018 @02:53PM (#17382762)
A major pain point with JVM even today is the startup time. This is especially true for command line tools. I use hdfs tools and it is really slow to start. Someone wrote a Go replacement that is 100X faster to start. None of the JVM sophistication means anything if it cannot solve simple common world problems. The java community has failed in this regard in my opinion.

[1] https://github.com/colinmarc/hdfs

Re:From Java to Go, and Back Again (2016) by rhencke on Saturday June 23, 2018 @03:12PM (#17382859)
Keep your eye on Graal - specifically its native-image component.

Not only do you get instant startup, you also get a statically linked binary that doesn't need a JRE present to run. Throw it a JAR - get a native binary for your system.

https://github.com/oracle/graal

Re:From Java to Go, and Back Again (2016) by guitarbill on Saturday June 23, 2018 @03:21PM (#17382894)
Someone used GraalVM to eliminate cold-start penalty for Lambdas, genius [0] ! I'm very excited about Graal, if only because it'd make deployments easier, but the debuggability remains to be seem.

[0] https://news.ycombinator.com/item?id=17284022

Re:From Java to Go, and Back Again (2016) by sreque on Saturday June 23, 2018 @03:12PM (#17382853)
Totally agreed that java fails hard for use cases involving small, lightweight binaries that are low memory and fast to start. This is an area where golang shines on the other.

People are starting to experiment with AOT compilation via graal to make headroom in this space, but the techonology being used feels young, nascent, and experimental or immature:

https://medium.com/graalvm/instant-netty-startup-using-graal...

https://www.innoq.com/en/blog/native-clojure-and-graalvm/

Interestingly most high-level runtimes also have slow startup, including python, ruby, and node.js, but java's feels worse because people seem to want to use heavyweight frameworks like spring or aspectj that absolutely murder startup time, that for instance generate bytecode on startup or use classpath scanning to discover dependencies.

Re:From Java to Go, and Back Again (2016) by thermodynthrway on Saturday June 23, 2018 @03:23PM (#17382916)
Yeah it's a bad trade-off developers don't realize they're making sometimes. Spring is Gigantic. Application containers like Tomcat aren't much better. It's easy to write huge apps in Java that still perform well so there's not much pressure to modulize huge monolithic libraries. So we all just deal with the 200+ deep stack frames.

Newer frameworks like Vert.X and Dropwizard address this pretty well. We have a fairly large Dropwizard project that still starts in ~5 seconds. Also some written in Spring MVC that take 2 minutes...

Also, God AspectJ let's you create horrible abominations. And it feels like it was designed to encourage you to do so. A great example of why you shouldn't always use self modifying code even if it's easy to do.

Re:From Java to Go, and Back Again (2016) by thermodynthrway on Saturday June 23, 2018 @03:06PM (#17382823)
This is actually being addressed, eventually. There's work being done to lower the startup time in Java 9-10 but I'm not sure what state it's in. Basically cache everything from the first run to make future launches almost instant
Re:From Java to Go, and Back Again (2016) by ptx on Monday June 25, 2018 @02:00AM (#17390185)
I played around a bit with that, i.e. app class-data sharing and AOT compilation. It turns out Java 9 comes with an enormous regression in launch performance, so that even with app CDS enabled it is slower than Java 8 to start.

Java 10 is slightly better but still slower than Java 8 by default. Enabling app CDS gets you back to comparable performance to Java 8. With AOT enabled (in addition to app CDS) it might be faster, but that just crashes on machine (and only works on Linux anyway).

So don't get your hopes up too much.

Re:From Java to Go, and Back Again (2016) by ivan_gammel on Saturday June 23, 2018 @02:30PM (#17382642)
Python is older than Java.
Re:From Java to Go, and Back Again (2016) by pjmlp on Sunday June 24, 2018 @03:57AM (#17385503)
You can since around Java 1.2 time actually, the problem is that most devs don't want to pay for commercial tools.

Almost all third party commercial JDKs have some form of AOT support.

Re:From Java to Go, and Back Again (2016) by cordite on Saturday June 23, 2018 @02:30PM (#17382641)
Native images are getting more attention, but they give up a lot of this runtime magic.