Nemerle is a .NET language that supports three programming paradigms: one that most programmers consider to be OOP is a paradigm, a functional paradigm (algebraic data types, pattern-matching) and metaprogramming (AOP, quasi-citation, syntax extension of nemerle itself through a-la macros lisp). All this is laid on rails of strict static typing and seasoned with a powerful type inference system.
In a single whole, this is combined as follows: the structure of the program is defined by classes, that is, the code looks like the good old C #, but the FP is responsible for living inside the method. Metaprogramming is difficult to notice - it can be disguised as an attribute of a class or a “standard” while construct, which is actually a macro, which when compiled, turns into tail recursion, which in turn is converted into a loop on the IL compiler of nemerle . I say clean, since almost all control commands in nemerle, such as if, when, unless, while, for, are implemented as macros. In this way, you can write code on nemerle, do not know anything about metaprogramming, but use it in full and not suspect it. Briefly, if you have not heard anything about it, it will not prevent you from coding with nemerle. This also applies to the OP - no one bothers you to use functions with side effects. But even if you start writing code on nemerle, as if it is C # and score on meta, FP, then you can be surprised - nemerle supports tuples, default parameters and replaces delegates with functional types, that is, solves the compatibility problem of delegates with the same signature - instead Func <int, int> it is enough to write only the signature, for example, int-> int.
I learned this from
articles on the RSDN, blogs and documentation, but I always wanted to try to pee on nemerle myself. Unfortunately, I did not do this before for various reasons - either I worked with people who did not share my point of view on what a comfortable programming language should be, or was afraid to start a big project in a new language; but honestly it was just laziness. A couple of days ago, I was knocked down by the flu and I decided to fulfill the dream of writing on nemerle. The experimental rabbit was my long-running project on Sharpe, which has been my hobby for several months now. Maybe someday I will write about him in Habré, but so far without details: one of the main functions of parsing expressions and working with trees representing these expressions. It was easy to cover this part with tests, therefore I adhered to TDD when developing, as a result I had 73 tests for 71 files. Such a complete test coverage gave me confidence and I decided on such a refactoring as a change of language. For three days I completely rewrote the code on nemerle that expanded my understanding of it.
')
I found the language very convenient, because where I didn’t want to rewrite nemerle-style code, I turned off the brain and mechanically transferred the code from sharpe to nemerle, but where I thought it reasonable to use the AF style, I used it, and it helped to reduce project size up to 38 files. I was able to achieve this result due to the fact that I used the FP where it belongs, namely, the analysis of expressions and work with trees: it is natural to represent the tree in functional languages ​​as an algebraic data type, which greatly simplifies working with it. After my acquaintance with nemerle, I revised the list of my favorite universal programming languages, now the first place is occupied by nemerle as a representative of static typing and xotcl, which represents a dynamic unit.
With this article, I wanted to remind once again that testing is cool, and to draw the attention of the habrasoobshchestva to nemerle.
Below is a small collage that reflects the level of integration of nemerle and MS VS 2008, as well as the syntax of the language.
