Live data from Hacker News

Nim 1.0

nim-lang.org

51–60 of 308 posts

Re: Nim 1.0

#51

Question (genuine, not trolling): what's the use-case for Nim regarding other languages? What are its pros/cons?

I've used it to develop command-line based utilities. The binaries tend to be small and fast.

Re: Nim 1.0

#52

Question (genuine, not trolling): what's the use-case for Nim regarding other languages? What are its pros/cons?

At first blush, it's easy to describe Nim as C-flavored Python, but I'm not sure that quite captures it. The syntax is similar, but that's about where the similarities end - Python is deeply, fundamentally a dynamic language, and Nim one of the more firmly statically typed non-functional languages out there. You could also describe it as being competitive with Rust, but with more compromises for the sake of developer…

Nim's syntax is very similar to Python simply because both are expressive, lean and have no braces. Naturally Python is dynamically typed and this, unfortunately, affects performance and maintainability.

Re: Nim 1.0

#53
post #38

Shameless plug, but by a nice coincidence, Manning has a discount on all printed books today. Among them is my book, Nim in Action, available for $25. If you're interested in Nim it's a great way to learn :) It was published in 2017 but we've ensured Nim is compatible with it (all book examples are in Nim's test suite), so apart from some minor deprecation warnings all examples should continue to work. Grab a copy he…

I can confirm, the book is excellent and worth a read-through.

Re: Nim 1.0

#54
post #7

Earlier quoted context omitted.

It's interesting to hear the constraints the language developer wanted from the beginning (20k lines, macro system drives most of the language development) and the various compromises they had to make along the way. > Furthermore, we don't really know yet how to leverage a macro system in order to give us extensibility on the type system level, so Nim's core needed generics and constraints for generics. I'm curious t…

I haven't looked into Nim in as much detail as Rust (though I did make some contributions to the compiler/language a number of years ago), but one aspect that has always seemed notable to me is that it seems to defer type checking of generic code until it is instantiated (this is what happens in C++), so these functions will all typecheck until you actually try to use them: proc foo[T](): float32 = result = "foo" + 4…

>it seems to defer type checking of generic code until it is instantiated (this is what happens in C++) ... and you don't get some error pointing to code internal to the function when the user applies types that don't work.

Worth noting that C++ is going the opposite way with concepts. The compiler still won't enforce that `template void foo(T t) { t++; }` needs a `requires Incrementable T` (like Rust would require with trait bounds). But if `foo` does use the concept `template`, then a call like `foo(S{})` will raise an error at the callsite, not at the `t++` line.

Re: Nim 1.0

#55
post #31

Earlier quoted context omitted.

It's as easy as Python and as fast as C. That was my take when I looked at it and bought the book last year.

> as fast as C I mean, it actually is C, since the code is transpiled to C.

Nitpick, but it actually compiles down to C. Nim works at a higher abstraction and the compilation is a one-way street. But what is more important is that it generates efficient C code, it looks ugly, and it's not something you would ever dream of writing yourself, but it's been optimised to give fast run-times. Often times in benchmarks the Nim code with optimisations comes out as fast as the C code with optimisations, even in some cases beating it.

Re: Nim 1.0

#56

Question (genuine, not trolling): what's the use-case for Nim regarding other languages? What are its pros/cons?

Those are valid questions when evaluating an unknown technology. How could anyone consider this trolling? Not to digress but have we become too sensitive?

Sometime people troll by sealioning: http://wondermark.com/c/2014-09-19-1062sea.png

(I'm not accusing the granparent post)

Re: Nim 1.0

#59

Congrats guys!!! This has been much-anticipated and I'm very excited. I personally wish that the owned reference stuff ( https://nim-lang.org/araq/ownedrefs.html ) had been part of 1.0, but I think that at some point shipping 1.0 >> everything else. I've been following (and evangelizing) Nim for a while, this will make it easier to do so.

It is part of 1.0, but you have to enable it using the "--newruntime" build switch.
Post reply on HN