It's been a couple of months and I'm still slower writing code in Factor than in Python or Scheme. So why am I still writing code in Factor? Well it turns out that the problem is also the attraction:

You can't hack in factor.

In python you can hack out code in multi-line functions, parking results in variables and combining them in subsequent lines. You can have a function that fills half the screen and manipulates >10 local variables and still trivially keep track of what's going on.

Factor on the other hand scales horribly both with respect to lines of code per word (function) and the amount of local state (number of variables). This is because local state is manipulated on a stack which you have to keep track of in your head. Anything exceeding 3 variables and a single line of code and the cognitive load starts to ramp up exponentually. Four variables and the mind is constantly distracted trying to keep track of the stack order. Five and you're spinning wheels, going nowhere fast.

So instead you're constantly having to come up with neat composable abstractions to fold up the state. This is the sort of thing that makes code elegant, loosely coupled and small in any language. However where as with other languages splitting your code into neat composable blocks is considered good practice, in factor you simply don't have any choice: you just can't keep parking state on the stack.

Not surprisingly factor is absolutely jam-packed with abstraction mechanisms: blocks, partial application, objects, generic functions, parsing words (macros), dynamic variables, namespaces, modules. You name it. And because the language forces tiny composable reusable functions the library is packed full of them.

Plus, factor has excellent tools for traversing code. This is super important in a language which encourages thousands of discreet one liners and I think this is the first time I've seen this stuff done properly without tying you to an IDE. (in fact there's so much good here that I should probably devote a whole post to it)

All this may actually make factor is the ultimate teaching language. Why? - well in other languages the novice programmer can write an awful lot of procedural code using just functional decomposition before feeling the pressure to look for other abstractions. With factor that pressure is there almost from the start and so the novice is forced to search the bigger picture for abstraction possibilites almost constantly. I think it's this abstraction pressure which helps people to 'get' language features in an intuitive tanguable way, and that's pretty much the point of a teaching language.

So will the factor attraction last with me? The interesting thing will be to see if I ever get up to 'scheme speed' with factor. At the moment I have to be really switched on and concentrating each time I code. I'm forced to step back all the time to see if there's a better way to do something, and I'm constantly re-writing stuff. I'm sorta hoping this is just early days - that at some point I'll get to a level of experience where I spot the bigger ideas much quicker. Either way, factor is a lot of fun to use and is compelling in the way an interesting puzzle is. And ultimately I'm sure this is making me a better programmer.