« Answering PG'S Arc Challenge: On the Road to a DSL| Main | Buy a Jeep, Fund a Startup »

Feb 2010 New F# Compiler Bugs

| | Comments (0)

I have been playing around with F# for over a year now, and I really love it. I *think* I have most of it mastered, except maybe active patterns and workflows -- but I'm getting close to groking those. Recursion still makes me scratch my head for a bit, but I can recurse with the best of them once I get going.

What sucks is running into bugs -- not mine, but the compiler's. Here are two I ran into last week that's caused a lot of pain (and information about a possible third one)

The app I'm working on has a couple of really large record types. The reason I would want to have a record with a huge number of fields is to pre-calculate and keep track of a Cartesian product of two other records. It's not something I wanted to rebuild every time I needed it.

What I found was that creating and manipulating large types in F# causes the F# compiler to crash. Once you get past 300 fields or so, somehow the stack has a tendency to overflow, no matter what you set the stack size to be.

At first I thought this was a property of having modules that were too big, but that wasn't it. Then I thought it might be that some of my code has long pattern matching in it.

I emailed Microsoft tech support for F# and within minutes I was in a conversation with an engineer. He thought it was the huge matching structures too -- turns out this is a known bug -- but that wasn't it. After scripting around a bit, he also determined that huge record types just aren't happening yet in F#. The workaround is to break your types up into two pieces. Ouch.

At the same time, I also noted that computing field values when you are creating the type has a tendency to make the compiler barf when you use really long types. So, for instance, if you have a type with 200 fields and each field is being created by some bit of code (instead of a simple assignment)? That's going to hose up the compiler as well. (I am not sure of the exact number of fields or what with this -- if you get this, you'll know it) The workaround here is to pre-compute the RHS of your field assignments before you create the type, then just refer to your precomputed types.

What hurts the most? The app was working and compiling fine in 2010 beta but is just a dead hunk of bits in 2010RC.

Leave a comment

About this Entry

This page contains a single entry by DanielBMarkham published on February 26, 2010 1:21 PM.

Answering PG'S Arc Challenge: On the Road to a DSL was the previous entry in this blog.

Buy a Jeep, Fund a Startup is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Social Widgets





Share Bookmark this on Delicious

Information you might find handy
(other sites I have worked on)





Recently I created a list of books that hackers recommend to each other -- what are the books super hackers use to help guide them form their own startups and make millions? hn-books might be a site you'd like to check out.
On the low-end of the spectrum, I realized that a lot of people have problems logging into Facebook, of all things. So I created a micro-site to help folks learn how to log-in correctly, and to share various funny pictures and such that folks might like to share with their friends. It's called (appropriately enough) facebook login help