Sunday, September 07, 2008

Enter Lyra

Stringed instruments, get it?Let me state this loud and clear: I'm proud of Freya and the Freya compiler. I think my goals, or almost all of them, has been achieved: there's a working implementation of a powerful general programming language, running on a powerful interesting framework. What's more: I have great plans for Freya, including the addition of some interesting features not found in similar languages.
There's a catch, however: Freya is a complex language, requiring a complex implementation. And I'm virtually alone, by my own decision, developing the language, the compiler and a simple IDE for testing... and that shows. For instance: almost all relevant features from C# 2.0 has already been included and implemented in Freya, and we already have some features from C# 3.0, as extension methods, and object and collection initializers. Nevertheless, there are some equally important features still missing, such as anonymous methods and complex type inference for lambdas (type inference for generic method calls, however, is already working). And the worst part is that we'll need to rewrite the type attribution from the compiler in order to accommodate the powerful inference engine required for these enhancements.

So enter Lyra (pronounced as lie-rah). Lyra is a fully developed and independent programming language derived from Freya. Its syntax is almost identical to Freya's, but we have introduced some simplifications, in order to make it easier to understand and implement. These are some of the differences:
  1. Implementation in Lyra takes place along with declaration. No more separated implementation for sections, for including executable content.
  2. Property and event implementations have changed accordingly. The new implementation syntax is very compact and easy to understand, and uses four new special "keywords": get:, set:, add: and remove:. Semicolons are an integral part of the corresponding tokens, and they avoid both those dirty contextual keywords and disturbing valid identifiers in existing code.
  3. Interface delegation is supported, but it has moved to the implementing member declaration.
  4. Constructor calls now requires parentheses, except when followed by a list initializer.
  5. In compensation, constructor calls can now start an object path.
  6. Local variable declarations have been moved to the statement list, as declaration statements. This trick avoids some syntactic anomalies while defining properties and events.
Let's see an example showing how to write properties in Lyra:
property Items[Index: Integer]: Boolean;
get:
// Compound assignments are not expressions.
Index -= Min;
// then is optional before a keyword.
if Index < 0 or Index > High
raise new ArgumentException("Index");
// Symbolic and literal operators are both allowed.
Result := (Bits[Index div 32] &
(1 << (Index mod 32))) <> 0
set:
Index -= Min;
if Index < 0 or Index > High
raise new ArgumentException("Index");
if Value then
Bits[Index div 32] |= 1 << (Index mod 32)
else
Bits[Index div 32] &= ~(1 << (Index mod 32))
end
Of course, we can still use most of the Freya tricks, such as expression-based methods and properties (and operators, and iterators), the abbreviated syntax for constructor chains, implicitly implemented properties (I think Freya/Lyra's trick is better than C#'s). Assertions are fully supported, even when declared in an interface type. Numeric types are still implicitly extended with static members from the Math class. Lyra, in other words, is as powerful as Freya... but probably more elegant, too.

In the next months, all our research and implementation effort will concentrate on Lyra. These are some of our planned tasks:
  • Anonymous methods and lambdas are still missing. Probably, I'll implement only one of the syntactic varieties, but I still have some troubles with the syntax: C#'s lambdas, when implemented verbatim, don't make a valid LALR(1) grammar.
  • I still believe in the usefulness of access sentinels: wrapping code that would be inserted by the compiler around methods that access some class members. This is a safe form of Aspect Oriented Programming (and no, properties don't do the same trick!)
  • Lyra will feature mixins declared with interfaces. You'll be able to add common implementation methods to interfaces, as in this example:
IStack = interface[X]
property Count: Integer; readonly;
method Push(Value: X);
method Pop: X;

// These are the new "mixins":

property IsEmpty: Boolean =>
Count = 0;

method Push(Values: IEnumerable[X]);
begin
for v in Values do Push(v)
end

method Clear;
begin
while Count > 0 do Pop
end
end
  • It's some kind of funny that extension methods (that's what mixins are, at the end of the day), access sentinels and assertions are related by their implementations. For instance, pre and postconditions are implemented in Freya as extension methods. Class invariants' implementation, on the other hand, uses a similar approach as data sentinels to avoid firing in internal call boundaries.
  • I must acknowledge that most assertion implementations I know, beyond Eiffel, are shallow, incomplete or plainly wrong. Most of them don't handle inheritance and don't support assertion on interface types. Assertions in Freya addressed these problems, and Lyra will continue enhancing assertions support.
  • I have to complete the "Intellisense" compiler. This is a second (lighter) compiler that must take care of class navigation and code completion. I can't use the main compiler: it performs some code generation tasks very early in the compiling process.
  • Of course, Visual Studio integration is still an important item in the shopping list, just as CodeDOM support is.
  • Compiling must be moved to an isolated application domain, in order to avoid problems when unloading compiled assemblies.
  • Dynamic methods and "dynamic programming" support, you said? Huh, I hate the very concept! But you were kidding, weren't you?
