Forums  > Software  > Java for finance  
     
Page 2 of 3Goto to page: 1, [2], 3 Prev Next
Display using:  

silverside


Total Posts: 1412
Joined: Jun 2004
 
Posted: 2012-09-07 15:28

@signalseeker

no - I haven't used Java much, but generally GS code is high quality, so I thought I would share the link to the NP community.


tristanreid


Total Posts: 1677
Joined: Aug 2005
 
Posted: 2012-09-13 08:59
Following up on a conversation off-line:
http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java

You can tell that this page was written with a bias toward c#, a lot of the comparisons are questionable, and even the syntax highlighting used on the page is better for the c# code. That said...

The highlights to me:

-the way java handles object vs primitive types isn't very flexible and leads to workarounds. For example the lack of structs (as pointed out by FDAX), and the inability in java to 'unset' a primitive type to null, which leads to workarounds like magical numbers or an extra boolean to keep track

-if you ever call other language environments like COM, you get a variable that has properties/methods that are known by you, but not the compiler. In java you handle this by either creating fake stubs and casting or by calling everything using a string mechanism of some sort. In c# you have the dynamic keyword, which allows you to call things normally without the compiler complaining

-delegates and closures - this is huge. Even if you're not into the functional programming thing, just doing stuff like event handling is much simpler when you can pass a reference to a function around

-generators (the yield return thing). You can't quite do the same thing with Java using iterators. I actually wrote the examples of this on the comp sci generators Wikipedia page some time ago, but the problem with iterators is that you only get one return expression, you can't do a series of returns the way you can with yields.

-no operator overloading in java. I honestly don't use this all that much in c#, but I think it highlights the trend that Java tries too hard to protect a programmer from himself.

Anyway, none of this alleviates my suspicion that in a couple years we're all going to be talking about JavaScript anyway... Evil Grin

-t.


the only reason it would be easier to program in C is that you can't easily express complex problems in C, so you don't. -comp.lang.lisp

MadMax


Total Posts: 424
Joined: Feb 2006
 
Posted: 2012-09-13 10:12
Not a java fan and only had basic experience with it, but it thought I should point out that the lack of delegates and closures can be alleviated (I think) by combining it with other JVM languages like Scala and Clojure.

tristanreid


Total Posts: 1677
Joined: Aug 2005
 
Posted: 2012-09-13 11:58

That's true.  Scala also fixes some of the other nice-to-have's like operator overloading and multi-line strings (which I forgot in my list above, but I REALLY like in C#)

What Scala and Clojure can't fix is the relative weakness inherent in the JVM. Two things that FDAXHunter pointed out last night:  lack of ability to efficiently use memory (no struct), and the precision of the DateTime libraries (Java has 1,000 ticks per second, C# has 10 million).  It's basically that CLR gives you more raw-metal access than JVM.

-t.


the only reason it would be easier to program in C is that you can't easily express complex problems in C, so you don't. -comp.lang.lisp

signalseeker


Total Posts: 237
Joined: Oct 2006
 
Posted: 2012-09-13 15:46
There is system.nanoTime for higher than millisecond precision and fastutil for collections of primitives. I remember seeing some libs which provide structs but have personally never used them. I prefer working with arrays or collections of primitives when I care about memory efficiency.

I thought both the articles presented in this discussion were quite biased and even inaccurate at times.

There is no doubt in my mind that C# is a superior language to java but I am not sure how the JVM compares to CLR in terms of performance. It would be interesting to see some research papers on that topic.

At the end of the day the biggest factors in choosing a language/platform is whether you are working on unix or windows and your programming ability.

IMO historically java has mostly appealed to below average programmers and most of the java code out there is pretty bad. That does not really mean you can't write fast code in java. FWIW LMAX is an example and one of the top US equity exchanges have their core matching engine written in java.

The dark is light enough.

Nonius
Founding Member
Nonius Unbound
Total Posts: 12723
Joined: Mar 2004
 
Posted: 2012-10-28 14:38
by the way, this guy's library seems pretty decent.

Michael Thomas Flanagan's java library

Chiral is Tyler Durden

Nonius
Founding Member
Nonius Unbound
Total Posts: 12723
Joined: Mar 2004
 
Posted: 2012-11-04 00:39
problem is...I'm getting

Exception in thread "main" java.lang.UnsupportedClassVersionError: flanagan/complex/Complex : Unsupported major.minor version 51.0


i'm running

java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-10M3811)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)

