Atom

Why Atom?

Some of the most satisfying programs are little tools that save you from doing the same thing twice.

A quick script might end up reading a binary file or becoming something you share with a coworker. Atom exists so you can keep working in the language you started with.

Counting log entries by level
levels = ['info', 'warn', 'info']
totals = {}

for level in levels:
    seen = get(totals, level, 0)
    totals[level] = seen + 1

print(totals.info)  // 2

Change your mind as you go

Atom is dynamically typed so you can try an idea before settling on the shape of your data. Give a value a name, run the script, and see what happens. When a plain list grows into a collection of records, you can change it where you use it.

Keep a few tools close at hand

Once you know get, set, and count, you can use them with arrays and dictionaries. In the log example, get supplies a zero the first time a level shows up, so the loop needs no separate setup for new entries.

Common jobs like reading a file or parsing JSON already have a home in the standard library.

Pack the data that needs it

If you’re holding audio samples or passing a buffer to C, the size and order of each value matter. A packed array stores fixed-width values side by side. That can keep a large buffer compact and gives native code a layout it can work with.

A buffer of 16-bit audio samples
samples = create(i16, 480)
samples[0] = 1200
print(samples[0])  // 1200

Build an executable when it’s time

Run the source as you work. With a C toolchain installed, you can build the same program into a native executable to share. Native compilation can also help with code that spends a lot of time in a tight loop. The gain depends on what the program does.

Run it locally, then build it
atom run app.atom
atom build app.atom -o app