Settings

Theme

I enjoy using the Nim programming language at Reddit

old.reddit.com

91 points by Guzba 3 years ago · 21 comments (20 loaded)

Reader

birdfood 3 years ago

It's cool to read that treeform is using Nim at reddit (and helps explain why he's so prolific!). I see the same question sometimes asked "what is Nim's killer feature", "what is Nim better at than other languages" and the answer given is usually "there is no killer feature, Nim is great at lots of stuff!". But I would argue Nim's killer feature is pragmatism. I think it's the most pragmatic language I've come across.

I love that I feel like I'm writing a cross between a dynamic scripting language and a functional language, but that nothing is off limits. I can still dive into memory management if I want to, yet I'm not forced to deal with a cliff of complexity up front. I'd be happy to choose Nim for command line tools, server code, or games and I can't think of another language where this is the case for me.

I've started writing some small internal tools in Nim for work. The language is approachable for other devs who "aren't into languages" to pick up if needed, but I can also share binaries with them so they can just use the tools without needing to set up an env.

  • renox 3 years ago

    I hope I won't start yet another flamewar.. Have you tried D?

    It's also a language I'd call pragmatic.

    • bet3lgeuse 3 years ago

      The worst thing about D is the forum full of sad and bitter people complaining that D isn't more popular.

      Other than that, it's a spectacular language.

    • birdfood 3 years ago

      Haven't tried it really only due to a lack of time (and I've played with too many languages in the past 12 months)

poulpy123 3 years ago

What really seems to characterize Nim is its ability to be used as glue language between different codes. C/C++/objective-c/javascript interoperability is native, python interoperability seems to be pretty good. It makes me think a lot to python before it exploded in popularity with machine learning and education

  • treeform 3 years ago

    I started using python around 2005 and Nim does have that feel of early python. Nothing was set in stone and the fields were open. Lots of optimism.

  • arc776 3 years ago

    Yeah definitely. Unlike Python though it's fast and light on memory, so once you have a prototype it's often already performant enough to be developed into a final product. Things like that save a lot of time and money in the long run.

planetis 3 years ago

Great read, totally agree on the last point. Hope Nim gains more traction.

michal_f 3 years ago

Nim is interresting. Its easy to read (and write) about pros. But what are cons?

  • treeform 3 years ago

    Nothing is without the cons. I would say:

    * Libraries: there is no NPM ecosystem to get anything you need.

    * Stack-overflow: If you looking for a aswers there might not be anyone who encounters it before. You might have to dig really deep to find some thing.

    * Some times you might run into a compiler bug usually related with performance of the generated code. Like it generates correct code bug it's slow for no reason and minor changes to the code make it fast again.

    * Relying on OpenSSL especially v3 especially on windows is a big problem, but thats more on openSSL i think. I actually wrote a library around this that uses platforms HTTP/SSL instead: https://github.com/treeform/puppy

    * Not having HTTP gzip support in standard library. You can always work around with zippy though: https://github.com/guzba/zippy

    * async stack traces are really hard to read.

    * not enough docs around the different ways to do threading. There is no one solution some times you want a quick thing, some times you are doing CPU tasks other times you are doing network tasks (where async is better). But many big languages struggle here, there is no one fits all threading solution.

    It's definitely not style case insensitivity which everyone loves to bike-shed about.

    • vanyle 3 years ago

      For the ecosystem, https://nimble.directory/ is listing quite a few packages. It's still nowhere near the size of the JavaScript ecosystem, but it's a good start.

      • treeform 3 years ago

        Unlike JavaScript libraries, Nim libraries seem to be a lot more sane and self contained. No left-pad nonsense or downloading 20 dependences.

    • goodpoint 3 years ago

      > there is no NPM ecosystem

      That's a pro, not a con!

    • elcritch 3 years ago

      Note the async stack traces have gotten better recently! They mostly report like other stack traces now. I actually forgot I was using async for a bit. Theres still some bugs I think.

  • poulpy123 3 years ago

    A lot of the cons are a matter of personal taste, such as the whitespaced block (like python), or the weird variable case management (only the case of the first letter is case sensitive and the variable are underscore insensitive).

    The biggest objective cons are the small community, and possibly for some people the usage of a GC The GC can be not used but I don't know if it's really practical since it's not something that I need, I just saw people complaining.

    • treeform 3 years ago

      The super fast libraries mention in the article Pixie, Zippy, SuperSnappy all use GC. They can beat or tie with the best C libs. But in order to be fast they don't use GC in the critical hot paths but pre-allocate work buffers to the right size or allocate stack objects instead. Surprisingly, going outside the bounds of the GC does not feel that foreign or wried in Nim. It's not hard.

    • rurban 3 years ago

      So memory safety is a cons point now?

rlipsc 3 years ago

It's great to hear Nim in production stories!

> I feel like Nim made me fall in love with programming again.

Same. It's just so frictionless and productive, and you know your code will run on basically any platform in a nice, efficient, self contained executable.

For me it's a language of sensible defaults. Speed and safety first, and opt-in machine level control. Want to target that obscure microcontroller? No worries: https://github.com/PMunch/ratel.

Want to use Unreal? Sure: https://github.com/jmgomez/NimForUE.

Want to target the web? Native React support with https://github.com/andreaferretti/react.nim or web apps with https://github.com/karaxnim/karax.

The list goes on! https://github.com/nim-lang/Nim/wiki/Curated-Packages

But, what if you want to use that battle tested C++ library? Nim can compile to C++ so you have native ABI FFI!

There's also a lot to be said for automation with AST macros. The language is built around them, they're not just a tacked on after thought. As a result, it's very easy to do everything from removing boilerplate copy pasta errors to creating mini languages or even generating APIs from data. This can give you new paradigms in approaching solutions for things that are quite painful in other languages.

I feel like this language could be a weapon of mass production for many businesses once they dip their toes in!

  • PenguinCoder 3 years ago

    It's less that "Reddit uses NIM" but rather one guy at Reddit uses NIM to do work. I see tech debt on the horizon.

    • arc776 3 years ago

      > It's less that "Reddit uses NIM" but rather one guy at Reddit uses NIM to do work.

      They are the same thing. No one is saying Reddit bases their entire infrastructure on Nim. The point is just that the language is being successfully used in a business context.

      This might not be important to you if you're not a user of the language, but for people that are, it is significant for two reasons: 1) it shows it's 'good enough' to do analytics & data processing for a large, data heavy company and 2) creates confidence/proof it can be used in a business context.

      As for technical debt, I doubt that's the case. The post mentions internal tools and processing, these kind of things are often not subject to high developer churn.

      Besides, Nim has a pretty easy to read syntax that's similar to Python. People who have talked about onboarding developers to the language (such as https://youtu.be/5wljNaPkU7M?t=586) say it has been fairly straightforward to train for if desired.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection