Monday, May 25, 2009

LayerD SDK 0.5.3

I've updated the LayerD SDK with a new release that includes several bug fixes. It doesn't include new functionality from 0.5.2. It fixes an annoying bug that occurred the first time that you use a new assembly for .NET platform :-) .

Download the SDK on SourceForge: http://sourceforge.net/projects/layerd

LayerD SDK Release Alpha 0.5.3

This SDK version Alpha 0.5.3 includes the following components:

Quick start

To make programs on LayerD framework you must make the programs on one high level language (currently Meta D++, also there is a Java clon that is distributed separately). After that, you must compile Meta D++ source code using metadppc.exe compiler and the generated .zoe files with zoec.exe compiler. Check the instructions on Meta D++ Programmers Guide.

It’s recommended to read the Meta D++ programming guide for .NET programmers even if you don’t program for that platform because of generic concepts explained in this document.

There isn’t an IDE currently available. I use Notepad++ editor or Visual Studio and have custom macros that call compilers. You can use any text editor.

Note: There is plug-in for Visual Studio that implements a kind of “Intellisense”; it’s only a concept and don’t work on programs that have more than one file but it can be useful (on files with less than 1500 lines of code :-P ).

More information on: http://layerd.net, http://layerd.blogspot.com, http://sourceforge.net/projects/layerd.

Please don’t hesitate to contact me at alexis.ferreyra@yahoo.com for information or if you want to contribute with the project.

Compiler Usage and Hello World programs

Compiler Usage and hello world programs: http://layerd.wiki.sourceforge.net/compiler_usage

Debugging

Programs can be debugged using standard infrastructure of the target platform. For example, if you program for .NET you can use Visual Studio or SharpDevelop for debugging. If you develop for Java take into account that Zoe Code Generator for Java is Alpha version and don´t generate equivalence between Meta D++ source code and generated Java code, so it will be a bit more challenging but you can use any Java IDE to debug generated code, frequently visit LayerD’s website because this module will be updated frequently. /p>

To debug classfactorys (compile time functionality) you can use –wfd flag on zoec.exe compiler the compiler will wait until a compiler attaches to the compiler process before continue. So you can run the compilation with –wfd flag and attach to zoec.exe process from a debugger like Visual Studio (first set breakpoints on compile time source code).

Languages features implemented on this SDK

LayerD is a large, ambitious and little complex project so not all desired features of Meta D++, Zoe, and Zoe Code Generators are implemented. Currently these are the features included until now:

  • Main features of Zoe and Meta D++ languages to support standard object oriented programming like classes, interfaces, single inheritance, enumerations and statements.
  • Compilation of Classfactorys, standard and interactive.
  • Multiple compile times on Zoe compiler.
  • Interactive compilation for Meta D++ language.
  • Generation of .NET assemblies for desktop and mobile, .exe and .dll.
  • Generation of .class files for Java (using javac compiler)
  • Automated import of types for .NET platform but not including generic types, nulleables and attributes.
  • Automated import of types for Java platform but not including generic types or annotations.

Changes from 0.5.2 version

  • Know bug when first compiling a program for .NET fixed.
  • Bugs while merging nodes at compile time fixed.
  • Bugs about expressions not being captured for compile time execution fixed.
  • Several bugs on Java importer module fixed.
  • Several bugs on .NET and Java code generator fixed.

Documentation

LayerD SDK FAQ

Why is this SDK in mixed English / Spanish ?

Because I don't have time to maintain both English and Spanish SDK. So, I'm translating all to English. If you want to help me that will be great!!

There is a distribution for Linux ?

No, there isn't. It's perfectly possible to compile all modules in Linux but I don't have time to do that and I use Windows more than Linux. May be you can help me with this task.

Can be used to develop commercial applications ?

Yes, In fact it was used for at least two pretty big commercial projects (both on .NET). Please let me know if you use LayerD on a commercial project ! You don't have to pay me for that, this is a free and open source project. If you make money consider a donation :-)

Thanks for downloading LayerD SDK,
Be happy doing compile time programming :-)

Distribution date: May 25, 2009

Sunday, May 24, 2009

How to use LayerD compilers

Meta D++ compilation

To compile a Meta D++ program into a Zoe program use the "metadppc.exe" compiler:

C:\LayerD\bin\metadppc.exe helloworld.dpp

