Hacker News new | past | comments | ask | show | jobs | submit login
All in with Nuitka (nuitka.net)
289 points by polyrand on Dec 9, 2022 | hide | past | favorite | 77 comments



Godspeed Kay.

I think I've told this story before, but oh well. Years ago, not long after Nuitka became a thing, I was blown away by all the effort put into this thing by -1- person. I asked to donate, and suggested he add a donation button to his page someplace. Kay couldn't believe anyone would want to just give him money, and seemed in disbelief with the idea and that I wanted to send money.

I don't know why that sticks with me. It seemed like such a humble exchange. We exchanged a few emails, he's a really smart and kind person. The world would be so lucky if more maintainers mirrored his spirit. Really wish him the best on this.


Related:

Nuitka: An extremely compatible Python compiler - https://news.ycombinator.com/item?id=28377541 - Sept 2021 (84 comments)

Nuitka: a Python compiler written in Python - https://news.ycombinator.com/item?id=27537819 - June 2021 (181 comments)

Nuitka 0.6.0 released - https://news.ycombinator.com/item?id=18092837 - Sept 2018 (14 comments)

Nuitka: A Python compiler - https://news.ycombinator.com/item?id=17683932 - Aug 2018 (6 comments)

Nuitka: A Python compiler - https://news.ycombinator.com/item?id=16980704 - May 2018 (4 comments)

Nuitka: A Python Compiler - https://news.ycombinator.com/item?id=16822005 - April 2018 (5 comments)

Nuitka: a Python compiler - https://news.ycombinator.com/item?id=15354613 - Sept 2017 (60 comments)

Nuitka Progress in 2015 – Python Compiler - https://news.ycombinator.com/item?id=10994267 - Jan 2016 (52 comments)

Nuitka – A Python Compiler - https://news.ycombinator.com/item?id=9089523 - Feb 2015 (5 comments)

Nuitka: a Python compiler - https://news.ycombinator.com/item?id=8771925 - Dec 2014 (135 comments)

Nuitka — A Python Compiler - https://news.ycombinator.com/item?id=1746340 - Oct 2010 (33 comments)


Things are picking up in compiled Python land! Also shedskin [0] which I thought was very promising but dead, has suddenly had a bunch of commits, quickly gaining Python 3 compatibility.

0: https://github.com/shedskin/shedskin


Nuitka is a pretty good compiler! I tried it this year for a small script that was used to automate generating Excel sheets with macros in them on Windows. It worked surprisingly well, but the ~100MB size was a turn off (and our Go binaries seem tiny compared to it). Though, we ended up writing a much faster and practical Powershell script for the same.

But python code as a statically compiled native executable is really cool, compared to other solutions like using pyInstaller.


Your link to the commercial subscription page is not working.

Missing a : in https://


My team and I love Nuitka. For us, it is an important part to maintain the legacy servers (=Windows).

Thanks a lot, and I hope our small contribution via subscription helps.


Fantastic; I've been a fan of this since the early days, even if I haven't tried it yet I've been following the updates.

I was never quite sure how to apply this to the old code base of shoebot, (a python creative code environment based on nodebox), I think if I start from fresh I might try again.


It’s great for deployment. I’m still weirded out when the result works so well, when every other Python deployment solution always fails on some common package.


FYI to the author - the link to "Please become a subscriber of Nuitka commercial" is broken. Needs a colon probably. This could hurt conversions.


Thank you for working on Nuitka.

I've been thinking a lot about transpiling lately. GCC and Clang are state of the art optimizing compilers for C/C++ and it's interesting that all the effort to optimize compilers is for those languages.

Any other language has to do a significant amount of work to build a standard library and value-add features.

There's languages such as D, Dart, Nim, Crystal, Zig, Pony which are impressive but receive little attention.

I'm working on my own multithreaded language, I want multithreaded software to be easier to write. It currently looks similar to Javascript but that might change.

To come back to transpiling, it's interesting finding something that's orthogonal between the source language and the target language that you can add value add features. C with arbitrarily nested hashmaps, safe strings would be useful.

