Hacker News new | ask | show | jobs
Generate Python extensions using Nim language (ramanlabs.in)
112 points by eagledotRL 1525 days ago
6 comments

I suspect Nim has a good shot at getting popular, by piggybacking on Python syntax, the same way several other languages (e.g. Java, JavaScript) got popular by piggybacking on C syntax. Python just became number 1 on TIOBE index. Once part of the generation of developers just starting now, Python-first, needs to learn a systems programming language, Nim provides a path of least resistance for migration, close to the syntax they will be already used to.
For me, Nim provides much of the developer productiveness of Python, but with higher performance.

I'm a big fan of Nim, and while I love Python, I keep finding more ways to use Nim instead of Python because it means if my proof-of-concept in Nim gets popular, I can avoid making trade-offs in scaling (due to performance).

Very good point. For Python enthusiasts, Nim positions itself nicely as a next step. I don't think Nim will ever reach the heights that Python has amazedly found itself at, but do think there is going to be a bit of "gravitational influence", that keeps giving Nim some public attention.

Eventually, Nim could find itself on the TIOBE top 50 to 30 rankings. That would put it among known languages such as D, Scala, and Haskell. Which might not seem like much, but considering all the new programming languages that are out here now, it is actually quite significant. The competition among newer languages (Rust, Crystal, Zig, Vlang, Odin, Julia...) vying for attention and to replace some of the older ones is fierce.

The problem with Nim is that it doesn't follow the Zen of Python (nor does Python anymore but Python doesn't need to compete as a new language).

Basically, it's just too complicated and all over the place.

I mainly program in Python, but Nim has its own Zen and I respect that it's different.

    Copying bad design is not good design.
    If the compiler cannot reason about the code, neither can the programmer.
    Don’t get in the programmer’s way.
    Move work to compile-time: Programs are run more often than they are compiled.
    Customizable memory management.
    Concise code is not in conflict with readability, it enables readability.
    (Leverage meta programming to keep the language small.)
    Optimization is specialization: When you need more speed, write custom code.
    There should be one and only one programming language for everything. That language is Nim.
If I wanted Zen of Python I'd just keep programming in Python ...
Python ecosystem, say Pytest, doesn’t follow Python zen either. It has implicit magic all over the place. String parsing from function names, the entire concept of fixtures is exact opposite of “explicit is better than implicit”.
I've used https://github.com/yglukhov/nimpy and I have to say the package, the author and the nim community were all phenomenal in helping me implement nim code that works as a Python package.
I've asked (sometimes stupid) questions in the Nim Matrix channel about some particular thing I was stuck on, and every time someone has answered it graciously and almost immediately. The community has been great, and I'm starting to really like the language.

For me it's like Python in the sense that I can bang out a quick, single-file program on a whim, but if it starts growing beyond that Nim is really fast, expressive, and portable. I can cross-compile a binary for any common platform (Nintendo Switch even), and then just send it over and run it.

Yes. community has been an outstanding factor in my whole journey of Nim so far.It becomes so easy to try out new features with such active feedback.
Also of interest for people might be Genny. It’s a Nim library to automate creating language bindings for other languages. Currently it supports Python, Node, and C.

https://github.com/treeform/genny

Maybe also of interest is a nascent package for R calling Nim (or vice versa): https://github.com/SciNim/rnim
To add to that, there's also a Nim <-> Julia bridge: https://github.com/clonkk/nimjl
To add to that, there's also a Nim <-> JVM bridge: https://github.com/yglukhov/jnim

And wrapperless C++ interop through macros: https://github.com/n0bra1n3r/cinterop

I'm toying a bit with nim these days, and I find it quite pleasant. it is a pity that it did not find the same success as go or rust
This makes me want to write Python extensions using Nim using Spry - http://sprylang.se