Pseudoc – compile pseudocode (or any other code) to native executables using AI

4 hours ago 3

pseudoc lets you compile pseudocode into blazingly fast (🔥) native executables using AI 🚀

Compiling pseudocode example

pseudoc works by sending your pseudocode to a large language model, telling it to translate it into a Go program. After that, an embedded Go compiler is used to compile it down to a self-contained native executable!

pseudoc combines two technologies that should probably not be combined: AI & Compilers. This allows for many innovative features not seen in any other compilers:

Non-reproducible builds 🎲

Since LLMs are unpredictable, you get completely different results every time 🔥

$ ./pseudoc -o main1 samples/http_server.psc $ ./pseudoc -o main2 samples/http_server.psc $ md5sum main1 main2 2262e29a66a3b19dcf60322401c182d8 main1 2546d0415080b70347766e8ea5d0cdf4 main2

Mandatory internet access 🌐

To compile your program, you need access to the internet! Not to mention you also get to pay credits every time you compile any program.

Note

This feature can optionally be disabled by self-hosting your own LLM.

Drop-in replacement compiler for any language 🔥

Since any code can be considered as being pseudocode, pseudoc is technically a compiler for all languages in the world!

For example, pseudoc makes Python programs over 40x faster! 🔥👇

# samples/primes.py contains a simple prime counting program $ time python samples/primes.py Counted 664579 primes up to 10000000 real 1m55.709s user 1m55.173s sys 0m0.007s $ ./pseudoc -o primes samples/primes.py && time ./primes Counted 664579 primes up to 10000000 real 0m2.567s user 0m2.551s sys 0m0.003s

You can get precompiled executables of pseudoc from the Releases. Alternatively, compile it yourself:

go mod tidy go generate ./src go build -o pseudoc ./src ./pseudoc --version

The environment variables OPENAI_URL and OPENAI_API_KEY must be set to any OpenAI Chat Completions API compatible endpoint. The OPENAI_MODEL variable must also be set to the LLM you want to use. Select a model that supports reasoning for best accuracy. You can use a .env file (see .env.example for a template).

Compile a program:

./pseudoc -o server samples/http_server.psc

Output intermediate representation instead of executable:

./pseudoc -S -o server.go samples/http_server.psc

Good luck and Godspeed.

Read Entire Article