I love the simplicity of Python sourcecode and I think complicated tools should be built in it for approachability. But transpiling or compilation is the problem.


> GCC and Clang are state of the art optimizing compilers for C/C++ and it's interesting that all the effort to optimize compilers is for those languages.

The optimizers from GCC and Clang aren't usable just for C/C++. Both compilers have frontends for different languages that share the optimization pipeline. For example, GCC has a D frontend, and the Zig compiler has a LLVM backend.


Yup, rust swift Julia and I think crystal use LLVM. Zig used it to bootstrap too

LLVM has definitely enabled more language diversity!


If you're like me and stick all your Python programs into your system with pipx[1] be wary, running Nuitka out such env will cause you lots of pain with library discovery. I felt so dumb after reinstalling it normally.

[1]: https://github.com/pypa/pipx


A lot of Python tools now support the ability to search for packages using in a different installation/environment from the one that is actually running the tool. Maybe we can run a fundraiser in order to pay the developer to add this feature.


This is nice. Hope there will be one day way to get executable for android or iOS. Even if someone maybe wouldn't write commercial python mobile app to be distributed in app store but such option would be super useful at least for me to prototype apps and directly test on mobile phones, e.g. desktop usually don't have sensors (accelerometer, gyroscope, magnetometer) or advanced camera or depth/lidar cameras. So most of the time you have to write some native app that will save those data, move it to desktop, prototype desktop python script using those data and overall whole process takes much longer.

Wish I could write python script with python libraries such as: OpenCV, Open3d, SDL, tensorflow and execute directly on android/iOS.


I've heard promising things about Nuitka so this will be a good time to try it out and see how .exe size compares to one generated by PyInstaller.

Also I think instead of undetermined donation amount a fixed $99 personal commercial license would be successful.


One thing I never understood about compilers:

Doesn't all CPUs offer a different set of opcodes? How can a compiler then work for different CPUs?

For example, this Wikipedia page is listing the CPUs that support instructions for fast SHA calculations:

https://en.wikipedia.org/wiki/Intel_SHA_extensions

How could a compiler ever use those, when not all CPUs support them?


Usually you compile for the lowest common denominator. For example, the version of GCC I use defaults to -march=x86-64, which is a common subset of instructions that should be supported by a 64-bit x86 CPU. You can override this with an argument like -march=sandybridge or -march=native (the latter enables all instructions your current machine can handle).

In principle, you could distribute many different binaries optimized for different CPUs. However, the more common approach in high-performance software is to compile most of the program for a generic instruction set and write several versions of the hottest parts. Then you detect the supported CPU features at runtime and dispatch appropriately.


CPUs offer feature flags that can be queried to learn about the availability of a particular extension. If a compiler wants to generate code that uses an extension if available, but falls back to an explicit (but slower) implementation if that's not the case, it can simply generate a branch instruction in front of the opcodes using the extension which checks for the feature flag first, branching into the fallback implementation if the extension isn't available.


That's true, though in practice - at least in C, C++, Rust, Go etc. - the compiler won't do that automatically. You need to write code to do it yourself (which very few people do for obvious reasons).


Simple. A compiler doesn't generate code that works on all different CPUs.

It generates code that works on 1) one CPU, or 2) a family of CPUs, or 3) (less commonly) multiple families of CPUs.

But not all CPUs.

I think you can see how 1) works. Plus, improved versions of a CPU are often backwards compatible, so if the program works on an older Intel x86-64 CPU than it very likely works on a newer one, or on an AMD x86-64 CPU or other compatible CPU.

2) works because programs can query the processor to see which additional features are supported. In your SHA extension example, https://www.intel.com/content/www/us/en/developer/articles/t... says:

> Availability of the Intel® SHA Extensions on a particular processor can be determined by checking the SHA CPUID bit in CPUID.(EAX=07H, ECX=0):EBX.SHA [bit 29].

