Chris Donnan : Programming – Brooklyn Style
software, trading, family, fun
Posted c#, programming on Monday, February 19th, 2007.
Puzzle:
What will it print?

Well – it calls the object overload all 3 times…
Lets see the IL

So – you see that it does the cast to !T (generic parameter T) but it STILL calls the ‘object’ override in L_0008. I have played and played with this. There is another IL syntax that shows !1, etc for the VALUE OF generic parameter 1 I believe, but the IL does not get generated to call the object override.
This is a somewhat contrived example, but I have on a few times now (this is why I am complaining at this point) tried to use a genric as a parameterized type for a block of code that needed simply to have that – a parameterized type. That said – a generic value WILL NEVER call the polymorphic overrides – it will always use object. It seems that there is IL that COULD be generated (the !1 – etc. syntax), but it is not.
So – there is my rant. Generics are a great tool, but sometimes they can cause a headache
-Chris
You can leave a response, or trackback from your own site.
Posted programming on Saturday, February 17th, 2007.
As long as it passes the approval of my current employer – I will be speaking at CodeCamp NYC ‘07. I will be speaking on scaling agile practices. It should pass corp approval, but since my day to day work is attached to this stuff – investment banks keen to monitor what people say in public.
Fun fun;
Chris
You can leave a response, or trackback from your own site.
Posted programming on Saturday, February 17th, 2007.
During an interview, a candidate brought up reactor/ proactor patterns – blast from the past.
Here is a good link to a list of Patterns for Concurrent, Parallel, and Distributed Systems.
-Chris
You can leave a response, or trackback from your own site.
Posted algorithmic trading on Saturday, February 3rd, 2007.
Congrats Anton!
Quant House acquires SmartQuant program trading technology
I have used SmartQuant for years. I started looking at while it was an open source C++ project many years ago now. SmartQuant is a .net based framework for developing automated trading systems. I own a license from a few years ago with a trader partner of mine (Rod – you are the man!). We actually had an option (expired useless as most do) to extend our license to be ‘available to commercially resell’ SmartQuant. We never got to all that – too many other things goin’ on.
The product has matured much over the past several years. I licensed it when the product was ’smartquant’. Since then – the product changed a bunch and became ‘quant developer’ I believe. I had used it in fits and starts for various auto-trading projects. At times – it was great and helpful, at times – a punishment – as all software is at times. It is a very well written bit of software I can say with certainty. I hope the best for all involved here.
The guys at QuantHouse have made a great play in my way of thinking. You can really write autotrading systems in C#, VB, C++ – any CLR compliant language. They provide a nice IDE – things like ‘meta-strategies’, some basic optimization options, some neural net ’stuff’ and a great general toolbox for developing, testing and running trading systems.
Best of luck guys!
Chris
You can leave a response, or trackback from your own site.
Posted c#, programming on Saturday, February 3rd, 2007.
I spent several months doing .net 2.0 work, then, several months back to a 1.1 project. We have just moved our 1.1 project from nant to msbuild. I am a fan of msbuild, custom tasks and such – it seems like a total better solution than our nant solution. When you have complex work to do – it can get ugly fast – but it seems less ugly with msbuild. In any case – now that that project has been upgraded – I am back the past few weeks to .net 2.0. I really missed anon-delegates more than anything else. Closures are powerful, iterators rock, generics – yes – nice. All of that said – there is at least one glaring problem with generics as implemented in the current CLR.
Generics currently lack covariance/ contravariance
While delegates currently support co/contra variance – generics still lack this behavior. As someone who spends a lot of time building and co-evolving frameworks – this has proven to be troublesome for projects. This is something that irked me ~7-10 months ago and it is back to irritate me again.
Allow me to illustrate…
ArrayList< Car > = new ArrayList< Car >();Â
This is the easiest – no magic at all – same type on each side of the “=” and same type parameter. Of course – this works fine.
Next
IList< Car > = new ArrayList< Car >();Â
Of course this works – this is normal stuff; the inheritance/ implementation of the ‘left side’ of the generic instance declarations work fine (meaning IList/ ArrayList work fine). IList – sure ArrayList implements that – we are good. They also both have a type parameter of type Car – this is fine, we are good to go.
How about this:
IList< Car > = new ArrayList< Ferrari >();Â
In this example lets say Ferrari extends Car. Alas – this does not work. The inheritance/ implementation of the ‘left side’ of the equation (IList/ ArrayList) works fine – but the inheritance on the ‘right side’ of the equation (Car/ Ferrari) DOES NOT WORK. The inheritance scheme does not matter – they are not THE SAME TYPE. This is the ‘crux of the biscuit’ as they say. This is the problem I am talking about
.
Alas -
ArrayList< Car > = new ArrayList< Ferrari >();Â
This does not fix the issue – same problem – even though there is now no inheritance on the ‘left side’ of the equation – and there is simple inheritance on the rights side – it does not matter. The inheritance on the ‘right side’ of the equation does not work in CLR 2.0. Generic types are invariant unfortunately.
This article has an interesting idea on a potential syntax to denote allowed co/contravariant. The idea is that you can use a + or a – in the generic type declaration to denote desired co/contravariant behavior.
Anyhow – there is my complaint rant on generics. I would rather have them as is today than not at all – that is for sure
-Chris
PS – I did not point it out earlier – but all co/contravariance mean is: in one case – your supplied class is a sub-class of the type parameter, in the other case – a super-class of the type parameter.
PPSÂ - Another issue – the new constraint does not allow new(args) to enforce that the template type allows a specific constructor – also annoying!
You can leave a response, or trackback from your own site.
