fbpx

Java for quant development?

(Last Updated On: May 8, 2011)

Java for quant development?

Is there any book introducing to Java, but dedicated for quants? Or which books would you recommend to learn Java? I am familiar with C/C++, Basic/VBA, but I have never written any line of code in Java ๐Ÿ˜‰

Very interested by this as well, although my knowledge of OO programming is lower since I do not know C++

I would rather advise to start learning the basics of the language. Thinking in Java should help with that. Once you get to know the basics you can start applying it to something simple such as B&S, Newton Raphson. A big difference with C++ other than the fact that you don’t have pointers, is the size of the java library.

I’ve never read any java based quant/finance book but then again I don’t like Java. Why not just pick up a generic Java book? You’ll most likely get a better glimpse of Java itself and then you can just leverage the financial aspects you already know from C++ and implement those in a “Java friendly way”.

For books if you prefer a erratic learn as you go with an original project in mind I’d go for a reference book such as Java Pocket Guide or Java in a nutshell.

If you prefer a step by step approach Head first Java is good to start (but a bit basic) and from there Effective Java and/or Thinking in Java (3rd ed is freely available on authors homepage).

Note these recommendations come from a person with years of experience since the only one I’ve read/used is Java Pocket Guide as as noted above I don’t like Java.

Without any longing to turn this into a flame war on languages. Why the interest in Java if you already have C++ nailed down?

Thanks, so I’ll begin with Eckel’s book.

you can review: Java Methods for Financial Engineering: Applications in Finance and Investment of Philip Barker

There is a specification for Java realtime which I have heard about in Java conferences(http://java.sun.com/developer/technicalArticles/Programming/rt_pt1/ and http://java.sun.com/javase/technologies/realtime/faq.jsp). Not having experienced it personally, I cant comment much on it but the focus here is on making executing of Java programmings more predictable.

 

 

 

BTW, before we dismiss Java on performance alone, Audi has an autonomous vehicle using Java RTS
http://www.gizmag.com/audis-autonomous-audi-tt-conquers-pikes-peak-how-long-before-it-betters-a-human-driver/17001/

and was used in Mars Rover
http://www.cnn.com/2004/TECH/space/01/16/space.mars.java.reut/index.html

If you can learn (and use ) Scala or Clojure instead, you’ll get the benefits of the JVM, but also a richer, more powerful language and libraries. (full disclosure: I co-wrote the O’Reilly Scala book.)

I’d like to second Carlos’ comment about “Java Methods for Financial Engineering”. I’ve only had a browse of it in Waterstones, but it looked very solid. It won’t teach you Java/OO, but it will give you a quant context on how the language can be used for pricing problems.

The source code for the book, Java Methods for Financial Engineering: Applications in Finance and Investment, appears to be available here:
http://www.bwatechnology.net/source.htm

Good choice — Java, especially for those in the fixed income world. But while working in the front office the #1 complaint is that you have to go to IT for a data-dump out of a Java application. Almost 98% of the time the on-screen apps don’t have immediately available data “export” routines, and you are left to cut&paste something messy.

 

I just believe in code purity ๐Ÿ˜‰ Java is interpretive, hence it will always be slower for things that need to go fastest. For the benefit of Java, Java is a mature language that fully embraces OOD and does run pretty seamlessly with just about any very heavy weight appliance out there. I like Java, it’s ability to run on all sorts of platforms give the coding in Java all sorts of benefits. You just have to know how to blend it with other languages (C/C++/Asm) to get the most bang for the buck, how to design it so it can take advantage of multiple platforms and design features and external coding in more native languages for when you need the speed.

 

I would recommend “Java Methods for Financial Engineering Applications in Finance and Investment. – Philip Barker”

I think there are many good reasons to expand your programming toolkit in general. Sure C++ is great at many things, in particular speed, but there are many reasons *not* to use C++ as a general programming platform. Java has lots of benefits. If you are proficient in C/C++ I agree that looking at one of the O’Reily “in a nutshell” books would likely be all you need. However, I will also recommend you look at Scala, Clojure, and/or Groovy. These are “programmer” programming languages, everything becomes easier and a lot more fun.

The main issue with Java isn’t speed, it’s garbage collection pauses. Java isn’t interpreted. HotSpot compiles “hot” byte code to native code. Also, because its doing global, runtime analysis, it can perform optimizations, like speculative inlining of polymorphic methods, that a C/C++ compiler can’t do, because the latter is limited to static, local analysis. Hence, there are many scenarios where Java out-performs similar native code.
However, it’s difficult to eliminate garbage collection pauses (although the JVM team continues to improve this issue). The real-time versions of Java provide better response guarantees, but pay a throughput penalty. Also, Java applications have a tendency to be more bloated than native apps. Care is required to avoid depending on too many extra libraries (jars). It’s true that RAM is relatively cheap, but cache misses are another very important factor in performance that few people appreciate. That is, going to memory is very expensive now, so you want to keep as much code and data in the CPU caches as possible.

Well, I think it’s speed too. Yeah, you can hyperdrive java with HotSpot and write it to machine but you just don’t have that total control (or at least feeling that you do) in java like you do have in C/C++. You have to get exotic to come close to what you get in C/C++ out of the box (not counting MS’s pollution with their mutations) in terms of speed and brute horsepower. GC just adds to the party where you freeze up and stutter on some level every so often – very painful…. although I have heard of some good products that seek to eliminate just that. As per language bloat, every language has it. Generalized toys come with a prize, obesity.

I say, write it in assembly >;)

 

This might not be quite on-topic, but if garbage collection is a problem with Java, have people tried Erlang? In Erlang, each process is GC’d independently, so pauses are insignificant. Erlang is not terribly fast on a single core, but it’s very easy to distribute an erlang application across many cores or machines.

You know, I sat and pondered your comment about java compiled into native could be just as fast as C++/C compiled native. It makes sense on the external, OOD mentality – machine code is machine code right? Well, not really. Java has one feature that C++/C does not, Java plays policeman with indexes and pointers. Every operation done is checked for out of bound violations in Java. In C++/C, it is the wild west. I can make a void pointer point to anywhere in the universe and fight with the processor to do what I want. C++ just doesn’t care and that translates into speed. Sure, you can make a darn fast Java (that skips to a GC heartbeat) but you can’t beat the insanity of C++/C.

That might be more applicable C than C++ at least I hope people don’t code that way just for the heck of it. Sure you can do this in C++ as in C but I’m sure most people will use boost smart pointers and boundary safe indexable objects rather than goof around playing cowboy. Unless of course you love gnitty gritty debugging or have a QA team and hate them (#define TRUE FALSE might be a better approach)

 

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!
Don't miss out!
Get my TRADE LIKE A BOSS 2 PDF Books

You will received instantly the download links.

Invalid email address
Give it a try. You can unsubscribe at any time.

NOTE!

Check NEW site on stock forex and ETF analysis and automation

Scroll to Top