Live data from Hacker News

Making a Python interpreter in 1024 bytes

austinhenley.com

91–100 of 120 posts

Re: Making a Python interpreter in 1024 bytes

#91
post #24

The code makes me smile, because it's nasty . This isn't like C4, a tiny but complete C compiler which does error checking on its subset. Instead, this is worse than Sector C, which takes every shortcut and just plain assumes everything in the source is right. This "Python" just plain assumes for keywords: Any "f" is a "for [x] in range[y]" (exactly that, no other for's). Any "w" is a "while". Any "i" is an "if". Any…

It looks very much like some techniques used when minifying JavaScript.

Re: Making a Python interpreter in 1024 bytes

#92

But to be honest, I wonder what is the smallest interpretable and practical Turing Complete VM? I would argue that implementing a brainfuck that we lower Python interpreter to, or even say like an interpreter untyped lambda calculus or SKI combinator would be very useful, especially for the hardware bootstrapping. I'm talking about things like SectorLisp https://justine.lol/sectorlisp/

I think we would need to balance practicability and code size since they tend to be mutually exclusive. Generally speaking, code size is not an important metric to make useful code, and usefulness is usually not the main point of code golf exercises such as this one.

The exception to this is obviously embedded systems with very low amounts of resources where C and assembly are practically unrivaled.

Re: Making a Python interpreter in 1024 bytes

#97
post #84
post #67

Earlier quoted context omitted.

As they say in TDD, write a test, then write the simplest code that will make it pass. Clearly supporting multiple functions starting with 'p' would be overengineering.

By that standard, this is totally over-engineered. Just hardcode it.

Good idea. Write a python script, and then code the minimal c interpreter possible to make that specific script work, utilizing the script itself as string reference (and any other way one can manage to utilize it in the interpreter itself).

Re: Making a Python interpreter in 1024 bytes

#99
More interesting idea was to make compiler for some subset of Python bytecode. But Antigravity said this idea suxs, for some complex reasons. If the target is ATtiny, makes more sense to ask the AI translate Python to C++, which approach works amazingly well indeed.

Re: Making a Python interpreter in 1024 bytes

#100

But to be honest, I wonder what is the smallest interpretable and practical Turing Complete VM? I would argue that implementing a brainfuck that we lower Python interpreter to, or even say like an interpreter untyped lambda calculus or SKI combinator would be very useful, especially for the hardware bootstrapping. I'm talking about things like SectorLisp https://justine.lol/sectorlisp/

A single machine code instruction is sufficient: https://en.wikipedia.org/w/index.php?title=One-instruction_s...>
Post reply on HN