Nemerle is Notable


Published on

My presentation about Nemerle language on

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Nemerle is Notable

  1. 1. Nemerle is notable Nemerle is notable Denis Rystsov 2011
  2. 2. Nemerle is notableOrigin
  3. 3. Nemerle is notableNemerle Experience
  4. 4. Nemerle is notable Environment Managed 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
  5. 5. Nemerle is notableWhy not try? Nemerle is almost a superset of C#, so if you know C# you can use Nemerle.
  6. 6. Nemerle is notableWhy not try? By the way, Nemerles compiler can compile C# code, so you can try it on exising C# project
  7. 7. Nemerle is notableWhy not try? Why not try?
  8. 8. Nemerle is notablePart I - use your C# habits Part I - use your C# habits
  9. 9. Nemerle is notableHello world / C#
  10. 10. Nemerle is notableHello world / Nemerle
  11. 11. Nemerle is notableExtension Methods / C#
  12. 12. Nemerle is notableExtension Methods / Nemerle
  13. 13. Nemerle is notableLINQ / C#
  14. 14. Nemerle is notableLINQ / Nemerle
  15. 15. Nemerle is notableObject Initialization / C#
  16. 16. Nemerle is notableObject Initialization / Nemerle
  17. 17. Nemerle is notableAnonymous Types / C#
  18. 18. Nemerle is notableAnonymous Types / Nemerle
  19. 19. Nemerle is notableYield return / C#
  20. 20. Nemerle is notableYield return / Nemerle
  21. 21. Nemerle is notableDynamic / C#
  22. 22. Nemerle is notableDynamic / Nemerle
  23. 23. Nemerle is notableType casting / C#
  24. 24. Nemerle is notableType casting / Nemerle
  25. 25. Nemerle is notableTry..Catch / C#
  26. 26. Nemerle is notableTry..Catch / Nemerle
  27. 27. Nemerle is notablePartial / C#
  28. 28. Nemerle is notablePartial / Nemerle
  29. 29. Nemerle is notableArrays / C#
  30. 30. Nemerle is notableArrays / Nemerle
  31. 31. Nemerle is notableAttention! Wild dinosaur!
  32. 32. Nemerle is notableGoto? What is about.. GOTO? unlike C# Nemerle doesnt support it, but..
  33. 33. Nemerle is notableThe proper use of goto The only one legal usage of goto is exit from nested loops Nemerle provides a better solution named code blocks
  34. 34. Nemerle is notableNamed code blocks
  35. 35. Nemerle is notableBeyond C# After this short intro you can write apps in Nemerle in C# style. But Nemerle goes far beyond it
  36. 36. Nemerle is notableDesired C# features It supports the most desired features of the next versions of C# right now
  37. 37. Nemerle is notablePart II - desired C# features Part II - desired C# features
  38. 38. Nemerle is notableObject initializers with events
  39. 39. Nemerle is notablePainless XML generation
  40. 40. Nemerle is notableINotifyPropertyChanged language support
  41. 41. Nemerle is notable`Safe navigation operator
  42. 42. Nemerle is notableDesign by contract
  43. 43. Nemerle is notableSequence initialization (list comprehension)
  44. 44. Nemerle is notableYield from lambda
  45. 45. Nemerle is notableImproved lazy support
  46. 46. Nemerle is notablePart III functional programming Part III functional programming (FP)
  47. 47. Nemerle is notableWhat is FP? Typical signs of FP Monads Type inference Pattern matching Algebraic data types Built-in tuple support Local (nested) functions
  48. 48. Nemerle is notableNemerle supports FP Nemerle supports it all
  49. 49. Nemerle is notableType inference
  50. 50. Nemerle is notableLocal functions
  51. 51. Nemerle is notableBuilt-in tuple support
  52. 52. Nemerle is notableMonads Monad is creational functional programming design pattern that deals with computation creation. The upcoming C# 5 async/await feature is particular case of a monad (creation of asynchronous computation). Computation expressions are monads + monoids. Nemerle supports computation expressions.
  53. 53. Nemerle is notableMonads Consequently Nemerle supports the upcoming C# 5 async/await feature right now among the other monads.
  54. 54. Nemerle is notableExample of easy composition of two async methods
  55. 55. Nemerle is notableAlgebraic data types Short intro to algebraic data types
  56. 56. Nemerle is notableAlgebraic data types Lets learn ADT by example Suppose we need to work with expressions like a + sin(b)
  57. 57. Nemerle is notableAlgebraic data type Of couse we need trees
  58. 58. Nemerle is notableOOP approach to trees (class hierarchy)
  59. 59. Nemerle is notableFP approach to trees (ADT - algebraic data type)
  60. 60. Nemerle is notableAlgebraic data type semantic After we rewrite OOP code with variant (ADT) we should consider `Sum as a constructor of type `Tree `l,`r as its params (not a Tree.Sums elds) But if they are params, how get them back from a `Tree typed object?
  61. 61. Nemerle is notableAlgebraic data type Disassembling (pattern matching) Pattern matching solves this problem. It checks if object is constructed with constructor specied in a pattern and if it is true it binds actual parameters of constructor with names of variables the pattern. Lets see on the following example.
  62. 62. Nemerle is notablePretty Printing of `Tree typed object
  63. 63. Nemerle is notableAlgebraic data type OOP vs. FP OOP 72 SLoC (pretty printing with visitor pattern) FP 25 SLoC (pretty printing with pattern matching)
  64. 64. Nemerle is notableVariant is OOP enabled algebraic data type
  65. 65. Nemerle is notablePattern matching goes beyond disassembling Pattern matching can be nested.
  66. 66. Nemerle is notableAlmost all features are macros Nemerle seems to be complex, but. . .
  67. 67. Nemerle is notableAlmost all Nemerle features are macros Dont worry Nemerle is a simple language and almost all features are macros parts of standard library, not a language. Macros is a plugin to compiler. You can write your own macros to introduce new language constructs or eDSL.
  68. 68. Nemerle is notableAlmost all Nemerle features are macros Youve already meet macros in this presentation, they are. . .
  69. 69. Nemerle is notableAlmost all Nemerle features are macros LINQ Object initialization Anonymous types Late (dynamic) XML-Literals INotifyPropertyChanged macro Safe navigation Design by contract Computation expressions Lazy macro and even if while foreach
  70. 70. Nemerle is notableAdvanced macros Beside macros copying useful features from another languages there are macros adding unique features. One of them is Nemerle.Peg. It is a macro-library that allows to describe grammar in the attribute and during the compilation necessary methods for parsing text in this grammar will be added to the class. Also there are some macros supporting design patterns.
  71. 71. Nemerle is notableNemerle is cool Nemerle is cool. It was proved.
  72. 72. Nemerle is notableMetric Some metric of using Nemerle in home pet long-term research project formula search engine
  73. 73. Nemerle is notableMetric Two years ago rst prototype was rewritten from C# to Nemerle 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%.
  74. 74. Nemerle is notableAdditional materials Nemerle on google code Nemerle site Sources code of examples shown in this presentation