I don’t use F#-console apps very often – indeed I almost never use those because there is F# interactive for quick tests and I use F# more for libraries. And of course you don’t write console-apps very often nowadays – indeed I only use them for quick host in my WCF projects and those are always very tiny C# applications.
But today I finally had the need to write a quick one. Ok take the template and just write your various lets and you are fine.
But well I like my project’s namespaces nice so put in some
namespace OhWhatEver open System module Main = ...
Ok but what will be the entry-point? Well convention over configuration right (wrong) – so I went and tried
let main args = Console.WriteLine("Hello?") 0
Compile (no complain) – start and …. nothing.
– of course –
after some googling (who needs knowledge if you’ve got a internet search as you start site) I soon found the solution:
[< EntryPoint >] let main args = Console.WriteLine("Hello!") 0
This is no complaint but those things really bug me – why do I have to use those attributes in F# where C# and even VB.net uses project settings for things like this?
It’s no problem (might be even nicer) but if you are used to the other languages those things just scream “F# is NOT a first class language no matter what they say” to me.