ArticleslgStudy

mathematics

Nemerle

Nemerle is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Nemerle rather than just read about it. In short: Nemerle is a general-purpose, high-level, statically typed programming language designed for platforms using the Common Language Infrastructure (.NET/Mono). It supports multiple paradigms, including functional, object-oriented, aspect-oriented, reflective, and imperative programming.

Key takeaways

  • Nemerle belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Nemerle to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Nemerle from memory before moving on to harder problems.

Reference excerpt

Nemerle is a general-purpose, high-level, statically typed programming language designed for platforms using the Common Language Infrastructure (.NET/Mono). It supports multiple paradigms, including functional, object-oriented, aspect-oriented, reflective, and imperative programming. The language features a simple C#-like syntax and a powerful metaprogramming system. In June 2012, the core Nemerle developers were hired by the Czech software company JetBrains. The team focused on developing Nitra, a framework for implementing existing and new programming languages. Both Nemerle and Nitra appear to have since been abandoned or discontinued by JetBrains; Nitra has not received updates from its original creators since 2017, and Nemerle is now maintained independently by the Russian Software Development Network. However, no major releases have occurred, and development progress remains slow. JetBrains has not referenced Nemerle or Nitra for several years. The language is named after the Archmage Nemmerle, a character in the fantasy novel A Wizard of Earthsea by Ursula K. Le Guin.

Features

Nemerle's most notable feature is the ability to mix styles of programming that are object-oriented and functional. Programs may be structured using object-oriented concepts such as classes and namespaces, while methods can (optionally) be written in a functional style. Other notable features include:

strong type inference a flexible metaprogramming subsystem (using macros) full support for object-oriented programming (OOP), in the style of C#, Java, and C++ full support for functional programming, in the style of ML, OCaml, and Haskell, with these features: higher-order functions pattern matching algebraic types local functions tuples and anonymous types partial application of functions The metaprogramming system allows for great compiler extensibility, embedding domain-specific languages, partial evaluation, and aspect-oriented programming, taking a high-level approach to lift as much of the burden as possible from programmers. The language combines all Common Language Infrastructure (CLI) standard features, including parametric polymorphism, lambdas, extension methods etc. Accessing the libraries included in the .NET or Mono platforms is as easy as in C#.

Type inference

Everything is an expression

Tuples

Pattern matching

Functional types and local functions

Variants Variants (called data types or sum types in SML and OCaml) are forms of expressing data of several different kinds:

Metaprogramming Nemerle's macro system allows for creating, analysing, and modifying program code during compiling. Macros can be used in the form of a method call or as a new language construct. Many constructs within the language are implemented using macros (if, for, foreach, while, using etc.). "if" macro example:

Braceless syntax Similarly to the braceless syntax later added to Scala, Nemerle allows the programmer to optionally use a whitespace-sensitive syntax based on the off-side rule, similarly to Python. The following curly-brace snippet:

could be rewritten as:

Notably, it is not possible to break expressions or alternative clauses in matches over multiple lines without using a backslash \:

In order to activate this syntax, the user must add #pragma indent to the top of the file or use the compiler option -i.

IDE Nemerle can be integrated into the integrated development environment (IDE) Visual Studio 2008. It also has a fully free IDE based on Visual Studio 2008 Shell (like Microsoft Visual Studio Express) and SharpDevelop (link to plugin source code). Nemerle can be also integrated into Visual Studio (up until 2017) using add-ins and extensions.

Examples

Hello, World! The traditional Hello World! can be implemented in a more C#-like fashion:

or more simply:

Examples of macros Macros allow generating boilerplate code with added static checks performed by the compiler. They reduce the amount of code that must be written by hand, make code generation safer, and allow programs to generate code with compiler checks, while keeping source code relatively small and readable.

String formatting The string formatting macro simplifies variables to string manipulations using $ notation:

Declarative code generation StructuralEquality, Memoize, json, and with are macros which generate code in compile time. Though some of them (StructuralEquality, Memoize) can look like C# attributes, during compiling, they will be examined by the compiler and transformed to appropriate code using logic predefined by their macros.

Database accessibility Using Nemerle macros for SQL you can write:

instead of

and this is not just hiding some operations in a library, but additional work performed by the compiler to understand the query string, the variables used there, and the columns returned from the database. The ExecuteReaderLoop macro will generate code roughly equivalent to what you would have to type manually. Moreover, it connects to the database at compilation time to check that your SQL query really makes sense.

New language constructs With Nemerle macros you can also introduce some new syntax into the language:

defines a macro introducing the ford (EXPR ; EXPR) EXPR syntax and can be used like

ford (i ; n) print (i);

Nemerle with ASP.NET Nemerle can be either embedded directly into ASP.NET:

...Or stored in a separate file and entered with a single line:

PInvoke Nemerle can take advantage of native platform libraries. The syntax is very similar to C#'s and other .NET languages. Here is the simplest example:

References

Further reading Publications about Nemerle in RSDN Magazine, Russian official science magazine Moskal, Michał (27 June 2005). "Type Inference with Deferral" (PDF). Institute of Computer Science, University of Wrocław. {{cite journal}}: Cite journal requires |journal= (help) Presentation "Nemerle is notable" by Denis Rystsov Article "Unconventional languages for unconventional supercomputers" by Andrey Adinetz

External links Official website GitHub project and repository (new development) Google Code project and repository (old development) Nemerle Forum Nemerle presentation on Microsoft Research SSCLI RFP II Capstone 2005 workshop Nemerle at 99 Bottles of Beer

Worked examples

Example 1 — a first encounter with Nemerle

Start with the simplest possible case. Write down what Nemerle claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Nemerle before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Nemerle ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Nemerle

In research
Nemerle appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Nemerle in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Nemerle is common in secondary-school and first-year university syllabi. It links to neighbouring topics .NET programming languages, 2003 software, Aspect-oriented programming, so understanding it makes those chapters shorter.
In everyday life
Look for Nemerle outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Nemerle in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Nemerle means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Nemerle out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Nemerle in simple terms?

Nemerle is a general-purpose, high-level, statically typed programming language designed for platforms using the Common Language Infrastructure (.NET/Mono). It supports multiple paradigms, including functional, object-oriented, aspect-oriented, reflective, and imperative programming.

Why does Nemerle matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Nemerle?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Nemerle.

Tags

  • .NET programming languages
  • 2003 software
  • Aspect-oriented programming
  • Extensible syntax programming languages
  • Functional languages
  • High-level programming languages
  • Object-oriented programming languages
  • Procedural programming languages
  • Programming languages
  • Programming languages created in 2003
  • Statically typed programming languages

Keep exploring