Let me insist, anyway: Freya development hasn't been abandoned. As soon as Lyra moves to the next level, we'll update Freya in order to keep the pace.

Labels: ,

12 Comments:

At 12:22 PM, Anonymous Anonymous said...

Hi Ian, very interesting! Good luck! What about your Commanet postings? Best, Dave.

 
At 10:33 PM, Blogger Yeradis P. Barbosa Marrero said...

Hello and good day to you Ian Marteens

First all, sorry by my english....
Second all, congratulations for your work


I´m posting this because i think your Freya Programming Language is very interesting to me, thats why my post

After a while browsing your Freya web i have been unable to find the download links to begin testing this language

So i have two question for you
first:

Where is the Freya Compiler? I mean the download link

second:

Where is the IDE you had built for testing the language ) once again ;) i mean the download link

Thanks to you....

mmmh....
One more :s

Exist a Freya manifest in spanish and all related information?

Perhaps as I have seen in this post ("Enter Lyra") Freya is no longer available but maybe in return Lyra is what i´m a looking for because is the most recent version of MPL ("Marteens Programming Language" ;-) )

Maybe
Once again sorry by my english

With no more....
Bye bye

 
At 5:11 PM, Blogger Ian Marteens said...

Hi, Yeradis:

Use this link to download an installer for Arpeggio (a small testbed for Lyra):

http://www.marteens.com/arpeggio/setup.zip

This release contains the compiler, a simple IDE, full help and some projects. I'm preparing a full release with sources. I'm gonna start an open-source project, since I can't spend more time with this project right now.

Once again sorry by my english

No te preocupes. Además hablo bien el español. Te he contestado en inglés por si a alguien más le interesaba la descarga. Más adelante liberaré el código fuente.

Un saludo...

 
At 7:05 PM, Blogger Yeradis P. Barbosa Marrero said...

Hello and good day Ian Marteens

Thank you very much for your response and the download link

I Will wait to the release of the project, meanwhile this is enough for me to test it and learn it.

Muchas gracias de verdad que si ;)

Sin mas...
Me despido.

 
At 3:29 PM, Anonymous Stefan said...

Hi,

I've been watching your blog for a while and found your ideas very compelling.

I would like to encourage you to start an open source project for a next generation Pascal/Delphi.NET language.

CodeGear has abandoned .NET by licensing Oxygene - which is not bad, but an incompatible closed source language has a very uncertain future. If we want to keep the spirit of Pascal/Delphi alive we finally need a modern open source approach besides the old-fashioned FreePascal which is able to gain wider audience and community support. I belive that Lyra/Freya could fill this gap and I'd love to contribute once this is open source.

Excellent work!

-Stefan

 
At 9:42 AM, Anonymous Anonymous said...

Very promising.
Just one remark; unless you want to remain as close as possible to Pascal, why not drop the 'begin...end' for blocks?
Modula-2 did it, Eiffel did it and I think it feels better.
Oh, and I don't like the need for statement separators (;) in languages like Pascal, C... neither.
But that's just my 2cent.
PS: Just for your interest: I am a professional Delphi programmer.

 
At 12:16 AM, Anonymous Rulx Narcisse said...

I am exited to hear about Lyra and Freya; it sounds like new to me.

I am looking for more infos.

 
At 11:29 PM, Anonymous Anonymous said...

Ian,

impresionante

 
At 4:59 AM, Blogger vu/34mp4 said...

辣妹走光正妹走光脫衣秀脫衣走光色情自慰自拍成人全裸打炮打手槍打飛機巨乳巨奶女優大奶性交性愛淫蕩淫慾淫亂淫婦淫妹淫叫淫水淫女情慾情色做愛限制級波霸口交18禁

 
At 6:08 PM, Anonymous Anonymous said...

lyra ha matado a freya?

 
At 3:41 AM, Anonymous Kell said...

Before you use a Lyra language, you first need to understand the Lyra model. This system contains a network of finite state machines and datapaths. This language requires only a single assignment in functions.

 
At 2:50 PM, Anonymous Anonymous said...

I think Freya should be listed here:
http://www.dotnetlanguages.net/DNL/Resources.aspx

 

Post a Comment

<< Home