Archive

Posts Tagged ‘Programming Languages’

From nand to tetris

This looks like a great course+book: The elements of computing systems.

Rob Pike on concurrency

September 18, 2007 Leave a comment

Watch this great Google talk with Rob Pike. He talks about concurrent processes and message passing in the context of Newsqueak – a programming language that he wrote 20 years ago. What he describes is very similar to the Erlang programming model except that channels are first class citizens.

Exceptions – checked or not?

The Java Posse #127 podcast talks about the possibility of removing checked exceptions from the Java language. The JavaPosse folks seem to universally like them. No one knew what Scala did with respect to checked exceptions. Turns out that it does not have them!

3.3. Why are there no throws annotations on methods, unlike in Java?

Compile-time checking of exceptions sounds good in theory, but in practice has not worked well. Programmers tend to write catch clauses that catch too many exceptions, thus swallowing exceptions and decreasing reliability.

If you haven’t seen the Scala language yet, check Martin Odersky’s Google Techtalk.

I tend to avoid checked exceptions. This is the way that the Spring folks have gone and – of course – Anders Hejlsberg. Anders did a great job designing the C# language.

I’m still digging into an article on dev2dev which promotes checked exceptions and points out that that the times they get annoying is where the Java API was poorly designed. For me this still points that checked exceptions are a experimental language feature perhaps best left out of industry programming languages for now.

Typecase for Java

I was just reading Stephen Colebourne’s blog. He is the other of Joda-Time which looks to be a useful replacement for java.util.Calendar and java.util.DateTime… but I digress.

I was digging into the blog and found an entry about adding autocasts to Java by reusing the instanceof “syntax”. I quite like the proposed “syntax” (which is really nothing, the compiler just detects were you are using instanceof already). The consensus in the blog comments is that there’s a problem with the syntax because the variable can be assigned to. However that can be fixed by mearly disallowing assignment to the variable inside the instanceof block. All that said, it is much cleaner to use a special syntax like typecase to do this which introduces a variable binding. In this way, the expression need not just be a variables but could be a full expression – perhaps a method call e.g. the problem is shown by “if (fred.getBar() instanceof FooBar) {“.

Of course, this has been done before with the typecase expression like in Modula-3. Modula-3 is a very cool but dead language, a prerunner to Java with a more Modula/Pascal syntax. Check out the language spec for typecase. Unfortunately the original Modula-3 site, SRC, is down, perhaps try SRC later or Google’s cache of the original typecase page.

Programming Language Inventor or Serial Killer?

April 23, 2006 Leave a comment
Categories: Programming Tags: , , ,

When can I get a fix of language goodness?

February 1, 2006 Leave a comment

After reading a recent paper by Erik Meijer and Peter Drayton I am convinced that I’ll be programming in C# or one of it’s descendents sooner rather than later in order to get my fix of language goodness.

The paper is “Static Typing Where Possible, Dynamic Typing When Needed: The End of the Cold War Between Programming Languages“. I think of this as “How to have your cake and eat it too” for the programming language community :). I really loved the paper. My eyes glazed over at one or two type equations but perhaps I’ll get back to those :). It’s a laundry list of cool language features most of which I would want in my favorite language and others that I’d like to tweak a little bit probably.

I loved the rant on XML: “XML is a prime example of retarded innovation”. I really hate how people love XML. NoXML. Ok? They even mention that it’d be better to use something akin to CORBA style IDL for interplanguage communication between the CLR and JVM worlds using a binary wire format. But let’s not leave out scripting languages like Perl, Python and Ruby. Perhaps something like Joe Armstrong’s Universal Binary Format – UDF – is worth considering in this space. Hessian is another reasonable looking solution to this (even if it does seem to fall on the “Java rulez” side of things).

… more to come on this post

Better *is* better and worse is worse

January 10, 2006 Leave a comment

I’ve read the original Worse Is Better article by Richard Gabriel a couple of times now. I discovered it via my interest in programming languages (Lisp in this case).

Jim Waldo reminds us that Better really is *better* in Artima article Worse is worse.

Ruby on .NET?

December 7, 2005 Leave a comment

I appears that researchers at QUT‘s Programming Languages and Systems group are working on an implementation of Ruby for .NET. The “secret” is reveal on this page. The work is support by Microsoft Research. Davis Thomas also mentions it in an article about the emergence of agile languages. There seem to be no other sources of information at present.

It turns out that John Gough organised a birds of a feather for Implementing Dynamic Languages on the .NET CLR at the Dynamic Languages Symposium back in October (2005).

QUT is my old university and John Gough my was my favorite lecturer. I studied compiler construction under John and later wrote a small compiler under his supervision in C# targetting .NET (and using his book Compiling for the .NET CLR as a resource). It’s a small world. I’m working in the UK at the moment. The guy who sits next to me at work comes from South Africa. He studied under Pat Terry at Rhodes University. Pat is also a compiler guy. John and him were involved on the Modula-2 language commitee. Turn’s out that I used Pat’s Coco/R (C# version) on that project.

Java…Ruby…Groovy

http://onestepback.org/articles/groovy/groovyspeed.html

If you read the entire article above please note that closures have *indefinite* extent , not *dynamic* extent.

Continuations for curmudgeons

April 24, 2005 Leave a comment

Sam Ruby has a much praised blog entry entitled “Continuations for Curmudgeons“.

I didn’t like the tone of the article which seem to treat the C programmers as some kind of dinasaur with no interest in other languages (or language features).

There was no mention of Scheme. When learning about continuations I think it’s best to learn from the source. That source appears to be the Scheme programming language. R5RS includes call-with-current-continuation function usually shortened to call/cc. A really good introduction to Scheme with coverage of continuations for non-trivial applications is contained in Dorai Sitaram’s Teach Yourself Scheme in Fixnum Days (TYSiFD).

Sam seems to have some confusion about continuations and there relationship to closures, iterators, generators and coroutines. Just because a language has a “yield” keyword doesn’t mean it has first class continuations. Yield is usually used for generators. One of the highlights of TYSiFD is implementing coroutines with continuations.

Ruby supports first class continuations. The callcc method is available from the Kernel class. I played around with the code from the Ruby documentation of the Continuation class. You really don’t need call/cc for the contrived example there:

original_guys = ["Freddie", "Herbie", "Ron", "Max", "Ringo"]

puts "method 1: (first-class) continuation"
guys = original_guys.clone
callcc{|$k|}
puts(message = guys.shift)
$k.call unless message =~ /^R/;

puts
puts "method 2: continuation with different way of setting global"
guys = original_guys.clone
callcc{|k| $k = k}
puts (message = guys.shift)
$k.call unless message =~ /^R/;

puts
puts "method 3: just a loop"
guys = original_guys.clone
loop {
  message = guys.shift
  puts message
  if (message =~ /^R/)
    break
  end
}

puts
puts "method 4: (tail) recursion using methods/functions"
puts "          Ugly - needs guys to be global variable."
$guys = original_guys.clone
def myloop
  message = $guys.shift
  puts message
  unless message =~ /^R/
    myloop
  end
end
myloop

puts
puts "method 5: (tail) recursion using blocks"
guys = original_guys.clone
myloop = Proc.new{
  message = guys.shift
  puts message
  unless message =~ /^R/
    myloop.call
  end
}
myloop.call

puts
puts "method 6: using each and catch/raise"
guys = original_guys.clone
catch (:early_exit) {
  guys.each {|item|
    puts item
    if item =~ /^R/
      throw :early_exit
    end
  }
}
Follow

Get every new post delivered to your Inbox.