I’m currently in the process of learning functional programming using the F# programming language. It’s a slow & long journey but I enjoy it and even though I’m not using it on any real project (yet), “It makes my C# better“. While learning F#, I came across a technique called Tail-recursion … this is something most of us have learned during our studies, but I’m not sure everybody is using it on a daily basis
I wasn’t really aware of the implications this could have at runtime if the compiler could recognize tail-recursive functions and optimize code for them (basically, generate a loop) : successive recursive calls don’t consume additional stack space and thus don’t eventually cause a StackOverflow exception (looking at the Call Stack debug window in Visual Studio shows that only 1 stack frame is being used).
It is very interesting to know that the F# compiler does optimize code when it encounters tail-recursive functions while the C# compiler (most of the time) doesn’t. So, basically, there is no limitation at the CLR level, it is mostly up to the compiler to optimize or not based on some heuristics. If the C# compiler is not on par with F# one (yet), some improvements have been made in the latest release (4.0).
If you’re interested by this topic, here is a list of very informative posts (.Net specific):
And if, like me, you are a newbie in functional programming but you are willing to learn (on the .Net platform with F#) I would recommend the following book : Programming F#
It seems that Oslo is generating some buzz lately, especially since one of the Oslo PMs tried clarifying the situation … still nobody seem to know what it actually is. So, is it another vaporware from Microsoft or is it a revolutionary way of developing software ? does it do coffee as well ?
Well, I obviously don’t pretend having the final answer but I wanted to give my 2 cents on the subject:
- I don’t think it’s just about database development … I have NHibernate, thank you.
- I don’t think either that it’s just about developing textual DSLs … there is Gold, ANTLRWorks, Boo, F# …
- I don’t think that’s it’s just a MDD modeling tool (Middle-Out approach with model transformations and full traceability between models !) … we have tons of them already, and very good ones.
- It might be viewed as a Language / Domain Workbench … (here, here, here & there).
- It might also be at some point a host for executable semantic models.
My hope is that it’s all of that, unified in a single consistent vision and bundled in an integrated suite of tools & technologies. This might well change the way we think about and develop, or should I say model, software.
Maybe I am completely wrong. But if there’s a good mix of those technologies in it, I am very excited about Oslo, even though it is still in its (very) early stages and the future is still somewhat unclear.
And you, what is your opinion about what Oslo is / should be ?
An interesting presentation that I also encourage you to watch (after those ones) is about Creating DSLs in Microsoft Oslo, by Amanda Laucher, if you have any interest in Domain Modeling, Domain-Specific Languages & Semantic Models.
Great presentation by Erik Meijer at OSCON 09 about Functional Programming and why it matters in these days of multi-core CPUs and distributed computing.
I have been reading & learning more and more for the past months about Functional Programming, F#, Parallelism & Concurrent Programming. It’s a tough ride but I believe it’s worth it.
Still, I’m not feeling confident enough to blog on the subject (have to finish 2 books before I start reading about a pure functional language, Haskell, as Erik recommends it).
Another excellent presentation : Concurrent Programming with F# by Amanda Laucher at QCON 2009.
Stay tuned … and go read about & learn those subjects too !
Quick description of the goodies that we will have in C# 4.0
The Future of C#