Chiral is Tyler Durden

astar


Total Posts: 176
Joined: Mar 2007
 
Posted: 2012-11-04 00:47
Your javac seems to be java 1.7 and the the bytecode interpreter is version 1.6. You probably have two different versions of java installed. The 1.6 runtime and the full dev environment of version 1.7, and the 1.6 occurs before 1.7 in the PATH, or the jar file is compiled with version 1.7 and your version is 1.6, anyway, java equivalent of dll hell

Nonius
Founding Member
Nonius Unbound
Total Posts: 12723
Joined: Mar 2004
 
Posted: 2012-11-04 17:47
so, in a word, make sure everything in sight is 1.7? (which means I have to install Mountain Lion by the way).

Chiral is Tyler Durden

Praetorian


Total Posts: 224
Joined: Apr 2009
 
Posted: 2012-11-05 00:00
Java support has moved directly to Oracle. The 1.7 JRE/JDK should run on 10.7.3 upwards, so a Mountain Lion Upgrade is not necessary.

astar


Total Posts: 176
Joined: Mar 2007
 
Posted: 2012-11-05 04:41
Why companies use cute names (of animals, rivers in their vicinity, characters from now-defunct shows, whatever) instead of normal numbers is beyond me.

Nonius
Founding Member
Nonius Unbound
Total Posts: 12723
Joined: Mar 2004
 
Posted: 2012-11-08 07:38
Don't know but mountain lion sucks. The machine is markedly slower.

Chiral is Tyler Durden

tristanreid


Total Posts: 1677
Joined: Aug 2005
 
Posted: 2012-11-08 17:28
A bit off-topic, but related to the posts earlier about Java's capabilities: IBM has a project called Metronome (link), it implements real-time garbage collection, meaning you can be guaranteed that your code won't be interrupted in sub-millisecond operations. They've used it for control of an autonomous helicopter, among other things.

the only reason it would be easier to program in C is that you can't easily express complex problems in C, so you don't. -comp.lang.lisp

katastrofa


Total Posts: 443
Joined: Jul 2008
 
Posted: 2012-11-08 22:43
"Why companies use cute names (of animals, rivers in their vicinity, characters from now-defunct shows, whatever) instead of normal numbers is beyond me."

Still, Mountain Lion is better than "Horny Hippo" or similar crap used to name every Ubuntu release.

Nonius
Founding Member
Nonius Unbound
Total Posts: 12723
Joined: Mar 2004
 
Posted: 2012-11-10 05:31
I don't give a fuck what companies call their crap, what I do care about is if it is crap.

anyway, astar, thanks, I sorted it out pretty easily. Still like certain elements of Java.

Chiral is Tyler Durden

jslade


Total Posts: 1123
Joined: Feb 2007
 
Posted: 2012-11-27 11:16
I got a dumb Java question: What do the cool kids use for a timeseries class? I'm working with some client code using jodatime and guava collections, and can't get over the feeling that this is kind of retarded.

"Learning, n. The kind of ignorance distinguishing the studious."

tron_at


Total Posts: 10
Joined: Nov 2009
 
Posted: 2012-11-27 13:02
Interesting question and I really don't know if I am a cool kid ;)
Currently I am using plain long and double arrays. A wrapper class facilitates the usage.

Who are you to wave your finger?

Praetorian


Total Posts: 224
Joined: Apr 2009
 
Posted: 2012-11-27 13:07
I have not found time series implementations in Java of any use and ended up implementing it myself. If you only want to play around and are not that much performance constrained, jquantlib has an implementation.

jslade


Total Posts: 1123
Joined: Feb 2007
 
Posted: 2012-11-28 06:38
Thanks for the pointers guys. I'm a big fan of longs and arrays, even though Java arrays are in retardo land.
Praetorian: is that how you do it also, or do you favor the "collections" idea?

"Learning, n. The kind of ignorance distinguishing the studious."

Praetorian


