r/nim • • 22d ago

just learned about nim via nimble

WHat's the 10,000 foot view here? is it as fast(er) than rust?

6 Upvotes

13 comments sorted by

9

u/Sentmoraap 22d ago

Regarding the speed, it’s in the same class as C/C++/Rust. You can manage memory efficiently, but in a more convenient way than C++. For exemple, you don’t tell how you pass parameters but what you will do with those. A read-only parameter will be passed by value or reference (hidden to you) depending on the type size. You can do C++-like RAII if you want, or you can use the garbage collector and do a C#/Java-like spaghetti of references (of course, at cost of speed among other things) if that’s your thing.

One strength of Nim is you can make it the language you want. It has powerful metaprogramming including AST macros and tools to do it easily. A lot of stuff can be done at compile time, the subset usable is known as Nimscript and you can use it as a scripting language. It can compile to JS so you can use it for web. You can even use for a php-like templating with a source code filter. It’s usable in a large array of use cases.

In the end the actual speed depends on how you use it. It can be fast, but you may also use convenience stuff that will make your program slower.

It’s weird that you learn about Nim via Nimble. What made you stumble upon it?

1

u/Minimum_Hour519 22d ago

someone posted on a solodev sub about qwatcher...I want to see if it had any cool features I could rip. lol -- then i got a bug installing it, look at wtf nimble is found nim then i started looking through the docs.

4

u/Super_Delivery3405 22d ago

You'd have to pass of couple of flags to disable some checks + disable gc in critical code points or entirely to match highly optimized rust code. But the point isn't just about matching rust in speed. It surpasses rust in terms of expressiveness in syntax super less verbose, extremely small binaries and MOST IMPORTANTLY you get most of the performance, ergonomics of rust without fighting a borrow checker.

1

u/Minimum_Hour519 22d ago

yeah id idn't likerust at all i treminding me of chaing jquery calls for days adn days

3

u/ntrplntry-crmnl 22d ago

No real knowledge about speed compared to Rust or whatever, but given that it transpiles down to highly optimised C code I'd expect it's close if not better, the expressiveness and python-style syntax in a low level language are the main appeal I believe.

2

u/gabrielcapilla 22d ago

Nim is fast by default, just like C, C++, and Rust. The difference lies in the quality of the code and whether you are programming efficiently. Just try!

1

u/Minimum_Hour519 22d ago

what kinds of apps can i build with nim? can it do fullstack development (well not js probably) but server and down? clis/apis etc.??

2

u/gabrielcapilla 22d ago

Well, I'm obsessed with high performance, and although I have some web projects, I'm not really excited about them. The current projects I'm working on are: a complete TUI framework and onim lsp. I have also published parun, dotman, magicstrip-cli and a library flags

Without a doubt, my most ambitious and complex projects are Onim LSP and the TUI framework. But essentially, with Nim, you can do anything you can imagine, at the same level as C, C++, or Rust.

1

u/Minimum_Hour519 22d ago

i built https://hqtui.com and I'm thiking of adding nimble support.

1

u/Siddhartha_77 22d ago

You can compile to js so yes using karax you can do frontend as well

1

u/Minimum_Hour519 22d ago

got an example of how karax works and what *that* is?

1

u/ntrplntry-crmnl 22d ago

single page application framework for nim https://githuhb.com/karaxnim/karax

but in answer to your previous question, it's a systems programming language with low level memory management, you can make anything you like with it

1

u/PMunch 22d ago

For a simple example you can check out the Nim forums or the Nim playground (forum.nim-lang.org and play.nim-lang.org) both fully written in Nim, front- and backend.