Dewy
An Everyday Language
Dewy is a language for clear, expressive computation—useful for anything from ordinary programming to complex engineering, science, and mathematics, and everything in between.
curl -fsSL https://dewy-lang.org/install.sh | bash
Quick start install for x86_64 Linux — or try µDewy in your browser.
text = "café 👨👩👧👦 🍀"
loop i in 0.. and c in text
if c not =? ' ' {
printl"{i}: {c}"
sleep(300ms)
}
0: c
1: a
2: f
3: é
5: 👨👩👧👦
7: 🍀
Dewy is in early development. The compiler is currently hosted in Python, and the browser playground only runs µDewy, Dewy’s small bootstrap language. See the roadmap and status.
Key Features
Capabilities at the heart of Dewy’s design, labeled by what the compiler supports today.
1# Units are values. Juxtaposition multiplies.
2mass = 10kg
3velocity = 30m/s
4energy = 1/2 * mass * velocity^2 # 4500 J
5
6force = 1000kg * 9.8(m/s^2) # 9800 N
7work = 20N * 10m * cos(45°) # 141.42 J
Physical units, built in
Dewy treats kilograms, meters, and seconds as part of the language, not a library. Juxtaposing a number with a unit multiplies them, dimensions carry through arithmetic, and mismatched dimensions are errors—so 20N * 10m is joules and 3m + 5s doesn’t compile.
1# Bounds are visible: [ ] includes, ( ) excludes.
2window = [0..10) # 0 1 ... 9
3evens = 0,2..100 # step inferred from the pair
4
516 in? (5..15] # false
6samples[end-3..] # the last four samples
7full_string[3..12) # slices use the same syntax
Ranges with clear bounds
Brackets say exactly which endpoints belong to a range, a second anchor sets the step—including negative steps—and the same bound forms drive loops and string slicing.
1ratings = [
2 'star wars' -> 73
3 'star trek' -> 89
4 'legend of the galactic heroes' -> 100
5]
6
7# One keyword covers while, for, and beyond.
8loop [show rating] in ratings
9 printl'I give {show} a {rating} out of 100'
10
11# Iterators compose logically.
12loop i in 0.. and letter in 'Dewy' consume(i letter)
One loop to rule them all
There is no for / while / do-while zoo—loop takes any condition. The in operator assigns the next value and reports whether one existed, so iterators can combine with and or or in a single loop.
1# Types can carry liquid refinement conditions.
2Positive = int< i=>i>?0 >
3NonEmptyArray = array< length>?0 >
4
5score:Positive = 42
6values:NonEmptyArray<int> = [3 5 8]
7
8# Proven facts can remove checks and guide layout.
9first = values[0]
Types that carry useful facts
Dewy’s liquid refinement system lets types state relationships such as “positive integer” or “non-empty array.” The compiler proves conditions from literals and ordinary control flow — a guard, a store, an iteration — then reuses those facts for safety, bounds-check elimination, and integer-width selection, so values[0] needs no runtime check.
1# `&` combines implementations into one overload set.
2format = ((value:int64):>string => "integer: {value}")
3 & ((value:string):>string => "text: {value}")
4
5printl(format(42)) # integer: 42
6printl(format("Dewy")) # text: Dewy
Functions are ordinary values
Function literals are expressions like any other: pass them, store them, and combine them. The & operator merges two implementations into one overload set, and each call selects the implementation whose parameter type matches the argument.
1counter = (start=0) => [
2 value = start
3 increment = () => (value += 1)
4]
5
6# make a new counter object
7count = counter(40)
8
9# called on access
10count.increment
11count.increment
12
13printl"count is {count.value}"
Objects, blocks, and functions are one thing
Dewy’s syntax is deliberately unified: functions can construct structural objects, members can capture their siblings, and accessing a zero-argument function member calls it. Fields and behavior live together without separate class machinery.