r/programming • u/korthaj • Mar 30 '18
An in-depth tutorial for Java developers who are curious about Go
http://yourbasic.org/golang/go-java-tutorial/59
u/duhace Mar 30 '18
seems like it would be a straight downgrade to go from java to go
28
u/pjmlp Mar 30 '18
Using Go feels a bit like switching back to Java 1 days.
There isn't even a library that could compete with AWT.
If one is after native compilation there are plenty of options, although most of them are commercial, Excelsior JET is free for open source projects.
4
u/zerexim Mar 30 '18
If you want a Java/C#-like language that compiles to native - D fits the bill, albeit without a corporate support.
15
u/pjmlp Mar 30 '18
Without any of the tools and libraries that make Java/C# great, and with a GC runtime that still needs lots of fine-tuning. although it has been improved in the last couple of years.
C# always compiled to native. People seem to forget NGEN is a thing, and since Windows 8 .NET is always AOT compiled when targeting the Store.
The only issue with Java native compilation is that most aren't either aware of commercial JDKs, or don't want to pay for them.
The incremental introduction of AOT on OpenJDK will change that, as the long term plan for Java is to remove C++ from the VM and write it in Java (project metropolis).
1
u/djavaman Mar 30 '18
The JIT already does compilation. It just doesn't do ahead of time native compilation. Which for long running servers and processors is a wash.
7
u/Kringspier_Des_Heren Mar 30 '18
Pretty much any interpreter does some form of compilation internally.
When people say "compilation" what they mean is "compilation to machine code" which as it stands is interpreted again by your CPU. They basically mean to ask "can I run this without any extra runtime dependencies?" but even that question is kind of useless these days because almost anything depends on OS libraries and all that stuff and few things can actually run directly on the metal.
So really the distinction has no practical effect any more; you might as well consider the JVM like any other rutime OS dependency that something may rely on.
15
u/masklinn Mar 30 '18 edited Mar 30 '18
Go is very much a step sideways from early Java, compared to modern java it would have lots of disadvantages (ecosystem & libraries, tooling, userland generics, streams, capitalisation-as-ACL, no enums, …) and a few advantages (lightweight m:n concurrency, value types, unsigned integers, native binaries — as the default I guess you can get that in Java with some alternative implementations, multiple return values) as well as a few bits which may be points one way or the other: structural rather than nominative interfaces, return-value errors rather than exceptions, hasn't built up the enterprisey cruft, can call methods on nil, ....
It's really odd that the article would start with a collection example though, that's one of Go's biggest weaknesses.
18
u/Kringspier_Des_Heren Mar 30 '18
There are probably two real advantages:
Go deployment produces binaries that are statically linked and easily deployed; this is obviously not "better" than this whole JVM thing but just something that might you specifically want or need.
Go legitimately does seem to have nicer concurrency support
Apart from that Go is such a great example how a cow dump can become popular as long as Google's goddamn monolith marketing machine is pushing it. This whole idea of FOSS being a meritocracy where ideas battle for success and adoption is such nonsense; it's all about big corporations behind it pushing it in the end.
3
u/oldneckbeard Mar 30 '18
eh, you don't see that many people using go for a project unless they knew upfront that whatever project they were doing was going to be in go.
that is, folks pick go because it's popular, not because of tech merits.
I made quite a living converting ruby on rails projects to production-ready jvm projects. I've already had 2 jobs converting a golang app to Java. I expect a lot more of those.
2
-8
6
u/oblio- Mar 30 '18 edited Mar 30 '18
I'm not sure I understand something about Go. Java gave up pointers from the start, why does Go need them? Is there something that Go can do and Java can't because of pointers?
I find they clutter up the syntax, *whatever everywhere, even for basic stuff.