That will generate a file with the same name but with .zoe extension.

To compile a program composed of more than one file call the compiler for each file:

C:\LayerD\bin\metadppc.exe helloworld1.dpp

C:\LayerD\bin\metadppc.exe helloworld2.dpp

C:\LayerD\bin\metadppc.exe helloworld3.dpp

Take into account that this is possible because the program analysis and code generation is implemented in the Zoe compiler and not in the Meta D++ compiler.

Zoe Compilation

When you have the .zoe files of your program you must compile them with "zoec.exe" compiler. If the program is composed of one file:

c:\layerd\bin>zoec.exe HelloWorld.zoe

That will generate an .exe file for .NET platform that is the default platform and module type.

If the program is composed of more than one file:

c:\layerd\bin>zoec.exe HelloWorld_Source1.zoe HelloWorld_Source2.zoe –pn:HelloWorld

The parameter "-pn:HelloWorld" set the output filename for the generated module, this is required when more than one file is provided for compilation. If your program is composed of only one file and you don't provide the "-pn" parameter then the filename of the sourcefile will be used for the module name.

All steps together

As you need to run Meta D++ compiler and Zoe compiler to get the executable/library these are all the steps together:

For a program composed of one source file:

c:\layerd\bin>metadppc.exe HelloWorld.dpp

c:\layerd\bin>zoec.exe HelloWorld.zoe

For a program composed of more than one source file:

c:\layerd\bin>metadppc.exe HelloWorld_Source1.dpp

c:\layerd\bin>metadppc.exe HelloWorld_Source2.dpp

c:\layerd\bin>zoec.exe HelloWorld_Source1.zoe HelloWorld_Source2.zoe –pn:HelloWorld

Take into account that there will be more than one high level LayerD language (in addition to Meta D++), the Zoe compiler is always used in the same form.

Generation of Dynamic libraries (.dll)

To compile dynamic libraries use the parameter "-lib":

c:\layerd\bin>metadppc.exe HelloWorldLib.dpp

c:\layerd\bin>zoec.exe HelloWorldLib.zoe –lib


 

To compile a Compile Time extension

Compile the extension source code:

c:\layerd\bin>metadppc.exe MyClassfactory.dpp

c:\layerd\bin>zoec.exe MyClassfactory.zoe –ae

Extension Added: MyClassfactory

Not special step required for client code, compile as always:

c:\layerd\bin>metadppc.exe MyClassfactoryClient.dpp

c:\layerd\bin>zoec.exe MyClassfactoryClient.zoe


 

More information on the wiki:

http://layerd.wiki.sourceforge.net/compiler_usage

And on the command line help of the metadppc and zoec compilers.

LayerD Wiki

I've started the LayerD Wiki page here:

http://layerd.wiki.sourceforge.net/

If you know something about LayerD maybe you can contribute :-).

It's very small for now but I will be updating :-P.

Sunday, May 3, 2009

LayerD SDK 0.5.2 - Now you can do Java compile time programming :-)

I'm releasing a new SDK (here sourceforge) that contains reference guides and a Zoe Code Generator for Java language, so you can do compile time programming for Java :-). It's alpha code and do not support things like generics, annotations or non-static inner classes but you can generate a lot of code on compile time :-), and play with new semantic structures or RAD tools using interactive compilation.

Here the readme of the SDK:

LayerD SDK Release Alpha 0.5.2

This SDK version Alpha 0.5.2 includes the following components:

Hardware Requirements

Even when any PC that can run Windows will work properly these are recommended specs:
  • 512MB RAM
  • Processor: 1.5GHz AMD/INTEL
  • Hard disk space :-).
It’s not recommended to run LayerD compilers from network or pendrives because of temporal files created could degrade compilers performance.

Software Requirements

  • Windows 2000/2003/XP/Vista (not tested on Windows 95/98)
  • Microsoft .NET SDK 2.0 or greater.
  • Java SDK 1.4 or greater to generate Java programs. (not mandatory, only to use Java Code Generator).
  • Others SDK can be needed depending on target programs (for example .NET Compact Framework SDK for mobile applications).

Quick start

