An Introduction to Nitra


 

Just over a year ago we announced that we’d brought on board some members of the Nemerle team, along with its lead Vlad. They have been working very hard over the past year to develop a technology named Nitra, something we spoke about briefly during JetBrains Day.

Why Nitra

Before explaining what Nitra is, let’s address the question of why it is we’ve been investing into this project.

At JetBrains we make tools for languages and frameworks. We support dozens of languages and the number of frameworks is probably close to 100, if not over. Every time a new language appears, be it a programming language, be it some new syntax for templates, we need to study it, learn it, implement the corresponding parser and then provide support for analysis and refactoring.

It’s not an easy task, and at the pace technology is moving and expectations increasing, it becomes more complicated. While we are coping, we could definitely make things easier. That’s WHY Nitra.

What is Nitra

Take a look at the following

image

Can you tell what that is (the name is a spoiler)? It’s a syntax module for Gherkin, a language used in Cucumber, a framework for defining executable specifications.

This syntax module is defined using Nitra. Add it to a project, and combined with a parser that also ships with Nitra, you can now parse Cucumber files, obtaining an Abstract Syntax Tree. This means that simply defining some grammar you get parsing capabilities.

But there’s more…

This is not just another parser generator

Nitra is not merely just another parser generator. There are a few key characteristics that make Nitra different and much more powerful.

Nitra is about extensibility

Nitra provides the ability to extend existing grammar either statically or dynamically. By not using scanning techniques it dramatically increases extensibility. This in essence allows us to not only define new languages but also extend existing ones. For instance, here’s an example of extending C# with a new .? operator.

image

Nitra is about tooling

Nitra is not only about creating and extending existing languages, but it also about tooling. Defining a syntax module will also provide features such as syntax highlighting, code folding, static analysis, refactoring, navigation and symbol lookup, effectively all the features that we provide in our existing tools and IDEs.

How does this help you, our users

Nitra leads to a much faster turnaround in providing support for new languages and frameworks. It will allow us to build support faster.

Instead of manually having to create parsers and language / tooling support for every new technology, Nitra will provide us with this with very little effort, in essence merely defining a syntax module.

This translates into a quicker turnaround with emphasis on quality, which ultimately provides you, our users, a better experience.

In addition, there is also the possibility of allowing end users to create their own DSLs without having to be experts in parsing or language implementations, and at the same time obtain capabilities such as error checking, syntax highlighting and more.

What next

As mentioned initially, Nitra has been under development for over a year. While there is a lot left to do, we have reached a point where we are comfortable enough to provide you with a status update, something we have owed you for some time.

But it’s not done yet. It’s still cooking.

For more information and updates, follow the Nitra Twitter account.

This entry was posted in News and tagged , . Bookmark the permalink.

37 Responses to An Introduction to Nitra

  1. Florin Patan says:

    NITRA sounds really nice.

    I’m currently working with the author of the GOlang plugin to update it and make it ready for IDEA 13 but we’ve seen that it would be really good if we could use a new parser / lexer for it.

    Is there any way to start using NITRA sooner? Or the better question is: when do you think NITRA will be stable enough to start using it?

    Thank you.

  2. Pingback: An Introduction to JetBrains Nitra | Enjoying The Moment

  3. Matt Davey says:

    As a long time fan of Nemerle and one of many people who have been very eager to hear news after the Nemerle announcement last year, it’s great to see this evolution. I am still hopeful that in time, as Nitra matures, we will see some of the advancements filter back into Nemerle and its small but dedicated community.

  4. Thomas says:

    So basically this is hat XML Schema is for XML.

  5. Sasha M. says:

    Anxious to hear how it all relates back to Nemerle. It seemed like a great language at the time you onboarded the crew and the fact that with renaming of .csproj into .nproj everything still compiled also was a major plus. But lack of tooling was crippling. Would love to revisit it one day!

  6. michal@hanu.la says:

    But why did you name it after a small town in Slovakia, notable for not being interesting in any way?

  7. How does Nitra relate to MPS? Looks like Nitra something like MPS. Why not using existing tool, but create a new one?

    • Hadi Hariri says:

      MPS is a programming environment / workbench that is available on the JVM. Nitra is more a language ‘workbench’ but not part of an environment and targets the CLR.

  8. Rob Hughes says:

    I’m confused by the section about extending grammar.

    In the .? example, it seems this will allow it to be parsed by Nitra but will not actually add any functionality (and the code would not compile). Is that correct? If so, then I’m not really sure what the benefit here is.

    • Hadi Hariri says:

      This would allow the C# language to be extended with .? operator, which in turn would mean you can use this operator in your C# code. Otherwise it wouldn’t be of much use :)

      • Rob Hughes says:

        So it’s a compiler as well? Or does it use something like Roslyn to extend the ‘regular’ compiler?

        Not knowing the Nitra syntax, I’m also confused about the SafeMemberAccess line – is that also expressing what the operator does, or is it expressing how it should be parsed (e.g. lexical info) or how it should be executed?

        • Vlad says:

          Currently Nitro provides tools to create a only parsers and a simple IDE support. At present you can to extend the parser only. But in the future, Nitra will provide toolset for building of robust compilers and IDE support. If we implements the C# compiler on Nitra, you will be able to extend it. And your constructions eventually be transformed to MSIL.

  9. Guido Smeets says:

    When will Nitra be released? Will Nitra be released open source? Or will it be a closed source paid license? If so, what will the price be?

    Any info would be appreciated. It looks very promising.

  10. Jonas Eriksson says:

    Looks very interesting – but I missed the basic information – where does Nitra live? In Visual Studio with ReSharper or in the Jetbrain IDEs ?

    Would it be possible to for example use Nitra to extend Html syntax with available AngularJs directives?

  11. Lorenzo says:

    Looks very interestin and promising!
    It reminds me of M in some ways… I loved M and I was so disappointent it got “cancelled” (chopped off and put in some obscure server product).
    I am interested as well about the “language extension” part. Is it meant to be a preprocessor, and spit out C# for csc.exe, or does it emits IL and somehow weaves it with the IL generated by csc?

    • Vlad says:

      Extensions are only supported for languages which ​​implemented on the Nitra. But no one prevents to implement the C# on Nitra. The C# parser already done.

    • mirhagk says:

      Since the C# parser is already done, it would be pretty trivial to make it as a preprocessor that spits out slightly modified C# code that will then be compiled by csc.

      It’d be pretty cool to see a VS extension that’d look for a Nitra extension file, and implement those extensions, getting some of the best parts of Nemerle (macros/syntax extensions) into C#. I may even have to look into doing this.

  12. Pingback: XML Schemas & Program Code Generation » Xml Europe Technology News

  13. raiph says:

    I’m pondering Nemerle/Nitra from a high level.

    After reading this article I’m thinking of them as something like a subset of NQP/Perl 6 but more focused / less ambitious and much faster (execution speed and time to market!). Are there any ways in which this is not a reasonable description?

  14. Pingback: Links for November 9th through November 16th

  15. Where is the repo hosted?

    What is the level of completeness? Can it implement a language like Haskell, Agda, Coq, Idris, F#, Cal Actor Language, Scheme, Scala, Perl, Rust, BitC, Ada, C++. Why I mentioned these is that they complicated to implement and schematics are different from normal languages. Best is to have a test suite of language features and target compatibility towards comprehensiveness.

    Perhaps you can add support for JVM and Native output support also

  16. Best is to have a multi paradigm test suite. Other features I can think about is something like JoCaml, Algo Skeletons, R, Fortress (through not active had many interesting features).

    Need not everything in at the 1st version but this can happen step by step.

  17. To be able to cover be the best tool for the trade all the following bases needs to be covered:
    1) All bases of the lambda cube
    2) Pattern calculus – theoretical sound pattern matching
    3) Process calculus

    If all the above 3 are supported then this would be the most powerful framework.

  18. Eagerly waiting to try out Nitra. Earlier I can get something more the better even if it is bleeding edge.

  19. Pingback: End of Month Research Roundup – January 2014 | endjin blog

  20. Pingback: Nitra goes Open Source! | JetBrains Company Blog

  21. Pingback: Nitra es ahora de código abierto | Donde El Futuro Es El Presente.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">