It gives an example C function with inline assembly which uses the "cpuid" instruction to get that information:

  int CheckForIntelShaExtensions() {
   int a, b, c, d;

   // Look for CPUID.7.0.EBX[29]
   // EAX = 7, ECX = 0
   a = 7;
   c = 0;

   asm volatile ("cpuid"
        :"=a"(a), "=b"(b), "=c"(c), "=d"(d)
        :"a"(a), "c"(c)
       );

   // Intel® SHA Extensions feature bit is EBX[29]
   return ((b >> 29) & 1);
  }
A compiler (or programmer) can have one code path execute if CheckForIntelShaExtensions() is true, and another if it's false.

3) works in collaboration with the operating system. For example, on macOS the compiler can compile once for x86-64 and again for its "M" series chips and bundle the results into a single binary. The OS knows the CPU and can select the right compiled code to start.

Do note that Nuitka doesn't do any of this. It compiles Python to C code, then lets the C compiler handle the above.


The bar is much lower than this question implies for compilers. People don't expect them to take advantage of those SHA instructions automatically. Or even SIMD instructions - in the 25 years we've had SIMD instructions in consumer CPUs, compiler generated code usually can't exploit it ("autovectorize") well. (Though largely it's because we haven't updated our programming languages to be conductive to this...)


SIMD instructions are so uncommonly used that when you see one in a binary, it is probably an inline memcpy.


I mean, its normal to use the instructions for floating point math even when its not actually vectorized, so they are in there all the time. And a 64bit target will tend to enable SSE2 which will get you quite a bit of auto-vectorization.

and anything in .NET land since .NET Core will have a ton of SIMD in it


Compilers do emit the instructions regularly, but they rarely manage to speed up the code much.


Typically compilers have a "frontend" which turns code into a syntax tree and different "backends" for each architecture they need to support. For example, clang is the C front-end for LLVM while Emscripten is a backend that allows it to output Javascript.

Though for highly specialized calculations like that. they're often written into popular libraries like OpenSSL with inline assembly for all relevant architectures.


You can set the level of instructions to use. There are some levels that are compatible enough with modern CPUs ( something like all x64 CPUS) that will work for most of people.

https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html


Notes on how to get list of available targets GCC supports:

https://stackoverflow.com/questions/47299458/how-can-i-deter...


I helped write a document for Debian about that, there are various ways you can select different instructions at runtime or build time etc:

https://wiki.debian.org/InstructionSelection


I'd imagine a combination of runtime extension checking, and baseline extension support. I.e. when you pass -mavx2 or -march=native to your Cxx compiler, it sets the baseline minimum for what op codes are used.


This is where Golang shines, you can run it as a single executable on Win/Mac/Linux at a small size without pre-install a package system(e.g. pip). I just wish Golang can have a cross platform GUI one day(like swing on Java that is), Wails looks promising.

Golang does have weakness as Python, both are pretty much irrelevant on Android and iOS by design, sadly.


Agree on the advantages of Golang. I have a love/hate kind of relationship with its error handling; I like the defacto standard pattern of explicit error handling and hate the boilerplate to implement it. If only it had the Result and Error types of Rust. Anyway, even the current setup is far better than having to deal with Python's Nonetype errors.


Best of luck. The world needs Nuitka.


It's too cheap. Kay needs to increase prices by at least an order of magnitude, and go per-application subscribing. An all-you-can-develop subscription should be at least 25K,if not more.


Tried nutika it compile but ends up in several hundred mb binary for non data science app.it bring no performance benefits either.

What's the benefits over shipping as docker?


* Just a normal executable rather than something that needs a separate runtime - yes I know Docker is near universal on Linux for developers but less so for users and it doesn't integrate well with user permissions.

* Works fine for graphical applications (again this is possible with Docker but not zero configuration).

* Despite your complaint about size I still suspect it's a lot small than a complete Docker image.

* Works natively on Windows, unlike Docker

BTW the ideal mode is standalone rather than onefile - this outputs a directory including your program and separate files for any C extensions modules. That will let you chase down the offending module(s) that are hundreds of MB. Which in your case there must be - I distribute a small Qt program and even that is only 10s of MB.


Also, you don't need to install Docker ;)