To make programs on LayerD framework you must make the programs on one high level language (currently Meta D++, also there is a Java clon that is distributed separately). After that, you must compile Meta D++ source code using metadppc.exe compiler and the generated .zoe files with zoec.exe compiler. Check the instructions on Meta D++ Programmers Guide.
It’s recommended to read the Meta D++ programming guide for .NET programmers even if you don’t program for that platform because of generic concepts explained in this document. There isn’t an IDE currently available. I use Notepad++ editor or Visual Studio and have custom macros that call compilers. You can use any text editor.
Note: There is plug-in for Visual Studio that implements a kind of “Intellisense”; it’s only a concept and don’t work on programs that have more than one file but it can be useful (on files with less than 1500 lines of code :-P ).
More information on: http://layerd.net, http://layerd.blogspot.com, http://sourceforge.net/projects/layerd.

Please don’t hesitate to contact me at mailto:alexis.ferreyra@yahoo.com for information or if you want to contribute with the project.

Debugging

Programs can be debugged using standard infrastructure of the target platform. For example, if you program for .NET you can use Visual Studio or SharpDevelop for debugging. If you develop for Java take into account that Zoe Code Generator for Java is Alpha version and don´t generate equivalence between Meta D++ source code and generated Java code, so it will be a bit more challenging but you can use any Java IDE to debug generated code, frequently visit LayerD’s website because this module will be updated frequently.

To debug classfactorys (compile time functionality) you can use –wfd flag on zoec.exe compiler the compiler will wait until a compiler attaches to the compiler process before continue. So you can run the compilation with –wfd flag and attach to zoec.exe process from a debugger like Visual Studio (first set breakpoints on compile time source code).

Languages features implemented on this SDK

LayerD is a large, ambitious and little complex project so not all desired features of Meta D++, Zoe, and Zoe Code Generators are implemented. Currently these are the features included until now:
  • Main features of Zoe and Meta D++ languages to support standard object oriented programming like classes, interfaces, single inheritance, enumerations and statements.
  • Compilation of Classfactorys, standard and interactive.
  • Multiple compile times on Zoe compiler.
  • Interactive compilation for Meta D++ language.
  • Generation of .NET assemblies for desktop and mobile, .exe and .dll.
  • Generation of .class files for Java (using javac compiler)
  • Automated import of types for .NET platform but not including generic types, nulleables and attributes.
  • Automated import of types for Java platform but not including generic types or annotations.

Languages features NOT IMPLEMENTED on this SDK

These are the desired features of languages and code generators not implemented in this SDK:
  • keyword modifier on classfactory members
  • setplatforms directive on classfactorys members
  • “hybrid” classfactorys
  • “auto instantiation” of classfactorys
  • calls blocking semantic on classfactorys (to warranty that all instance members of one classfactory will be executed on the same compile time or skipped to next compile time).
  • automatic re-composition of classfactorys
  • classfactorys that depends on other classfactorys currently installed on Zoe compiler
  • import of generics types and attributes/annotations on .NET and Java
  • homogenization of base types (for Java)
  • some kind of semantic checks are not currently implemented by Zoe compiler like requiring return instructions on all code paths, this checks are implemented by lower level compilers on code generators for .NET or Java, but the required behavior is to be controlled on Zoe compiler.
  • annotations or attributes are not implemented on Zoe or Meta D++ (even when it can be imitated by classfactorys)
  • generation of “Extended Zoe” is not implemented on Zoe compiler, so code generator for java, for example, can’t implement custom operators or properties.
  • multiple inheritance is not implemented
  • forced member virtualization is not checked by Zoe compiler
  • Meta D++ compiler doesn’t support Unicode files, only ASCII, but it must support Unicode :-P
  • support for more than one XML namespace on Zoe files

Documentation

Know bugs

As this is an alpha release it has several know bugs most important ones:
  • Sometimes you will get several errors that said something like “__error type is not found”. Rebuild the file with Zoe compiler and will fix the error.
    If you find errors on Meta D++ compiler or Zoe compiler (even if you are not sure) please let me know about that and if you can send to me the source that generate the error.

LayerD SDK FAQ

Why is this SDK in mixed English / Spanish ?

Because I don't have time to maintain both English and Spanish SDK. So, I'm translating all to English. If you want to help me that will be great!!

There is a distribution for Linux ?

No, there isn't. It's perfectly possible to compile all modules in Linux but I don't have time to do that and I use Windows more than Linux. May be you can help me with this task.

Can be used to develop commercial applications ?

