Live data from Hacker News

Java is better than C++ for high speed trading systems

news.efinancialcareers.com

201–210 of 483 posts

Re: Java is better than C++ for high speed trading systems

#201

Earlier quoted context omitted.

Ah right yes conflict of terminology. In the JVM devirtualising means making a virtual object a full object again, so the opposite of what you want to be happening. I don't think the JVM really names the optimisation you're talking about, but it does do it, through either a global assumption based on the class hierarchy, or an inline cache with a local guard.

What do you mean by “virtual object”, an object which has been broken up on the stack instead of a “real” object living as a single entity on the heap?

Remember back in cs101 where you had class animal, with subclasses dog and cat. You can call speak() on animal and get either ruff or meow depending on what animal is. Animal is a virtual object. The system needs to do some work to figure out which speak to call every time, the work isn't too bad, but it turns out that cpus basically never have the right thing in the cache, so it ends up being very slow compared to most of what you are doing.

When we say devirtualize we mean that we know animal is always a cat so we don't have to look up which speak to use.

Re: Java is better than C++ for high speed trading systems

#202

Earlier quoted context omitted.

Given the same conditions (i.e. people don't die) the same outcome would present itself. We have a history of bridges falling down, so much so that Wikipedia has a list on that: https://en.wikipedia.org/wiki/List_of_bridge_failures A particular one that caught my eye: Cimarron River Rail Crossing Dover, Oklahoma Territory United States 18 September 1906 Wooden railroad trestle Washed out under pressure from debris du…

The sarcastic/negative implication of your example is that software engineering today is where civil engineering was 100+ years ago.

I don’t think that is too far off the mark. Given 8 more decades of progress we might even be able to produce reliable code. Webpages will be 100GB of JavaScript though

Re: Java is better than C++ for high speed trading systems

#203

Earlier quoted context omitted.

The third one was definitely the least, it was losing money (and specifically to trader-invisible things that never got worked on). The whole of the trading strategy (and capital traded, return profiles, etc) between the first two was fairly different, so it’s hard to compare. I would say though that the first firm was significantly outperforming its peers in a way the second firm did not, although both were very suc…

It's generally pretty rare for a market maker to lose money over a whole year. Colour me surprised.

There's costs that aren't the PnL of buy-low-sell-high. The coders, the data, the infra. All cost money, a lot of money. Add to that there's a competitive aspect in the models interacting with each other, there's no slam-dunk.

There's at least a couple of MMs struggling these days.

Re: Java is better than C++ for high speed trading systems

#204

I’ve seen this sentiment before and worked on both a “low latency Java” team and low latency C++ teams. I have some sympathy for the idea that the JVM is better since it means you won’t spend all your time chasing crash reports. The thing is, like another comment hinted at, is that this issue is generally more reflective of the environment you build in than the technology choice. Here’s a good talk on the reasons for…

Am I understanding correctly that those firms really really care about latency & have unlimited money & chose C++/JAVA with a standard off-the-shelve compiler + an OS and/or JVM?? If you'd really really care about latency and have the resources, wouldn't it be more effective to just go bare metal? Bare metal as in: no OS (talk to the hardware registers directly from code), possibly a custom compiler, use all the rele…

There is only a limit amount of money to make. If your algorithm generates 100k in gross profit a year that doesn't even pay for the programmers to maintain it, unless they can do other things as well. (I'd guess common, there are a lot of algorithms) the sum total doesn't pay. Where it does pay you are better off spending money on fpga, or even asic.

Re: Java is better than C++ for high speed trading systems

#205
post #39
post #5

When you write Java in a C like syntax : "Chronicle's system is built in what Lawrey describes as "C-like Java" and it's this that he encourages people to code low latency systems in." I guess very limited number of constructors, and most of all the methods are static. And they still struggle to find programmers that can code that way.

Use the stack and not the heap. Pre-allocate arrays, avoid collections. Use LUTs. Avoid string processing, operate on bits and bytes as much as possible. Same applies to telecoms-development that has to be fast and predictable.

What is LUT?

Re: Java is better than C++ for high speed trading systems

#207
post #39

Earlier quoted context omitted.

Use the stack and not the heap. Pre-allocate arrays, avoid collections. Use LUTs. Avoid string processing, operate on bits and bytes as much as possible. Same applies to telecoms-development that has to be fast and predictable.

What is LUT?

https://en.m.wikipedia.org/wiki/Lookup_table

Re: Java is better than C++ for high speed trading systems

#208

Earlier quoted context omitted.

The worst (messiest, laziest and most chaotic) engineer I know works at a brokerage, coding obscenely large and unreliable edifices (and in a number of languages, from C++ to Excel+VB)... He does what he is asked, and doesn't worry about telling them what they need. They never demand code that doesn't crash, they see that as a fact of life, and developers are an overhead. Basically someone else owns the risk, the bro…

^^This^^ is why you shouldn't call software developers "engineers" (disclaimer, am software developer). "No-one ever explicitly specified that the bridge shouldn't fall down and kill everyone who was on it at the time", said no engineer, ever.

You shouldn't compare bridge building to developing a trading apps (on causes death, the other merely financial loss)

Compare bridge building to developing software for pace maker.

Now compare number of failures in both cases.

You get what you pay for, if you pay for developer you'll get a developer.

Re: Java is better than C++ for high speed trading systems

#209
post #110

Earlier quoted context omitted.

I've heard of people doing that 10-15 years ago. I'm sure it still works, but hopefully the GC situation has also improved.

A pause is still a pause though. One system I know of had a solution. Throw in a huge amount of RAM on the server and delay garbage collection until end of day.

But a pause that can happen when you want it is acceptable. A 3 second stall might be totally acceptable as long as it happens outside of a trade, and you can guarantee that.

Re: Java is better than C++ for high speed trading systems

#210
post #128

Earlier quoted context omitted.

But here we're talking about C++: you don't write malloc, you use containers that encapsulate memory management - likely std::containers with pool allocators. And you put things on the stack. Code is as readable if not more than java - there isn't any "new," anywhere in sight

Modern C++ is probably about as good, with sufficient team discipline. I don't have enough recent experience with C++ to have a strong opinion. IMO (possibly biased by how much I hated C++ in the 90s) it is easier to maintain clean code discipline in a large team with Java than it is with C++.

C++ after 11 is a very different beast. It's more pleasant to write compared with pre-11. Memory model, move semantics, smart pointers, lots of stuff standardized instead of left to the libraries.

Definitely depends on your team of course.

Post reply on HN