Nuitka's primary aim is performance, more so than self-contained deployment. It's a bit strange to pit Nuitka against "shipping with Docker". It's also surprising to hear that you saw no performance benefits at all - but then again, perhaps your application isn't that much Python but just a small bit of Python wrapped around fast libraries written in e.g. C?


I was under the impression that speedup with Nuitka was fairly modest and you probably get faster with pypy

e.g. there's some benchmarks here https://pybenchmarks.org/ and they mostly seem to go: Python 3 -> Nuitka (slightly faster) -> Cython (much faster) -> PyPy (faster again)

So I always assumed the main advantage was more in producing a single binary

And I'd consider that a big advantage over "shipping with Docker" for many use cases, e.g. building cli tools


Python 3 really changed a lot, more than I realized. My experiences with Nuitka are against Python 2 from a couple of years back, at a point where Nuitka marketed itself using its performance increases and brought (at least) a 3-5x speedup on almost everything you threw at it.


I wonder why Mypyc isn't in that benchmark.


i've not seen any performance boost for my code either via nuitka, using mostly pure python and a little numpy

not that i mean to complain about having a working python compiler, i think its neat


Not everyone is a computer expert. My Mum could download and run an executable; I doubt she'd have much luck via Docker :)


Good point


Code obfuscation is sometime important.


Typical "I'm a dev, don't know marketing" approach. This is a good strategy to end up barely surviving. I should know, I marketed something heavily for maybe 6 months 10 years ago and it still pays me an income. I couldn't do it for more than 6 months.


Sorry if this is a stupid question, but could Nuitka (which transpiles Python to C in some way) also work with PyPy to gain even more speed? Like PyPy to C?


Without discussing the merits of Nuitka or this guy, in my opinion, the following is a recipe for disaster:

  Please become a subscriber of Nuitka commercial, even if you do not need the IP protection features it mostly has. All essential packaging and performance features are free, and I have put incredible amounts of works in this, and I need to now make a living off it.

  Right now, I am far from being able to sustain my income from it, and I am taking a risk with this effort, hoping for support from you.
In a few years we will have a blog post about how Oss is not able to provide sustainable income and maybe the thing will switch to an hybrid license if possible.


I like the idea of software freedom as much as the next guy, but software being free for noncommercial use is significantly more important to me (and I think many people) than being fully free-as-in-freedom. If hybrid licensing makes it possible to make a living developing free-ish software, which is still essentially free for "the commons" but not for corporations (which lest we forget are not actually people), then I think that's better than the alternative of everything being proprietary. Do not let the perfect be the enemy of the good.

We will need to see a major culture shift in industry towards paying for support for free software before that can change. It's ridiculous that companies are willing to shell out so much money for proprietary SaaS products (especially in the data engineering space), but are not willing to pay for support/consulting of open-source products, even if the latter is cheaper. It's not entirely rational, but it's the way things are, and we are still a couple of years off from anything being different.

Well-intentioned developers deserve to make a living on free-ish software more than I deserve fully free software.


Paying a solo developer for support of their application is a nice idea in theory, but hard to sell internally when the cap on "how much is this worth to us" is lower than the cost of the lawyers it would take to get terms agreed with that developer. The change we need is not in the open-source ecosystem, but inside companies where so much value and attention is squandered by legal, marketing and other departments which can be grouped under ass-covering.


Your last para: beautifully put.


Nobody really 'deserves' anything. All things in life have to be earned one way or the other. (for both sides)


The Universal Declaration of Human Rights [1] begs to differ.

1: https://www.un.org/en/about-us/universal-declaration-of-huma...


This is the most hackernews philosophy I've ever heard.

Of course people deserve things.


Are you from nestle?...because they think exactly this about water...even if the earth gives it for free, but hey please earn your right to breathe air...and lets see how far you come.


Aren't earning & deserving two sides of the same coin? You deserve something because you did what was necessary to earn it - you earnt it so you deserve it?

e.g. in GP's comment - the 'well-intentioned developers' 'deserve' to make a living, because they earnt it by making the nice 'free-ish software' and being 'well-intentioned' etc.?


