domingo, 30 de octubre de 2016

[Discussion] Technical Overview of the Common Language Runtime

Hello, this time I would like to discuss a paper written by Erik Meijer and Jim Miller, Microsoft employee’s whose work is related to the Common Language Runtime. The paper is called Technical Overview of the Common Language Runtime and it can be found here.

The main topic of the paper is about the Microsoft’s Common Language Infrastructure (CLI), it explains the componentes of the CLI and the authors make superficial comparisons with the Java Virtual Machine.

Personally I don’t know much about virtual machines but it looks like the CLI has a lot of features that the JVM doesn’t have. For example that it could be used as a runtime for many kinds of programming language paradigms unlike the JVM that only suppots statically typed and object-oriented languages.

The CLI has a lot of primitive types which makes it powerful and very flexible. There are a lot of instructions available to modify and manage the evaluation and argument stack. You can do arithmentic operations, reference alterations to build for example a swap function, reference types and also value types. Something interesting is that it is mentioned in the article that one important feature is the tailcall function in order to support languages that only have recursion as a method for looping. Here it is said that this feature is not supported by the JVM but it makes me wonder about Clojure. A strong looping method in Clojure is the loop/recur functions and as far as I know it supported tailcalls so why in the article is said that it doesn’t support such feature. Maybe I’m wrong about this assumption about Clojure or maybe the JVM got updated in the last couple of years, but I would like to know.

Something that got my attention was all the stack behaviour and the operations done under it. I think that we will discuss more about it in the following classes of the Compiler Design course so we can implement the last phase of our compiler: code generation, which sounds very exciting.

References

http://webcem01.cem.itesm.mx:8005/s201613/tc3048/clr.pdf

jueves, 20 de octubre de 2016

[Discussion] Language Design and Implementation using Ruby and the Interpreter Pattern

Today I’m writing an interesting review, it is about a paper published by our class professor, Ariel Ortiz R.. Language Design and Implementation using Ruby and the Interpreter Pattern is the name of the paper, you can find it here[1].

This paper is particularly interesting for me because it involves a topic using the Ruby programming language, which is the one I love the most.

In general terms, the article talks about a framework called S-expression Interpreter Framework (SIF) which is like a DSL written for Ruby that allows you to interpret S-Expressions such like the ones from Lisp. This framework reminds me an article I red before about implementing Lisp in just 32 lines of Ruby code.[2]

This framework is an example of why I love Ruby. Thanks to using the Interpreter pattern, which by the way it’s also very easy to implement in Ruby, Ariel has managed to create a way that run Lisp-like programs.

When I was reading the article I didn’t get how this could be related to the Compiler Design course. After a while I understood that S-expressions are very useful when I compared to grammar definitions. And googled some exercises about compilers and in many cases I found examples of people implementing Lisp-like languages. I got amazed of the simplicity of this constructions!

I would liked to use this framework when I was taking the Programming Languages Course, most of all because the framework is developed in Ruby. Although it might not be the best language of the world, it’s very useful when you use it as a base for creating new frameworks or as a companion for teaching concepts.

Specifically about the SIF, it seems very extensible. I liked the way of how you can modify it very easily and add custom constructions using only just a new Ruby class.

References

[1] http://webcem01.cem.itesm.mx:8005/publicaciones/sif.pdf
[2] http://blog.fogus.me/2012/01/25/lisp-in-40-lines-of-ruby/

domingo, 9 de octubre de 2016

[Discussion] Compile-Time Metaprogramming

This time I listened the Software Engineering Podcast, Episode 57: Compile-Time Metaprogramming[1] where Laurence Tratt was present as guest.

Although the episode focuses in the Converge programming language (created by Tratt), it has some significant topics of general interest for the listeners. To explain this, we have to know what Converge is. It is a programming language that supports compile-time metaprogramming for implement DSLs. In common words, it has a macro built-in system that allows you to implement custom DSLs using the same language.

The main reason for creating such language is to provide a generic way to build DSLs and so to create easily ASTs from any grammar specified.
Tratt said that using a host language is very useful because you have already many common tasks solved for you out-of-the-box.

I really don’t know much about why building ASTs in runtime would be useful because this is a topic that we are currently starting to learn in the school but it seems that is a very complex stuff that Converge solves easily.

As Tratt explained, the language provides a function that lets you parse a grammar and build an abstract syntax tree for any input given by the user, you only have to specify the input, the grammar and your DSL so it sounds such a powerful tool. Another thing that he said is that you can program how the AST is created using the same Converge language. Again, I don’t know how this could be useful but it seems to be a nice feature of the language.

I liked that they explained some basic concepts such like the difference between a parse tree and a AST (i.e., parse is a two state process, first you take the input and tokenize, then you try to make sense in the language, while the purpose of the AST is only to get what the user tells you).
A interesting topic they talked about was error reporting. Although in Converge you can embed macros, it doesn’t suffer from the main errors that many programming languages have while trying to report an error where a macro is present. For example in C, when you have a macro and there is an error, because of the macro-expansion the exact place where the language is reporting the error could be wrong because the expansion is not considered in the report. This is solved in Converge so it is a great feature it has.

Personally I enjoy DSLs because in Ruby you have a lot of them coming to the surface very often. I have not tried yet to create one, only a simple one for a programming activity in a past course, but thanks to this activity now I know some useful tips for creating Domain Specific Languages.

The main quote I saved is: start small, evolve according to your user's needs.

References

[1] http://www.se-radio.net/2007/05/episode-57-compile-time-metaprogramming/

[Discussion] The mother of compilers

This post entry is an opinion about two resources: the article Grace Hopper - The Mother of Cobol[1] and the video documentary The Queen of Code[2].

Grace Hopper is the one who created the Cobol language. She was a mathematician and became a Navy Admiral in her young age. It is said that she also coined the term Bug. She worked with numeric tables and helped in the assembly of the Mark I machine. One of her main contributions to Computer Science is that she created the first compilers, A-0, B-0 that then converted to Flow-Matic in 1957.

Because she was a woman, she had troubles trying to follow her dreams. It seems unfair how society saw women in the past days. I think that nowadays this situation is changing. Although there are no much women in the Computer Science field, but projects start to arise following the trend of women inclusion.

I did not know Grace Hopper’s life but I liked a lot how she was concerned about teaching programming to young people. In the article they described her as a very strong woman and as it looks, she followed her dreams straight forward. It seems to me that she was a nice person and also very strong, although she was in a “men’s field” she never gave up or doubt about herself. It seems an admirable woman to me.

I quite get sad hearing that she was not allowed to teach in Harvard because they didn’t allowed women as teachers in the institution, the same goes to the navy that first they didn’t accept it, although years later she was recognized and admired. There was a phrase in the video that got my attention and it was that

Women in computing are like unicorns, they just don’t exist.
I think that back in those days, this phrase had more fundament than now. Today women movements have been changing how society thinks about gender inside companies and there have been special events that support the inclusion of women, for example Cisco has their own recruitment for women in our Campus and a special event for them. Movements like this are arising more often than before, nevertheless the fact that the number of women in computer science is very low, persist.

References

[1] http://www.i-programmer.info/history/people/294-the-mother-of-cobol.html [2] http://fivethirtyeight.com/features/the-queen-of-code/