Yes, In fact it was used for at least two pretty big commercial projects (both on .NET). Please let me know if you use LayerD on a commercial project !
You don't have to pay me for that, this is a free and open source project. If you make money consider a donation :-)



Thanks for downloading LayerD SDK,
Be happy doing compile time programming :-)

Distribution date: May 3, 2009

LayerD documentation

I'm releasing a new SDK that contains a Programmers Reference Manual for Meta D++ and a revised guide to Compile Time programming for .NET programmers.
This reference manual is only in Spanish and was made by Belén Licari, thanks Belén! I've revised most of it and it seems ok ! I will update the manual if I find mistakes.
This is not much documentation taking into account the extension of the project but it's something :-). If someone can help me translating this documentation to English it will be great!!

Tuesday, April 21, 2009

Interactive compilation and RAD tools with LayerD









PD: new SDK coming soon: classfactory debugging, several bug fixes, Java to Meta D++ compiler, basic manual about OO in Meta D++ (in Spanish), more samples.

PD2: I know, this is English... I don't have time to write both Spanish and English so I have to make a choice. ... In fact I don't have time to write in one single language :-P

Wednesday, February 18, 2009

Principles of Programming Research in the Computer Science Department at Carnegie Mellon

Un extracto que me pareció interesante de la carta de presentación del centro de investigación en programación (lenguajes) de la universidad de Carnagie Mellon:

"Our success in advancing an integrated view of Computer Science encourages us to take on even greater challenges, and opens up many new possibilities for us to explore. We envision that future languages will have fully formal definitions with fully checked proofs of their safety and security properties as a matter of course. Currently available tools, such as Twelf, are already expressive enough to make this feasible for realistic languages such as the POPLMark Challenge (posed by Pierce and others at UPenn) and large fragments of the ML language. Research is already under way on enriching their expressive power and convenience to make the task simpler, more modular, and easier to maintain and evolve. In particular we envision the development of logical frameworks that support a more direct and natural representation of shared state and of concurrent interaction than is currently feasible.

Our experience with the design and implementation of certifying compilers emboldens us to assert that in the future all compilers will be certifying compilers that will make use of expressive type systems in intermediate and object code, as well as source languages. Compilers are very complex software systems that are notoriously difficult to maintain and evolve. Certification permits a degree of self-checking within a compiler that greatly increases the modularity of the compiler itself, and correspondingly vastly enhances our ability to make significant changes to a component without disrupting crucial invariants assumed by other components. Moreover, certifying compilers generate object code that carries with it a machine-checkable proof of safety and security properties, eliminating or greatly reducing the need to rely on the correctness of a compiler to ensure the well-behavior of a binary executable.

The effectiveness of type systems for improving code quality, reducing development costs, and enhancing maintainability of software is by now beyond dispute. We believe that the trend toward languages with increasingly expressive type systems will accelerate, and that the demands for type systems of ever-greater expressive power will increase as developers become accustomed to their use. In the near future we expect to see type systems that are capable of expressing, and mechanically enforcing, crucial data structure and protocol invariants across module boundaries. In the longer term we expect a convergence of type systems and specification languages to achieve a complete integration of these important tools for reasoning about program behavior. There is every reason to pursue these goals aggressively, and we are optimistic that the foundation of tools and theories that we have developed will serve as a solid basis for this work.

Speaking more broadly, we believe that it is time to challenge the prevalent, if tacit, assumption that we must live with low-quality, unreliable software that is prohibitively expensive to improve, much less replace. Rather than accept the status quo and try to live with it, we do better to challenge it and try to do better. It is our contention that a comprehensive approach based on the application of fundamental theory to programming practice is the best strategy for overcoming the limitations of current software systems and practices."

Link: http://www.csd.cs.cmu.edu/research/areas/principleprogr/


 

Wednesday, January 21, 2009

Compiler research: the next 50 years

Este post no tiene que ver directamente con LayerD pero me pareció interesante compartir algunas partes de un interesante artículo titulado "Compiler research: the next 50 years" de la respetada publicación "ACM communications volume 52 issue 2". Transcribo las partes que me parecieron más interesantes:


 

Today, compilers and highlevel languages are the foundation of the complex and ubiquitous software infrastructure that undergirds the global economy. It is no exaggeration to say that compilers and high-level languages are as central to the information age as semiconductor technology.

