Friday, November 30, 2007
clock_stopped.png

My vista64 clock has stopped in the system tray... the funny thing is Renee (My Fiancee for those who don't know) has been asking me for the last half hour what the time is... and I've kept responding almost 11:30...

I hope they fix that in Vista SP1 - Damned if I'm getting a wall clock for my office!


posted @ Thursday, November 29, 2007 11:13:43 AM (New Zealand Daylight Time, UTC+13:00)    Comments [2] | Trackback |
 Thursday, November 29, 2007
So I'm learning F# in my spare time... I don't have much of that however.. so I kinda squeeze it in where I can, so I'm not progressing as fast I would like... None the less it's quite an easy language to get up to speed with, even as I stab at it blindly for half an hour a week... but some fundamentals can really trip you up when you're starting to learn and experiment without having developed a good mental model of whats going on... being a wannabe "expert" in the .Net framework and BCL doesn't necessarily give you much of edge when your moving from an imperative to functional programming language.

To that end this post is going to cover some really trivial observations, so for anyone that actually knows F# it's probably going to be pretty boring... and you might as well read something else ;o)

Anyway.. so, first off lets take evaluation order.

In C# I might write some code like so...


char
[] characters = new char[] { 'A','B','C','D','E'}

 

foreach (char c in characters)

    Console.WriteLine("character: " + c);


Now in F# I could write something similar...


let
characters = [| 'A'..'E' |]

 

for c in characters do

  print_endline "character: " + c.ToString()


But it wont compile... because it's evaluated/applied from left to right, so it equates to (print_endline "character:") + c.ToString() ... which can't compile because print_endline returns a result of type 'unit' (think void... though it is actually a return value)... thankfully it's a compiled language so these things are picked up immediately - but it can make for silly/confusing compilation errors when starting out.

Now, moving on from there.. past experience has also helped screw up my mental model... for example iteration related functions - if I was going to write an iteration function in C# the approach would generally be to do something like this:


public
void ForEach<T>(IEnumerable<T> items, Action<T> action)

{

    foreach (T item in items) action(item);

}

 

string[] words = new string[]

{

    "somewhere", "on", "earth", "little", "kids", "teach", "themselves",

    "a", "whistling", "sound", "to", "imitate", "bombs", "dropping"

};

 

ForEach(words, delegate(string s) { Console.Write(s + " "); });


I had the expectation of finding replicas in the F# built-in functions like List.iter etc. - in fact I even wrote code like this to start with, assuming it would work in the same manor.


List.iter words (fun word -> print_string (word + " "))


After that didn't compile I just swapped the parameters... it worked... but I saw some unusual behavior when stepping through it with the debugger... and it required further inspection... looking at the signature for List.iter revealed that it was actually a function that returned a function ...  ('a->unit) -> (list 'a -> unit)... hmmm..

So it turns out most of the built-in functions take a single function and return a function... so unlike the C# equivalent, the F# foreach would look something like the code below (though I suspect an F# guru might be able to write it in a more terse manor).


let
words = [ "somewhere"; "on"; "earth"; "little"; "kids"; "teach"; "themselves";

    "a"; "whistling"; "sound"; "to"; "imitate"; "bombs"; "dropping" ]

 

let foreach f  =

  let rec foreachInList l =

    match l with

    | head :: tail ->

      f head

      foreachInList tail

    | _ -> ()   

  foreachInList

 

let n = foreach (fun word -> print_string (word + " "))

n words

 

// or

 

words |> foreach (fun word -> print_string (word + " "))

 

// or

 

foreach (fun word -> print_string (word + " ")) words


It took me a minute or so of going hmmmm to absorb the beauty of that approach... obviously this is bread and butter of a functional programmer, but for a non-functional programmer like myself you tend to just see twice as much "work" going on (two function calls for starters).

Take a look at the second way of calling foreach... in this case |> applies the RHS as a filter on the LHS... because the function takes a single parameter we can do this easily.. but we can also chain them together... so we could alter our foreach function a smidgen:


let
foreach f  =

  let rec foreachOnList l =

    match l with

    | head :: tail ->

      f head

      head :: (foreachOnList tail)

    | _ -> [] 

  foreachOnList


So it's signature is no longer ('a->unit) -> (list 'a -> unit) but is instead ('a->unit) -> ('a list -> 'a list) ... now I can chain calls to my foreach together...


words
|> foreach (fun word -> print_string (word + " "))  |> foreach (fun word -> print_string (word.ToUpper() + "_"))


I really enjoy the elegance and simplicity of the filter syntax... if you replace the anonymous functions with functions you've already declared it suddenly becomes pretty, I think it reads nicer then chained extension method calls / fluent interfaces in C#.