If you are talking to a manager and you can't get them to understand why they need to pay the Nuitka author, talk about insurance. "If this guy doesn't get paid, he will abandon a key piece of our infrastructure (which speeds everything up by at least 3x, saving us X dollars/year) and we will be stuck with a maintenance time bomb in our system. If we pay this tiny fraction of what he is worth as a consultant, we are effectively joining an industrial alliance to support this technology. It's a good deal, think of this as out sourcing to the competent. If we don't pay him, we can use his stuff for free for a little while, but we will have a huge charge of Y dollars to pull his stuff out when he needs to get another job. Refactoring our system at that time will be risky and expensive, and we will get nothing for it. Think about this is cheap insurance, or hedging a bet. It's a good deal, I would sleep better at night if I knew the rest of our system could be structured this way."


> If you are talking to a manager and you can't get them to understand why they need to pay the Nuitka author, talk about insurance. "If this guy doesn't get paid, he will abandon a key piece of our infrastructure (which speeds everything up by at least 3x, saving us X dollars/year) and we will be stuck with a maintenance time bomb in our system. If we pay this tiny fraction of what he is worth as a consultant, we are effectively joining an industrial alliance to support this technology.

I've burned myself twice on this approach. Shortly after I/we started supporting them they changed their license terms. Of course since we were now paying customers we could still use it, but a significant reasons why I advocated for that software in the first place was because it was open source, and now I feel cheated and the advice I gave the company I worked for at that point turned out to be less valuable.

I do sometimes feel that once one get the taste for that sweet sweet recurring revenue it is hard to not start optimizing for it.

For completeness; it has also worked beautifully at least once.

And I guess I'll probably argue again for supporting open source.

But maybe I'll be a little more careful and try to ensure they can't pull these kinds of tricks on me (if a project accepts code contributions and doesn't have a CLA, it will be hard for them to pull such a bait and switch).


> If you are talking to a manager and you can't get them to understand why they need to pay the Nuitka author, talk about insurance

Finance is a significant obstacle to this goal. Multiple times I have been told, “There is a budget surplus-does anyone have any nice-to-haves we should purchase?” More than once, I have suggested (modest) donations towards open source project X that enables us to operate. Not once have I succeeded.

Not a real charity. Not a real purchase. Good will towards something already free does not make a compelling business case up the chain of command.


Except that your marginal payment doesn't actually work as insurance - if you're the only one to do it then Nuitka would still be abandoned, whereas if lots of others pay then your one payment is probably not going to make much difference to their decision.

I'm playing devil's advocate there: I do actually think it is the right thing to do to pay the author. But I don't think your argument would work with a manager.


This. The whole argument for donating is wrong, at least from the enterprise point of view.

If you want $$$ from enterprise, offer them cost saving or money making tech and charge for it. It can be built on top of your OSS, in fact this is a great way to get in touch with the companies... But don't rely on charity. In the companies I worked for paying for something you can get for free is simply not done, ever.


What this will do is get the gears moving on finding a good-enough alternative that is not a ticking time bomb.


While I'd love for making money from open source to work like this, you're right, it doesn't. This is essentially an appeal to charity, but the problem is that companies aren't good at donating to charity! If you're an engineer at a company, it's the path of least resistance to NOT pay for this, so that's 99% of users accounted for. Then even for the 1% who are happy to put the effort in, getting this through budgeting when there's so little up-side for the company is hard. It's not even like charitable donations which may be tax efficient and something the company can use for marketing purposes.

I'd suggest finding the features or support systems that only companies really care about and charging for them. Support, paid feature development, etc.


As much as I sympathise with this person and what he's doing, I must say I agree with you.

> This is essentially an appeal to charity.

...the problem is that it's not even very clearly an appeal to charity. It's sort of blurring a freemium opencore commercial model with charity.

Paying for the premium-tier of a freemium product is one possible message to put out there. An appeal to charity is quite another. They are different messages appealing to different motivations. But when combined, they sort of diminish each other's effectiveness as a possible sales message.

If I get into my charitable frame of mind, it produces cognitive dissonance to think that maybe this project doesn't need my charity if there are commercial users out there who can sustain the product by paying for the premium tier (as well they should if they make profitable use of the premium features).

If I get into my business purchaser frame of mind, it produces cognitive dissonance to hear the author talk of my purchasing decision as an act of charity. It makes me think that even the sales guy acknowledges that I won't be getting anything worth what I'm paying for here.

Not only that, but they also imply very different kinds of contracts, and as someone paying for this, I'd like to know which contract I'm getting into.

If it's a commercial contract, I expect some kind of warranty that everything will work, and some kind of support or right to my money back if it doesn't. That's just implied in a commercial deal of any kind. (And frequently that's the piece in an open core business model that you pay for when you pay for the premium tier). So if I pay, and I take my problem to the source, I don't then want to hear "Sorry, can't help you out, but I did say from the beginning that the money I took from you was more of a donation than a payment for a commercial deal of any kind, and it's kind of uncharitable of you to now expect me to fix your problem if it distracts me from building new features which, ostensibly, you were supposed to be supporting."


