nemerle is notable
DESCRIPTION
My presentation about Nemerle language on spbalt.netTRANSCRIPT
![Page 1: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/1.jpg)
Nemerle is notable
Nemerle is notable
Denis Rystsovtwitter.com/rystsov
2011
![Page 2: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/2.jpg)
Nemerle is notable
Origin
![Page 3: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/3.jpg)
Nemerle is notable
Nemerle Experience
![Page 4: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/4.jpg)
Nemerle is notable
EnvironmentManaged compiler written in Nemerle
Visual Studio 2008 plugin with debugger and autocomplete
Free IDE based on Visual Studio Isolated Shell
Sharpdevelop plugin
Mono support
NAnt plugin
![Page 5: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/5.jpg)
Nemerle is notable
Why not try?
Nemerle is almost a superset ofC#, so if you know C# you canuse Nemerle.
![Page 6: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/6.jpg)
Nemerle is notable
Why not try?
By the way, Nemerle's compilercan compile C# code, so youcan try it on exising C# project
![Page 7: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/7.jpg)
Nemerle is notable
Why not try?
Why not try?
![Page 8: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/8.jpg)
Nemerle is notable
Part I - use your C# habits
Part I - use your C# habits
![Page 9: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/9.jpg)
Nemerle is notable
Hello world / C#
![Page 10: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/10.jpg)
Nemerle is notable
Hello world / Nemerle
![Page 11: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/11.jpg)
Nemerle is notable
Extension Methods / C#
![Page 12: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/12.jpg)
Nemerle is notable
Extension Methods / Nemerle
![Page 13: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/13.jpg)
Nemerle is notable
LINQ / C#
![Page 14: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/14.jpg)
Nemerle is notable
LINQ / Nemerle
![Page 15: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/15.jpg)
Nemerle is notable
Object Initialization / C#
![Page 16: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/16.jpg)
Nemerle is notable
Object Initialization / Nemerle
![Page 17: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/17.jpg)
Nemerle is notable
Anonymous Types / C#
![Page 18: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/18.jpg)
Nemerle is notable
Anonymous Types / Nemerle
![Page 19: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/19.jpg)
Nemerle is notable
Yield return / C#
![Page 20: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/20.jpg)
Nemerle is notable
Yield return / Nemerle
![Page 21: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/21.jpg)
Nemerle is notable
Dynamic / C#
![Page 22: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/22.jpg)
Nemerle is notable
Dynamic / Nemerle
![Page 23: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/23.jpg)
Nemerle is notable
Type casting / C#
![Page 24: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/24.jpg)
Nemerle is notable
Type casting / Nemerle
![Page 25: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/25.jpg)
Nemerle is notable
Try..Catch / C#
![Page 26: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/26.jpg)
Nemerle is notable
Try..Catch / Nemerle
![Page 27: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/27.jpg)
Nemerle is notable
Partial / C#
![Page 28: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/28.jpg)
Nemerle is notable
Partial / Nemerle
![Page 29: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/29.jpg)
Nemerle is notable
Arrays / C#
![Page 30: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/30.jpg)
Nemerle is notable
Arrays / Nemerle
![Page 31: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/31.jpg)
Nemerle is notable
Attention! Wild dinosaur!
![Page 32: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/32.jpg)
Nemerle is notable
Goto?
What is about..
GOTO?unlike C# Nemerle doesn't support it, but..
![Page 33: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/33.jpg)
Nemerle is notable
The proper use of goto
The only one legal usage of goto is
exit from nested loops
Nemerle provides a bettersolution � named code blocks
![Page 34: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/34.jpg)
Nemerle is notable
Named code blocks
![Page 35: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/35.jpg)
Nemerle is notable
Beyond C#
After this short intro you canwrite apps in Nemerle in C#style.
But Nemerle goes far beyond it
![Page 36: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/36.jpg)
Nemerle is notable
Desired C# features
Itsupportsthe most desiredfeatures of the nextversions of C# right now
![Page 37: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/37.jpg)
Nemerle is notable
Part II - desired C# features
Part II - desired C# features
![Page 38: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/38.jpg)
Nemerle is notable
Object initializers with events
![Page 39: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/39.jpg)
Nemerle is notable
Painless XML generation
![Page 40: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/40.jpg)
Nemerle is notable
INotifyPropertyChanged language support
![Page 41: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/41.jpg)
Nemerle is notable
`Safe navigation' operator
![Page 42: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/42.jpg)
Nemerle is notable
Design by contract
![Page 43: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/43.jpg)
Nemerle is notable
Sequence initialization (list comprehension)
![Page 44: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/44.jpg)
Nemerle is notable
Yield from lambda
![Page 45: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/45.jpg)
Nemerle is notable
Improved lazy support
![Page 46: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/46.jpg)
Nemerle is notable
Part III � functional programming
Part III � functionalprogramming (FP)
![Page 47: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/47.jpg)
Nemerle is notable
What is FP?
Typical signs of FPMonadsType inferencePattern matchingAlgebraic data typesBuilt-in tuple supportLocal (nested) functions
![Page 48: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/48.jpg)
Nemerle is notable
Nemerle supports FP
Nemerle supports it all
![Page 49: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/49.jpg)
Nemerle is notable
Type inference
![Page 50: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/50.jpg)
Nemerle is notable
Local functions
![Page 51: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/51.jpg)
Nemerle is notable
Built-in tuple support
![Page 52: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/52.jpg)
Nemerle is notable
Monads
Monad is creational functional programming designpattern that deals with computation creation.
The upcoming C# 5 async/await feature is particularcase of a monad (creation of asynchronouscomputation).
Computation expressions are monads + monoids.
Nemerle supports computation expressions.
![Page 53: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/53.jpg)
Nemerle is notable
Monads
Consequently Nemerle supportsthe upcoming C# 5async/await feature right nowamong the other monads.
![Page 54: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/54.jpg)
Nemerle is notable
Example of easy composition of two async methods
![Page 55: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/55.jpg)
Nemerle is notable
Algebraic data types
Short intro toalgebraic data types
![Page 56: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/56.jpg)
Nemerle is notable
Algebraic data types
Let's learn ADT by example
Suppose we need to work withexpressions like
a + sin(b)
![Page 57: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/57.jpg)
Nemerle is notable
Algebraic data type
Of couse we need trees
![Page 58: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/58.jpg)
Nemerle is notable
OOP approach to trees (class hierarchy)
![Page 59: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/59.jpg)
Nemerle is notable
FP approach to trees (ADT - algebraic data type)
![Page 60: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/60.jpg)
Nemerle is notable
Algebraic data type � semantic
After we rewrite OOP code with variant (ADT) weshould consider`Sum' as a constructor of type `Tree'`l',`r' as its params (not a Tree.Sum's �elds)
But if they are params, how get them back from a`Tree' typed object?
![Page 61: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/61.jpg)
Nemerle is notable
Algebraic data type � Disassembling (pattern matching)
Pattern matching solves this problem. It checks if object isconstructed with constructor speci�ed in a pattern and if it is trueit binds actual parameters of constructor with names of variablesthe pattern.
Let's see on the following example.
![Page 62: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/62.jpg)
Nemerle is notable
Pretty Printing of `Tree' typed object
![Page 63: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/63.jpg)
Nemerle is notable
Algebraic data type � OOP vs. FP
OOP
72 SLoC (pretty printing withvisitor pattern)
FP
25 SLoC (pretty printing withpattern matching)
![Page 64: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/64.jpg)
Nemerle is notable
Variant is OOP enabled algebraic data type
![Page 65: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/65.jpg)
Nemerle is notable
Pattern matching goes beyond disassembling
Pattern matching can be nested.
![Page 66: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/66.jpg)
Nemerle is notable
Almost all features are macros
Nemerle seems to be complex,but. . .
![Page 67: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/67.jpg)
Nemerle is notable
Almost all Nemerle features are macros
Don't worryNemerle is a simple language and almost all features aremacros � parts of standard library, not a language.
Macros is a plugin to compiler. You can write your ownmacros to introduce new language constructs or eDSL.
![Page 68: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/68.jpg)
Nemerle is notable
Almost all Nemerle features are macros
You've already meet macros inthis presentation, they are. . .
![Page 69: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/69.jpg)
Nemerle is notable
Almost all Nemerle features are macros
LINQ Object initialization Anonymous typesLate (dynamic) XML-LiteralsINotifyPropertyChanged macro Safe navigationDesign by contract Computation expressionsLazy macro
and even
if while foreach
![Page 70: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/70.jpg)
Nemerle is notable
Advanced macros
Beside macros copying useful features from anotherlanguages there are macros adding unique features.
One of them is Nemerle.Peg. It is a macro-librarythat allows to describe grammar in the attribute andduring the compilation necessary methods for parsingtext in this grammar will be added to the class.
Also there are some macros supporting designpatterns.
![Page 71: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/71.jpg)
Nemerle is notable
Nemerle is cool
Nemerle is cool.It was proved.
![Page 72: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/72.jpg)
Nemerle is notable
Metric
Some metric of using Nemerlein home pet long-term researchproject
uniquation.com formula searchengine
![Page 73: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/73.jpg)
Nemerle is notable
Metric
Two years ago �rst prototype was rewritten from C# toNemerle in 3 days. Nemerle experience before 0.
Code was reduced by 46%.
Last month a new macro library (Nemerle.Peg) was applyed.
Code was reduced by 15%.
![Page 74: Nemerle is Notable](https://reader031.vdocuments.site/reader031/viewer/2022020713/554ebdb1b4c905064d8b46e5/html5/thumbnails/74.jpg)
Nemerle is notable
Additional materials
Nemerle on google code
Nemerle site
Sources code of examples shown in this presentation