In the coming decade, 2010 to 2020, compiler research will play a critical role in addressing two of the major challenges facing the overall computer field: Cost of programming multicore processors and Security and reliability of complex software systems.

Cultural Shift

To address these challenges, the compiler community must change its current research model, which emphasizes small-scale individual investigator activities on one-off infrastructures. Complete compiler infrastructures are just too complex to develop and maintain in the academic research environment.

Exploiting large-scale parallel hardware will be essential for improving an application's performance or its capabilities in terms of execution speed and power consumption. The challenge for compiler research is how to enable the exploitation of the power of the target machine, including its parallelism, without undue programmer effort.

Enable the creation of compiler research centers. There are few large compiler research groups anywhere in the world today. At universities, such groups typically consist of a senior researcher and a few students, and their projects tend to be short term, usually only as long as a Ph.D. project. Meanwhile, the few industrial groups studying advanced compiler technology tend to focus on near-term solutions, even as the compilers, the programs they translate and analyze, and the target execution environments have increased in complexity. The result is that too much of today's compiler research focuses on narrow problems, ignoring the opportunity to develop revolutionary strategies requiring long-term commitment for their development and evaluation.

The computer science community has achieved notable success in developing novel compiler infrastructures, including: compiler front-end development; program-analysis frameworks for research in compilers; verification tools, security applications, and software-engineering tools; and virtual machine frameworks for both mainstream and special-purpose languages. Even if the GNU and industry-developed compilers were a useful infrastructure for research, development of new robust, easy-to-use infrastructures by the researchers who need them are critical for future advances. Not only is it important to support such research projects, the research community must recognize their academic merit.

Compiler courses must clearly demonstrate to students the extraordinary importance, range of applicability, and internal elegance of what is one of the most fundamental enabling technologies of computer science.

Knowledge of the power and limitations of compiler algorithms is valuable to all users of compilers, debuggers, and any tool built using compiler algorithms that encapsulate many, if not most, of the important program-analysis and transformation strategies necessary for performance and correctness. Therefore, learning about compiler algorithms leads to learning about program optimization and typical programming errors in a deep and rigorous manner. For these reasons, programmers with a solid background in compilers tend to excel in their profession.

Definitivamente sería bueno que todo programador alguna vez construya su propio lenguaje de juguete aunque más no sea. Hoy por hoy hay muchas herramientas como para que esto sea una tarea más de tener ganas que de saber mucho para construir algo sencillo. Claro, si se quiere avanzar para abarcar lenguajes completos la dificultad y tiempo necesario aumenta mucho pero sigue siendo como todo una cuestión de ponerle laburo. En este sentido LayerD puede ser usado muy bien como herramienta didáctica para enseñar sobre compiladores ya que escribir un lenguaje LayerD de alto nivel es una tarea que se puede automatizar con cosas como Bison o JavaCC, para la etapa intermedia se puede usar el compilador Zoe que nos librara de la tarea de tener que diseñar y construir un analizador semántico a mano (cosa que suele ser lo más "complicado/laborioso" de un compilador por no haber prácticamente herramientas). Si se desea alterar la semántica de Zoe se puede modificar el código fuente en casos de querer cambiar mucho la semántica, o simplemente escribir un par de extensiones con classfactorys para cambios o incorporaciones no tan drásticas. Finalmente la generación de código se puede usar o modificar alguno de los generadores de código Zoe que hay.

Ojala, como dice el artículo se le dé más importancia a la investigación en relación a compiladores y en la próxima década veamos avances emocionantes al respecto. Personalmente, opino que son mucho más importantes los cambios y avances a realizar en lo que respecta al diseño de lenguajes de alto nivel que lo relacionado a mejorar los generadores de código de bajo nivel. Si bien coincido en que la generación de código optimizado y eficiente es clave, también pienso que es mucho más favorable para la ciencia de la computación y la industria del software cada vez que se logra elevar el nivel de abstracción en el desarrollo de software. Los primeros compiladores no generaban código super optimizado, sin embargo la ventaja de poder programar en un nivel de abstracción más alto le garantizo el éxito a los compiladores. El éxito de entornos de ejecución como Java y .NET no fue porque sus primeros intérpretes fueran excelentes, sí por poseer la capacidad de facilitar el desarrollo y mantenimiento del software.