Agreed, and it reminds me of an old psych experiment: participants were asked to do a simple chore like make a hot drink (I forget the details). Those that were paid nothing did it in the same time as those paid a significant amount, while those paid only a few pennies took a lot longer. Even though a few pennies is strictly speaking more than nothing, it changed the nature of the action from a kind gesture to transactional.


the problem is that companies aren't good at donating to charity!

You hit the nail on the head right there.

I know a billion-dollar company that uses all kinds of "free for personal use, $$$ for commercial use" software, and pays exactly $0 for the software.

Even where I work, I've had to choose commercial software over open source solutions because I can't get any middle manager to understand that paying people for work they've already done for free is the right thing to do.

And don't even get me started on the whole "If it's not available at CDW, we don't need it" crap.


What is CDW? The IT company or something else?


And don't even get me started on the whole "If it's not available at CDW, we don't need it" crap.

That sentence turns my stomach.


It's refreshing to see that candid disclosure upfront.

IMHO, one of the most important qualities of an engineer is honesty.

I'd take the concern about sustainability into consideration, but being upfront about the need to make money from this is more reassuring than a lot of the fake-it-till-you-make-it that we see.


If you want to make a living with Free Software, and the software is primarily used by businesses, take a very close look at Red Hat's business model. They nailed it perfectly. They don't dual license their software, it's all Free Software. They don't ask for donations. They sell a package of software and support that is almost identical to what you get from commercial business software. The only difference is the software just happens to be Free (That's why CentOS was able to exist, they didn't violate any of Red Hat's copyrights).

I wish more open source developers understood this. Corporations love the business model and Red Hat makes tons of money, they turn around and add to and create more and more Free Software, and those of us that are not corporations with deep pockets can still use and benefit from the software.


I know what you're saying but it is regrettable. The problem lies with people who want stuff for absolutely nothing, even if it's valuable to their work. Short-termism at work.


This is not people explicitly wanting something for nothing. The issue is that in a corporation the incentives of the engineer and the person who controls budgets are at odds.

The bean counter won't really be rewarded (not directly at least) for the engineer and the engineer's team being successful, but they'll be definitely penalized for being haphazard with finances. Ergo, their incentive is to be a stingy bastard by default.

This then puts a high bar on anything that is a cost, which mostly penalizes low expenditures counterintuitively. A line item of $200 is basically not worth fighting for. Something that costs $20000 is generally easier to justify in terms of effort even just subconsciously. Ultimately both line items take asymptotically the same effort to push through, but the larger one appears (at first sight) much more important. It may be that the $200 item is more valuable in the end of course.


Open source is about control, not money savings.

I will never in a thousand years run mystery binaries tied to a particular version of operating system and hardware.


Did you design your own cpu?

If the answer is no, then you are running mystery binaries :)


If you wish to not run mystery binaries, you must first invent the universe.


Currently working for a financial company that pays for Anaconda.

Another paid for python hosting with Divio.

Whatever both of these are offering is at least worth it.

Financial institutions could be a good fit to pay licensed for Nuitka (enterprise pricing included).


Wikipedia is a fine counter example.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: