11 ms·
Nimrod: A New Approach to Metaprogramming [video]
- dom96 13y agoSlides: HTML (http://nimrod-code.org/talk01/slides.html http://nimrod-code.org/talk01/slides.html) and PDF (http://nimrod-lang.org/talk01/slides.pdf http://nimrod-lang.org/talk01/slides.pdf)
- _pmf_ 13y agoThank you!
- idlewan 13y agoI really enjoy the language so far. For me, it's the perfect middleground between C and python: a fast compiled language, and one where you can be as productive as in python. I also tend to prefer catching errors early, and having a typed language that warns and errors at compile-time is great.
- joshbaptiste 13y agoheh.. sounds like Go
- randallsquared 13y agoIt's a lot more complicated than Go, but in return you get generics, templates, and AST macros.
- klibertp 13y agoLess opinionated. Supports generics. And meta-programming seems much more advanced. I'm particularly happy to see hygienic macros.
- idlewan 13y agoWith Nimrod's macro, you can do awesome things. It can improve readability a good deal. Here's an example I made: https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/nawak/nawak_app.nim#L44 https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast... Go version: https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/go/src/hello/hello.go#L92 https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast...
- skybrian 13y agoThe Nimrod version is shorter, but it seems harder to tell whether error-checking is done right.
- idlewan 13y agoNimrod has exceptions. I am catching them (https://github.com/idlewan/nawak/blob/specialpages/nawak_mongrel.nim#L58 https://github.com/idlewan/nawak/blob/specialpages/nawak_mon...) and returning a 500 error page with the detailed exception message. So you need less explicit error-checking everywhere with a language that support exceptions.
- pjmlp 13y agoGo is not that modern, for those of us that know the alternative world of Algol family of languages.
- TheCoelacanth 13y agoGo basically only has one modern feature (goroutines). Beyond that it's a throwback to Java version 1.
- skybrian 13y agoGo interfaces are also new.
- fedesilva 13y agoI hear people saying this all the time. Why? For me they are similar to type-classes+records but without polymorphism. Care to elaborate?
- klibertp 13y agoI looked at http://golangtutorials.blogspot.com/2011/06/interfaces-in-go.html http://golangtutorials.blogspot.com/2011/06/interfaces-in-go... and the only new aspect of Go interfaces I see is that they are implicit - they are considered implemented if the type implements functions that interface defines and you don't need to explicitly write "implements Something". This is a handy shortcut, but it doesn't look like a "serious feature". It also looks a bit like polymorphic variants in OCaml. Of course I might be missing something as I'm not that familiar with Go.
- wtetzner 13y ago> It also looks a bit like polymorphic variants in OCaml. Or like object types in OCaml. They also use structural typing.
- skybrian 13y agoActually it's a big improvement for large-scale programming due its effect on library dependencies. In Go you can easily declare an interface that matches a type in someone else's library without creating a hard dependency on that library. You can also superset and subset interfaces easily. That way you get loose coupling (almost like "duck-typing") in a mostly statically checked language. Contrast with Java where you'd have to both create a new interface and write an adapter class in a separate "glue" library that has hard dependencies on both libraries.
- fedesilva 13y agoNo. It has polymorphism and metaprogramming, things that Go (at least parametric polymorphism) eschews.
- hcarvalhoalves 13y agoI've found some (arguably minor) things to be kinda messy. Maybe the result of a one-person language that grows too much before getting some feedback. 1) Everything is (strangely) called a procedure, and then there's syntax to differentiate arguments that will be modified in place (proc myproc(myarg : int, inplacearg : var int)). Kinda weird, and a lost opportunity to have checking for pure functions at compile time. 2) import vs. include. Why have include at all to shoot yourself in the foot if you have cheap namespacing? 3) If vs. When ? 4) varargs feels kinda unnecessary 5) Case-insensitive. Oh... why? On the bright side, I like how OO was implemented. I disagree that it's a middleground between C and Python though. I see it more like an evolution of Pascal, it has the same niceties (ALGOL-like, static types, builds executables) and some things added on top (no VM, but GC'ed, metaprogramming).
- idlewan 13y agoOh, it does bring a lot to the table that C and Python don't have. You're totally right, it is not a middleground per se, it is just the language I was looking for. If I try to answer your points: -> 1) The procedure keyword comes from Pascal. I am not shocked by it, when I learned programming the teacher used to call them procedures also. The 'var' in procedure arguments could be considered the opposite of the 'const' of C/C++. Everything is const by default in Nimrod, but if you want something modified in place you indicate it. -> 2) Herm... I got nothing. I haven't used include, I didn't see the use for it yet. -> 3) 'when' is compile-time, 'if' is at runtime. -> 4) Unnecessary? varargs is quite useful. For example, if you use redis, you can do db.del("akey", "anotherone", "otherkey"), instead of having to fiddle with an array. Varargs makes some calls cleaner. -> 5) "The idea behind this is that this allows programmers to use their own preferred spelling style and libraries written by different programmers cannot use incompatible conventions." from the Nimrod manual (http://nimrod-lang.org/manual.html http://nimrod-lang.org/manual.html). It forces you not to name functions and variables too closely. So you won't be able to have different things named myStuff and my_stuff because it will refer to the same variable or proc. You enforce your own writing style. That is debatable. You have others enforcing a style, like with gofmt. The case insensivity did not disturb me, though (but I admit it surprised me at first).
- lmm 13y agoDo you know how it compares to a modern typed functional language - Haskell, OCaml, F# or Scala?
- TylerE 13y agoOcaml with better metaprogramming, an actually helpful compiler, and syntax that doesn't feel like having your eyes gouged out by a rusty spoon.
- rayiner 13y agoOn a related note, the most principled approach to macros for an infix language I've yet seen is Honu (brought to you by the Racket people): http://www.cs.utah.edu/plt/publications/gpce12-rf.pdf http://www.cs.utah.edu/plt/publications/gpce12-rf.pdf.
- jessaustin 13y agoInteresting, but I'm troubled that they got the first function (on the first page) wrong. (You can leave out the discriminant when it's zero, but not otherwise.)
- pjmlp 13y agoI'll take the time to read the paper later. Do you know how does it compares with Dylan's macros?
- breuleux 13y agoFunny you should say that, because I've been working on my own approach this month: https://github.com/breuleux/liso https://github.com/breuleux/liso I'm probably going to post about it soon in more detail, if people are interested.
- mortyseinfeld 13y agoWish it were a Intellij plugin and for Clojure instead of Racket. I'd buy it.
- 13y ago
- skrebbel 13y agoI am very intrigued by Nimrod. The language seems to have goals that overlap with e.g. Rust, but with a bunch of really interesting design decisions (e.g. GC by default, but first class support for manual memory management). Given the amount of force driving Rust (and Rust's PR machine), compared to Nimrod which seems to be really pushed forward by one single person, I'm really impressed by how far Nimrod got. I really want to start using Nimrod for real work.
- progman 13y ago> I really want to start using Nimrod for real work. I have actually used both Rust and Nimrod for real work (same project, first Rust then rewrite in Nimrod). My experience is that Nimrod is far easier to handle than Rust. It feels like Python with the native speed of C. There are a lot of nice features built into Nimrod, for instance native Perl regular expressions and seamless import of C functions. As for me it is the most productive language I ever encountered. I know many languages.
- pjmlp 13y ago> GC by default, but first class support for manual memory management Since Mesa/Cedar (1978) there have been quite a few systems languages proposing that approach. http://bitsavers.trailing-edge.com/pdf/xerox/parc/techReports/CSL-83-11_The_Cedar_Programming_Environment_A_Midterm_Report_and_Examination.pdf http://bitsavers.trailing-edge.com/pdf/xerox/parc/techReport...
- Dewie 13y agoInitially, I was kind of 'meh' towards Nimrod since Rust already looked so good. But when I recently read about the features, especially the metaprogramming and compile-time features, it seems like it could be really fun and powerful to program in.
- fedesilva 13y agoIf I understand correctly once you stop using the GC, Nimrod is not memory safe. Rust is.
- 13y ago
- M2 13y agoNimrod is a really good general-purpose language with a clear and readable syntax
- wcbeard10 13y agoFrom the little I know about metaprogramming, it sounds analogous to doing string manipulations in a language, and then eval'ing it (which is heavily frowned upon, at least in python). How is this understanding wrong?
- andreasvc 13y agoBecause here you're not doing string manipulation, but AST manipulation (i.e., the datastructure you get after parsing the language).
- skybrian 13y agoIt's a bit higher level, roughly like generating HTML using a templating library that auto-escapes to avoid XSS attacks. There are fewer ways to screw up and since it happens at compile-time, it's more secure. Generally speaking, if you would normally do something using reflection, you can also do it using code generation, which should compile to faster code (since you're not interpreting it at runtime) but possibly at the cost of code bloat and making the code harder to follow.
- chipsy 13y agoIf you're familiar with front-end web coding, it's comparable to manipulating the properties of DOM objects vs. assigning an innerHTML string. Building a string is crude but sometimes effective - but when you want to really engineer something, you want to have every node made available as a data structure, since that puts it in a form suitable for algorithm design. In a lot of instances, a macro isn't particularly more complicated in intent than a string + eval solution; it's just a much more verbose way of attacking the problem.
- laichzeit0 13y agoHeh. The name nimrod has a very insulting connotation where I live. Nimrod: an inept person. Really we actually use it as an insult to people, e.g. "man that guy is such a nimrod", "you're a nimrod". Very weird choice for a name :)
- desal 13y agoYou can thank bugs bunny for that http://en.wikipedia.org/wiki/Nimrod#Idiom http://en.wikipedia.org/wiki/Nimrod#Idiom
- stuhood 13y agoGiven the current trends in language design, it's interesting that Nimrod declares itself an imperative language, and that this talk doesn't discuss lambdas at all.
- klibertp 13y agoBoth lambdas and closures are there: http://nimrod-lang.org/manual.html#closures http://nimrod-lang.org/manual.html#closures There is some support in the library for things like map, filter. It's not the focus of a language though, which is ok - I love FP, but it's not like it's the only way forward. Diversity is good.
- dded 13y agoNear the top of Nimrod's homepage (http://nimrod-lang.org/ http://nimrod-lang.org/) is the following quotation, which leads me to believe that the language creators think they have picked a good name: The most important thing in the programming language is the name. A language will not succeed without a good name. I have recently invented a very good name and now I am looking for a suitable language. -- D. E. Knuth But "Nimrod" might not be as good of a name as they hope. The biblical Nimrod was a "mighty hunter", and the name may have that connotation in Europe: the British seem to have always had a warship or a warplane (or both) named Nimrod, for instance. But in the US, due to the ironic use of the name by Bugs Bunny to address Elmer Fudd, we tend to associate "Nimrod" with incompetence and gullibility.
- dded 13y agoI'm not sure why this is down-voted. Connotations differ in different cultures; I merely point out that "Nimrod" does not have a universally positive connotation. If this is connotation is intentional, perhaps as humor, please just tell me I'm not getting the joke.
- dom96 13y agoI believe that the reason the name Nimrod was picked was because according to the Bible Nimrod was the first king. The fact that the word has a negative connotation in the US is a bad coincidence. It however seems too late to change the name now. But is it really so bad? Many people use Git and in Britain 'git' has similar negative connotations, as Nimrod does in the US.
- dded 13y ago> But is it really so bad? I don't know. It's not like "Gimp", which is viewed by some as insulting to handicapped people. But it wasn't clear to me that the Nimrod developers were even aware of the US connotations, so I brought it up. Perhaps the "Git" comparison is apt; as far as the US is concerned, that's the sort of name that's been picked.