4 ms·
May I ask why you've chosen Go over Java, which is becoming very popular in the HFT industry, even for latency-critical code? The code generation tools are bet
by pron 12y ago
May I ask why you've chosen Go over Java, which is becoming very popular in the HFT industry, even for latency-critical code?
The code generation tools are better (what you call "compile time IO"), the IDEs are much better, it has generics which you seem to miss, performance is better (the GCs are state-of-the-art), monitoring is much better, the language is also regular and simple, and you don't have to write inheritance-heavy code if you don't like.
As someone who likes both Java and Go, I find it surprising that anyone would choose the latter for long-running server code, especially where performance matters. Go is great for quick command-line apps or very simple services, but when you need to build an important server, Java wins out every time.
Certainly for your particular requirements and preferences, Java seems to have all of Go's advantages and (almost) none of the disadvantages.
- Horusiath 12y agoTaking from the author's paragraph: - Emacs - Java IDEs may look better, but this doesn't seem to be an issue for author. Also other tools are very mature for such youn language as Go. - Goroutines - Java has no built-in equivalent or one opinionated way of green-threading, only frameworks requiring months of expertise. From perspective of person, who need to switch language quickly this is very discouraging. - No inheritance - Java design patterns are clearly no-no in the described context (they were presented as anti-pattern). - Built-in, effective templating - again one easy path to start with, also powerfull enough to write your own tools if needed. Go is simply easier/faster to start with and most of the performance problems were not GC-bound, so JVMs maturity wasn't such an advantage.
- pron 12y ago> -Goroutines https://github.com/puniverse/quasar https://github.com/puniverse/quasar (I'm the main author) > Built-in, effective templating So does Java (and for a long time): http://docs.oracle.com/javase/7/docs/api/javax/annotation/processing/Processor.html http://docs.oracle.com/javase/7/docs/api/javax/annotation/pr... > and most of the performance problems were not GC-bound The author's complaints were about GC pauses, and besides, Java is faster even for non-GC bound tasks. > Go is simply easier/faster to start with Maybe, but just a little, and mostly because Java has (too?) many libraries to choose from. Even if the differences you highlight are indeed true (a point on which I disagree), those differences are, at best, quite small, while the advantages in Java's favor are much bigger, certainly in those areas that matter to the author.
- acqq 12y agoHow do you avoid too many allocations to happen in Java? The GC is certainly slower with more allocated elements but I seldom see any code example in Java which doesn't behave like the allocations don't cost anything. More than that, it seems that the whole language is based on that premise? As I consider the info you already provided a good argument for Java, I hope you can provide some good links.
- rwallace 12y agoJava has a generational garbage collector, so short-lived allocations pretty much don't cost anything, and by and large it's exactly the short-lived allocations that are the ones you could have optimized away in e.g. hand-tuned C++.
- acqq 12y agoWhat about an object being always handled only through the pointer? Does that mean that the array of 10M objects is actually an array of 10M pointers and 10M allocated objects, all of which have to be allocated, deallocated and the travelled through by the garbage collector? And what if it's not an array, but some more complex form? Is there a clean way to group a lot of objects to be treated by the allocator, deallocator and the GC as the single allocation unit? I understand that some language lawyers think that's not important ("just use the 'new,' the VM should care and not you") but for somebody like me who's used to the C level of control and actually cares and measures the performance differences which can result in the different number of servers needed to solve the problem, it really is.
- pjmlp 12y agoCurrently not and this is part of the Java 9-10 roadmap. However all JVMs have state of the art profilers like e.g. Visual VM, Java Flight Recorder and many others that help track down which data structures might need some help.
- pron 12y agoThis kind of stuff matters to Java developers, too, as, perhaps surprisingly, Java has become a high-performance language, especially when it comes to concurrency (as it offers low-level support for memory fences, and includes state-of-the-art implementations of concurrent data structures). As pjmlp said, the issue of "array of structs" is being addressed in Java 10. In the meantime, for contiguous memory allocation, you can make use of off-heap memory (which also helps those "more complex forms"). But the flip side is that Java's memory allocation is a lot faster than C's (i.e. in throughput -- not latency, as there are GC pauses), and most GCs are copying collectors that automatically arrange objects contiguously (though it's far from being good enough for arrays of object, as you need to follow references, and every object carries additional overhead, which is precisely why this is being addressed in Java 10).
- apta 12y ago> May I ask why you've chosen Go over Java, which is becoming very popular in the HFT industry, even for latency-critical code? Hype.
- logicchains 12y agoI didn't personally make the decision. We don't have any teams using Java, we do have a team using Go. Ergo, Go was chosen.
- pron 12y agoAh, OK, then. It's as good a reason as any, I guess. You should know though, that Java is now quite popular in HFT circles, especially in the UK, with high-performance libraries and monitoring tools[1] specifically tailored to that industry. In spite of a difference in marketing, you'll find that Java can get you much close to C++ than Go can. You have better control over execution and a runtime of higher quality overall. Even though Go's runtime is statically linked while Java's isn't, Java is very much a C++ replacement in many circumstances, while Go makes for a terrific Python replacement if you need fast scripts and command line tools (which is why you mostly see Python->Go and C++->Java transitions). Not that Go is always more appropriate than Python or Java is always better suited than C++, but at least those are the common alternatives, and the ones that make the most sense considering the design decisions of those languages. For you particular needs, I have no doubt you'll find Java to be the more appropriate choice. [1]: Like this: http://openhft.net/ http://openhft.net/