Showing posts from July, 2012

Why should we do code katas

"When the guidance comes from someone who is a genuine Master programmer, then it’s possible he/she is trying to show us something we don’t even know we don’t know. How can we find out, other than by exploring the suggested path?" Why should we do code katas.

Checking arguments for null in Nemerle: revisited

It's turned out that Nemerle has full fledged design-by-contract feature! Let's see how the code from the previous post can be rewritten: It's really both elegant and powerful compared to hand-written "if (arg == null) throw new ArgumentNullException(...)" or using the Microsoft contracts library. Contracts may be bond right to arguments themselves: Which causes: "Nemerle.Core.AssertionException: assertion ``name != null && name.Length > 0'' failed in file Main.n, line 107: The ``Requires'' contract of parameter `name' ha s been violated." Amazing! :) However, if checking for null value is what's only needed, there's one more option: the NotNull macro attribute:

Checking arguments for null in Nemerle

An impossible thing in languages like C# and F#:

Nemerle. Finally.

It took 5 seconds compiled in debug. What I'm extremely interested in the moment that Nemerle macros. However, Visual Studio support seems as poor as for F# :( No even "find usages" or "rename"... Uh...

Update 21.06.15, new code:

Result in Release configuration - 1.45 seconds.

Binary trees in F#: functional polymorphism

That's it. Having no class hierarchy with its usual noisy methods overriding and so on, we've got polymorphism - succinct and highly readable. Wow!