let
capitalize (c: string) = c.ToUpper()

let pad c = c + " "

 

words |> List.iter (fun word -> word |> capitalize |> pad |> print_string)


At any rate, my half hour of F# exploration is up for the week.

posted @ Thursday, November 29, 2007 9:08:32 AM (New Zealand Daylight Time, UTC+13:00)    Comments [0] | Trackback |
 Wednesday, November 28, 2007
I came across this blog entry and to me at least, it just seems wrong?

To quote:

"These are two very different uses of the term that I've heard and both are explicitly not "automatically" in the true sense of that word. The point of automagically is when its not automatic at all and either you don't care (case one) or its a lie (case two). Now if people agree I'll update the wiki entry but I thought I'd first check what others had seen."


Perhaps I've been misinterpreting the use of the word, but In development circles I've always taken it to mean a process that does work automatically, as if by magic - potentially with a hint that there is definitely "magic" involved, i.e. perhaps what's happening automatically is not deterministic or a little dodgy (a hack), or is is in some way cool/extraordinary i.e. table names being pluralized automagically from their associated entity class names in an ORM, which when I first saw it done many years ago was "magic" by comparison to having to specify the pluralized names by hand.

Is this really a negative term suggesting that somethings not automatic at all? Is my whole life a lie? (Don't answer the second one ;o)
posted @ Tuesday, November 27, 2007 9:01:55 PM (New Zealand Daylight Time, UTC+13:00)    Comments [2] | Trackback |
stump
I’ve seen a few posts flying round between Ivan (1,2) and Ayende (1) re: meta programming in C# v.next and the implications of it being a statically typed / pre-compiled language...

It’s an interesting thought, but I can’t help wondering if implementation of a rich meta-programming environment in C# - allowing changes at both a class and instance level at run-time - wouldn’t go against the original spirit of the language itself, for me at least I’d be looking for a different language if I yearned for meta programming on a daily basis... one that was built from the ground up with my desires in mind.  Take a moment to consider if C# had been built with meta-programming in mind from the outset, would we have bothered with declarative attributes?... ruby seems to get on fine without them (well at least until you try to integrate ruby with Java or .Net libraries)... and what about interfaces, what’s the point of them?

Language spirit is an interesting thing – I don’t think it’s something intangible (this is science after all), but often it’s something that’s difficult to put into words, because it’s a feeling coming up from a rapid and subconscious judgement call as you work with a language (ah la Blink) – it’s also something that’s difficult to appreciate until you start sitting down and thinking about writing a programming language of your own (what you haven’t? For shame!)... and it builds an immediate appreciation for languages like C# and ruby and there founders – there are lot of difficult decisions, compromises and reasonable defaults that need to be decided on – and a massive amount of jiggling to make sure it all fits well together – so that you can finally identify the essence of the language – and worst of all you’re not just having to satisfy your internal subconscious judgement calls, but a large audience in the development community, so that your language will be adopted by people because it feels "right" to them.

I still gravitate towards programming language pragmatics as a good book for examining the spirit of languages throughout the years and guises – it's definitely a book computer science student’s should all be armed with on their first year, though I doubt many will be interested in the nuances of Fortran today.

Now, following up on that – I’d like to contrast meta programming with functional programming... are we in need of meta programming as we move towards a more functional approach by necessity (to reduce the overall complexity of software, and take better advantage of existing/emerging hardware by working at a higher level of abstraction, allowing for judgment to be made on our behalf i.e. about parallelization) and what makes more sense for a language like C#?

Personally I see C# moving more and more towards providing a pleasant bridge language between the imperative world and the purely functional word (weighed in favour of the imperative world, where as F# is weighed in favour of the functional world) ... and as such it makes more sense to me at least to draw inspiration from that domain, then dynamic languages and meta programming... just my opinion of course. 

Given the time frames between C# versions – IronRuby should be mature enough by the time c# v.net arrives that it should be a moot concern, and IronPython is already pretty capable in the meta programming stakes as well, if you can hack the whitespace sensitivity.

Funnily enough (and this a bold claim I know :) – but I think the pattern matching support and associated features in F# would prove far more valuable tools for solving many of my day to day problems in C# than meta programming would be, when I take a subjective look at the code I write and the goals it’s generally trying to achieve combined with the existing features and practices I’ve already embraced in C# (IoC/DI) it looks to "click" together in a much more cohesive manor.

Thoughts?
posted @ Tuesday, November 27, 2007 8:01:50 PM (New Zealand Daylight Time, UTC+13:00)    Comments [0] | Trackback |
 Tuesday, November 27, 2007
Just a quick note that the Architecture chat that was scheduled for this thursday is going to be postponed until Next Thursday (December 6th) because I'm unavailable this week.

I'll post about it and email the dot.net.nz user group (for you non-subscribing philistines :) next week to remind you all.

See you all next week!

posted @ Tuesday, November 27, 2007 9:15:32 AM (New Zealand Daylight Time, UTC+13:00)    Comments [0] | Trackback |
 Thursday, November 22, 2007
I'm not going to be around Thursday next week to host the architecture chat...

There are a couple of options:
  • The show goes on as usual, and someone else can flick me a brief summary.
  • We reschedule for another day (Wednesday or Friday)
  • Have it the following Thursday (December 6)
Let me know what everyones preferences are...

Chez,

 - Alex

posted @ Wednesday, November 21, 2007 7:03:28 PM (New Zealand Daylight Time, UTC+13:00)    Comments [0] | Trackback |
 Tuesday, November 20, 2007


For those that are interested, there is an Enterprise Architect Symposium being held in Auckland and Wellington at the end of this month (Thursday 29th November in Auckland, and Friday 30th November in Wellington) - click on the image or link above to see a schedule or to register interest.

There are some interesting nuggets there for an architect/analyst, especially around model driven architecture/generation and UI/UX prototyping - with people presenting from Sparx Systems in Australia (the company which develops Enterprise Architect), Catch Limited and a number of business in New Zealand including the North Shore City Council and IAG.

posted @ Monday, November 19, 2007 7:44:35 PM (New Zealand Daylight Time, UTC+13:00)    Comments [0] | Trackback |
I've had a few people trying to use the replacement New/Edit list form hack I posted a week or two ago, and struggling to get the correct set of fields to display so I've written a couple of followup wiki entries:
Hopefully these will prove useful for anyone trying to make use of these hacks, and provide enough hints to implement something functional with the code snippets.




posted @ Monday, November 19, 2007 7:36:08 PM (New Zealand Daylight Time, UTC+13:00)    Comments [0] | Trackback |
 Sunday, November 18, 2007

A good turnout this week, with I believe 8 or so attendee's, and some great discussions.

So let's get into it...

First off while everyone was arriving Keith talked about his recent experiences with F#, including the implementation of the classic TDD "bowling game" exercise - which he's been blogging about lately, I myself have bitten by the F# bug and have been grappling with getting my head around the concepts in the language this weekend - it's a lot of fun, especially pattern matching and pulling apart the type system - but I've got a few more "ah hah" moments to go through before I've grokked it I think... Considering this language is going to be mainstreamed into the VisualStudio.Net product, and it's suitability for building parsers (among other things) I definitely think this is a skill worth adding to the toolbox.

From F# Keith then talked about his tangent into non-Von Neumann programming languages, and in particular Function-level programming, which works at a higher level then functional languages, suited to working with array-level information i.e. matrices - allowing for variable-free development (Tacit programming) it lets you do some pretty amazing things.

The function-level language that Keith took a look at was "J" (an APL-like language) which is cryptic - just like APL (at least to the uninitiated) but incredibly powerful i.e. a tacit implementation of the quicksort algorithm looks like this:

quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)

