Tag Archives: F#

Fun with FunScript

FunScript is a compiler or better a transpiler, which converts F# code into JavaScript code.
I have not tried it much since the last couple of days and I’m really amazed how well it works.

I had really good expierences creating D3 charts but I wasn’t shure how well it works with AngularJS, with all his dependency mechanisms and “magic” behind the scenes.
So I thought I give it a try!

I came up with this DSL like syntax:

The DSL code looks like this (mainly it wraps the kinda ugly generated code):

It is still a bit clunky to use (mainly to get angular’s dependency injection to work) and it is far from completed, but at least a simple controller works!

The downsides of using FunScript to generate JavaScript code is the additional code generation step, it generates more verbose code than writing similar code in JavaScript and the debugging is chunky (but that’s a problem nearly every transpiler has). I don’t know of a source map file for the generated code, but maybe I’m missing something.

On the other side you can use this nice functional and composable code in places where I never thought it is possible to get it to work!

The sample project can be found here.

Tagged , , , ,