A modern, dynamically-typed programming language implemented in Go that combines simplicity with powerful features for building APIs, web clients, and data processing applications.
- Dynamic Typing - Flexible type system
- First-Class Functions - Functions as values, closures, higher-order functions
- Object-Oriented - Classes with methods, properties, and inheritance via
this - Object Literals - Create objects with
{key: value}syntax - String Interpolation - Embed expressions in strings with
${expr} - Compound Assignment -
+=,-=,*=,/=operators - Increment/Decrement -
++,--operators - Ternary Operator -
condition ? true : false - Control Flow - if/else, while, for loops
- Arrays/Lists - Dynamic arrays with indexing and nested structures
- Escape Sequences - Support for
\n,\t,\r,\\,\",\'in strings - Lexical Scoping - Block-level scope with proper closure support
- HTTP Client - Full support for GET, POST, PUT, DELETE requests
- Structured Responses - Access status codes, headers, and body separately
- Custom Headers - Send custom headers with requests
- JSON Integration - Seamless JSON parsing and serialization
var response = httpGet("https://api.example.com/users/1");
var data = jsonParse(response.body);
print data.name;
var json = jsonStringify(object);
var prettyJson = jsonStringifyPretty(object);
var parsed = jsonParse(jsonString);
fileWrite("data.txt", "Hello, Lango!");
var content = fileRead("data.txt");
fileAppend("data.txt", " More text.");
var exists = fileExists("data.txt");
fileDelete("data.txt");
fileCopy("source.txt", "dest.txt");
var files = fileList(".");
strLen(str) // Length
strUpper(str) // Uppercase
strLower(str) // Lowercase
strSplit(str, delim) // Split to array
strJoin(array, delim) // Join from array
strContains(str, substr) // Contains check
strReplace(str, old, new)// Replace all
strTrim(str) // Trim whitespace
arrayLen(arr) // Length
arrayPush(arr, item) // Add item
arrayPop(arr) // Get last item
arraySlice(arr, start, end) // Slice
arrayConcat(arr1, arr2) // Concatenate
mathFloor(num) // Round down
mathCeil(num) // Round up
mathRound(num) // Round nearest
mathAbs(num) // Absolute value
mathMax(a, b) // Maximum
mathMin(a, b) // Minimum
mathPow(base, exp) // Power
mathSqrt(num) // Square root
mathRandom() // Random 0-1
toNumber(value) // Convert to number
toString(value) // Convert to string
toBoolean(value) // Convert to boolean
time() // Unix timestamp
sleep(milliseconds) // Sleep
- Clone the repository
git clone https://github.com/yourusername/Lango.git
cd Lango- Build the interpreter
go buildREPL Mode:
./Lango # Linux/macOS
.\Lango.exe # WindowsScript File:
./Lango script.lango # Linux/macOS
.\Lango.exe script.lango # Windows// Variables and types
var name = "Lango";
var version = 1.0;
var isAwesome = true;
// Functions
fun greet(name) {
return "Hello, " + name + "!";
}
print greet("World");
// Classes
class Counter {
init(start) {
this.value = start;
}
increment() {
this.value = this.value + 1;
}
}
var counter = Counter();
counter.init(0);
counter.increment();
print counter.value; // Output: 1
// Fetch user data from API
var response = httpGet("https://jsonplaceholder.typicode.com/users/1");
if (response.status == 200) {
var user = jsonParse(response.body);
print "Name: " + user.name;
print "Email: " + user.email;
print "City: " + user.address.city;
// Save to file
fileWrite("user.json", jsonStringifyPretty(user));
print "Saved to user.json";
}
// Process CSV data
var csv = "John,25,NYC,Jane,30,LA,Bob,35,SF";
var parts = strSplit(csv, ",");
var users = [];
for (var i = 0; i < arrayLen(parts); i = i + 3) {
var name = parts[i];
var age = toNumber(parts[i + 1]);
var city = parts[i + 2];
print name + " is " + toString(age) + " years old from " + city;
}
// Read, process, and save data
var data = fileRead("input.txt");
var lines = strSplit(data, "\n");
var output = "Processed Data:\n";
for (var i = 0; i < arrayLen(lines); i = i + 1) {
var line = strTrim(lines[i]);
if (strLen(line) > 0) {
output = output + strUpper(line) + "\n";
}
}
fileWrite("output.txt", output);
var x = 10;
var name = "Lango";
var flag = true;
var nothing = nil;
if (x > 5) {
print "Greater";
} else {
print "Smaller";
}
while (x > 0) {
print x;
x = x - 1;
}
for (var i = 0; i < 10; i = i + 1) {
print i;
}
fun makeCounter() {
var count = 0;
fun increment() {
count = count + 1;
return count;
}
return increment;
}
var counter = makeCounter();
print counter(); // 1
print counter(); // 2
class Person {
setName(name) {
this.name = name;
}
greet() {
print "Hi, I'm " + this.name;
}
}
var person = Person();
person.setName("Alice");
person.greet();
var numbers = [1, 2, 3, 4, 5];
print numbers[0]; // 1
numbers[1] = 10; // Modify
var nested = [[1, 2], [3, 4]];
print nested[0][1]; // 2
// Create objects with literal syntax
var person = {name: "Alice", age: 30, city: "NYC"};
print person.name; // Alice
person.age = 31; // Modify property
// Nested objects
var config = {server: {host: "localhost", port: 8080}};
print config.server.host; // localhost
// Mixed values
var data = {str: "hello", num: 42, arr: [1, 2, 3]};
print "Line 1\nLine 2"; // Newline
print "Tab\there"; // Tab
print "Quote: \"hi\""; // Escaped quotes
print "Back\\slash"; // Backslash
var multiline = "First\n\tIndented\nLast";
// String Interpolation
var name = "User";
print "Hello ${name}";
// Compound Assignment
var x = 10;
x += 5; // 15
// Increment/Decrement
x++; // 16
// Ternary Operator
var status = x > 10 ? "High" : "Low";
- REST API Clients - Build clients to consume REST APIs
- Web Scraping - Fetch and process web data
- Data Processing - Transform and analyze data
- File Automation - Automate file operations
- Configuration Management - Generate and manage config files
- System Scripting - Quick automation scripts
- FEATURES.md - Comprehensive feature documentation
- examples/ - Example scripts demonstrating all features
api_example.lango- HTTP requests and JSON handlingfile_example.lango- File I/O operationsstdlib_example.lango- Standard library functionscomplete_api_demo.lango- Complete API client demo
Lango is a tree-walking interpreter written in Go:
scanner.go- Lexical analysis (tokenization)parser.go- Syntax analysis (builds AST)interpreter.go- Tree-walking interpreternetwork.go- HTTP client implementationjson.go- JSON parsing and serializationfileio.go- File system operationsstdlib.go- Standard library functionsenvironment.go- Variable scopes and environmentsexpr.go,stmt.go- AST node definitions
All networking, file I/O, and standard library functions are implemented as native Go functions, providing:
- Fast execution (near-native performance for I/O)
- Efficient memory usage
- Reliable error handling
- Thread-safe operations
Requirements:
- Go 1.23.3 or later
Build:
go mod init Lango # First time only
go buildRun tests:
./Lango ./build/test_script.langoContributions are welcome! Areas for improvement:
- Add escape sequence support to scanner (β Completed)
- Implement object literal syntax
{key: value}(β Completed) - Add async/await for non-blocking operations
- WebSocket support
- Database drivers (SQL, MongoDB)
- Regular expression support
- HTTP server capabilities
- Module/package system
MIT License - see LICENSE file for details
Built following principles from "Crafting Interpreters" by Robert Nystrom.
- Simple Syntax - Easy to learn and read
- Powerful Features - Networking, JSON, File I/O built-in
- Go Performance - Fast execution with native Go functions
- Practical - Designed for real-world scripting tasks
- Extensible - Easy to add new built-in functions
Made with β€οΈ using Go
