Articles | TomasP.Nethttp://tomasp.net/articlesArticles2010, Tomas PetricekArticlesUsing custom grouping operators in LINQhttp://tomasp.net/articles/custom-linq-grouping.aspxSun, 07 Feb 2010 20:13:32 GMTIn LINQ, we can group data using the "group by" clause. However, there are other potentially useful implementations of grouping. For example, we may want to group only adjacent elements or group ascending or descending parts of the data. This article shows how to use custom behavior when grouping data using "group by" in LINQ query.Tomas Petricek<p>You can use LINQ to write queries that perform grouping of data using <code>group by</code> or ordering of data using <code>orderby</code> clause. LINQ provides the default (and the most common) implementation of both of the operations, but sometimes you may need a slightly different behavior when grouping or ordering data (this article is motivated by a <a href="http://stackoverflow.com/questions/2194761/can-i-use-linq-to-retrieve-only-on-change-values" type="external">question on StackOverflow</a> which needs to do exactly that for grouping).</p> <p>Let's look at a simple example, which shows when we may need a different behavior when grouping data. For example, we may have the following list of stock trades containing a name of a stock and the price of the trade (stored for example as a list of <code>TradeInfo</code> classes with properties <code>Name</code> and <code>Price</code>):</p> <pre lang="csharp"> { { Name = "MSFT", Price = 80.00 }, { Name = "MSFT", Price = 70.00 }, { Name = "GOOG", Price = 100.00 }, { Name = "GOOG", Price = 200.00 }, { Name = "GOOG", Price = 300.00 }, { Name = "MSFT", Price = 30.00 }, { Name = "MSFT", Price = 20.00 } }</pre> <p>Now, we may want to group adjacent trades into a single summary record which will contain the name of the stock (which is same for all trades in each group), the number of trades in the group and an average price in the group. The desired results are:</p> <pre lang="csharp"> { { Name = "MSFT", Count = 2, AvgPrice = 75.00 }, { Name = "GOOG", Count = 3, AvgPrice = 200.00 }, { Name = "MSFT", Count = 2, AvgPrice = 25.00 } }</pre> <p>The operation that we want to do is very similar to <code>group by</code> in LINQ, but it doesn't do quite the same thing! If we used <code>group by</code>, we would get only two groups as the result. However, as I wrote earlier, we want to group only <em>adjacent trades</em>. You could write your own extension method to do this, but then you need to leave the elegant LINQ query syntax. In this article, I'll show you how to get the desired results using a simple LINQ query with a <code>group by</code> clause...</p>Accelerator and F# (IV.): Composing computations with quotationshttp://tomasp.net/articles/accelerator-quotations.aspxTue, 12 Jan 2010 03:20:36 GMTIn this article series we're talking about the Accelerator project, which can be used from F# to write code that runs in parallel on GPU or multi-core CPU. In this article, we'll look at building complex data-parallel programs with F# quotations, we'll implement blur filter and we'll also discuss architecture and performance.Tomas Petricek<p>In this article series, we're talking about the Accelerator project and I'm presenting an F# library that I implemented, which allows you to use Accelerator [<a href="http://tomasp.net/blog/accelerator-quotations.aspx#accelfsh4links">references</a>] in a more sophisticated way. We've seen two examples of using Accelerator directly (see also <a href="http://tomasp.net/blog/accelerator-intro.aspx">introduction</a> and <a href="http://tomasp.net/blog/accelerator-life-game.aspx">Game of Life</a>). In the <a href="http://tomasp.net/blog/accelerator-dataparallel.aspx">previous article</a> I introduced my F# library for working with Accelerator. We've seen F# functions from the <code>DataParallel</code> module, we implemented an algorithm that rotates an image using these functions and finally, we've seen that we can take this ordinary F# code and run it using Accelerator. This is all possible thanks to F# quotations, which we can use to get an AST (a source code) of an F# function we wrote (if the function is marked in some special way).</p> <img src="http://tomasp.net/articles/accelerator-quotations/blur.png" alt="Blurred photo of Prague" style="float:right; margin:10px" /> <p>In this part of the series, we're going to look at working with quotations explicitly. We'll use meta-programming techniques to work with Accelerator. Meta-programming means writing programs that manipulate with other programs or pieces of code. This is exactly what we're going to do in this article. We'll write an F# function (running on CPU) that builds a program, which we'll then run using Accelerator.</p> <p>This is quite interesting approach, which isn't possible when we call Accelerator methods as standard F# functions or .NET methods. The benefit is that we'll clearly see which parts of program run on CPU and what parts execute on GPU or using X64 multi-core target. We could also perform more complicated optimizations with the code (because this wouldn't affect the readability). Just for your reference, here is the list of articles in this series in case you missed some of them:</p> <ul> <li><a href="http://tomasp.net/blog/accelerator-intro.aspx">Accelerator and F# (I.): Introduction and calculating PI</a></li> <li><a href="http://tomasp.net/blog/accelerator-life-game.aspx">Accelerator and F# (II.): The Game of Life on GPU</a></li> <li><a href="http://tomasp.net/blog/accelerator-dataparallel.aspx">Accelerator and F# (III.): Data-parallel programs using F# quotations</a></li> <li><strong>Accelerator and F# (IV.): Composing computations with quotations</strong></li> </ul> <p>However, enough with theory and let's take a look at some code samples! This time, we'll implement blurring of an image (also called convolution). Another example how to write this in F# using Accelerator is Satnam Singh's blog post [<a href="#accelfsh4links">4</a>]. Our example will be different, because we'll write the code as standard F# program and then have it translated to Accelerator automatically using quotations. We'll also talk about the architecture of the library that we're using and look at some performance results.</p> Accelerator and F# (III.): Data-parallel programs using F# quotationshttp://tomasp.net/articles/accelerator-dataparallel.aspxMon, 04 Jan 2010 12:50:13 GMTWe already discussed how to write programs that run on GPU using MSR Accelerator. In this article, we'll write an image rotation using data-parallel F# functions and then use a library that translates it to Accelerator automatically.Tomas Petricek<p>If you've been following this article series, you already know that Accelerator is a MSR library [<a href="http://tomasp.net/blog/accelerator-dataparallel.aspx#accelfsh3links">1</a>, <a href="#accelfsh3links">2</a>] that allows you to run code in parallel on either multi-core CPU or using shaders on GPU (see <a href="http://tomasp.net/blog/accelerator-intro.aspx">introduction</a>). We also discussed a direct way to use Accelerator from F# (by calling Accelerator methods directly) and <a href="http://tomasp.net/blog/accelerator-life-game.aspx">implemented Conway's Game of Life</a>. In this article, we'll look at more sophisticated way of using Accelerator from F#. We'll introduce F# quotations and look at translating 'normal' F# code to use Accelerator.</p> <img src="http://tomasp.net/articles/accelerator-dataparallel/rotated.png" alt="Rotated Prague photo" style="float:right; margin:10px" /> <p>In general, F# quotations allow us to treat F# code as data structure and manipulate with it. This is very similar to C# expression trees, but the F# implementation is more powerful. We can also mark a standard method or a function with a special attribute that tells the compiler to store quotation of the body. Then we can access the quotation and traverse it or modify it. In this article we'll use a function that takes an F# quotation (containing a limited set of functions) and executes it using MSR Accelerator. Implementing this functionality is a bit complicated, so we won't discuss the implementation now. We'll leave this for some future article of this series. In future, we'll also look at other interesting possibilities that we have when writing code using quotations. Here is a list of articles in this series and of the articles that I'm planning to add:</p> <ul> <li><a href="http://tomasp.net/blog/accelerator-intro.aspx">Accelerator and F# (I.): Introduction and calculating PI</a></li> <li><a href="http://tomasp.net/blog/accelerator-life-game.aspx">Accelerator and F# (II.): The Game of Life on GPU</a></li> <li><strong>Accelerator and F# (III.): Data-parallel programs using F# quotations</strong></li> <li><a href="http://tomasp.net/blog/accelerator-quotations.aspx">Accelerator and F# (IV.): Composing computations with quotations</a></li></ul> Accelerator and F# (II.): The Game of Life on GPUhttp://tomasp.net/articles/accelerator-life-game.aspxMon, 28 Dec 2009 21:16:03 GMTThis article shows how to use Accelerator from F#, which I <a href="accelerator-intro.aspx">already discussed</a>, to implement a massively parallel version of the famous Conway's Game of Life.Tomas Petricek<p>In the <a href="accelerator-intro.aspx">previous article</a>, I introduced the Microsoft Research Accelerator library. It allows us to write computations with arrays in C# and execute them in parallel on multi-core CPU or more interestingly, using GPU shaders. In the previous artcile, we've seen how Accelerator works and how it can be accessed from F#. In this article, we'll look at one more interesting F# demo - we'll implement the famous Conway's Game of Life [<a href="accelerator-life-game.aspx#accelfsh2links">1</a>] using Accelerator. We'll use a v2 version of Accelerator which has been announced just recently and is available from Microsoft Connect [<a href="accelerator-life-game.aspx#accelfsh2links">2</a>].</p> <div style="text-align:center;"> <object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/wiZnTfx2re8&amp;hl=en&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/wiZnTfx2re8&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> </div> <p>This article is the second one from a series about using Accelerator from F#. Today, we'll use Accelerator types directly from F# - this is the simplest possible approach and is very similar to the way you'd work with Accelerator in C#. However, we can use some nice F# features such as custom operators to make the code more readable. In the next article, we'll discuss a different approach - we'll look how to execute more "standard" F# code (that doesn't reference Accelerator explicitly) with Accelerator using F# quotations. The list of articles may change, but here is a list of articles that I'm currently planning to write:</p> <ul> <li><a href="http://tomasp.net/blog/accelerator-intro.aspx">Accelerator and F# (I.): Introduction and calculating PI</a></li> <li><strong>Accelerator and F# (II.): The Game of Life on GPU</strong></li> <li><a href="http://tomasp.net/blog/accelerator-dataparallel.aspx">Accelerator and F# (III.): Data-parallel programs using F# quotations</a></li> <li><a href="http://tomasp.net/blog/accelerator-quotations.aspx">Accelerator and F# (IV.): Composing computations with quotations</a></li> </ul> Accelerator and F# (I.): Introduction and calculating PIhttp://tomasp.net/articles/accelerator-intro.aspxMon, 21 Dec 2009 03:21:03 GMTThis article shows how to write F# programs that run in parallel as shader programs on GPU or on multi-core CPU using Microsoft Research Accelerator project.Tomas Petricek<img src="http://tomasp.net/articles/accelerator-intro/montecarlo.png" alt="Calculating Pi using Monte-Carlo" style="float:left; margin:10px" /> <p>I already wrote about two projects that I worked on during an internship at MSR back in 2007 (<a href="http://tomasp.net/blog/aspnet-in-fsharp.aspx" type="external">ASP.NET support in F#</a> and <a href="http://tomasp.net/blog/fswebtools-intro.aspx" type="external">F# WebTools</a>). Even though this was more than 2 years ago (and I did one more internship at MSR in the meantime), I still have one more project that I never published on the web. The folks from the F# team reminded me of this project recently, so I thought I could finally publish it. The project used Microsoft Research Accelerator [<a href="#accelfsh1links">1</a>, <a href="#accelfsh1links">2</a>], which is a C# library for developing array-based computations and executing them on a GPU. More recently, the Accelerator team at MSR published Accelerator v2 [<a href="#accelfsh1links">3</a>], which was a good motivation to update my original project...</p> <p>In this article, we'll look at the simplest way of using Accelerator from F#. Accelerator provides a managed interface that can be naturally used from both C# and F#. We can use a mix of method calls and overloaded operators to describe a computation. In F#, we'll also define our additional custom operators to make the code a bit nicer. After we introduce Accelerator using a simple C# demo, we'll look how to calculate an approximate value of the PI number using a Monte-Carlo method.</p> <p>This article is the first one from a series about using Accelerator from F#. The list of articles may change, but here is a list of articles that I'm currently planning to write:</p> <ul> <li><strong>Accelerator and F# (I.): Introduction and calculating PI</strong></li> <li><a href="http://tomasp.net/blog/accelerator-life-game.aspx">Accelerator and F# (II.): The Game of Life on GPU</a></li> <li><a href="http://tomasp.net/blog/accelerator-dataparallel.aspx">Accelerator and F# (III.): Data-parallel programs using F# quotations</a></li> <li><a href="http://tomasp.net/blog/accelerator-quotations.aspx">Accelerator and F# (IV.): Composing computations with quotations</a></li> </ul> F# Webcast (IV.) - Developing standard .NET librarieshttp://tomasp.net/articles/fsharp-webcast-objects.aspxMon, 15 Jun 2009 20:09:04 GMTThis webcast demonstrates how to wrap an existing F# code into an object oriented library that can be nicely used from C# and how to use it when developing ASP.NET web application. The demo uses script for processing RSS feeds from the previous webcast.Tomas Petricek<p>In the previous parts of this webcast series we've developed an F# script that downloads RSS feeds asynchronously and in parallel and searches them for the specified keywords. We followed the usual F# development style, so after introducing <a href="fsharp-webcast-functional.aspx">the basic functional concepts</a>, we wrote the code in <a href="fsharp-webcast-dotnet.aspx">the simples possible style</a> and demonstrated how to use <code>System.Xml</code> and <code>System.Net</code> namespaces. Then we <a href="fsharp-webcast-async.aspx">refactored the existing code</a>, to run asynchronously and process the results potentially in parallel, which was very easy thanks to F# <em>asynchronous workflows</em>.</p> <p>In this part of the series, we'll make the next evolutionary step of our sample application. We'll turn the code that originally used F# tuples and lists into code that uses standard .NET objects and we'll also see how to declare a class in F#. This simple modification will turn the script into an F# library that is almost indistinguishable from a library developed in C#. We'll also look how you can use the library from C# web application to show the interop between C# and F# in practice. We'll start with the code from the <a href="fsharp-webcast-async.aspx">previous part</a>, so if you missed that, you may want to check it out or download the source code.</p> F# Webcast (III.) - Using Asynchronous Workflowshttp://tomasp.net/articles/fsharp-webcast-async.aspxFri, 05 Jun 2009 03:39:39 GMTIn the previous part you've seen how to write a simple function for downloading RSS feeds and processing them. In this part, we look how to improve the function to download data asynchronously and process them potentially in parallel.Tomas Petricek<p>In this webcast, we'll look at improving the code for downloading and processing RSS feeds that I presented in <a href="fsharp-webcast-dotnet.aspx">the second part</a> (if you didn't see earlier parts, <a href="fsharp-webcast-dotnet.aspx">the first one</a> was an introduction to basic functional ideas). The previous part demonstrated how to use .NET libraries and we implemented a simple <code>downloadUrl</code> function for obtaining content of from the web and we've also seen how to load the data into an XML document object and how to filter items. In this part, we'll modify the code to run asynchronously and potentially in parallel. To use some of the functionality, you'll need to get <code>FSharp.PowerPack.dll</code>, which is available with the VS 2008 installation or as a separated download for VS 2010 [<a href="#fswc_asy">4</a>]. </p> <p>Now that we have the first version of the code, we can start <em>refactoring</em> it. I'm using the term in a slightly vague meaning - we're of course going to change the behavior of the code. We'll wrap it into F# <em>asynchronous workflow</em> to run without blocking threads and we'll also run multiple downloads in parallel. However, this can still be viewed as refactoring in some sense, because we're not changing the <em>core</em> behavior of the code. As you can see from the webcast, these kinds of refactorings are also very nicely supported by F# syntax...</p> F# Webcast (II.) - Using .NET librarieshttp://tomasp.net/articles/fsharp-webcast-dotnet.aspxMon, 01 Jun 2009 14:57:53 GMTThis is the second part of the webcast series that introduces the F# language. It shows how to use .NET libraries from F# to download RSS feed and how to work with the obtained data using tuples, sequence expressions and other F# features.Tomas Petricek<p>About a week ago I posted <a href="fsharp-webcast-functional.aspx">the first part</a> of my F# webcast series. It focused on explainining the basic ideas behind functional programming such as immutability, recursion and passing functions as arguments to other functions (or methods in C#). In the first part, we've seen some C# code to demonstrate the ideas and also a bit of F#, mainly to show the basic language features. </p> <p>The second part is going to be exclusively about F#. It'll demonstrate how we can start writing a demo application that grabs data from RSS feeds and processes them. You'll learn how to access .NET libraries from F# (in particular, we'll use <code>System.Net</code> and <code>System.Xml</code>). We'll develop the code iteratively, which means that we'll start by simply enumerating the RSS elements using <code>for</code> loop and printing the results and then we'll refactor the code to use <em>tuples</em> and <em>sequence expressions</em> to turn it into processing code that generates a sequence of feed items. Finally we'll also demonstrate how to use some of the functions from the previous part such as <code>List.filter</code> in practice.</p>F# Webcast (I.) - Introducing functional conceptshttp://tomasp.net/articles/fsharp-webcast-functional.aspxMon, 25 May 2009 13:39:54 GMTNow that Visual Studio 2010 beta 1 is out, it may be a good time finally try the new F# language. To make the exploration easier, I created a web cast series that demonstrates interesting aspects of F#. In this part, we'll look at basic functional concepts and working with data.Tomas Petricek<p>Now that <a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx" type="external">Visual Studio 2010 Beta 1</a> is out, it is finally a good time to take a look at one of the (in my opinion) most interesting new features in the new release - <a href="http://blogs.msdn.com/dsyme/archive/2009/05/20/visual-studio-2010-beta1-with-f-is-now-available-plus-matching-f-ctp-update-for-vs2008.aspx" type="external">the F# language</a>. F# existed for quite a long time now as Microsoft Research project, but is now becoming a real Microsoft product. Interestingly, F# is still available as a <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=7bb32f32-9fac-4f34-ad56-b0bda130cf00" type="external">plugin for Visual Studio 2008</a>, so if you want to try it you don't have to install the whole new beta of 2010.</p> <p>There are already many resources for learning F# including my <a href="http://tomasp.net/blog/functional-overview.aspx">functional programming overview</a>, which is a Manning Greenpaper for the book <a href="http://www.functional-programming.net" type="external">Functional Programming for the Real World</a> that I'm writing with Jon Skeet and my <a href="http://tomasp.net/blog/fsharp-i-introduction.aspx">four-part F# introduction</a>. There are also some useful links on the official <a href="http://www.fsharp.net">F# web site</a> including some talk recordings. However, I haven't yet seen any good F# webcast focusing mainly on showing F# source code, starting from simple functional concepts to the real-world features like asynchronous workflows and object-oriented programming in F#, so I decided to create one.</p> <p style="text-indent:0px;"><strong>So, here it is...</strong></p> Imperative computation in F# (II.) - Writing break and continuehttp://tomasp.net/articles/imperative-ii-break.aspxSat, 25 Apr 2009 16:31:15 GMTIn the previous article of this series, we've implemented a computation expression that allows us to write imperative 'return' in F#. In this article, we'll add support for 'break' and 'continue'.Tomas Petricek<p>As I already wrote in the <a href="http://tomasp.net/articles/imperative-i-return.aspx">first part of this series</a>, the F# language doesn't support some of the language constructs known from imperative languages such as C#. In particular, we cannot use imperative <code>return</code> statement that returns the result of a function from any place in the function code. In functional languages, every construct is an expression, so to get the overall result of the function, the F# language evaluates the expression and the value of the expression is used as the result. In the previous article, we've seen that we can simulate this construct in the F# language using F# computation expressions and I showed how to implement computation named <code>imperative</code> that allows us to write for example the <code>exists</code> function for working with sequences like this:</p> <pre lang="fsharp"> let exists f inp = imperative { for v in inp do if f(v) then return true return false } </pre> <p>In this article, we're going to look at two more imperative constructs and we're going to talk about <code>break</code> and <code>continue</code>. We'll see that we can quite easily extend the computation builder from the previous article to allow writing code that is syntactically very close to what you would write in C#. As I already mentioned, there are of course some performance overheads when using computation expressions, but I find it very interesting how nice imperative syntax we can get in functional F#:</p> <pre lang="fsharp"> imperative { for x in 1 .. 10 do if (x % 3 = 0) then do! continue printfn "number = %d" x } </pre> <p>The only difference between this code and the code we'd probably write if F# supported <code>continue</code> as a keyword is that we need to wrap the code inside the <code>imperative</code> computation and that we need to add the <code>do!</code> primitive before the <code>continue</code> value. Now that we've seen an example of using the <code>continue</code> value inside the imperative computations, let's look how we can extend the computation builder from the previous article to add this feature...</p> Imperative computation in F# (I.) - Returning results from a functionhttp://tomasp.net/articles/imperative-i-return.aspxThu, 19 Mar 2009 02:05:03 GMTEven though F# supports some imperative constructs such as for and while loops, it doesn't support some of the advanced constructs like imperative return and break. In this series, we'll look how we can implement these constructs ourselves using F# computation expressions.Tomas Petricek<p>One of the limitations of F# is that it doesn't very well support some of the advanced imperative language constructs such as <code>break</code>, <code>continue</code> or imperative style of returning value from a function, meaning that you can't write something like <code>return false</code> in the middle of the function. This has good reasons. F# doesn't in principle have the notion of <em>currently executing statement</em> and instead treat every code you write as an expression. Clearly, when there is no <em>current statement</em>, we cannot jump to other statements. If you're looking for more information about these basic principles, you can take a look at my book <a href="http://www.functional-programming.net" target="external">Real World Functional Programming</a>, which covers this distinction in details in chapter 2, but we'll look at a brief example that will clarify this idea shortly.</p> <p>Often, there is really no need to use <code>break</code> or other imperative constructs in F#, because you can write the same thing more elegantly using one of the provided higher order function such as <code>Seq.exists</code> or <code>Seq.tryfind</code>. However, there are still some cases where the imperative programming style makes it easier to express our original intention. Also, implementing your own higher order functions (akin to <code>Seq.exists</code>) would sometimes be much easier if we could just use imperative return.</p> <p>So, what can be done about this?</p>Functional Programming in .NET using C# and F# (Manning Greenpaper)http://tomasp.net/articles/functional-overview.aspxThu, 11 Dec 2008 01:48:07 GMTThis article is partially an excerpt from my <a href="http://www.manning.com/petricek">book</a>. It introduces the benefits of functional pogramming, and explains the essential aspects of the functional style using F# and C# 3.0. Finally, it also shows how functional style influences the application architecture.Tomas Petricek<p> Functional programming languages have been around for a while and were always astonishing for their ability to express the ideas in a succinct, declarative way allowing the developer to focus on the essence of problem rather than on technical details of the solution. Recently, functional paradigm is gaining new prominence as an efficient way to handle development of multi-processor, parallel and asynchronous applications.</p> <p> Functional ideas are arising in C# as well as in other main-stream languages and functional languages are becoming an alternative for real-world projects. Also, Microsoft recently introduced a new language called F#, which has a strong background in traditional functional languages, but as a .NET language also benefits from the rich .NET and Visual Studio ecosystem.</p> <div class="rdecor"> <img src="http://www.tomasp.net/img/cover_main.gif" alt="Book cover" /><br /><small>Available via MEAP | 500 pages<br />Softbound print: March 2009 (est.)</small></div> <p> This article is partially an excerpt from my book <strong><a href="http://www.manning.com/petricek">Real-world Functional Programming in .NET</a></strong> [<a href="#fpgpref">1</a>]. Thanks to my editors at <a href="http://www.manning.com" type="external">Manning</a> I have the permission to publish it on my blog. We’ll look at several aspects of functional programming and how the same concepts, which are essential for the functional paradigm, look in the F# and in C# 3.0 with LINQ. We will shortly look at the basic programming language features like lambda functions and type inference that are now available in both F# and C#. Functional programming isn’t only about language features, but also about using different programming style, so we’ll look at some high level concepts as well. These include using immutable data structures for developing code that can be executed in parallel and writing code in a more declarative style.</p> <p> Thanks to the combination of C# 3.0 and F#, this article shows the ideas in a way that should be familiar to you in C#, but also shows a further step that you can take with a primarilly functional language F#. If you're a .NET developer and you want to understand what functional programming is and how it can help you to become better and more productive then continue reading. If you'll find this article interesting, then don't forget to check out the <a href="http://www.manning.com/petricek">book</a>, which explains everything in larger detail and discusses many other interesting ideas.</p> Reactive Programming (IV.) - Developing a game in Reactive LINQhttp://tomasp.net/articles/reactive-iv-reactivegame.aspxMon, 24 Nov 2008 03:00:00 GMTIn this article, we'll implement a simple iteractve game using the <strong>Reactive LINQ</strong> project. The article shows that this way of handling events gives us amog other things a great degree of composability.Tomas Petricek<p>In this part of the article series about <strong>Reactive LINQ</strong>we're going to implement a slightly more complicated application using the library that I introduced in the previous three articles. We're going to use basic event stream queries from the <a href="reactive-ii-csevents.aspx">second article</a> as well as advanced operators introduced in the <a href="reactive-iii-linqoperators.aspx">third part</a>. This time, I'll also show the F# version of all the examples, so we're going to build on the ideas from the <a href="reactive-i-fsevents.aspx">first part</a>.</p> <p>I originally wanted to write the demo only in Visual Basic, because I think that it is really amazig to show an idea that came from functional programming in a language that no one (maybe until recently) connects with functional programming. Then I realized that I really want to show the F# version too, because F# was an inspiration for the whole <strong>Reactive LINQ</strong> idea and it is interesting alone as well. But finally, I thought that don't showing the C# version may look offensive to many readers (especially since I'm still C# MVP...). So, I ended up writing the game in all three languages, but the code is surprisingly similar in all of them!</p> Reactive Programming (III.) - Useful Reactive LINQ Operatorshttp://tomasp.net/articles/reactive-iii-linqoperators.aspxFri, 21 Nov 2008 19:59:02 GMTIn the previous article, I introduced <strong>Reactive LINQ</strong>. Today, we're going to look at other operators that canbe used for working with events. We'll see aggregation is useful and how to dynamically change (switch) behavior.Tomas Petricek<p>In the <a href="reactive-ii-csevents.aspx">previous article</a>, I introduced <strong>Reactive LINQ</strong>. I explained the different point of view that we can use when working with .NET events. The idea is that .NET events can be viewed as streams of values. The value is information about the event (such as position of a mouse click or a mouse movement). These streams can be processed using LINQ queries - we can for example filter all values that are not interesting for us using <code>where</code> LINQ clause. For example if we want to handle clicks only in some specified area.</p> <p>In the previous article, I talked about basic LINQ query operators such as <code>select</code> and <code>where</code> and some useful methods that <strong>Reactive LINQ</strong> provides (for example for merging event streams). Today, we'll take a look at two more advanced kinds of operations that we can use for working with event streams. In particular, we'll talk about aggregation operators (that you certainly know from LINQ) and about switching. Switching is a concept from functional reactive programming and it allows us to change dynamically how the application behaves. However, I'll explain this in a more detail soon.</p> <p>In this article, I'm going to use mostly C# (and some Visual Basic). The functionality that I'm describing in this part isn't part of the standard F# <code>Event</code> module that I discussed in <a href="reactive-i-fsevents.aspx">the first part</a>. I implemented most of them in F# too, but I'm not going to write the samples in both of the versions in this part. If you've seen the first two articles, you'll be definitely able to use the F# versions as well, because they follow exactly the same ideas as the C#/LINQ versions. I'm going to talk about a larger demo application in the last section and I'll show an F# version as well, so you'll see some F# examples in the next part. This part serves more as a reference of the available operators, so you may read only some parts of it, then jump to the last one (to see an exciting example!) and then come back here.</p> Reactive programming (II.) - Introducing Reactive LINQhttp://tomasp.net/articles/reactive-ii-csevents.aspxWed, 19 Nov 2008 19:57:15 GMTIn the second part of the series about reactive programming, I introduction the <strong>Reactive LINQ</strong> project, which allows writing event processing code in C# using LINQ queries.Tomas Petricek<p>In this article I'm going to introduce my project <strong>Reactive LINQ</strong>. This is largely inspired by the ideas that come from functional reactive programming in the Haskell language and from functionality that's available for working in events in F#. I introduced these ideas in my previous article in this mini-series, so if you're interested in learning more about these interesting technologies, you should definitely read the previous article about <a href="reactive-i-fsevents.aspx">First class events in F#</a>.</p> <p>In this article, we're going to look how to apply the same ideas to the C# language and how to use LINQ queries for processing events. This article is <a href="http://tomasp.net/blog/dynamic-linq-queries.aspx">just</a> <a href="http://tomasp.net/blog/csharp-async.aspx">another</a> my article that shows how to implement some idea from functional programmin in C#. I believe this will once again show that the new features in the C# 3.0 aren't just about querying databases, but are more widely useful even in situations that are not directly related to data-processing. </p> Reactive programming (I.) - First class events in F#http://tomasp.net/articles/reactive-i-fsevents.aspxSun, 16 Nov 2008 17:14:04 GMTThe LINQ project and changes in C# 3.0 are interesting because they allow implementing many ideas from functional languages in C#. In this article I'll explain "first-class events" in F# and later I'll implemet similar concept using LINQ.Tomas Petricek<p>I believe that the LINQ project and changes in C# 3.0 and VB 9 are interesting because they allow rewriting of many ideas from functional programming. An ability to express queries easily is one of these ideas, but it is definitely not the only one. There are many other interesting ideas. The C# 3.0 language isn't primary a functional language, so it isn't easy to discover the idea if you use only C#, but it is possible to implement it if you know the idea already.</p> <p>I already wrote a few interesting C# examples that were inspired by some functional idea. I'm a big fan of the F# language, so it is not a surprise that I started with an F# version of the problem and then looked at the way to do the same thing in C#. In particular, this is how my article about building dynamic queries in C# came to the existence - the F# version used <a href="http://tomasp.net/blog/dynamic-flinq.aspx">FLINQ and Quotations</a> and then I demonstrated how to do the same in <a href="http://tomasp.net/blog/dynamic-linq-queries.aspx">C# using expression trees</a>. Another example is my article about asynchronous programming in C# <a href="http://tomasp.net/blog/csharp-async.aspx">using iterators</a>, which shows how to implement something like F# <a href="http://blogs.msdn.com/dsyme/archive/2007/10/11/introducing-f-asynchronous-workflows.aspx">asynchronous workflows using iterators</a> in C# 2.0.</p> <h3>Functional Reactive Programming</h3> <p>Today, I'm going to look at another very interesting idea from functional programming. It is called <em>Functional Reactive Programming</em> and it comes from the Haskell community. You can find a list of related <a href="http://www.haskell.org/frp/" type="external">Haskell projects here</a>. However, similar things (though they are not purely functional and simplified) are available in the F# language as well. Don Syme introduced them in his blog post called <a href="http://blogs.msdn.com/dsyme/archive/2006/03/24/559582.aspx">F# First Class Events: Simplicity and Compositionality in Imperative Reactive Programming</a>. In this article, I'm going to briefly introduce the implementation available in F# and I'll extend it a little bit to allow some more interesting things. In the second article from this series, I'll show how to implement the same thing in C# 3.0 (and in VB 9 too!)</p> Dynamic Lookup in F#http://tomasp.net/articles/fsharp-dynamic-lookup.aspxWed, 04 Jun 2008 01:50:08 GMTDynamic languages allow you to represent a member using a symbol or a string and to use this symbol to work with the member. In this article I'll show how to do same thing in statically-typed way in F#.Tomas Petricek<p>Many people view <em>dynamic</em> and <em>statically-typed</em> 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 <em>dynamic</em> language feature in F#, which is undoubtedly <em>statically-typed</em>. 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 <em>symbols</em> in Ruby, but I'll shortly explain what exactly I mean).</p> <p>I intentionally wrote <em>statically-typed</em> and <em>dynamic</em> instead of <em>dynamically-typed</em>. In my understanding <em>dynamic</em> is a broader term while <em>dynamically-typed</em> and <em>statically-typed</em> are of course two distinct groups. On the other side <em>dynamic</em> refers to language features that are usually available in <em>dynamically-typed</em> languages, just because it is easy to support them in a nice way. This doesn't mean that having a <em>dynamic</em> feature in a <em>statically-typed</em> language would be impossible - it is just more difficult to implement it in a way that would be similarly elegant. </p> F# Support for ASP.NET and Notes on Sampleshttp://tomasp.net/articles/aspnet-in-fsharp.aspxSat, 08 Mar 2008 23:07:29 GMTIn this article I look at the F# suppot for ASP.NET and at some interesting aspects of the samples that are available in the F# distribution.Tomas Petricek<p>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 [<a href="#myfsstuff">1</a>], 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#. </p> Writing Silverlight applications in PHPhttp://tomasp.net/articles/php-in-silverlight.aspxFri, 07 Dec 2007 17:16:14 GMTIn this article we will look how Phalanger can be used for developing Silverlight applications in the PHP language. We look at basic concepts like XAML as well as at a more complicated game.Tomas Petricek<p>In my <a href="http://tomasp.net/blog/phalanger-future-notes.aspx">last post</a> 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.</p> <img src="/articles/php-in-silverlight/car_intro_sm.png" alt="Simple Silverlight App in PHP" style="margin:10px; float:left;" /> <p>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 <a href="http://news.php.net/php.on.dlr" type="external">PHP on DLR</a> 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!</p> <p>If you can't wait to try the demos before looking at the sources, here are the links:</p> <ul> <li><a href="http://tomasp.net/articles/php-in-silverlight/simplegui.html" type="external">Simple car demo</a> - Click on the car and it will move!</li> <li><a href="http://tomasp.net/articles/php-in-silverlight/game.html" type="external">Helicopter game demo</a> - Click left button to fly up!</li> </ul>Infinite Cheese Fractal using WPF 3D and F#http://tomasp.net/articles/infinite-cheese.aspxSat, 24 Nov 2007 23:22:04 GMTThis article describes a 3D version of famous Sierpinski carpet fractal implemented in the F# language using WPF 3D libraries from .NET 3.0.Tomas Petricek<p>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 [<a href="#wpffractref">1</a>], 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! </p> <div style="text-align:center;"> <object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/8wV7UgLeKdM&amp;hl=en&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/8wV7UgLeKdM&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> </div> Asynchronous Programming in C# using Iteratorshttp://tomasp.net/articles/csharp-async.aspxThu, 15 Nov 2007 03:08:35 GMTIn this article we will look how to write programs that perform asynchronous operations like manipulation with network in C# using iterators without the typical inversion of control caused by the use of delegates.Tomas Petricek<p>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 <code>Begin<em>Something</em></code> 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. <code>while</code> loop) you have to use global variables and write your own control mechanism.</p> <p>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.</p> F# Overview (IV.) - Language Oriented Programminghttp://tomasp.net/articles/fsharp-iv-lang.aspxSat, 03 Nov 2007 00:00:04 GMTIn 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.Tomas Petricek<p>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 <em>active patterns</em>, <em>computation expressions</em> and <em>quotations</em>.</p> <p>Defining precisely what the term <em>language oriented programming</em> 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 <em>language</em> 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.</p>F# Overview (III.) - Imperative and Object-Oriented Programminghttp://tomasp.net/articles/fsharp-iii-oop.aspxSat, 03 Nov 2007 00:00:03 GMTIn the third part of the F# overview, we will look at the F# features that are essential for a smooth interoperability with other .NET languages and form a second part of the F# core language - that is object oriented and imperative programming.Tomas Petricek<p>In the third part of the F# Overview article series, we will look at language features that are mostly well known, because they are present in most of the currently used programming languages. Indeed, I'm talking about imperative programming, which is a common way for storing and manipulating application data and about object oriented programming which is used for structuring complex programs.</p> <p>In general, F# tries to make using them together with the functional constructs described in the <a href="fsharp-ii-functional.aspx">previous part</a> [<a href="fsharp-ii-functional.aspx" target="_blank">^</a>] as natural as possible, which yields several very powerful language constructs.</p>F# Overview (II.) - Functional Programminghttp://tomasp.net/articles/fsharp-ii-functional.aspxSat, 03 Nov 2007 00:00:02 GMTIn the second part of the F# overview we will look at functional programming, which is probably the most important paradigm used with the F# language, because F# is built on the same grounds as many functional languages.Tomas Petricek<p>In the second part of the F# overview we will look at functional programming, which is probably the most important paradigm used with the F# language, because F# is built on the same grounds as many functional languages. We will first examine the standard F# data types, which are useful to allow the functional programming style and we will also look at a few functional tricks.</p> <p>As already mentioned in the <a href="fsharp-i-introduction.aspx">Introduction</a> for this article series, F# is a typed functional language, by which I mean that types of all values are determined during the compile-time. However, thanks to the use of a type inference, the types are explicitly specified in the code very rarely as we will see in the following examples. Basic data types (aside from a standard set of primitive numeric and textual types that are present in any .NET language) available in F# are tuple, discriminated union, record, array, list, function and object. In the following quick overview, we will use the F# interactive, which is a tool that compiles and executes the entered text on the fly.</p> F# Overview (I.) - Introductionhttp://tomasp.net/articles/fsharp-i-introduction.aspxSat, 03 Nov 2007 00:00:01 GMTFirst article of the F# Overview series introduces the F# language and gives a quick overview of the programming paradigms that will be discussed in the upcoming articles.Tomas Petricek<p>In my bachelor thesis I included a short introduction that covered all of the important aspects of the F# programming language and I thought that it may be useful to extend it a little bit to cover also a topics that were not important for my thesis and post it as an article, so there is one and relatively short article that introduces all the interesting F# features. The article got however a bit longer than I expected, so I decided to split it into a three parts that would introduce three different <em>paradigms</em> that are supported by F#. Of course, this series won't teach you everything about F#, but it tries to cover the main F# design goals and (hopefully) presents all the features that make F# interesting and worth learning. In this first part I will shortly introduce F# and the supported paradigms that will be discussed in the upcoming articles.</p> F# Quotations Samples on CodePlexhttp://tomasp.net/articles/fsharp-quotation-samples.aspxThu, 20 Sep 2007 04:33:49 GMTThis article describes a few samples available in the F# Samples project at CodePlex that demonstrate how to work with the F# quotations using active patterns.Tomas Petricek<p>Some time ago, Granville Barnett (see his <a href="http://gbarnett.org/">homepage and old blog</a> [<a href="http://gbarnett.org/" target="_blank">^</a>] or a <a href="http://weblogs.asp.net/gbarnett/">new blog</a> [<a href="http://weblogs.asp.net/gbarnett/" target="_blank">^</a>]) had a great idea and started a CodePlex project called <a href="http://www.codeplex.com/fsharpsamples">F# Samples</a> [<a href="http://www.codeplex.com/fsharpsamples" target="_blank">^</a>] to host various samples written in F# to demonstrate the most important concepts of both functional programming and F#. I quite like this idea, so I asked Granville if I could join and add some samples that I wrote and today I finally found a time to update what I wanted to upload to the latest version of F# and put it online.</p> Building LINQ Queries at Runtime in F#http://tomasp.net/articles/dynamic-flinq.aspxSat, 18 Aug 2007 02:38:11 GMTIn this article I will introduce FLinq, the F# support for language integrated query and show how we can construct a database queries dynamically in a type-safe way in F#.Tomas Petricek<p>In an article about building LINQ queries at runtime in C# 3.0, I described how you can build a LINQ query dynamically, for example by combining a set of conditions using the 'or' operator in the where clause. I mentioned that the way I implemented it is largely influenced by the F# language, which provides very natural way for manipulations with code like this. In this article I will first shortly introduce FLINQ sample, which is an F# library implementing LINQ support and than I will implement the same examples I presented in the earlier article in F#.</p> Building LINQ Queries at Runtime in C#http://tomasp.net/articles/dynamic-linq-queries.aspxMon, 30 Jul 2007 02:10:17 GMTCommon criticism of LINQ is that it doesn't support a scenario where queries are build dynamically at the runtime. In this article I show that this can be acutally done very well for most of the common scenarios.Tomas Petricek<p>Since the first beta versions of LINQ we could hear comments that it is perfect for queries known at compile-time, however it is not possible to use it for building queries dynamically at runtime. In this article I show that this can be actually done very well for most of the common cases. The solution offered by Microsoft (mentioned in [<a href="#dynqlinks">1</a>]) is to build query from a string, however this has many limitations and it in fact goes completely against what LINQ tries to achieve, which is writing queries in a type-safe way with full compile-time checking. In this article I will first show a few support functions to make the life a bit easier and then we will use them for building two sample applications that allows user to build a query dynamically. The solution is largely motivated by my previous use of F#, where working with “expressions” is possible at more advanced level, however I’ll write about F# later and now let’s get back to C# 3.0...</p>F# Web Tools: "Ajax" applications made simplehttp://tomasp.net/articles/fswebtools-intro.aspxFri, 13 Jul 2007 04:32:29 GMTThis article introduces the F# Web Toolkit, which is an "Ajax" web framework that solves three major problems that many people have to face when developing modern web applications.Tomas Petricek<p>Traditional "Ajax" application consists of the server-side code and the client-side part written in JavaScript (the more dynamicity you want, the larger JS files you have to write), which exchanges some data with the server-side code using XmlHttpRequest, typically in JSON format. I think this approach has 3 main problems, which we tried to solve in F# Web Toolkit. There are a few projects that try to solve some of them already - the most interesting projects are Volta from Microsoft [<a href="#fswtintrolinks">1</a>], Links language [<a href="#fswtintrolinks">3</a>] from the University of Edinburgh and Google Web Toolkit [<a href="#fswtintrolinks">2</a>], but none of the projects solve all three problems at once. </p> <ol> <li>Limited client-side environment</li> <li>Discontinuity between server and client side</li> <li>Components in web frameworks are only server-side</li> </ol> <p>The aim of the F# Web Toolkit is to solve all these three problems...</p>Using PHP objects from C# in a type-safe wayhttp://tomasp.net/articles/ducktyping-in-phalaner.aspxMon, 30 Apr 2007 01:26:24 GMTIn this article we present new features in the Phalanger beta 4 which make it possible to use objects from any PHP script in C# using type-safe way.Tomas Petricek<p>When you want to call PHP scripts from mainstream .NET languages, like C# you can follow two different ways. First you can use the pure mode as I demonstrated in one of the earlier articles on PHP application called Texy!. This approach can be used only for some specific applications, because pure mode has several restrictions - the two most important restrictions are that no global code or inclusions are allowed (you have to specify all source files during the compilation), but thanks to this restrictions Phalanger is able to produce classes that are compatible with .NET and can be called from C#. Second option is to create object dynamically by its name and perform all method invocations by name too. This approach can be used with any PHP scripts, but it isn't very convenient. In this article we present new features in the Phalanger beta 4 which extend the second approach and make it possible to use objects from any PHP script in C# using type-safe way.</p> Keep your multi-core CPU busy with F#http://tomasp.net/articles/fsparallelops.aspxSat, 24 Mar 2007 23:13:48 GMTCode which makes it possible to write applications that take advantage of multi-core CPUs by parallelizing F# filter and map functions.Tomas Petricek<p>The growth of computer CPU speed is slowly being replaced by the growth of number of CPUs (or cores) in the computer at least for the close future. This causes a revolution in the way software is written, because traditional and most widely used way of writing concurrent applications using threads is difficult and brings several serious issues. Some predictions say that within a few years, almost every computer will have about 16 cores, so there is a huge need for programming paradigms or idioms that help developers write concurrent software easily (see also <a href="http://www.gotw.ca/publications/concurrency-ddj.htm">The Free Lunch Is Over</a> [<a href="http://www.gotw.ca/publications/concurrency-ddj.htm" target="_blank">^</a>] written by Herb Sutter).</p> <p>Functional programming languages (especially pure functional languages) are interesting from this point of view, because the program doesn't have side-effects which makes it very easy to parallelize it (programs in pure functional languages can't have any side-effects by design, in other functional languages like F# the side-effects can be eliminated by following functional programming style). </p> <p>This article describes the code that makes it possible to parallelize some common F# constructs like the <code>List.map</code> and <code>List.filter</code>...</p>CLinq - LINQ support for the C++/CLI languagehttp://tomasp.net/articles/clinq-project.aspxFri, 02 Mar 2007 17:11:05 GMTCLinq project is a library that makes it possible to use LINQ technologies from the C++/CLI language.Tomas Petricek<p>I started working on this project, because I attended C++ class at our university and I had to do some application in C++. Because I hate doing useless projects I wanted to work on something interesting and so I started thinking whether it would be possible to enable LINQ support in C++/CLI...</p> <p>C++/CLI is a very flexible language and the following example proves that enabling LINQ support in C++/CLI isn't impossible. The following database query returns name of contact and company for all customers living in London:</p> <pre lang="c++"> // create connection to database NorthwindData db(".. connection string .."); // declare database query Expr&lt;Customers^&gt; cvar = Var&lt;Customers^&gt;("c"); CQuery&lt;String^&gt;^ q = db.QCustomers -&gt;Where(clq::fun(cvar, cvar.City == "London")) -&gt;Select(clq::fun(cvar, cvar.ContactName + Expr&lt;String^&gt;(", ") + cvar.CompanyName)); // execute query and output results for each(String^ s in q-&gt;Query) Console::WriteLine(s); </pre> <p>If you are interested in more information about CLinq project you can...</p> <ul> <li><a href="/articles/clinq-project.aspx">.. continue and read the entire article</a></li> <li><a href="http://www.codeplex.com/linqextensions">Visit the CodePlex project homepage</a> [<a href="http://www.codeplex.com/linqextensions" target="_blank">^</a>]</li> </ul>Overload resolution in Phalangerhttp://tomasp.net/articles/phalanger-overload-resolution.aspxThu, 15 Feb 2007 21:46:45 GMTPHP doesn't support method overloading, so Phalanger has to solve an interesting problem when calling overloaded .NET method from PHP.Tomas Petricek<p>PHP language itself doesn't method support overloading (having two methods with same name, but different number or types of parameters). This brings an interesting problem to Phalanger, because most of .NET languages support this and if we want to be able to call any .NET object from PHP we need to add support (at least) for calling of overloaded methods. The latest Phalanger release contains overload resolution described in the <em>Integrating PHP with CLR</em> document [<a href="#phpoverloadlnk">1</a>].</p> <p>For example, when calling the <code>Console::WriteLine</code> method (which has a lot of overloads), Phalanger dynamically generates a piece of code that we call dynamic stub, which is responsible for choosing the most appropriate overload depending on the actual parameter types. This stub is generated only once for every method, which makes this implementation very efficient. The difficult part of overload resolution is, how can the stub determine what is the best overload? PHP language has a lot of implicit conversions, so when you pass the string <code>"10.2 Little Piggies"</code> to a method it can be implicitly converted to float (<code>10.2</code>) (For more details see [<a href="#phpoverloadlnk">2</a>]). Another example of implicit conversion is that any boolean value can be converted to string (empty string or string <code>"0"</code> are converted to <code>false</code>, every other string is converted to <code>true</code>).</p> <p>In this article I'll describe how does the dynamic stub look like in current version of Phalanger, what problems can it cause and how are we going to fix it in the future version!</p>Compiling Texy! with Phalangerhttp://tomasp.net/articles/aspnettexy.aspxMon, 12 Feb 2007 00:45:45 GMTThis article describes how to compile Texy! with Phalanger and how to use the produced assembly in ASP.NET application written in C#.Tomas Petricek<p>Texy! [<a href="#texyphallinks">1</a>] is a convertor from text format (similar to formats used in some wiki applications) to valid XHTML code written in PHP. The syntax is described at Texy! web page [<a href="#texyphallinks">2</a>]. Unfortunately, it is only in Czech language, but the syntax is very straightforward, so you can understand it without learning Czech :-).</p><p> In this article, we'll examine how to compile Texy! using Phalanger in pure mode. In this mode it is possible to use objects from PHP like any other .NET objects, so we can later used the compiled assembly for example in the following C# code:</p> <pre> <span class="c">// Create instance of Texy! parser</span> Texy t = <span class="k">new</span> Texy(); <span class="c">// Call the 'process' method and cast result to string</span> <span class="k">string</span> parsed = (<span class="k">string</span>)t.process(txtTexy.Text); <span class="c">// Display parsed text using literal</span> ltrOutput.Text = parsed; </pre>Can't return anonymous type from method? Really?http://tomasp.net/articles/cannot-return-anonymous-type-from-method.aspxTue, 23 Jan 2007 23:54:31 GMTThis article describes anonymous types - one of the new C# 3.0 features and shows interesting trick that can be used when returning anonymous type from method.Tomas Petricek<p>One of the new features introduced in C# 3.0 which will be available in Visual Studio "Orcas" (currently in CTP version) is anonymous type. Anonymous type is something very similar to tuple type from Cω [<a href="#returnanonymous">1</a>] (which is based on tuple types known from many functional programming languages including F#). Anonymous types are extremely useful in LINQ queries, because it allows you to construct type with several properties without declaring the type (with all the properties). Example of query with anonymous type looks like this:</p> <pre> <span class="k">var</span> q = <span class="k">from</span> c <span class="k">in</span> db.Customers <span class="k">where</span> c.Country = <span class="s">"Czech Republic"</span> <span class="k">select new</span> { FullName=c.Name+<span class="s">" "</span>+c.Surname, Address=c.Address }; </pre> <p>Ok, it's probabbly not the best example, but it demonstrates the point - you want to return some information from query and you don't need to declare type that contains <code>FullName</code> and <code>Address</code> properties before, because you need it only for this single query (and you want to return only these two fields, so you don't transfer additional data that you don't need from database).</p><p>Now let's get to the second point... </p> Concepts behind the C# 3.0 languagehttp://tomasp.net/articles/csharp3-concepts.aspxSun, 15 Oct 2006 15:19:03 GMTIn this article I'll describe concepts that influenced the design of the C# 3.0. Most of these concepts are known from other programming languages like Haskell, LISP or languages developed at Microsoft Research.Tomas Petricek<p>One of the lectures that I attended last year was <a href="http://www.mff.cuni.cz/toISO-8859-2.en/vnitro/is/sis/predmety/kod.php?kod=PRG003">Programming Methodology and Philosophy of Programming Languages</a>. The lecture was mostly about history of programming languages and how several features evolved, disappeared and than after many years appeared again in another programming language.</p><p>As I final work I decided to write an article that describes ideas that influenced the design of the C# 3.0 language. Some of these features are known from functional languages (for example from LISP or Haskell), some other were developed at Microsoft Research and appeared in the F# language or Cω. I also wanted to show in what ways are these features limited in the C# 3.0. I think that thanks to these limitation, the C# 3.0 is still a simple (or at least not difficult) to understand which is very important for mainstream language, but I find it interesting to know what is possible in other (less limited) languages.</p><ul><li>You can also <a href="http://tomasp.net/articles/csharp3-concepts/csharp3-concepts.pdf">download the article in PDF</a> (404kB)</li><li>The article is also available at <a href="http://www.codeproject.com/useritems/csharp3-concepts.asp">CodeProject.com</a></li></ul>F# metaprogramming and classeshttp://tomasp.net/articles/fsclassmeta.aspxSat, 14 Oct 2006 01:36:10 GMTThis article presents prototype that makes it possible to use F# metaprogramming to analyse and translate classes written in special way. Tomas Petricek<p>F# quotations allows you to easily write programs that manipulate with data representation of program source code. If you're not familiar with quotations I recommend reading my previous article [<a href="#fsclassmeta-links">1</a>] that contains short introduction to this topic first. Quotations can be used for example for translating subset of the F# language to another code representation or another language.</p><p>To get the quotation data of the expression you can either use <code>&lt;@ .. @&gt;</code> operator or <code>resolveTopDef</code> function. In the first case the code written between the "<code>&lt;@</code>" and "<code>@&gt;</code>" is converted to data during the compilation. The <code>resolveTopDef</code> function allows you to get quotation data of top-level definition (function) from compiled library at runtime (you have to use <code>--quotation-data</code> command line switch while compiling the library). I mentioned that quotations can be used to represent only subset of the F# language. Currently, one of the quotation limitations is that it's not possible to enclose the whole class in the quotation operators. It is also not possible to get the representation of the whole class at runtime nor the representation of class members (for example methods). </p><p>In this article I'll present a simple method that makes it possible to use F# quotations for working with classes as well, however this is rather a prototype that can be used for experimenting and discovering areas where working with classes might be useful, not a fully working solution.</p>F# quotations visualizer - reloaded!http://tomasp.net/articles/quotvis-reloaded.aspxSun, 01 Oct 2006 21:39:06 GMTNew and improved version of quotation visualizer. Supports more language constructs and makes it possible to open quotations from compiled F# assembly.Tomas Petricek<div style="float:right;margin-left:10px;"><a href="http://www.tomasp.net/articles/quotvis-reloaded/screen.png" target="_blank"><img style="margin:10px;border-style:none;" src="http://tomasp.net/articles/quotvis-reloaded/screen-sm-sm.jpg" alt="Quotation Visualizer" /></a></div><p>Some time ago, I wrote an article about useful utility called <a href="http://www.tomasp.net/blog/quotvis.aspx">F# quotations visualizer</a>. This utility can be used to show visual representation of F# quotations, that can represent (subset of) source code written in F#. There are two ways that you can use to get F# quotations - first is using operators <code>&lt;@@ ... @@&gt;</code> (this returns quotation of the code written inside the operator), second method is to get quotation of top level definition from compiled F# assembly (you have to explicitly enable this using command line switch <code>--enable-quotation-data</code> while compiling assembly). </p><p>Because I added several new features to the original Quotations visualizer, I decided to publish the latest version - here is the list of main improvements:</p><ul><li>Rewritten using active patterns (new F# language feature)</li><li>It is possible to extract quotations from compiled F# assembly (if it contains quotation data)</li><li>Added support for several missing language constructs</li></ul>ASP.NET web applications in F#http://tomasp.net/articles/aspnet-fsharp-intro.aspxSun, 13 Aug 2006 21:06:33 GMTThis article shows how ASP.NET can be extended to support F# language using CodeDOM provider.Tomas Petricek<p>CodeDOM (Code Document Object Model) is set of objects (located in <code>System.CodeDom</code> namespace) that can be used for representing logical structure of .NET source code. These classes are used for generating Web service references (using <code>wsdl.exe</code> tool), for generating typed datasets and in many other situations. The most interesting use of CodeDOM classes is in ASP.NET where ASP.NET generates code from <code>aspx</code>/<code>ascx</code> files and compiles this code into web site assemblies (together with the code written in code behind files).</p><p>This means, that you can use any language for developing ASP.NET web sites, as long as you implement CodeDOM provider that generates source code from CodeDOM structure and can compile these source files (this can be simply done by executing command line compiler). I was recently working on CodeProvider for the F# language, and finally it supports everything what is needed by ASP.NET (however it is complete and it doesn't work for example with <code>wsdl.exe</code>). Using this CodeDOM provider you can write ENTIRE web site in F# (including in-line code enclosed in &lt;% ... source code ... %&gt;). I also created project template for F# web site that can be imported to Visual Studio 2005, so you can easilly try writing web pages in F#...</p>LINQ extensions - Simplified keyword searchhttp://tomasp.net/articles/linq-expand-update.aspxFri, 28 Jul 2006 03:57:38 GMTArticle describes LINQ extension that adds support for returning rows that contain any or all of specified keywords in string column.Tomas Petricek<p>Recently, I came across interesting question at LINQ Forums (Dynamic conditions: How to achieve multiple "OR" conditions with LINQ? [<a href="#updlq">1</a>]). The question is whether LINQ (and especially LINQ to SQL) provides any simple way to return only records that contain one or more of specified keywords in the name. The question looks simple, but it is simple only if you know the number of keywords that you want to look for. In this case you can write following LINQ query:</p><pre><span class="c">// Products that contain "kwd1" or "kwd2" in the name </span><br /><span class="k">var</span> q = <span class="k">from</span> p <span class="k">in</span> db.Products <span class="k">where</span> p.ProductName.Contains("kwd1") || p.ProductName.Contains("kwd2") <span class="k">select</span> p; </pre><p>The problem with previous code is that you can't use it if the list of keywords is dynamically entered by user (and so its length may vary). Of course, if you want to run query on in-memory data, you can get very nice results by writing extension method called <code>ContainsAny</code> that performs test for keyword array, but if you want to be able to translate query to SQL, the situation is a bit complicated.</p>F# quotations visualizerhttp://tomasp.net/articles/quotvis.aspxWed, 21 Jun 2006 02:20:03 GMTApplication that displays graphical representation of given F# quotation (using Windows Forms TreeView control)Tomas Petricek<p>I already <a href="http://tomasp.net/blog/fsquotations.aspx">explained</a> what F# quotations are and I explained how you can do some simple manipulations with it. In this article I'd like to present an application that I wrote and that can be helpful when working with quotations. It displays clear graphical representation of given F# quotation (using Windows Forms TreeView control). </p><div style="text-align:center;"><a href="http://tomasp.net/articles/quotvis/qv_apps.gif" target="_blank"><img style="margin:10px;border-style:none;" src="http://tomasp.net/articles/quotvis/qv_apps_sm.gif" alt="Quotation Visualizer" /></a></div>Calling functions in LINQ querieshttp://tomasp.net/articles/linq-expand.aspxSat, 10 Jun 2006 14:26:52 GMTThis article describes method that allows you to reuse parts of LINQ queries across data access layer.Tomas Petricek<p>The <a href="http://msdn.microsoft.com/data/ref/linq/">LINQ Project</a> [<a href="http://msdn.microsoft.com/data/ref/linq/" target="_blank">^</a>] is an extension to .NET Framework and most important .NET languages (C# and VB.Net) that extends these languages with query operators and some language features that make it possible to integrate queries in the languages. Thanks to LINQ you can write queries that read data from database (or any other data source). For example, imagine that you want to write set of queries for eshop and you need to perform a price calculation in more queries. The problem with LINQ queries is that you can't simply call a function written in C# that calculates price. The following example is NOT WORKING for this reason:</p><pre><span class="c">// function used in filter</span><br /><span class="k">static</span> <span class="k">decimal</span> CalcPrice(Nwind.Product p) { <span class="k">return</span> p.UnitPrice * 1.19m; }</pre><pre><span class="c">// query that uses MyFunc</span><br /><span class="k">var</span> q = <span class="k">from</span> p <span class="k">in</span> db.Products <span class="k">where</span> CalcPrice(p) &gt; 30m <span class="k">select</span> p </pre><p>I think that this is a big limitation, because when you want to keep some more complex logic in the data access layer you should be able to reuse parts of queries that are similar across more queries. The good thing is that with latest release, LINQ became extensible so it is possible to write a extensions that allow this scenario...</p><ul><li>You can also <a href="http://tomasp.net/articles/linq-expand/linq-expand.pdf">download the article in PDF</a> (80kB)</li></ul>F# - Simple quotations transformationhttp://tomasp.net/articles/fsquotations.aspxSun, 28 May 2006 15:58:20 GMT This article describes very simple code that I wrote while learning how to work with the F# quotations library. Tomas Petricek<p>This article describes very simple code that I wrote while learning how to work with the F# quotations library. Using the F# quotations you can get tree representation of the quoted expression. This allows you to write code that takes code written in F# as data and performs some code analysis or compiles/translates that code to different language. This is very similar to the new C# 3.0 expression trees where you can get expression tree from lambda expression and translate this tree for example to SQL (using DLINQ). However expression trees in C# 3.0 are very limited when compared with F# quotations, so that's one of the many reasons why F# is interesting language.</p>.NET, C# - Používání a psaní enumerátorůhttp://tomasp.net/articles/enumerators.aspxSun, 21 May 2006 03:14:53 GMTV tomto článku se podíváme na psaní vlastních kolekcí, které implementují rozhraní IEnumerable a lze je tedy procházet pomocí příkazu foreach.Tomas PetricekV tomto článku se podíváme na psaní vlastních kolekcí, které implementují rozhraní IEnumerable a lze je tedy procházet pomocí příkazu foreach..NET - Stahování souborů z internetuhttp://tomasp.net/articles/download.aspxSun, 09 Apr 2006 13:42:35 GMTV tomto úvodu jsou popsané základní postupy pro stahování textových a binárních souborů z internetu.Tomas PetricekV tomto úvodu jsou popsané základní postupy pro stahování textových a binárních souborů z internetu.C# - Dokumentace pomocí XML komentářůhttp://tomasp.net/articles/xmldoc.aspxSun, 09 Apr 2006 02:15:43 GMTV tomto článku se dočtete jakým způsobem lze v jazyce C# pomocí XML komentářů a nástroje NDoc vytvářet dokumentaci.Tomas PetricekV tomto článku se dočtete jakým způsobem lze v jazyce C# pomocí XML komentářů a nástroje NDoc vytvářet dokumentaci.Aho-Corasick string matching in C#http://tomasp.net/articles/ahocorasick.aspxSun, 04 Dec 2005 00:18:30 GMTC# implementation of very efficient Aho-Corasick keyword matching algorithm with multiple keywords support.Tomas Petricek<p>I implemented this algorithm because I worked on one project where we needed to filter bad language in comments submited by users (You wouldn't believe what anonymous users sometimes write). First I tried simple solution using <code>String.IndexOf</code> and using <code>Regex</code>, but none of these solutions was very suitable for this problem, so I decided to implement Aho-Corasick algorithm which is probabbly the best algorithm for this purpose.</p><p>Article (published here an on CodeProject.com) describes implementation of this algorithm for pattern matching. In simple words this algorithm can be used for searching text for specified keywords. This implementation is usefull when you have a set of keywords and you want to find all occurences in text or check if any of the keywords is present in the text. You should use this algorithm especially if you have large number of keywords that don't change often, because in this case it is much more efficient than other algorithms that can be simply implemented using .NET class library.</p><p>Aho-Corasick search algorithm is very efficient if you want to find large number of keywords in the text, but if you want to search only for a few keywords it is better to use simple method using <code>String.IndexOf</code>. </p>.NET - Globalizace a lokalizace aplikací (2.)http://tomasp.net/articles/localization.aspxSun, 17 Jul 2005 17:00:55 GMTV druhé části tutoriálu o lokalizaci a globalizaci aplikací se dočtete o tom jak vytvářet více-jazyčné aplikace.Tomas PetricekV druhé části tutoriálu o lokalizaci a globalizaci aplikací se dočtete o tom jak vytvářet více-jazyčné aplikace.Multi column layout controlhttp://tomasp.net/articles/columncontrol.aspxThu, 07 Jul 2005 16:31:19 GMTAsp.Net control that allows developers to display articles in multi-column layout.Tomas PetricekAsp.Net control that allows developers to display articles in multi-column layout..NET - Globalizace a lokalizace aplikací (1.)http://tomasp.net/articles/globalization.aspxWed, 06 Jul 2005 00:44:35 GMTV tomto tutoriálu se dočtete o tom, jak vytvářet aplikace, které fungují nezávisle na lokálním nastavení.Tomas PetricekV tomto tutoriálu se dočtete o tom, jak vytvářet aplikace, které fungují nezávisle na lokálním nastavení..NET - Literatura a webové stránkyhttp://tomasp.net/articles/dotnetlinks.aspxSat, 02 Jul 2005 18:55:35 GMTTento článek se snaží poskytnout seznam kvalitních knih a webových stránek s .Net tématikou a poradí vám kde hledat odpovědi na vaše otázky.Tomas PetricekTento článek se snaží poskytnout seznam kvalitních knih a webových stránek s .Net tématikou a poradí vám kde hledat odpovědi na vaše otázky..NET - Úvod do Reflectionhttp://tomasp.net/articles/reflection.aspxSun, 19 Jun 2005 00:07:18 GMTV tomto článku se podíváme na to co umožňuje Reflection. Ukážeme si jak lze za běhu zjišťovat informace o objektech a jak je lze používat.Tomas PetricekV tomto článku se podíváme na to co umožňuje Reflection. Ukážeme si jak lze za běhu zjišťovat informace o objektech a jak je lze používat.WinForms - Vývoj TabletPC aplikacíhttp://tomasp.net/articles/msinkdemo.aspxSat, 11 Jun 2005 03:03:34 GMTV tomto článku naleznete několik ukázek popisujících tvorbu programů pro platformu TabletPC.Tomas PetricekV tomto článku naleznete několik ukázek popisujících tvorbu programů pro platformu TabletPC.C# - Unsafe kód a ukazatelehttp://tomasp.net/articles/unsafecode.aspxSun, 05 Jun 2005 21:36:53 GMTTento článek popisuje jak lze v jazyce C# pracovat s ukazateli a obsahuje ukázku přímého přístupu do paměti bitmapy.Tomas PetricekTento článek popisuje jak lze v jazyce C# pracovat s ukazateli a obsahuje ukázku přímého přístupu do paměti bitmapy..NET - Kolekce a seznamy objektůhttp://tomasp.net/articles/collections.aspxSun, 05 Jun 2005 21:19:02 GMTTento článek popisuje práci s poli a základními kolekcemi jako je ArrayList a Hashtable pod platformou .Net.Tomas PetricekTento článek popisuje práci s poli a základními kolekcemi jako je ArrayList a Hashtable pod platformou .Net.ASP.NET - Ovládací prvky používající JavaScripthttp://tomasp.net/articles/aspjavascript.aspxSun, 05 Jun 2005 21:16:27 GMTV tomto tutoriálu jsou popsány základní techniky, které je potřeba znát při tvorbě ovládacích prvků založených na JavaScriptu.Tomas PetricekV tomto tutoriálu jsou popsány základní techniky, které je potřeba znát při tvorbě ovládacích prvků založených na JavaScriptu.ASP.NET - Dynamické vytváření ovládacích prvkůhttp://tomasp.net/articles/dynamicasp.aspxThu, 05 May 2005 23:24:15 GMTTento tutoriál vysvětluje, jakým způsobem lze z kódu stránky dynamicky vytvářet ovládací prvky a jak lze uchovávat nastavení těchto prvků.Tomas PetricekTento tutoriál vysvětluje, jakým způsobem lze z kódu stránky dynamicky vytvářet ovládací prvky a jak lze uchovávat nastavení těchto prvků..Net - Používání Windows API funkcíhttp://tomasp.net/articles/wininterop.aspxMon, 25 Apr 2005 01:11:52 GMTTento článek vysvětluje, jak je možné používat WinAPI funkce pomocí platform invoke v .Net aplikaci.Tomas PetricekTento článek vysvětluje, jak je možné používat WinAPI funkce pomocí platform invoke v .Net aplikaci.WinForms - Screensaver a kreslení pomocí GDI+http://tomasp.net/articles/screensaver.aspxMon, 11 Apr 2005 21:29:25 GMTTento článek vysvětluje jak lze za použití objektově orientovaného programování vytvořit spořič obrazovky v .NETuTomas PetricekTento článek vysvětluje jak lze za použití objektově orientovaného programování vytvořit spořič obrazovky v .NETuWinForms - Aplikace s podporou pluginůhttp://tomasp.net/articles/pluginsarch.aspxFri, 01 Apr 2005 00:19:58 GMTTento úvod vysvětluje jak lze v .Net aplikaci umožnit rozšiřování pomocí pluginů a jak přistupovat k nastavení v konfiguračním souboru.Tomas PetricekTento úvod vysvětluje jak lze v .Net aplikaci umožnit rozšiřování pomocí pluginů a jak přistupovat k nastavení v konfiguračním souboru.WinForms - Spolupráce mezi více formulářihttp://tomasp.net/articles/formsinter.aspxThu, 31 Mar 2005 23:26:19 GMTTento článek popisuje základy spolupráce mezi více formuláři ve Windows Forms aplikaci.Tomas PetricekTento článek popisuje základy spolupráce mezi více formuláři ve Windows Forms aplikaci.Avalon - Okna a panely v XAMLhttp://tomasp.net/articles/avalonwin.aspxTue, 22 Mar 2005 01:53:33 GMTTento článek se snaží shrnout pár základních principů v Avalonu, což je framework pro tvorbu uživatelského rozhraní v nadcházející verzi Windows (Longhorn).Tomas PetricekTento článek se snaží shrnout pár základních principů v Avalonu, což je framework pro tvorbu uživatelského rozhraní v nadcházející verzi Windows (Longhorn).Práce s programem Windows Messengerhttp://tomasp.net/articles/msncontrol.aspxTue, 08 Mar 2005 02:20:05 GMTCo vše lze dělat pomocí COM objektů programu Windows MessengerTomas PetricekCo vše lze dělat pomocí COM objektů programu Windows MessengerAsp.Net 2 - Master pageshttp://tomasp.net/articles/aspmasterpg.aspxMon, 03 Jan 2005 00:00:00 GMTProblém jednotného vzhledu a společných některých částí stránky je v nové verzi Asp.Net řešen pomocí tzv. master pages. Funguje to tak, že v master stránce je kód, který má být stejný na všech stránkách a ostatní stránky dodávají pouze obsah... Master pages v Asp.Net 2 je již poměrně známá a velmi očekávaná věc. V tomto článku jsem se pokusil doplnit známé fakty o některé další zajímavosti týkající se master pages, jako je například dynamické načítání master stránky a další. Tomas PetricekProblém jednotného vzhledu a společných některých částí stránky je v nové verzi Asp.Net řešen pomocí tzv. master pages. Funguje to tak, že v master stránce je kód, který má být stejný na všech stránkách a ostatní stránky dodávají pouze obsah... Master pages v Asp.Net 2 je již poměrně známá a velmi očekávaná věc. V tomto článku jsem se pokusil doplnit známé fakty o některé další zajímavosti týkající se master pages, jako je například dynamické načítání master stránky a další. Universal enumeration editor controlhttp://tomasp.net/articles/enumedit.aspxFri, 31 Dec 2004 03:54:54 GMTAsp.Net and WinForms control for editing any enumeration data typeTomas PetricekAsp.Net and WinForms control for editing any enumeration data typeFractal snow screensaverhttp://tomasp.net/articles/fractalsnow.aspxFri, 31 Dec 2004 03:40:15 GMTDescribes how to draw snowflakes using fractals and contains a nice snow screensaver.Tomas PetricekDescribes how to draw snowflakes using fractals and contains a nice snow screensaver.Asp.Net 2 - Kompilacehttp://tomasp.net/articles/aspcompile.aspxSun, 05 Dec 2004 00:00:00 GMTJak je to s dynamickou kompilací v Asp.Net 2 a co bude jinak oproti aktuální verziTomas PetricekJak je to s dynamickou kompilací v Asp.Net 2 a co bude jinak oproti aktuální verziASP.NET Popup Controlhttp://tomasp.net/articles/asppopup.aspxSat, 20 Nov 2004 04:07:14 GMTHighly customizable JavaScript popup control for web page wrapped in ASP.NET custom control.Tomas PetricekHighly customizable JavaScript popup control for web page wrapped in ASP.NET custom control.Graphical ASP.NET Controlshttp://tomasp.net/articles/graphicalcontrols.aspxSat, 20 Nov 2004 03:25:26 GMTGraphical radio button and check box ASP.NET controlsTomas PetricekGraphical radio button and check box ASP.NET controls