Total Posts: 224
Joined: Apr 2009
 
Posted: 2012-11-28 17:07
My implementation is made of arrays. Arrays have the advantage that you can insert in constant time if your data to be inserted is already sorted (which should be the case for time series data). The insertion method checks if it can simply append at the end, otherwise is has to make a binary search (for random insertions). Lookup is made by binary search. Of course this implementation has a caveat: You can either insert ascending or descending in a fast way. You could make the implementation a little bit more flexible by handing the constructor if you want to insert ascending/descending - I did not need that.

The problem with any hashing collection is, that you have to pay O(log n) for insertion. I have not found this kind of implementation anywhere on the web, so I had to do it myself.

The hassle is to extend the array from time to time. Look at the implementation of some collections to get an idea of how to do that in an efficient way. Or use ArrayLists and give up a little bit of performance.

signalseeker


Total Posts: 237
Joined: Oct 2006
 
Posted: 2012-11-28 23:17
Take a look at fastutil.

The dark is light enough.

Nonius
Founding Member
Nonius Unbound
Total Posts: 12723
Joined: Mar 2004
 
Posted: 2013-01-21 12:49
question on Esper for java.

there's an example of a OHLCBar in Esper.

you need to do something like this:


cepConfig = new Configuration();
cepConfig.getEngineDefaults().getThreading().setInternalTimerEnabled(false);

cepConfig.addEventType("TickDataRecord", TickDataRecord.class.getName());


cepConfig.addPlugInView("examples", FartMe, OHLCBarPlugInViewFactory.class.getName());

Now, I want to modify the OHLCBarPlugInView itself so that it contains a few more data members. It is easy to have a constructor accomodate those new data members, but that constructor is only called from the OHLCBarPlugInViewFactory factor, which, in turn, is not exactly visibly constructed in the code above....what i did as a temp work around, but which cannot work as a good solution, is to add public static data members in the Factory itself and then set them with...

OHLCBarPlugInViewFactory.Splug=MySplugValue;

but of course that would be at the class level, and I want each object to have its own splug value.

ideas? workarounds?



Chiral is Tyler Durden

tristanreid


Total Posts: 1677
Joined: Aug 2005
 
Posted: 2013-01-21 20:28
Hey Nonius,

I've never used Esper, but I think the intent of the plugin / factory is that your class will subclass OHLCBarPlugInViewFactory, the actual instance construction will take place in some static factory method (probably called getXXX, createXXX, makeXXX, something like that - XXX will be something like OHLCBarPlugInView, or just PlugInView), you can override that function in your own factory to customize how you want the construction to take place. In other words:

MyPluginFactory extends OHLCBarPlugInViewFactory{
public OHLCBarPlugInViewFactory getPlugInView(SetupVars vars){
MySplugValue = //...go get appropriate information to pass into constructor...
return new MyPluginFactory(MySplugValue);
}
}

the only reason it would be easier to program in C is that you can't easily express complex problems in C, so you don't. -comp.lang.lisp

Nonius
Founding Member
Nonius Unbound
Total Posts: 12723
Joined: Mar 2004
 
Posted: 2013-01-21 22:10
Tanks Tristan, but the statement that creatEs the factory itself is

cepConfig.addPlugInView("examples", FartMe, OHLCBarPlugInViewFactory.class.getName());

The function to override would have to be passed Splug arg, but there's no point in my code to do that....so I was going to embed Splug in the factory itself.

So, the factory spawns PlugInViews but it doesn't spawn them in my source code. Not sure if im being clear for you.

Chiral is Tyler Durden

tristanreid


Total Posts: 1677
Joined: Aug 2005
 
Posted: 2013-01-22 17:27

I googled the classname, looks like it takes a ServiceContext argument.  I think you want your PlugInViewFactory to make use of your the ServiceContext to get Splug, rather than have it passed in as a distinct argument. 

Looks like there's some sort of VariableService interface for this?  If I'm leading you astray, I apologize in advance...

-t.

 


the only reason it would be easier to program in C is that you can't easily express complex problems in C, so you don't. -comp.lang.lisp
Previous Thread :: Next Thread 
Page 2 of 3Goto to page: 1, [2], 3 Prev Next