5 ms·
IMO Go has far more boiler plate than Java. Go is going to have countless amounts more boiler plate for simple logic. Just like your comment below try writing o
by vips7L 4y ago
IMO Go has far more boiler plate than Java. Go is going to have countless amounts more boiler plate for simple logic. Just like your comment below try writing one of these in go:
var lst = users.stream()
.filter(User::isAdmin)
.map(u -> u.id() + “ : “ + u.name())
.limit(10)
.toList();
static boolean isPrime(int n) {
return switch (n) {
case 0, 1 -> false,
default -> !IntStream.range(2, n).anyMatch(i -> n % i == 0)
}
}
- musabg 4y agoSecond one in Go: func IsPrime(n int64) bool { return big.NewInt(n).ProbablyPrime(0) } Each language has its own pros and cons. Go wants to be explicit and simple to be understood. Java is fully-featured. This is just anectodal evidence anyways. And these are tools in the and, and no point for a "tool fight".
- vips7L 4y agoThe point of that example wasn't to show if there was a standard library function for it. It was to show the verbosity of writing code that contains if conditions, loops, and generic programming. I obviously could have written: new BigInteger(n).isProbablyPrime(0);
- bin_bash 4y agoMy general point is that if you put Ruby up against a nonspecific compiled language it's hard to argue Ruby is better. When you analyze something like Go vs Ruby or Go vs Java then the warts of particular languages come out.
- bin_bash 4y agoYou may be right. My knowledge of Java is from 1.4 in college and vastly out of date. I should spend some time actually learning modern Java and less time avoiding it.
- vips7L 4y agoThere's still some verbosity. I would kill for C# like properties for mutable data classes (JPA entities). I also really like Kotlin/Scala style apply functions for interfaces and Kotlin's delegates for making easy decorators, but none of these have ever convinced me to leave Java behind. The only languages that have come close are C# or D because of their lower level capabilities.
- weatherlite 4y agoNew Java is pretty damn good actually, I don't see a real need for Go over it other than compile time perhaps.
- petercooper 4y agoJava has a lot going for it but the JVM remains anathema to a lot of developers. Modern C++ has similar stigma on the language end – it's possible to write fantastically expressive and terse code in it nowadays, but it maintains a reputation.
- bin_bash 4y ago2 years ago I spent 2 months learning C++ coming from almost entirely scripting languages throughout my career. (Though I have a CS degree so a decent academic background in memory management) I came away liking C++ more than I thought I would. I didn't find it hard to learn but it was time consuming. Where learning Rust I never understood the basic concepts enough to be productive, I could be productive pretty quick with C++. The trouble is there is a lot to learn because the language is just so old and has been through so many revisions. To some extent you can't just limit yourself to the modern stuff since in order to learn the modern stuff you need a basic understanding of what it was before to know why things are done the way they are now. You also run into code samples that use the old stuff or corner cases where they're needed. I also think it really gets you to think about how computation and memory is happening at the metal level which is great for optimization but I think for most of the work I do it would be largely a distraction. I see this is a downside, not an upside. That said, you're definitely right. You can have nice, expressive code in C++: I just think the learning curve is the biggest problem. I'd be happy to use C++ in my next project though.
- vips7L 4y agoJavac is still probably going to compile faster than go. Javac doesn't have to do ANY optimizations. I doubt you'll find a compiler faster.