"Language
42" is a computer language under development. We believe it has
potential to be quite revolutionary. Language 42 has six primary
goals: - Foster extreme code reuse
- Run much faster than C
- Compile to both software and hardware
- Run faster on reconfigurable computers
- Allow users to extend the language
- Support parallel programming
42 borrows heavily from C, Python, Verilog, and DataDraw.
It will run faster than plain-old-C for memory-intensive
applications, just like DataDraw based applications do today. The
language is designed with hardware-description features as well as
programming features, and even classes can be compiled into efficiently
executing hardware. Our hope is that even the compiler could run
faster on a reconfigurable FPGA-based computers than traditional
computers. 42 takes extensibility to the next level: there are
almost no language constructs which cannot be added by users as a
library. For example, support for classes is in a library, not
the core language. Parallel programming is supported in a
hardware-description style, where processes communicate through signals. Until
the initial compiler is completed, there wont be any user-manual for
42. However, the language reference documentation is being
developed in parallel with the compiler. To view the current
state of the project, sign-out the source code: svn co https://graillang.svn.sourceforge.net/svnroot/graillang/trunk l42 The langauge documentation can be found in the doc directory, which you can view on-line here. You can also view the example code. Extreme Code reuseThis example shows how 42 can reuse linked-list code: Class A Class B relationship A B linkedList The "relationship" declaration is syntactic sugar for an equivalent "reuse" declaration: reuse LinkedList Parent -> A Child -> BIn
short, it says to use package "LinkedList" as a template, even though
it is not declared with any special template syntax. Replace the
"Parent" class with "A", and the "Child" class with "B". The
result is that class A gets a "first" pointer to class B, and class B
gets a "next" pointer. 42's reuse
declaration allows multiple classes to be modified at the same time,
making simple constructs like traditional linked-lists very simple to
implement. The resulting code is as fast and simple as hand-coded C. In addition, the LinkedList
code spcified that we need to remove objects of type B from linked
lists on A when we destroy them. In general, users never have to
write destructors, or worry about dangling pointers, or live with a
speed hit due to garbage collection. Extending 42Users
can extend 42 in pretty much any way possible. The 42 compiler
uses a GLR-like parser which can be extended by the user at any time.
For example, to add a new operator "**", you could write
syntax orExpr: xorExpr '**' orExpr -> functionCall:[power, 1, 2]
This
tells 42 compiler that '**' should call the function "power" when it
sees the "**" operator. In general, extending 42 is done through
describing new syntax, and writing code to transform the parse tree
into equivalent code which does not rely on the new feature. The
final parse tree is in terms of a simple subset of 42, called Core 42,
which can trivially be translated into C, and which makes a good
hardware description language for behavioral synthesis tools.
|