The Fan Programming Language

bearophile bearophileHUGS at lycos.com
Thu Jun 12 11:45:34 PDT 2008


Paul D. Anderson:
> From a blog highlighted on java.net --
> http://www.jroller.com/scolebourne/entry/the_fan_language_is_it

There are lot of new languages coming up now, but they are quite similar, because most of them run on just two virtual machines, sharing the same problems, garbage collector, etc.

I have seen the following in another language (I don't remember what one, maybe Scala, and I think it's an interesting thing. Boo language too allows something similar), I think this may be useful for D too:

>Dynamic coding
Fan encourages more dynamic coding styles. If you use the dot to call a method (as per normal Java) then the method is compile time checked. If you use the arrow operator, then the method is called by reflection. Further, if the method called by reflection doesn't exist, then this error can be caught (the 'trap' method) which is like the 'method missing' concepts in other languages and enables powerful DSLs to be written.
  obj.doStuff()   // compile-time checked call, as per Java
  obj->doStuff()   // runtime reflection call

This can also be thought of as enabling duck typing.<


Regarding the "each" method and the like, I think it may be useful, but Python list/gen comps are simpler and nicer looking, while C# linq is more powerful:

>
list.each |Str val, Int index| {
  echo("$index = $val")
 }
<


Regarding semicolons:
>Lines do not need a semicolon at the end. A newline will suffice. 

Groovy and Scala too don't require them, you can see some groovy examples here:
http://shootout.alioth.debian.org/gp4/groovy.php
For example:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=nbody&lang=groovy&id=0
You can see that semicolons are an useless form of redundancy.

Bye,
bearophile



More information about the Digitalmars-d mailing list