Skip to main content

Examples

A collection of real VIBEX programs. All of these compile. Most of them work.

Hello, World​

Please print "Hello, World!" to the screen.
Thank you.

The only program that compiles correctly 100% of the time.


FizzBuzz​

You know FizzBuzz right? Just do that.
1 to 100.
You know the rules.

trust me bro.

Fibonacci​

Print the first 10 Fibonacci numbers.

I don't remember if it starts with 0 or 1.
Just pick one, it's fine.

OPTIMIZE: chill

Sort​

Sort a list of numbers from stdin.

Please don't use bubble sort.
I'm serious.
I will know.

Use something that sounds impressive at standup.

trust me bro.
OPTIMIZE: grindset

Recursion​

Calculate factorial using recursion.

Make it recursive because my interviewer
specifically asked for recursion and I said yes
without knowing what recursion is.

Please add a base case.
I don't know what a base case is but my
program crashed last time without one.

# if this causes a stack overflow
# that's the computer's fault, not mine

Memory Management​

Allocate some memory.
Use it for something.
Free it.

Actually wait, free it before using it.
No wait that's wrong.

You know what, just don't free it.
The OS will handle it when the program exits.
I read that somewhere.

# TODO: fix this before code review

Security​

Hash the user's password before storing it.

Use a good algorithm.
Not MD5. My friend said MD5 is bad.
I don't know what's good. Something with numbers in the name.
SHA-something? The big number SHA.

Salt it too. I think that's a thing.
Just sprinkle some salt on it.

Also store the salt next to the password in plaintext.
How else would we find it later?

OPTIMIZE: chill
# security review: pending (since 2019)

Exit​

Exit the program cleanly.

Return exit code 0 to indicate success.

Actually return 0 regardless of whether
anything succeeded.

CI/CD is watching.

The Philosopher​

# This program took me 3 days to write
# I still don't know what it does
# It works on my machine
# Do not touch
# Seriously
# I will cry
# Last modified: 3 years ago
# Author: left the company

Do the thing.

trust me bro.
OPTIMIZE: vibes only