Yes, no variables, and one line of code! Compared to the C# equivalent which is normally 12 to 20 lines long, depending on braces etc.

Keith highlighted some good points - in that it actually becomes very readable once you understand how the language is put together, and it certainly shouldn't be discounted before your attempted to understand just what it is your discounting - I guess the message here is don't be a blub programmer.

I actually wonder wether working at this higher level actually makes the barrier of understanding what's going on lower in many cases - for instance, no variables = no mental state you have to keep in your head as you look at the code... I suspect long-term it would probably take less time to understand what this one line of code is doing, then reading through 20 to 30 lines of C# code, with variables, recursions/loops state and scope - especially with a set of unit tests to back it up, providing the specification and aiding in understanding what's expected/happening in your snippet of J code.

And of course, function-level programming is well suited to parallelization and optimization, more so then value-level or functional languages - a popular topic among the group.

After that a little discussion was had around SSIS, ETL tools etc. - largely caused by a protagonist (who shall remain nameless ;o) stirring up some trouble in the dot.net.nz Sql mailing list this week - the net effect is that there are largely disparate views between many of the senior DBA/Dev community at the coal face vs. Microsoft, marketing etc. To quote the message:

 "SSIS is a dog, great for BA's, but otherwise is always seems to fall short!".

Everyone basically agreed with this statement - SSIS just doesn't provide a good experience for developers and admins, take a look at Ayende's list on his wiki if you want a bit of a (depressing) laugh at the common pain points for developers.

As much as Microsoft employees reiterate that SSIS "is not a dog" - the reality is drawing pretty pictures with a sub-par UI is not productive for a developer, and the end results are notoriously brittle and hard to collaborate with other developers on.

