Earlier quoted context omitted.
why not just use C++ or something and never deallocate memory then?
Malloc is usually slower than GC-based allocation (which basically just increments a pointer). Of course, one can emulate this via custom allocators in C++. My guess is that Java development is just easier and quicker, and the JIT may even result in more effective optimizations than AOT compilation.
We chose Java for our high-frequency trading application
261–270 of 287 posts
Re: We chose Java for our high-frequency trading application
#262Earlier quoted context omitted.
The market is a machine that routes society’s resources into making nearly everything. Making better routing decisions has immense value. When someone can profit from the same decision everyone else would make by doing it 0.000000012 days more quickly, IMHO he’s exploiting a design flaw in the way the market clears. That’s amplifying noise rather than signal.
ok, that was a bit of my original question (not well asked). i understand any civilisation needs funding to grow (do we need growth is another core question), and possibly market to do so. yet any meaningful decision won't be made at the millisecond scale, sure you can train a model to learn short term rules and generate long term profit. but does that profit society as a whole, i doubt it.
If we’re going to paint anyone as “real” villains in the world of trading then I’d argue it’s the informed big block traders. ie hedge funds, banks trading exotics with a high barrier of entry, etc. At least MMs are largely market neutral.
Re: We chose Java for our high-frequency trading application
#263Re: We chose Java for our high-frequency trading application
#264Earlier quoted context omitted.
here is one: https://github.com/questdb/questdb . Disclaimer, I work on this project. Main reason we use Java is speed of development (which increased with amount of base libraries written) and ease of testing.
Would you do it again? Coming from C/C++ first, Java then and coming to C# it just feels so much more pragmatic with f.ex. struct(s), slices and stackalloc (and unsafe blocks with pointers in a pinch) allowing for GC less programming w/o resorting to turning pointers to integers and using function calls for memory access all around. (Noticed that you do i guess query compilation via the ASM toolkit?)
Re: We chose Java for our high-frequency trading application
#265Re: We chose Java for our high-frequency trading application
#266Earlier quoted context omitted.
What the GP is referring to (Misc.Unsafe) is basically going back to manual pointer reads/writes (IE writing more or less C code in Java), the benefit is you get C speed/memory layout/cache-locality but with the downside of writing it in a less suited language (Java). HOWEVER If you DO _allocate_ much then 1TB seems like a great choice since GC pauses are killers w.r.t. latency in comparison to cache issues. A cache…
Can you explain why you would code java this way instead of dropping down to C?
Those unsafe bits are a tiny portion of the overall code.
Re: We chose Java for our high-frequency trading application
#267Earlier quoted context omitted.
Can you explain why you would code java this way instead of dropping down to C?
Probably because they started out in Java and don't want a full rewrite once they've gotten this far (might be that they don't have many C++ devs anyhow). I remember working on similar codebases 10 years back when J2ME games were still a thing (J2ME runtimes usually had horrible GC's and some people really went overboard in trying to avoid them) and it wasn't that fun at all (Even if the questDB codebase that is link…
GraalVM is the new name of MaximeVM one of the JVM meta-circular JVMs. Other well known ones being JikesRVM and SquawkVM.
What Oracle and others in the Java community are doing is reducing the need to drop down to C with support for value types and more fine grained control over native memory.
Java 16 will have the first preview release of the new low level memory APIs.
Re: We chose Java for our high-frequency trading application
#268Earlier quoted context omitted.
Which version of Java are you using? And what is Rnd? The class included with JDK is Random. We rely on escape analysis to elide such object creation for us and it works reasonably well. If something this trivial doesn't work for you, file bug with them. We have had success with that as well.
This ran on Java 11. This isn't so much of an issue for us. We are trying to avoid allocations, even as trivial as those. There are other examples that allocated where they should not, for example this lambda will allocate. () -> System.out.println(1) I lost hope in escape analysis quite frankly. Rnd is something I have written because Java's Random is slow and clunky. https://github.com/questdb/questdb/blob/master/c…
Re: We chose Java for our high-frequency trading application
#269Earlier quoted context omitted.
This is perhaps the most "blub" comment ever written. There are whole classes of bugs that can be caught with more advanced type systems that the Rust type system + borrow checker will never catch. No null pointers and immutability is the bare minimum. If you're interested, check out https://www.youtube.com/watch?v=10gSoVZ5yXY for an example of the types of compile time guarantees can be had.
Does OCaml have dependent types? I thought that was a Coq and Idris (and Haskell, to a lesser extent) thing. I am aware that dependent types exist, but quite frankly I've yet to see a popular/ergonomic language implement them. As much as we'd like absence of null pointers, error types, and immutability to be the norm it is not and it will take decades until it is.
Re: We chose Java for our high-frequency trading application
#270Basically all robust HFT shops are using Java, python is great for prototyping but in the end too slow.
All robust HFT shops? What do you mean by robust and how did you come to that (to me) surprising conclusion?