TP

What to teach as the first programming language and why

The number of Google search results for the phrase "choosing the first programming language" at the time of writing is 15,800. This illustrates just how debated the issue of choosing the first programming language is. In this blog post, I will not actually try to answer the question posed in the title of the post. I will not discuss what language we should teach as the first one. Instead, I will look at a more interesting question.

I will investigate the arguments that are used in favour of or against particular programming languages in computer science curriculum. I am more interested in the kind of argumentation that is employed to support a particular choice than in the specific languages involved. This approach is valuable for two reasons. First, by looking at the argumentation used, we can learn what educators consider important about computer science. Second, understanding the motivations behind different arguments allows us to make our own debates about the choice of a programming language more informed.

The scope of this blog post is limited to the choice of the first programming language taught in an undergraduate computer science programmes at universities. This means that I will not discuss other important contexts such as choices at a primary or a secondary education level, choices for independent learners and choices in other university degrees that might involve programming.

Note that this blog post is adapted from an essay that I wrote as part of a Postgrduate Certificate for Higher Education programme at University of Kent, so it assumes less knowledge about programming than a typical reader of my blog has. This makes it accessible to a broader audience thinking about education though!

Published: Monday, 2 December 2019, 4:48 PM
Tags: functional, research, academic, programming languages, philosophy, writing
Read the complete article

Update on the F# Deep Dives book

It has been some time since I last wrote about F# Deep Dives - a new project that I'm working on together with Manning, Phil Trelford and a number of F# experts, so I'd like to write a quick update. In summary, working on a book with more than 10 co-authors is more difficult than one would think (and 10 people cannot write a book in 1/10 of the time :-)), but now that the holidays are almost over, you can expect more frequent updates again!

First of all, I shoud mention that you can buy the Early Access preview of the book from Manning and there is already one in advance review of the book from Ted Neward (thanks!) who says:

As of this writing, the early-access [...] version had only Chapters 3 and Chapter 11, but the other topics [...] are juicy and meaty. [T]he prose from the MEAP edition is pretty easy to read already, despite the fact that it's early-access material. In particular, the Markdown parser they implement in chapter 3 is a great example of a non-trivial language parser, which is not an easy task (...).

As I mentioned, the book is unique in that it is not written just by me and Phil - each chapter is written by a real-world F# expert and many of them use F# in production. The disadvantage is that they are all busy people, but we have close to half of the planned chapters available already...

Published: Tuesday, 27 August 2013, 4:15 AM
Tags: manning, f#, writing, books, deep dives
Read the complete article

Announcing: Literate programming tools for F#

For some time now, I've been writing my F# blog posts (and other F# articles published elsewhere) by combining F# code snippets and Markdown formatting. In fact, I even wrote a Markdown parser in F# so that I can post-process documents (to generate references etc). You can read about the Markdown parser in an upcoming F# Deep Dives book - currently, it is available as a free chapter!

During the Christmas break, I finally found enough time to clean-up the code I was using and package it properly into a documented library that is easy to install and use. Here are the most important links:

To learn more about this tool and how to use it, continue reading!

Published: Tuesday, 22 January 2013, 5:35 PM
Tags: open source, f#, writing, literate
Read the complete article

Manning: F# Deep Dives deal of the day

The F# language has been around for longer than many people suspect. My first, completely outdated, blog post was from May 2006. The Microsoft Research releases, sometime around 2006 were the first stable versions that gained some interest and slowly attracted commercial users.

A lot has changed since the early days. F# now includes powerful features like computation expressions and asynchronous workflows and F# 3.0 comes with unique type provider mechanism.

There is an increasing number of users from diverse domains: F# is used to model complex domains in finance and science; asynchronous and concurrent features are used to write server-side components of social games and trading systems, but also in web programming; the expressivity of F# is used by machine learning experts to handle dirty data or classify XBox players. Moreover, the F# Software Foundation has been recently founded to support the collaboration between different commercial users, open-source community and academia.

There is an increasing interest in F#, but many of those who approach it ask (excellent) questions such as: "In what problem domains can I benefit from F#?" or "How do I use F# in finance/science/gaming or web programming?" and most importantly "How do I approach different problems in F#?"

Published: Tuesday, 18 December 2012, 5:19 PM
Tags: manning, f#, writing, books
Read the complete article

F# Math - Numerical computing and F# PowerPack

This article is the first article of a series where I'll explain some of the F# features that are useful for numeric computing as well as some functionality from the F# PowerPack library. Most of the content was originally written for the Numerical Computing in F# chapter on MSDN (that I announced earlier), but then we decided to focus on using F# with third party libraries that provide more efficient implementation and richer set of standard numeric functionality that's needed when implementing machine learning and probabilistic algorithms or performing statistical analysis. If you're interested in these topics, then the last section (below) gives links to the important MSDN articles.

However, F# PowerPack still contains some useful functionality. It includes two additional numeric types and an implementation of matrix that integrates nicely with F#. The series also demonstrates how to use features of the F# language (and core libraries) to write numeric code elegantly. In particular, we'll use the following aspects:

These are just a few of the F# language features that are useful when writing numeric code, but there are many others. The usual F# development style using interactive tools, type safety that prevents common errors, units of measure as well the expressivity of F# make it a great tool for writing numeric code. For more information, take a look at the MSDN overview article Writing Succinct and Correct Numerical Computations with F#.

Published: Wednesday, 2 November 2011, 2:30 AM
Tags: functional, f#, writing, math and numerics
Read the complete article

Extending Monads with Pattern Matching (Haskell 2011)

Some time ago, I wrote a paper about joinads and the match! extension of the F# language. The paper was quite practically oriented and didn't go into much details about the theory behind joinads. Many of the examples from the F# version relied on some imperative features of F#. I believe that this is useful for parctical programming, but I also wanted to show that the same idea can work in the purely functional context.

To show that joinads work in the pure setting, I created a Haskell version of the idea. The implementation (available below) is quite simple and consists of a pre-processor for Haskell source files and numerous examples. However, more important part of the recent work of joinads is a more detailed theoretical background.

The theory of joinads, together with the language design of Haskell extension that implements it is discussed in a paper Extending Monads with Pattern Matching, which was accepted for publication at the Haskell Symposium 2011. Here is the abstract of the paper:

Sequencing of effectful computations can be neatly captured using monads and elegantly written using do notation. In practice such monads often allow additional ways of composing computations, which have to be written explicitly using combinators.

We identify joinads, an abstract notion of computation that is stronger than monads and captures many such ad-hoc extensions. In particular, joinads are monads with three additional operations: one of type m a -> m b -> m (a, b) captures various forms of parallel composition, one of type m a -> m a -> m a that is inspired by choice and one of type m a -> m (m a) that captures aliasing of computations. Algebraically, the first two operations form a near-semiring with commutative multiplication.

We introduce docase notation that can be viewed as a monadic version of case. Joinad laws make it possible to prove various syntactic equivalences of programs written using docase that are analogous to equivalences about case. Examples of joinads that benefit from the notation include speculative parallelism, waiting for a combination of user interface events, but also encoding of validation rules using the intersection of parsers.

Links to the full paper, source code and additional materials are available below.

Published: Wednesday, 20 July 2011, 12:19 AM
Tags: parallel, writing, research, haskell, joinads
Read the complete article

Deal of the day: Real-World Functional Programming

Some time ago, I received my copies of Real-World Functional Programming. I started working on it back in May 2008 and as many people who had more experience with writing books told me, it took longer than I was expecting! Anyway, I have to say, it was worth it, holding the actual printed book with my name on the cover is just fantastic!


The goal of the book is to present functional programming concepts and ideas in a readable form. I wanted to create a book that will teach you how to think functionally without using the usual shock therapy that people usually feel when seeing functional programming for the first time. There are already a couple of reviews that suggest I was quite successful:

Deal of the day (January 24)

Finally, here is one great news if you're interested in getting the book! Real-World Functional Programming is Manning's Deal of the Day this Sunday, January 24. On this day, the print book is available for $20 from the Manning website, with code dotd0124.

Published: Sunday, 24 January 2010, 5:00 PM
Tags: random thoughts, functional, universe, writing
Read the complete article

Real-World Functional Programming: Completed and printed!

If you're following my blog or if you're interested in F# or functional programming in .NET, you probably noticed that I was working on a book Real-World Functional Programming. At some point, we called it Functional Programming for the Real-World, but then we changed the title back to a better sounding version Real-World Functional Programming (subtitle With examples in F# and C#). The book is also reason for a lower number of blog posts over the last year. Over the last month or so, we were doing the final edits, reviewing the final PDF version (I fixed quite a lot minor issues, synchronized book with the Beta 2 F# release and so on). Anyway, before a few days, I received the following email (as an author, I receive the same emails as those who ordered the book through the Manning Early Access Program, so that I can see what we're sending to our dear readers):

Dear Tomas Petricek,
We are pleased to announce that Real-World Functional Programming is now complete! As a MEAP subscriber you can download your copy of the finished ebook right now! (...) This ebook is the final version, identical to the softbound edition, which is currently being printed and will be available on December 24. If you chose the printed book option when you originally subscribed, we'll ship it to you automatically—no action required from you.

Finally finished!

Yes, that's right. The book is finally completed and as far as I know, it has been printed last week! If you already ordered the book, you won't receive it before Christmas, but it should come shortly after. I can't wait to see the book actually printed. The transition from the Word drafts I initially wrote to a final PDF version was already felt fantastic and I thought "It looks like a real book!" Among other things, there are now graphical arrows with comments inside listings, which looks really great and makes code listings much easier to read. Now I can look forward to seeing the actual book. Maybe I'm too conservative, but I have to say that I'm really glad that I wrote the book before everything is going to be published just electronically!

