frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Show HN: Nimic – Pure Python as a systems language with AOT compilation

https://github.com/dima-quant/nimic
13•dima-quant•1d ago

Comments

dima-quant•1d ago
nimic is a lightweight pure Python package that emulates Nim types and constructions, making it straightforward to transpile to Nim and compile AOT. Key principle: nimic code is valid Python that runs unmodified in CPython and also transpiles to equivalent Nim code.

Because nimic code is just standard Python with type hints and ctypes shims, it is a fully valid CPython script, so you can use the Python REPL during development, drop a breakpoint in the middle of a heavy algorithmic loop and inspect the variables natively.

Zero Lock-In: You don't need a special runtime engine. If the Nim compiler is not available, your script still runs (albeit slower than standard Python due to some emulation overhead) on any machine with Python installed.

Seamless Distribution: You can use this to develop high-performance logic natively in Python, debug it with Python tooling, and then compile to a native executable or C-extension via Nim.

Why Nim? Its syntax maps well to Python, it is rather clear how to emulate its constructions in Python, and its performance is comparable to C (as it compiles to C). Port of the "trace-of-radiance" Nim project to nimic can be found in "ndsl_raytracer" in my GitHub repo (dima-quant). With the compiled executable the render time for a single 512x288 scene dropped from many hours in Python to just 10 minutes on a single M1 CPU core. The repo also includes nimic ppm to mp4 converter.

Similar projects: - Pyccel (https://github.com/pyccel/pyccel): Python extension language using accelerators - SPy (https://github.com/spylang/spy) is a variant of Python specifically designed to be statically compilable while retaining a lot of the "useful" dynamic parts of Python. - Codon (https://github.com/exaloop/codon) is a high-performance Python implementation that compiles to native machine code without any runtime overhead.

It is still work in progress, e.g. there is no JIT and multiprocessing support yet, but now I'm not sure what functionality would be best to implement next. Any suggestions?

IshKebab•1h ago
I would start with a human-written README and benchmarks?
dima-quant•54m ago
Yeh, indeed, the README was mostly generated, though the introduction is largely human-written :-) Is some specific description missing? I can provide more practical code examples directly in README. The benchmarks are mostly on runtime performance I assume?
graemep•8m ago
So the big advantage of nimic is that code remains valid Python and all valid Python cam be compiled?

The transpile to a language that transpiles to C approach is unusual. Downsides of that other than slower compilation?

actionfromafar•1h ago
Similar idea as Shedskin which is a (large subset of) Python to C++ transpiler

https://github.com/shedskin/shedskin

dima-quant•44m ago
Good suggestion, now I recall I heard about this project before. Good to see it is in active development.
vshulcz•10m ago
The line I'd push on is "valid Python that runs unmodified in CPython." True at the syntax level, but the speedup isn't really coming from Nim as a backend, it comes from how much of Python's dynamism you can pin down at compile time. Refcounting semantics, __getattr__, values that change type at runtime, isinstance-based dispatch, monkeypatching in tests: the moment you statically commit to any of those, you've defined a subset, and the subset is the actual product, not the transpiler.

I've spent a fair bit of time generating specialized straight-line code for hot Python paths, killing the per-call attribute and dict lookups the interpreter does. The lesson was that dispatch-bound code claws back most of its overhead without ever leaving CPython. Where AOT-to-native actually pulls ahead is numeric and loop-bound work, where the interpreter loop and boxing dominate. Your 512x288 render is exactly that case, which is why it looks so strong.

So the benchmark I'd want isn't render time, it's what fraction of a real module transpiles with no rewrites. That number tells me whether this is a systems language or a fast path I have to hand-shape around. Codon and Shedskin both hit that wall. Curious where Nimic draws the line.

Show HN: Nimic – Pure Python as a systems language with AOT compilation

https://github.com/dima-quant/nimic
13•dima-quant•1d ago•7 comments

Show HN: Write SaaS apps where users control where their data is stored

https://github.com/wolfoo2931/linkedrecords/
47•WolfOliver•6d ago•24 comments

