loading...
Cover image for Ode to Nimpy

Ode to Nimpy

juancarlospaco profile image Juan Carlos ・3 min read

Alt Text

The Nim experience

So far...

When PIP3 got broken on Arch Linux,
lots of Python modules got broken,
my Nim Nimpy Python modules continue working.

When Python3 become default on most Linux,
lots of Python modules got broken,
my Nimpy Python modules continue working.

When "ABI3" of Python3 launched,
some Python modules got broken,
my Nimpy Python modules continue working.

When Python3.8 become default on Linux,
lots of Python modules got broken,
my Nimpy Python modules continue working.

Alt Text

"Deprecation Warning" for a year on Nimpy,
my Nimpy Python modules continue working.

"Experimental" features for a year on Nimpy,
my Nimpy Python modules continue working.

If Nimble get broken someday, just use Git or Curl,
Install packages is copy&paste a file.

My Nimpy Python modules are faster than PyPy,
the most super-optimized Python3.8 code is several orders of magnitude slower than the crappiest unoptimized equivalent on Nim.

Most times I use a lot less lines of code than CPython, without code-golf,
it is not only about more performance but also it uses less code.

C interop is a lot better than CTypes, JavaScript too,
you can interoperate with anything that has C/C++ or JS API.

I write a lot less Type Annotations thanks to Type Inference,
but yet Types are strongly enforced,
variables are not None out of thin air, integers are not float out of thin air.

Deploy

Deploy anywhere where you can compile C:

Alt Text

  • scp the binary to the server & run!, forget installers and prepared environments, those are kludges of the past.

You can learn today

Hello World:

echo "Hello World"

For Python:

import nimpy

proc hello() {.exportpy.} =
  echo "Hello World"
  • {.exportpy.} is a Pragma to export to Python, is like a Decorator.
  • proc is like def of Python, it also has func for Pure-Functional.
  • You can use Python Syntax, but for this example I go with std lib.

On Python:

from module import hello
hello()

Install, Tutorial, Documentation, Manual, Docker, Chat, Try Nim on the browser, Nim for Python devs, Standard Library, Python integration, Python Syntax, Python/Nim Cheatsheet.

Advanced Nimpy Example:

Alt Text

Welcome to the Nim

50 years on the past you can compile C,
100 years on the future you can compile C.
Dennis Ritchie was right.
πŸ‘‘πŸ₯°πŸ‘

Posted on by:

juancarlospaco profile

Juan Carlos

@juancarlospaco

.10x frAgile FullStuck Midend Devlooper, Python, Nim, Arch, OpenSource, EN|ES, Argentina, UTC-3, Atheist, WFH Nim Team Leader

Discussion

markdown guide