Here is a couple of links that you may found interesting if you want to look inside the book...

Published: Saturday, 19 December 2009, 9:54 PM
Tags: functional, random thoughts, universe, writing
Read the complete article

Functional Programming in .NET using C# and F# (Manning Greenpaper)

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.

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.

Book cover
Available via MEAP | 500 pages
Softbound print: March 2009 (est.)

This article is partially an excerpt from my book Real-world Functional Programming in .NET [1]. Thanks to my editors at Manning 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.

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 book, which explains everything in larger detail and discusses many other interesting ideas.

Published: Thursday, 11 December 2008, 1:48 AM
Tags: functional, c#, parallel, meta-programming, writing, f#
Read the complete article

Calculating with infinite sequences on MSDN

About a year ago, I wrote an article about using lazy computations in C# 3.0. It was published by the C# Community PM Charlie Calvert at the C# Developer Center. The article was a first of two articles where I wanted to demonstrate that C# 3.0 can be used for implementing useful constructs known from functional languages. I realized that I never posted the link to the second article to my blog, so you can find the annotation and link below.

However, I remembered about these two articles because I was just working on chapters 11 and 12 of the Real-world Functional Programming in .NET book that I’m writing. Lazy values, which were the topic of my first article, are discussed in the second part of chapter 11 and IEnumerable and F# sequences are the topic for the first part of chapter 12. Because I already wrote two articles on this topic, I had to think really hard to find better (and still simple enough) examples where these concepts are useful in practice. I also finally have enough space to show how these two concepts relate and talk about some interesting background – for example in Haskell, lazy sequences are in fact just ordinary lists that are lazy thanks to the Haskell nature.

A year ago, I definitely wouldn’t believe that today, I’ll be writing about the same topics, but this time as part of a book that has partly the same goal as these two articles – to show that functional programming ideas are really useful in the real-world and can enrich your programming toolbox (no matter whether you’re using C# or F# language). Anyway, here is the link to the second article – as usual when I look at something that I worked on a long time ago, I think I should rewrite it to make it better :-), but it still gives you an idea what is the book that I’m working on about...

Published: Thursday, 13 November 2008, 2:36 AM
Tags: c#, functional, universe, writing, links
Read the complete article

Functional Programming in .NET book - An update

Recently, I announced on my blog that I’m working on a book for Manning called Real world Functional Programming in .NET. The goal of the book is to explain the most interesting and useful ideas of functional programming to a real world C# developer. I'm writing this book, because I believe that functional programming is becoming increasingly important. Here is a couple of reasons why you should have this book on your bookshelf:

The book is available via the MEAP (Manning Early Access Program) and if you want to get a better idea what is the book about, you can read the first chapter for free. Anyway, it is more than a month since I posted the announcement, so I decided to write a brief update....

Published: Monday, 20 October 2008, 10:10 PM
Tags: functional, c#, universe, web, writing
Read the complete article

Announcing: Real-world Functional Programming in .NET

If you’ve been reading my blog or seen some my articles, you know that I’m a big fan of the F# language and functional programming style. I’m also often trying to present a bit different view of C# and LINQ – for me it is interesting mainly because it brings many functional features to a main-stream language and allows using of many of the functional patterns in a real-world. Elegant way for working with data, which is the most commonly used feature of C# 3.0, is just one example of this functional approach. Talking about real-world applications of functional programming, there is also fantastic news about F#. It was announced last year that F# will become fully supported Visual Studio language and the first CTP version of F# was released this week!

I always thought that the topics mentioned in the previous paragraph are really interesting and that functional programming will continue to become more and more important. That’s why I’m really excited by the news that I’d like to announce today – I’m writing a book about functional programming in F# and C#....

Published: Tuesday, 2 September 2008, 8:03 PM
Tags: functional, random thoughts, universe, parallel, writing
Read the complete article

All blog posts by tag

f# (112), functional (66), research (44), c# (37), asynchronous (27), parallel (23), academic (22), functional programming (20), universe (20), programming languages (18), meta-programming (18), philosophy (15), links (15), presentations (14), data science (12), writing (12), joinads (12), thegamma (11), web (10), data journalism (9), math and numerics (9), random thoughts (9), talks (8), phalanger (8), haskell (7), mono (7), webcast (7), fslab (5), open source (5), visualization (4), fun (4), accelerator (4), design (3), type providers (3), linq (3), f# data (3), .net (3), training (2), coeffects (2), deedle (2), monads (2), art (2), fractals (2), funscript (2), new york (2), manning (2), books (2), teaching (1), fable (1), machine learning (1), comonads (1), fake (1), f# formatting (1), deep dives (1), async (1), events (1), trainings (1), london (1), literate (1)