I’m happy to annouce the FAKE 2.4 release with F# 3.1 support.
If you new to FAKE you should read the getting started guide or clone the new F# ProjectScaffold.
Go and grab the bits
Thanks to the 6 new ccontributors in the last months we are now 45! That’s so awesome.
Feel free to contact me if you need help for the upgrade.
It’s a long time since the last major FAKE release and the community has contributed a lot of really cool features. This is so awesome and I want to thank all the contributors. You rock.
Today, I’m happy to annouce the FAKE 2.2 release. This release is really a very big change, so if you are still on FAKE 1.x there might be some problems for the upgrade. Feel free to contact me if you need help.
There is really a lot happening in this release so I want to talk about some of the improvements. Let’s start with the change of the project stucture. We separated the projects into different nuget packages in order to deploy a much smaller FAKE.Core package. These are the packages we have on nuget.
- Fake.Deploy – allows to use FAKE scripts in deployment.
- Fake.Experimental – exciting new stuff we want to try out and might want to remove again.
- Fake.Gallio – contains the Gallio runner support.
- Fake.SQL – Contains tasks for SQL Server.
- Fake.Core – All the basic build features and FAKE.exe.Ă‚Â If you only want the basic functionality then you would probably want to use this.
- FAKE – Contains all the stuff above. We keep this package for compatibility.
As you can see the FAKE.Deploy package is now finally released. A big thanks to Colin Bull and all the others that are working in this area.Ă‚Â See thisĂ‚Â tutorialĂ‚Â for more information.
Another interesting sub project is FAKE.Boot by Anton Tayanovskyy. It’s also released today. Read more about it in Anton’s blog.
Of course we have plenty new tasks:
New globbing system
We (which means Colin đź™‚ ) changed the implementation of the file scanning in FAKE. The original implementation was way to complicated and had tons of bugs in it. The new version is really elegantĂ‚Â and only a fraction of the original code size. If you are interested in Functional programming check this out. It’s an interesting problem.
You will notice that a lot of the original file pattern functions are marked as obsolete. The file patterns implement IEnumerable, so you don’t need to use the “Scan” function any more.
I have some ideas how to reorganize the project and how to make it easier to debug build scripts. There are also ideas floating around how we can change the way FAKE bundles the FSI and but this still needs some time.
In the meantime we try to improve the existing tasks and continue to improve the documentation.
Up for grabs
The FAKE project joined the Up For Grabs project and I started to addĂ‚Â tasks which are meant for new contributorsĂ‚Â to join the project. So if you want to get involved in FAKE then these might be interesting for you.
I want to start using SemVer but I still have to figure out all the details of the new version number strategy. If someone has ideas about this then please let me know.
Monitoring external projects
Most of the tasks in FAKE are calling external tools. It’s very hard to test this properly so one approach is that FAKE is dogfooding the latest FAKE version to build itself. This ensures that most issues are catched very early. But of course FAKE’s own build script doesn’t use all the supported tasks.
In order to make FAKE more stable I want to monitor more external projects. So if you have an OSS project with a public CI build which is using FAKE then please let me know. I will try to maintain a list of these projects and will start to monitor if a new FAKE version would break these projects.
Go and grab the bits
Thanks again to all the 39 contributors – I thinks that’s an awesome number for an OSS Ă‚Â project that’s written in F#.
I love to work on open source projects, but from time to time I have my doubts. My friend Daniel Nauck created a wonderful open source licensing project (see my blog post) and now we had to see this:
I am not a lawyer and rebranding a tool might be permitted by the MIT license, but seriously what are they thinking?
They even removed license information from the source files.
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
ItĂ˘â‚¬â„˘s really ironic to violate the license of a licensing tool, but please donĂ˘â‚¬â„˘t be that guy!
Christian Clausen and Bent Rasmussen released their second static analysis tool for Dynamics NAV called Prism. This time it has more features and itĂ˘â‚¬â„˘s even faster than Supervision.
Ă˘â‚¬Ĺ“Load time for Developers Toolkit for a typical full database is approximately 25 minutes which compares to Prism’s 20 seconds. Load time is a serious productivity and/or quality killer, as people will either work with old objects in Developers Toolkit, wait another 25 minutes to reprocess the objects, or even decide to just go ahead and change code without understanding how the current code is actually working.Ă˘â‚¬Âť
The biggest new feature is Ă˘â‚¬Ĺ“Find usagesĂ˘â‚¬Âť:
Check out the project page and watch the presentation at the Community for F# which gives some details about the implementation.
Until yesterday I thought I would be the only person on this planet who plays with a combination of F# and Dynamics NAV. Turned out I was wrong.
Christian Clausen and Bent Rasmussen created a really really cool static analysis tool for Dynamics NAV written in F#. For those who worked with the Dynamics NAV DeveloperĂ˘â‚¬â„˘s Toolkit this is your new friend:
Ă˘â‚¬Ĺ“Supervision is a free software program which can transform C/AL object text files into color-coded hyper-linked interactive HTML files.
The purpose of Supervision is to give Microsoft Dynamics NAV developers an easy and intuitive way to browse C/AL source code which provides better insight into the semantics of C/AL programs.Ă˘â‚¬Âť
Some of the features are:
- Usages of user-defined functions, variables, parameters, fields, system-defined variables, and object types link to their declaration
- Usages of C/AL system functions link to official Microsoft C/AL language documentation
- Code coloring
- ItĂ˘â‚¬â„˘s blazing-fast
Check out the project page and watch the presentation at the Community for F# which gives some details about the implementation.
Triggered by a short tweet by Tomas Petricek and a blog post by Don Syme I had a couple of conservations about null as a value, Null as a type (Nothing in Scala), the null object pattern and the Maybe monad (or Option type in F#). I decided to share my opinion on this topic in order to help others to make their own opinion.
Part I – Null as a value
Unfortunately most programming languages have some kind of null pointer. We are now even at a point where some people claim that Tony HoareĂ˘â‚¬â„˘s famous billion dollar mistake costs actually a billion dollar per year.
But before we start to think about solutions to the null pointer problem let us first see where null values might come in handy.
In a statement oriented language like C# it is sometimes not that easy to represent uninitialized state.
As you can see we forgot to initialize peter in the missing "else-branch" which might lead to a NullReferenceException. There are a couple of things we can do to prevent this from happening. First of all we should omit the explicit initialization with null:
In this case the C# compiler throws an error telling us "Use of unassigned local variable ‘peter’".
In expression oriented languages like F# the problem doesnĂ˘â‚¬â„˘t exist. We usually write initializations like this:
There is no way to forget the else branch since the types donĂ˘â‚¬â„˘t match.
Consider a search function which tries to find a Person in a list:
Unknown values are probably the most common cause for the introduction of nulls and in contrast to uninitialized values they have much more global effects.
Solutions to unknown values
1. Using explicit exceptions
One easy solution to get rid of the nulls is to make the exception explicit:
One benefit here is that we have a concrete exception which is telling us what went wrong. Unfortunately nothing forces us to handle this exception in the calling method. This means the program can still crash. Another problem is that if we use try/catch as a control flow statement (i.e. use it very very often) then we might slow down our program.
And there is still a philosophical question: is it really an exception if we donĂ˘â‚¬â„˘t have a person in our repository?
2. Using out parameters and returning bools
If we want to make the result of our search a little more explicit we can also introduce a boolean return value:
This is a pattern which is actually used everywhere in the .NET framework, so it must be good right?!
Just a simple question here: What did we gain exactly? If we forget to check for nulls why would we remember to check the bool?
There is another interesting observation here. Due to the introduction of out parameters we also introduce the uninitialized value problem in every calling method, which is bizarre.
3. Null object pattern
Ă˘â‚¬Ĺ“In object-oriented computer programming, a Null Object is an object with defined neutral ("null") behavior. The Null Object design pattern describes the uses of such objects and their behavior (or lack thereof).Ă˘â‚¬Âť
So obviously this makes only sense in a context where objects have observable behavior. So letĂ˘â‚¬â„˘s add some behavior to our Person class:
Now we can use this in the search method:
Let’s look at this solution for a moment.
- Pro: Implementation of missing behavior is trivial
- Pro: We donĂ˘â‚¬â„˘t introduce null values Ă˘â‚¬â€ś> we wonĂ˘â‚¬â„˘t get NullReferenceExceptions
- Pro: The name of the class carries information about the reason for the null value
- Cons: In order to to get rid of the Person(string name, int age) constructor in the null-object we had to introduce an interface
- Cons: In order to use the interface we had to modify the Person class. This might be a real problem if we donĂ˘â‚¬â„˘t have access to the source. We would need some kind of ad-hoc polymorphism like HaskellĂ˘â‚¬â„˘s type classes, ScalaĂ˘â‚¬â„˘s Traits or ClojureĂ˘â‚¬â„˘s Protocols (read more about the expression problem)
- Cons: Everything we want to do with Persons has to be part of the IPerson interface or we have to fall back to explicit runtime type tests, because there is no way to get to the data:
- Cons: Without ad-hoc polymorphism the Person class is getting more and more complex over time since we are adding all the behavior to it. Compare it with our starting point where it was a simple data representation. We totally lost that.
- Cons: Errors/bugs might appear as normal program execution. [see Fowler, Martin (1999). Refactoring pp. 261]
DonĂ˘â‚¬â„˘t use this approach itĂ˘â‚¬â„˘s really not a good solution.
4. The Option type (a.k.a. Maybe monad)
The option type is a way to push the idea from 2. Ă˘â‚¬Ĺ“returning boolsĂ˘â‚¬Âť into the type system. There are lots of tutorials about the option type on the web, but for now itĂ˘â‚¬â„˘s enough to know that it is something which is based on the following idea:
In order to allow pattern matching in C# we introduce a small helper:
With this idea we can get rid of all null values in the program, we donĂ˘â‚¬â„˘t have to introduce an IPerson interface, the null case is type checked and the best thing is itĂ˘â‚¬â„˘s really easy to create functions like IsOlderThan12:
Please donĂ˘â‚¬â„˘t implement the option type yourself. Even in C# itĂ˘â‚¬â„˘s much easier to just reference FSharp.Core.dll and use FSharpx (read 10 reasons to use the F# runtime in your C# app).
Of course this is only the tip of the iceberg. If you read more about the option type you will see that its monadic behavior allows all kinds of awesome applications (e.g. LINQ, folds, map, Ă˘â‚¬Â¦).
5. The Either type
One of the benefits of the null object pattern above was that it allows to encode the reason for the missing value. In some cases we need the same thing for the maybe monad. So let’s try to capture the reason in the None case:
Now we can use this in the TryFindPerson method:
As with the option type please don’t rewrite this stuff yourself. There is a Choice type in F# which helps to capture this idea and Mauricio has a couple of blog posts which explain how to use it from C# (of course FSharpx is helping here again).
6. The (singleton) list monad
The option type captures the idea that we can either have one value or nothing. We can do the same thing with List<T>:
Of course this uses only a small subset of the power of IEnumerable<T> but I wanted to show the similarity to the maybe monad. You can read more about the Ă˘â‚¬Ĺ“poor manĂ˘â‚¬â„˘s option typeĂ˘â‚¬Âť on MauricioĂ˘â‚¬â„˘s blog.
We saw a couple of very different solutions to get rid of null values. Normally I’d only use the option type or the either type (if I need to carry the reason). In some very rare situations (e.g. C# only projects) I would also use singleton lists.
I wouldnĂ˘â‚¬â„˘t use the other solutions. They are potentially dangerous, especially if your project gets bigger.
I would be happy to read your opinions.
There was a lot of confusion about the document type providers in the last couple of months. The reason was Tomas Petricek and Co. worked on an improved version in the FSharp.Data project and most people lost track which feature was in which project.
In order to make things clearer I removed the Freebase, CSV, JSON and XML type providers from the fsharpx project. From now on they are only in the FSharp.Data project (on github and nuget).
I hope this doesnĂ˘â‚¬â„˘t make things worse and I apologize for the confusion. On the bright side you now get a couple of new features and a really cool documentation.
You can read more about this on TomasĂ˘â‚¬â„˘s blog.
"Portable.Licensing is a cross platform open source software licensing framework which allows you to implement licensing into your application or library.
It is targeting the Portable Class Library and thus runs on nearly every .NET/Mono profile including Silverlight, Windows Phone, Windows Store App, Xamarin.iOS, Xamarin.Android, Xamarin.Mac and XBox 360. Use it for your Desktop- (WinForms, WPF, etc.), Console-, Service-, Web- (ASP.NET, MVC, etc.), Mobile (Xamarin.iOS, Xamarin.Android) or even LightSwitch applications."
Yep, you read this correct. This project gives you a free licensing tool for all .NET/mono platforms including stuff like Android and iOS. ItĂ˘â‚¬â„˘s hosted on github and already on nuget and the Xamarin store, so itĂ˘â‚¬â„˘s pretty easy to use – even from F#.
Create a license
There is a really good documentation on the github project page (and there is even a sample implementation for a License Manager app), but just to give you a small glimpse:
Make sure to keep the private key private and distribute the public key with your app.
Validate a license
So try it out and donĂ˘â‚¬â„˘t forget to thank Daniel Nauck for this awesome new tool.