Skip to content

Atum246/dialect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dialect πŸ—£οΈ

A programming language that reads like English.

    ____  _       __     ____  __    ______   ________
   / __ \(_)___ _/ /_   / __ \/ /   / ____/  /  _/ __ \
  / / / / / __ `/ __/  / / / / /   / /       / // / / /
 / /_/ / / /_/ / /_   / /_/ / /___/ /___   _/ // /_/ /
/_____/_/\__,_/\__/  /_____/_____/\____/  /___/_____/

What is Dialect?

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()

Installation

# 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

Quick Start

# 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

Features

Core Language

  • βœ… Variables (set, the...is, fix for 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 (// and note:)
  • βœ… Modules and imports

Standard Library

  • πŸ“ 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

Developer Tools

  • πŸ–₯️ Interactive REPL with history
  • πŸ› οΈ CLI tool with run, repl, check, new, version
  • βœ… File extension: .dl
  • πŸ“ Beautiful error messages

Syntax Reference

Variables

set name to "John"           // variable
the score is 100             // variable (alternate)
fix pi to 3.14159            // constant
set name to "Jane"           // reassign

Data Types

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

Control Flow

// 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

Functions

to greet(name) do
    say "Hello, " + name
done

to add(a, b) do
    give back a + b
done

set result to add(10, 20)

Classes

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

Error Handling

be careful when:
    // risky code
if something fails as error:
    say "Error: " + error
done

File I/O

write "data" to "file.txt"
append "more" to "file.txt"
read from "file.txt" into content

JSON

set data to json_parse('{"name": "John"}')
say data["name"]
say json_stringify(data)

Examples

Check the examples/ directory:

  • hello.dl β€” Hello World
  • conditions.dl β€” Control flow
  • functions.dl β€” Functions and recursion
  • collections.dl β€” Lists, maps, and data
  • oop.dl β€” Object-oriented programming
  • errors.dl β€” Error handling
  • fileio.dl β€” File operations
  • demo.dl β€” Complete feature showcase

File Extension

Dialect files use the .dl extension.

License

MIT


Dialect β€” Code that reads like English. πŸ—£οΈ

Releases

No releases published

Packages

 
 
 

Contributors