Dynamic Lookup in F#
Many people view dynamic and statically-typed languages as two distinct groups (and this is often a reason for never-ending discussions). In this article, I'll try to show one interesting example, which demonstrates that these two groups are not in fact that distinct and that you can implement a common dynamic language feature in F#, which is undoubtedly statically-typed. The feature that I'm talking about is dynamic invoke using a symbolic representation of the member (this is something that can be done using symbols in Ruby, but I'll shortly explain what exactly I mean).
I intentionally wrote statically-typed and dynamic instead of dynamically-typed. In my understanding dynamic is a broader term while dynamically-typed and statically-typed are of course two distinct groups. On the other side dynamic refers to language features that are usually available in dynamically-typed languages, just because it is easy to support them in a nice way. This doesn't mean that having a dynamic feature in a statically-typed language would be impossible - it is just more difficult to implement it in a way that would be similarly elegant.
Read the complete article (English)
Wednesday, June 04, 2008
Thesis: Client-side Scripting using Meta-programming
I realized that I haven’t yet posted a link to my Bachelor Thesis, which I partially worked on during my visit in Microsoft Research and which I successfully defended last year. The thesis is about a client/server web framework for F# called F# WebTools, which I already mentioned here and its abstract is following:
“Ajax” programming is becoming a de-facto standard for certain types of web applications, but unfortunately developing this kind of application is a difficult task. Developers have to deal with problems like a language impedance mismatch, limited execution runtime in web browser on the client-side and no integration between client and server-side parts that are developed as a two independent applications, but typically form a single and homogenous application. In this work we present the first project that deals with all three mentioned problems but which still integrates with existing web technologies such as ASP.NET on the server and JavaScript on the client. We use the F# language for writing both client and server-side part of the web application, which makes it possible to develop client-side code in a type-safe programming language using a subset of the F# library, and we provide a way to write both server-side and client-side code as a part of single homogeneous type defining the web page logic. The code is executed heterogeneously, part as JavaScript on the client, and part as native code on the server. Finally we use monadic syntax for the separation of client and server-side code, tracking this separation through the F# type system.
The full text is available here: Client side scripting using meta-programming (PDF, 1.31MB)
Read the complete article (English)
Monday, March 17, 2008
New Version of Phalanger with Silverlight and VS 2008 Support
At the Lang.NET Symposium I presented several new features in Phalanger. I already posted the presentation and samples on the blog (here) and the talk is also available as a video on the Lang.NET web site (here - actually, due to the huge demand the site is down now, but I hope it gets back soon!) Anyway, the most interesting thing is that I've used Phalanger Integration for Visual Studio 2008 during the talk, which wasn't available in any Phalanger release until now.
I have to mention one more thing before talking more about the new release - Phalanger Integration for VS 2008 works with Visual Studio Shell, which means that you can get Visual Studio 2008 with Phalanger Support for free! Yes, that's right. Microsoft offers so called Visual Studio 2008 Shell, which is an "empty" IDE with no integrated languages and you can install Phalanger Integration into this version, which means that you can get very good Phalanger IDE (for Windows) for no cost at all!
If you can't wait to install this new version, you can skip the overview article and go directly to the installation links.
Read the complete article (English)
Tuesday, March 11, 2008
F# Support for ASP.NET and Notes on Samples
As I mentioned earlier, I spent three months as an intern in Microsoft Research in Cambridge last year and I was working with Don Syme and James Margetson from the F# team. Most of the time I was working on the F# Web Toolkit, which I introduced on the blog some time ago [1], but I also worked on a few additions that are now part of the F# release. Probably the most useful addition is a new implementation of the CodeDOM provider for the F# language which makes it possible to use ASP.NET smoothly from F# (but it can be used in some other scenarios as well) together with two ASP.NET sample applications that you can explore and use as a basis for your web sites. This was actually a part of the distribution for a few months now (I of course wanted to write this article much earlier...), so you may have already noticed, but anyway, I'd still like to write down a short description of these ASP.NET samples and also a few tips for those who're interested in writing web applications in F#.
Read the complete article (English)
Saturday, March 08, 2008
Phalanger at Lang.NET Symposium
Last week I attended the Lang.NET Symposium and I also did a short presentation about Phalanger (below you can find the demos and slides from my talk). By the way – during the trip from Prague to Seattle I missed a connecting flight from Paris, so I had one day to visit Paris and since I was traveling on Saturday I actually quite enjoyed it :-), so that’s where the picture comes from.
Overall it was really a fantastic event with many great talks from many interesting people. I hope that there will be recordings as a last year, so I won’t comment every topic that I found interesting (that would be really a long post). But just quickly – people from Microsoft often talked about DLR (dynamic language runtime) related topics, which was interesting as we’re planning to look at DLR in Phalanger. Luckily, Wez Furlong from the PHP community was there too, so we discussed how we could work on “PHP on DLR” project together (see also our mailing list).
There were also two talks about F# (from Luke Hoban and Harry Pierson), and it was a lot of fun to hang out with them. Finally, Erik Meijer presented the Volta project, which I was particularly interested in as it shares many goals and ideas with my F# Web Tools.
Non-Microsoft talks covered wider range of topics including Mono and Moonlight project (by Miguel de Icaza) and I actually had a chance to talk with Miguel about Phalanger and we even tried running the Helicopter sample on Moonlight – there were some issues, but it seems quite promising, so I hope to have the sample running on Moonlight on Linux quite soon! Miguel mentioned that the installation of Moonlight is currently a bit painful (due to some issues with media codecs), but it should be fixed in next few weeks, so I hope to be able to try it on my machine too!
Read the complete article (English)
Saturday, February 02, 2008
Writing Silverlight applications in PHP
In my last post about Phalanger I mentioned that our important goal is to support the Silverlight (2.0) platform. Shortly Silverlight is a cross-browser platform that can be used for developing client-side components that run in the web browser and contain rich media, graphics and can interactively communicate with the user. The language that can be used for writing Silverlight code can be in general any .NET language, so our goal is to allow using PHP by making Phalanger compatible with Silverlight.
First steps were already made and it is becoming possible to write some very interesting things in Silverlight using PHP, there is of course still a lot of work to do and we're discussing the future development with PHP development team (you can join the mailing list PHP on DLR for more info). In this article we will first show a very basic Silverlight example that uses PHP and later I will shortly comment more complicated example - a game (quite addicting, so be careful :-)!) where you have to fly with helicopter and avoid the walls. The source code for helicopter game is also attached, so feel free to modify it or create similar games!
If you can't wait to try the demos before looking at the sources, here are the links:
- Simple car demo - Click on the car and it will move!
- Helicopter game demo - Click left button to fly up!
Read the complete article (English)
Friday, December 07, 2007
A few notes about Phalanger future
First, I'd like to aplogoize for the lack of new about the Phalanger project recently. I spent some time working as an intern with the F# team in MSR Cambridge and I also had final bachelor exam this autumn. Anyway, this doesn't mean that there isn't anything new and interesting regarding the Phalanger project comming soon - actually (as I believe) the opposite is true! The topics that I'm going to further discuss in this article is our upcomming support for Silverlight platform, the relation between Phalanger and DLR and also our desire to make Phalanger more open to the community, so stay tuned!
Read the complete article (English)
Sunday, December 02, 2007
Infinite Cheese Fractal using WPF 3D and F#
I always liked fractals, because they look like objects from another world, but on the other side if you look at some things in our world you can see many similarities with fractals (but not quite as ideal with the infinite level of precision). One of my favorite fractals is 3D version of Sierpinski carpet [1], which itself is based on very famous Cantor set. Quite long time ago I thought that it would be nice to implement animation of flying through this fractal, but I was never good in 3D graphics and it looked like a lot of work, so I never get to doing it. Luckily, now with F#, which makes it very easy to write the code to generate the fractal and with WPF 3D, which can be easily used to animate the fractal, I finally had everything I needed to do it, so here it is!
Read the complete article (English)
Saturday, November 24, 2007
Asynchronous Programming in C# using Iterators
In this article we will look how to write programs that perform asynchronous operations without
the typical inversion of control. To briefly introduce what I mean by 'asynchronous' and
'inversion of control' - asynchronous refers to programs that perform some long running operations
that don't necessary block a calling thread, for example accessing the network, calling web services
or performing any other I/O operation in general. The inversion of control refers to the code structure
that you have to use when writing a code that explicitly passes a C# delegate as a callback to the
asynchronous method (typically called BeginSomething in .NET). The asynchronous method
calls the delegate when the operation completes, which reverses the way you write the code - instead of
encoding the control flow using typical language constructs (e.g. while loop) you have to
use global variables and write your own control mechanism.
The funny thing about this article is that it could have been written at least 3 years ago when a beta version of Visual Studio 2005 and C# 2.0 became first available, but it is using iterators in a slightly bizarre way, so it is not easy to realize that this is possible. Actually, I will use some C# 3.0 methods in the article as well, but only extension methods and mainly just to keep the code nicer. As with my earlier article about building LINQ queries at runtime, I realized that it can be done in C# when I was playing with the F# solution (called F# Asynchronous Workflows), where this approach is very natural, so I will shortly mention the F# implementation as well.
Read the complete article (English)
Thursday, November 15, 2007
F# Overview (IV.) - Language Oriented Programming
In the fourth article of the F# overview series, I will shortly describe how I understad the language oriented paradigm and how the F# language can be used for developing libraries using this paradigm. We will look how discriminated unions relate to this paradigm and at three specific features that support this paradigm, namely active patterns, computation expressions and quotations.
Defining precisely what the term language oriented programming means in context of the F# language would be difficult, so I will instead explain a few examples that will demonstrate how I understand it. In general, the goal of language oriented programming is to develop a language that would be suitable for some (more specific) class of tasks and use this language for solving these tasks. Of course, developing a real programming language is extremely complex problem, so there are several ways for making it easier. As the most elementary example, you can look at XML files (with certain schema) as language that are processed by your program and solve some specific problem (for example configuring the application). As a side note, I should mention that I'm not particularly happy with the term ‘language’ in this context, because the term can be used for describing a wide range of techniques from very trivial constructs to a complex object-oriented class libraries, but I have not seen any better term for the class of techniques that I’m going to talk about.
Read the complete article (English)
Saturday, November 03, 2007