Show HN: Brain Frog – Can you be random enough for 11 lines of JavaScript?

https://brainfrog.lol
37•AlexanderZ•5d ago•28 comments

Show HN: Nub – A Bun-like all-in-one toolkit for Node.js

https://github.com/nubjs/nub
240•colinmcd•19h ago•67 comments

Show HN: Wordit – Change One Letter, Keep the Chain Going

https://victorribeiro.com/wordit/
25•atum47•1d ago•14 comments

Show HN: Monolisa v3 – a typeface for developers and creatives

https://www.monolisa.dev/
174•bebraw•2d ago•79 comments

Show HN: LookAway, a Mac break reminder that knows when not to interrupt

https://lookaway.com
64•_kush•20h ago•21 comments

Show HN: peerd – AI agent harness that runs entirely in your browser

https://github.com/NotASithLord/peerd
60•NotASithLord•1d ago•22 comments

Show HN: Pure Effect – Reproduce production bugs on your laptop without a DB

https://pure-effect.org
55•tie-in•3d ago•13 comments

Show HN: Promptctl – Git for your AI prompts

https://github.com/naya-ai/promptctl
4•shawnaya101•8h ago•0 comments

Show HN: An ASCII 3D Rendering Engine

https://glyphcss.com
205•apresmoi•4d ago•50 comments

Show HN: TikZ Editor – WYSIWYG editor for figures in LaTeX

https://tikz.dev/editor/
442•DominikPeters•1d ago•74 comments

Show HN: Got sick of ads, so I made my own logic puzzle site

https://puzzlelair.com/
244•HaxleRose•2d ago•151 comments

Show HN: Lumli – Privacy-first image tools that run entirely in your browser

https://www.lumli.de
6•lumli•14h ago•0 comments

Show HN: FastUbu – An Ultrafast Video Archive

https://fastubu.com/
46•lukeigel•2d ago•6 comments

Show HN: CleverCrow: give tokens to your favorite projects

https://clevercrow.io
65•zhubert•3d ago•79 comments

Show HN: Neural Particle Automata

https://selforg-npa.github.io/
87•esychology•2d ago•19 comments

Show HN: Graphical SQL Builder and Debugger

https://github.com/webofmarius/SQLJoiner
21•matei88•3d ago•6 comments

Show HN: Built an Obsidian plugin that rephrases your writing without takin over

https://rephrasethis.co
4•gpickett00•9h ago•0 comments

Show HN: The Cascade Graph – An interactive map of AI and energy constraints

https://atomprophet.io/tools/cascade/
26•antisyzygy•1d ago•12 comments

Show HN: Criterion Closet as a website – pull any of 1,247 films off the shelf

https://the-criterion-closet.vercel.app
191•olievans•4d ago•55 comments

Show HN: RealTube – Watch YouTube with filters for AI-generated content

https://realtube.io
4•danielpop•11h ago•1 comments

Show HN: GDPRedirect – Become EU compliant in one line of code (satire)

https://gdpredirect.com
4•apwn•11h ago•0 comments

Show HN: Shumai – open-source Frame.io alternative for creative work

https://github.com/shumaiOne/shumai
60•Yiling-J•1d ago•4 comments

Show HN: Treedocs: Documentation that automatically checks for staleness

https://dandylyons.github.io/treedocs/
52•DandyLyons•1d ago•18 comments

Show HN: RLM-based local debugger for AI agent traces

https://github.com/context-labs/halo
25•mikepollard_dev•1d ago•10 comments

Show HN: An LLM agent that emits typed intent

https://github.com/gabert/ontocortex
3•gabert•12h ago•1 comments

Show HN: Dspyer – self-correcting, optimizable LLM steps for DSPy and LangGraph

https://github.com/theramkm/dspyer
2•ramkm•12h ago•0 comments

Show HN: A pure ARM64 Assembly web server, now on Linux with CGI for no reason

https://github.com/imtomt/ymawky/tree/linux
49•imtomt•2d ago•23 comments

Show HN: Recall – Local project memory for Claude Code

https://github.com/raiyanyahya/recall
135•mateenah•3d ago•84 comments