Live data from Hacker News

Nim in 2020: A Short Recap

nim-lang.org

11–20 of 121 posts

Re: Nim in 2020: A Short Recap

#11
post #2

Very interesting. Is the memory model essentially a middle ground between GC-based and manual memory management?: > Scope-based memory management (destructors are injected after the scope) - generally reduces RAM usage of the programs and improves performance. How does Nim handle references? How similar is this to Rust's lifetimes GC-ed instead of manually managed? Is this essentially like Rust, with the main differe…

Seems Nim will do some static analysis where if it can infer a reference is locally scoped in some way, it will deterministically inject a call to the destructor at the end of the scope. If not, it will do reference counting which will also have (if using orc) an extra cycle detection pass so that the references count references can also handle cycles. Finally, Nim will also do some static analysis, and if it can infer that even though a reference is passed to something else, if it can tell that it isn't used afterwards from the previous place, instead of copying the data, it will share it, bit since it's not used by the previous owner you can think of it as moving it rather then sharing it. If Nim can't be sure this is the case or sees it isn't, then data will be copied.

That's what I understood at least. So ya, it does look like some kind of hybrid between statically inferable ownership semantics, reference counting, ARC and GC.

Re: Nim in 2020: A Short Recap

#14
post #10
post #5

Earlier quoted context omitted.

For me, it's a full stack language, write the frontent with karax https://github.com/pragmagic/karax or react bindings https://github.com/kristianmandrup/react-16.nim and backend in pure nim with any of the available web frameworks (jester/prologue/looper) and orms (ormin/norm) and share code and type declaration between the two.

How does karax run Nim client side? Cross compile to js or a wasm blob? Or something else entirely?

Nim compiles to js with `nim js source`. I'm not familiar with wasm but it's also possible, know people who have done that.

Re: Nim in 2020: A Short Recap

#15
post #10
post #5

Earlier quoted context omitted.

For me, it's a full stack language, write the frontent with karax https://github.com/pragmagic/karax or react bindings https://github.com/kristianmandrup/react-16.nim and backend in pure nim with any of the available web frameworks (jester/prologue/looper) and orms (ormin/norm) and share code and type declaration between the two.

How does karax run Nim client side? Cross compile to js or a wasm blob? Or something else entirely?

Nim compiles to js (as well as c and c++)

Re: Nim in 2020: A Short Recap

#16
post #12

Too bad nim uses a whitespace-sensitive syntax like python, something I personally dislike.

You're free to use Golang or another language.

Nim has a great feature set and will be a good fit for Python or Ruby teams wanting a more performant language. At the same time, it's more expressive than Golang and will fill a niche Golang couldn't meet.

I like that we now have Golang, Rust, Swift, Nim, and Kotlin. They're all doing new things and excelling at their own niches.

Re: Nim in 2020: A Short Recap

#17
post #11
post #2

Very interesting. Is the memory model essentially a middle ground between GC-based and manual memory management?: > Scope-based memory management (destructors are injected after the scope) - generally reduces RAM usage of the programs and improves performance. How does Nim handle references? How similar is this to Rust's lifetimes GC-ed instead of manually managed? Is this essentially like Rust, with the main differe…

Seems Nim will do some static analysis where if it can infer a reference is locally scoped in some way, it will deterministically inject a call to the destructor at the end of the scope. If not, it will do reference counting which will also have (if using orc) an extra cycle detection pass so that the references count references can also handle cycles. Finally, Nim will also do some static analysis, and if it can inf…

So if I understand that correctly: Nim will try to do a light version of Rust's borrow checking and then gradually move from static to dynamic solutions for memory management.

I read that Nim's GC is optional, does this mean it can be deactivated and when the static memory management fails, I can do it manually for the edge cases that would otherwise done by the GC?

Hope this makes sense, haha.

Re: Nim in 2020: A Short Recap

#18
post #5
post #4

In what cases is Nim a better option than Rust? Would be great if anyone with more experience can share more information.

For me, it's a full stack language, write the frontent with karax https://github.com/pragmagic/karax or react bindings https://github.com/kristianmandrup/react-16.nim and backend in pure nim with any of the available web frameworks (jester/prologue/looper) and orms (ormin/norm) and share code and type declaration between the two.

For a real-life example of this check out NimForum: https://forum.nim-lang.org

The front end is written with Karax (compiled to JS) and the backend with Jester.

Re: Nim in 2020: A Short Recap

#20
post #12

Too bad nim uses a whitespace-sensitive syntax like python, something I personally dislike.

I agree that the lack of explicit start/end markers for code blocks is a very unfortunate choice.

It was a bold choice by Python, but in my experience it turned out to be a poor choice, and not one to be copied.

That being said, it looks like a very exciting language and like Python I think I'd manage to enjoy it overall despite of that choice.

Post reply on HN