Ivan Krivyakov's Blog

Premature optimization is the root of all evil

June 29, 2008

Developing Large Projects in F#

After trying to build a slightly above-toy-size project in F#, I came to the conclusion that with current tools it would be quite difficult to maintain a project of even moderate complexity. Unfortunately, I don’t believe this situation will dramatically improve any time soon.
[read more...]

F# Type Casts

Typecast matters are complicated in F#. Unlike many other languages, F# does not perform implicit upcasts by default. E.g. if class Derived derives from Base, and we have

let func( b : Base ) = ...
let d : Derived  = ...

then func(d) will not work. [read more...]

June 22, 2008

F#: How to Make a Record Type Nullable

As I mentioned in the previous post, F# types (as opposed to classes) cannot be null. That is, you cannot explicitly make them null, but you can still end up with a null value. Here’s how:

1 type Foo =
2 { x : int }
3
4 let varObj : Object = null
5 let varFoo1 : Foo = null // this won't work
6 let varFoo2 : Foo = varObj :? > Foo // this will

[read more...]

F#: Types, Classes and Nullability

F# has two kinds of data types – “classes” and “types”. Types are bags of bits, similar to C structs, only immutable (that’s C, without sharp). Classes are classes in a normal object-oriented sense.

F# types cannot be null. Values that may or may not be present are expressed via special type 'a option. So, int option means optional integer, conceptually very similar to Nullable<int>. int option can take values None or Some(x).
[read more...]

June 19, 2008

F# – Another Disappointment: Lazy Evaluation

After exploring “lazy” keyword in F#, I was up for some disappointments:
* lazy (bla) cannot be transparently used in expressions instead of bla
* Results of lazy evaluation are not cached
* Parameters of lazy functions are evaluated eagerly

Let me explain each of these points.
[read more...]

June 13, 2008

More on F#

Here is my view on F# after about two days of playing with it.

Disclaimer: I am just starting with F#. Some annoyances I talk about may be really insignificant for an experienced F# programmer. Others may be fixed in the future versions. Overall, I don’t totally reject the idea that F# might be the next best thing after the sliced bread. However, in my subjective view it is not ready for prime time, i.e. real large-scale commercial usage.

The good

[read more...]

June 11, 2008

Starting with F#

I was on a very intense project which was abruptly canceled. So, now I can a) write to the blog again and b) do some interesting stuff. This post is about my first (very first) impressions on the F#.

[read more...]