Do I still hate Javascript? And yes, Deno is still Javascript don’t let anyone fool ya.

I dont care about edge

… I just need zero dependency binary executables. So, let’s mistake ourselves to create a Hello World binary executable for Windows with 🌈 Deno 🌈.

I am just following the basic getting started stuff from the Deno site. Don’t expect to learn something new here.

With high hopes I begin….

🔗 https://deno.land/manual@v1.34.3/getting_started/installation

Using Windows 10 here. So, will install with chocolatey:

choco install deno

By the way, Deno using Docker is super easy to use as well: https://github.com/denoland/deno_docker#run-locally

After installtion, first step:

Created a file:

first_steps.ts

console.log("Welcome to Deno!");

Then I ran it with:

deno run .\first_steps.ts

And it works. 🌈

Now, does it work with deno compile? Yes, yes it does. The exe file size is only 75 megabyte…. SEVENTY FIVE MEGABYTES! And there goes this entire experiment. :/

Okay let’s try this “experiment” with Nim

…the best ever programming language that nobody uses.

Using Chocolatey again because adding stuff to PATH on Windows is annoying.

🔗 https://community.chocolatey.org/packages/nim

This install MINGW. I should have started this experiment with a Docker Ubuntu container….. But we are in too deep now.

So, compiling this stupid helloworld program:

echo "Hello World!"

With:

nim c -r helloworld.nim

And guess the size. It is only, 175 KB! Geez! And it works on Windows as is! What kind of magic is this!!

But nobody even heard of Nim. Everyone uses Go

Okay time for Go. Using chocolatey.

With Go I have start with creating a Module first. That deducts one point already. With Nim you don’t need that.

go mod init example/hello

Then, stupid hello.go

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Then building that:

go build .

The executable is about 2 MB. So still behind Nim.

And finally freaking, Rust

…because all the cool kids use it!

We are going to not use Chocolatey this time. Rust has it’s own weird installation ritual process on Windows. Because you need Visual Studio to download some C compiler or something.

fn main() {
    println!("Hello, World!");
}

Building the binary:

rustc hello.rs

And the executable’s size is 159 KB.

Then finally Python

… because why not? Using Pyinstaller here.

🔗 https://pyinstaller.org/en/stable/usage.html

print("How is this thing still going?")

Build command:

pyinstaller .\goodbye.py

Ahhhh…. where is the executable. There is a bunch of files on two directories. The goal is to create single file zero dependency executable not this mess.

Let’s try with --onefile:

pyinstaller --onefile .\goodbye.py

Now, we have what we needed. The executable size is 6.7 MB which is:

stupid meme about Python being not great

TLDR

Not using Deno, duh. So, the stats for Singlefile Binary Executables With Zero Dependency for Windows or as I like to call it, SBEWZDW

Rank Language Size
🦀 Rust 159 KB
👑 Nim 175 KB
🐀 Go 1,925 KB
🐍 Python (With Pyinstaller) 6,784 KB
🐱‍🐉 Deno 75,099 KB

Even though you can say, Deno isn’t made to for making SBEWZDW. But having a native compile command says something else. Python doesn’t have anything, even with non-built-in library it was able to create an executable with a smaller footprint. So, I am skipping Deno for now.


Followup: Rust executable file size

Commands I ran to build the executable:

command size
rustc main.rs 159 KB
cargo build --release 156 KB
rustc -C debuginfo=0 -C opt-level=3 156 KB

Version info:

  • RustC version: rustc 1.70.0 (90c541806 2023-05-31)
  • Cargo version: cargo 1.70.0 (ec8a8a0ca 2023-04-25)

I am using Windows 10. I installed Rust with Rustup and Visual Studio C++ distribution.

My code, standard boilerplate created with cargo new

fn main() {
    println!("Hello, world!");
}

I decompiled the executable using this site: https://dogbolt.org/. The Hex-Rays version ran for me but not the other ones.

Here is the C++ code if you want to check it out:

https://gist.github.com/anyfactor/5ad2fd078c4ad6a9e49783cf6aed33c8