I’m not much of a Language sort of guy (either real or computer, I failed French 3 times at school) so when I was asked to participate in a workshop at the upcoming OT2004 conference on generics I said 'no way'.
I always have problems in translating the wordage that is used in programming to my model of how things work that gives me problems with languages. I remember struggling to learn C until it was pointed out that it was just like a very smart MASM; I then cottoned on very quickly. I then went on to message based programming with the Transputer and OCCAM (anyone remember this?) rather than C++ so missing out on the OO world and leaving me vaguely uncomfortable with Polymorphism etc. I never really understood the fuss about Java, it just looked like another programming language with support for some higher level concepts to me.
I’m also nervous about languages which have lots of rich functionality; I remember working with an APL guru who boasted that he could write pretty well any application in one line of APL. I challenged him ato do this and he did indeed write a complex application in one line of APL. Alas no one could understand the one line and a week later he didn’t understand it either.
Anyway programming Languages have never been my forte so I was happy to decline the generics session. However I have been sort of roped in as an assistant so I feel I should know something about them. As the conference is coming up I have spent the last couple of days researching generics and trying to get the usual impenetrable jargon to gel with my understanding of how languages and programming work. I have read the reference papers at http://developer.microsoft.co.uk/Portal/DesktopDefault.aspx?tabindex=2&tabid=85§ionhome=true but they have not helped much.
The conclusion that I am sort of coming to is that we started off with templates and generics are just a smarter version of that on the way to a true Aspect Oriented Approach, as a sort of half way house.
Funnily enough I have never had a problem with AOP because it fits so well into the hardware work I used to do, particularly VHDL. This has the concepts of functional elements of the program and other aspects such as timing and power which really resonate with me. So I understand what AOP is all about and how it works, I’m just less clear with the halfway house stuff like generics.
Well I will continue to read and see if it clicks but if anyone has any good, clear papers or pointers to pages on generics let me know.. Please!
I remember Occam fondly - I did my final year university project in it purely because it seemed interesting. Completely against the advice of my tutor, and I gained my lowest mark of the year (more I think because he didn't understand it), but heck I learned alot.
I'm almost the opposite - I'm more into the languages and never really got into the design side of things - patterns and stuff.
Articles - this is quite good
I really liked OCCAM, all the focus was on the threading and messaging (remember PRI / ALT / PAR?) rather than the programming.
Thanks for the link
There is a fairly abstract level at which generics could be deemed to be a form of AOP: if you consider AOP as being all about allowing greater orthogonality in your designs - the ability to separate out those aspects of a design which can reasonably be separated out - then yes, I guess generics offer a form of that. (And in the same vein, you could argue that functional programming is the same idea too.)
For example, generics let you seperate out the "What operation am I doing?" concern from the "What kind of a thing am I doing it to?" concern.
Some of the more advanced uses of generics in C++ (I'm thinking of what's called 'metaprogramming' here) sometimes take this line with generics to fairly extreme lengths. But C# and VB.NET take a somewhat more restricted approach in order to reduce complexity - they focus on the ability seperate out the 'type of thing' aspect, but not much else. (Whereas C++ is a lot more flexible, potentially leading to code that is a whole lot harder to understand.)
The truth is that there's some overlap in the scope of what you can do with generics, and what you can do with some other language features, especially interface implementation. Both are a form of polymorphism, it's just that one does runtime binding while the other does compile time binding. In a JIT-compiled environment like the CLR that distinction is gradually becoming less clear, and the performance tradeoffs becoming less marked.
Looked at close up, generics look fairly different from any implementation of AOP that I've seem so far though. (And functional programming looks different from either.) Perhaps that's because we haven't yet work out The Right Way to do any of these things...
On the other hand, maybe it's because generics and functional programming are tools designed to allow low level implementation details to be expressed more clearly, rather than high level design concepts. (As a developer I find both very useful. But I don't think I'd use either of them in a diagram showing the design of a system.) But I'm not sure if that's where AOP sits in the grand scheme of things. (I haven't really worked out what I think of AOP yet though.)
Ok, so I have reread the articles and had a hard think so I think I am beginning to get an understanding of generics. Ian is right, they are a very basic subset of AOP but so far away that really the linkage is not really very useful. I think that they are actually a mechanism for adding attributes (types) to calls, mainly when you are working with some sort of structure. Very basic stuff. I read with interest Ian's blog on this at http://www.interact-sw.co.uk/iangblog/2004/03/14/generics and also bruces at http://mindview.net/WebLog/log-0050
I agree with bruce that generics is a bit of an overstatement for what we have today and that latent typing (as defined by Bruce) would be nice but then agree with Ian that what we have today is useful in that it gets rid of the casting.
Thanks Dave and Ian, I think I am getting there!
Good new paper on Java Generics http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
Interesting discussion on Latent Typing and safety (among other things!) following on from Bruces blog at http://www.theserverside.com/news/thread.tss?thread_id=24445#113712
Quiz on Java Generics at http://www.grayman.de/quiz/java-generics-en.quiz
So I didnt do too well, I will go back over the tutorial!