
Virgil: a statically-typed language balancing functional and OO features - protomyth
http://lambda-the-ultimate.org/node/4716
======
octo_t
It seems very similar to Scala in several ways (var, def etc), but the way to
declare immutable fields is different from Scala

Scala

    
    
      val x:Int = 10 // Immutable
      var x:Int = 10 // Mutable
      def x:Int = 10 // function
    

Virgil

    
    
      def x:Int = 10 // Immutable + function
      var x:Int = 10 // Mutable
    

I think I prefer Virgils method, it feels much purer to me, in keeping with
functions as first class members, but I'm not sure how it would handle mutable
datastructures.

~~~
ismarc
It's actually more complex than that. You can use val and def in the same
places. The difference is when it is evaluated. val has the right hand side
evaluated immediately (such as, if it's a class member, it will be evaluated
when the class is constructed). def has the right hand side evaluated every
time it is referenced. So, val x = 5+5 would evaluate 5+5 and assign to x. def
x = 5+5 would set x to a function that takes no parameters and returns an int,
but if you had, say x + x, that function would be called twice, resulting in a
value of 20.

This difference is stark when you look at what it's doing, but allows for some
interesting uses when combined with lazy vals. We use it pretty extensively in
our configuration loader (using twitter-eval) that allows us to do per-value
overrides of configuration files by using lazy vals assigned to defs and then
using the defs in the application (of all the performance bottlenecks we have,
the possibly optimized out function call generated for the defs is
negligible). The end result is that you can derive values from configuration
settings prior to the configuration finishing being loaded. This means we
don't have to care what order the configuration files are loaded in (they're
separated by what they're configuring, with many shared between applications).

------
kodablah
Link to Google project page: <http://code.google.com/p/virgil/>

------
GIFtheory
Been there, done that: <http://caml.inria.fr/ocaml/>

~~~
mahmud
CLOS goes back to 1986 :-)

<http://common-lisp.net/>

~~~
_mhr_
Except that Lisp is dynamic, and OCaml is static.

~~~
mahmud
I overlooked that minor requirement. Sorry.

------
trungonnews
Doesn't Scala do this already?

------
MostAwesomeDude
I'm a little annoyed at the name, because of Virgil, the Java-like language
for embedded programming: <http://compilers.cs.ucla.edu/virgil/>

~~~
munificent
That's the same language, actually. Well, maybe a previous incarnation of it.
But both are Ben Titzer's babies either way.

------
weix
creating a special language is not hard, but it's really hard to make ppl feel
exciting to use it.

~~~
ritchiea
Terse comments aren't hard, just bash the OP without offering constructive
criticism.

The next programming language to become popular is going to provide some
substantial gain in either productivity or performance. It'd be nice to see an
argument for or against Virgil on that front.

