A programming language that reads like English.
____ _ __ ____ __ ______ ________
/ __ \(_)___ _/ /_ / __ \/ / / ____/ / _/ __ \
/ / / / / __ `/ __/ / / / / / / / / // / / /
/ /_/ / / /_/ / /_ / /_/ / /___/ /___ _/ // /_/ /
/_____/_/\__,_/\__/ /_____/_____/\____/ /___/_____/
Dialect is a fully-featured interpreted programming language designed to read like natural English. No cryptic syntax. No memorizing symbols. Just write what you mean.
// Variables
set name to "John"
the age is 25
// Output
say "Hello, " + name + "!"
// Conditions
if age > 18, then
say "You're an adult! π"
otherwise
say "You're a minor"
done
// Loops
for each fruit in ["apple", "banana", "cherry"]
say "I love " + fruit + "!"
done
// Functions
to greet(person) do
say "Hello, " + person + "! π"
done
greet("World")
// Classes
a Dog is defined as:
has: name, breed
to init(name, breed) do
set this.name to name
set this.breed to breed
done
to speak() do
say this.name + " says Woof! π"
done
done
set rex to new Dog("Rex", "Husky")
rex.speak()
# Clone and set up
git clone https://github.com/dialect-lang/dialect.git
cd dialect
ln -sf $(pwd)/bin/dialect /usr/local/bin/dialect
# Verify
dialect version# Run a file
dialect hello.dl
# Start the REPL
dialect repl
# Create a new project
dialect new myproject
# Check a file for errors
dialect check program.dl- β
Variables (
set,the...is,fixfor constants) - β All data types (numbers, text, booleans, lists, maps, nothing)
- β
Control flow (
if/otherwise,while,for each,repeat) - β Functions with parameters and return values
- β Full OOP (classes, inheritance, methods, properties)
- β
Error handling (
be careful when...if something fails) - β
String interpolation (
"Hello, {name}") - β
Comments (
//andnote:) - β Modules and imports
- π Text β
upper,lower,trim,split,join,replace,find,contains,format - π Lists β
add,sort,reverse,map,filter,find,flatten,unique,sum,range - πΊοΈ Maps β
keys,values,has_key,merge - π’ Math β
abs,round,ceil,floor,sqrt,pow,sin,cos,tan,log,random - π Files β
read_file,write_file,append_file,file_exists,list_files,delete_file - π HTTP β
http_get,http_post,http_put,http_delete - π JSON β
json_parse,json_stringify - βοΈ System β
run_command,current_time,sleep,get_environment,system_info
- π₯οΈ Interactive REPL with history
- π οΈ CLI tool with
run,repl,check,new,version - β
File extension:
.dl - π Beautiful error messages
set name to "John" // variable
the score is 100 // variable (alternate)
fix pi to 3.14159 // constant
set name to "Jane" // reassign
set num to 42 // number
set text to "hello" // text
set flag to true // boolean (true/false/yes/no)
set empty to nothing // nothing (null)
set list to [1, 2, 3] // list
set map to {"key": "value"} // map
// If/Otherwise
if condition, then
// ...
otherwise if other_condition
// ...
otherwise
// ...
done
// While
while condition
// ...
done
// For Each
for each item in list
// ...
done
// Repeat
repeat 5 times
// ...
done
to greet(name) do
say "Hello, " + name
done
to add(a, b) do
give back a + b
done
set result to add(10, 20)
a Animal is defined as:
has: name, sound
to init(name, sound) do
set this.name to name
set this.sound to sound
done
to speak() do
say this.name + " says " + this.sound
done
done
a Dog inherits from Animal:
to fetch() do
say this.name + " fetches the ball!"
done
done
be careful when:
// risky code
if something fails as error:
say "Error: " + error
done
write "data" to "file.txt"
append "more" to "file.txt"
read from "file.txt" into content
set data to json_parse('{"name": "John"}')
say data["name"]
say json_stringify(data)
Check the examples/ directory:
hello.dlβ Hello Worldconditions.dlβ Control flowfunctions.dlβ Functions and recursioncollections.dlβ Lists, maps, and dataoop.dlβ Object-oriented programmingerrors.dlβ Error handlingfileio.dlβ File operationsdemo.dlβ Complete feature showcase
Dialect files use the .dl extension.
MIT
Dialect β Code that reads like English. π£οΈ