On the flip side, we discussed alternatives i.e. cutting your own code, windows services, emerging tools like Rhino ETL - which a few of us like, but just can't justify dropping into a clients infrastructure at this point because it's a bit of a unknown quantity and quite immature - a bitter pill for a Microsoft-only organisation to swallow, because it's not necessarily mort-friendly at this stage.

After that we had the discussion about the IKVM.Net, boojay and grasshopper java <-> .net technologies - there still doesn't seem to be a silver bullet here for solving the problems of developing in .Net with the BCL etc. and then having it just "work" in the JVM on a Linux virtual machine, suitable for dropping into say the Amazon elastic cloud (EC2) - the more reasonable approach seems to be developing in java and then targeting either .Net or the native JVM, or developing in vanilla C, on a side note  I spent some time evangelizing about the boo language, and more importantly it's great extensible parser/compiler experience which makes it so very easy to write template engines and DSL's with it.  I'm still not 100% sure why mono doesn't work well in this case, but by experience a few have had a lot of trouble getting it work properly.

A short warning and Rant was had about Flash 8 (Action Script 2) by Peter - believe it or not, it doesn't have native support for 64 bit integers ... I haven't got time to verify it, but I'm assuming it's probably because it represents all numbers as double-precision floating point values. Grim tidings!

Following that we had a discussion around Framework development - this is a topic that's cropped up a number of times, so I won’t go too heavily into it... but basically it focused around a few discussion points:

  • Building applications with re-use in mind, and in fact building frameworks/factories for producing the application i.e. spend 80% or more of your time building the framework, and 20% of your time implementing the project with the framework, with the view of reusing/re-purposing the framework "next time".
  • It was argued that building frameworks is often YAGNI.
  • Why are parts of software you’re developing not naturally reusable?
    • Largely because development practices aren't focusing on composability and enforcing the principle of single responsibility.
    • Test driven design encourages Composability.
    • Without an IoC container it may be a little challenging at times.
  • Frameworks often require additional skills to maintain.
    • Is there a risk in letting Junior/Intermediate resource make changes?
    • Does the difficulty in finding/retaining senior resource make frameworks risky?

Lastly, we touched on other subjects - but my memory is a little hazy on the details:

  • The challenges in Porting data binding from WinForms to WPF when upgrading an application.
  • Brief thoughts on the features in Lightspeed 1.1, I like the aggregate-level validation support - something I forgot to mention was that the source code is available with the enterprise edition, which is great news - and that Ivan Towlson has joined the Mindscape team, you can see his first blog post here.
  • The Xero revenue announcement - a lot of us have either worked / started startups in the past, or are in still in the process of "starting up" - so it hardly came as a surprise that progress is slow... I think Nic Wise had it about right in this post - this led onto a discussion about the nature of the banking market, competing products, white boxing etc.
  • The fact that expression web is pretty sweet, and that there is still a load of html-only work out there.
At any rate, see everyone in 2 weeks time (29th of this month) - and thanks all for coming along, it's encouraging to see the numbers climbing back up after the Alex James exodus (btw, he has an msdn blog now, for anyone who missed the announcement).

 

posted @ Sunday, November 18, 2007 1:51:47 AM (New Zealand Daylight Time, UTC+13:00)    Comments [0] | Trackback |
 Wednesday, November 14, 2007
Yep, that time again, the 20th Architecture chat will be held this thursday, 11:30am at the Sylvia Park in Auckland (at Garrisons), all are welcome to come along.

Some topics (off the top of my head) this week include:
  • Java & .Net (didn't make it in last week)
    • The IKVM project (Java VM implemented in .Net)
  • ORM Love
    • NHibernate 2.0 features/maturation (and yes, it looks like the Castle trunk will be moving to it, hurray!)
    • Lightspeed 1.1 has been released.
    • Experiences of writing a Linq to query parser.
  • VS2008 very close
    • But ReSharper for C# 3.0 a while off.
    • Tempted by TeamSystem just to get the in-line "annotate" functionality.
And if anyone else has suggestions, feel free to throw me a comment/email etc. - obviously a bit topic light at the moment.

See you all Thursday!

posted @ Tuesday, November 13, 2007 6:54:18 PM (New Zealand Daylight Time, UTC+13:00)    Comments [0] | Trackback |
Search
FeedCount

Tags...
Who am I?
Alex Henderson
Alex Henderson
Auckland, New Zealand
Managing Director at Dev|Defined Limited

"Self Confessed Coding Junky for 15 years"
View Alex Henderson's profile on LinkedIn
 
Mobile: +64-21-402-969
Email: bittercoder 'at' gmail 'dot' com
MSN: bittercoder_nz@hotmail
Skype: alex.devdefined
Navigation