I am working through the famous CTM book, which looks like it could be like SICP for grownups.
CTM uses a language and platform called Mozart/Oz, which is freely downloadable and easy to get started with.
The development environment includes an Emacs-based REPL. It’s very easy to get started.
15 minutes after installing the program, I was able to code up the classic tail-recursive factorial:
declare
fun {Fact N}
fun {FactIter N Acc}
if N == 0 then
Acc
else
{FactIter N-1 Acc*N}
end
end in {FactIter N 1}
end
{Browse {Fact 23}}
The first part defines our factorial function, and the second evaluates 23! and displays the result in the browser, which will be familiar to anyone who use has used Common Lisp.
(Yes, Oz has arbitary-precision integer arithmetic built in, like any sane modern programming language. Yes, Oz is apparently lexically scoped.)
All in all, it looks like the CTM book should be quite enjoyable. I’ve heard it’s readable and its coverage of different programming paradigms — object-oriented, concurrent, logic, functional, imperative, constraint-based, declarative — is nearly comprehensive.
Let the holiday language snobbery commence!
What’s good, peoples? It’s been a while since I rapped at ya.
Because of my job, I’ve been learning VB.NET and the .NET framework.
I have yet to find anything really retarded. These are some notes mainly for my own purposes.
- And and Or still don’t shortcircuit. You have to use AndAlso and OrElse. Lame!
- Boxing and unboxing (converting between a primitive type and an object) can definitely affect performance if called many times. This isn’t surprising, but it bears remembering and repeating. Consider the following code snippet:
Option Strict On
Module BoxingTest
Public Sub NoBoxing(ByVal i As Integer)
If i = 5 Then
Console.WriteLine("omg!")
End If
End Sub
Public Sub DoBoxing(ByVal i As Object)
If CType(i, Integer) = 5 Then
Console.WriteLine("omg!")
End If
End Sub
Sub Main()
Dim n As Integer = 300000000
Console.WriteLine(Now)
For i As Integer = 1 To n
NoBoxing(i)
Next
Console.WriteLine(Now)
Console.WriteLine(Now)
For i As Integer = 1 To n
DoBoxing(i)
Next
Console.WriteLine(Now)
End Sub
End Module
On my machine, the boxing function takes about 10x longer than the one that’s directly with value types. Something to keep in mind if you’re working on a performance-sensitive application with tight inner loops.
- Generics and the other collections are nice. Generics seem to be really fast, faster than normal collections?
- The specialty collections, such as BitArray are efficient and nice (I can twiddle 10 million bits in under a second on a 2.8 Ghz machine).
- Visual Basic 2005 is C# in clown shoes.