2025-11-24 05:47:03 +00:00
# Waddle Programming Language
## Overview
Waddle is a modern, expressive programming language designed to be intuitive, readable, and powerful. It combines elements of object-oriented and functional programming with a focus on clarity and developer productivity.
## Key Features
### Language Characteristics
- Strong, static typing
- Object-oriented with interface support
- Functional programming constructs
- Explicit error handling
- Concise syntax
### Core Design Principles
- Readability first
- Explicit over implicit
- Minimal cognitive overhead
- Flexible type system
## Basic Syntax
### Type Declaration
2025-11-24 06:07:09 +00:00
#### Basic type definition
2025-11-24 05:47:03 +00:00
```waddle
Animal {
// Type implementation
}
2025-11-24 06:07:09 +00:00
```
#### Inheritance
```waddle
2025-11-24 05:47:03 +00:00
Animal/Dog {
// Dog-specific implementations
}
2025-11-24 06:07:09 +00:00
```
2025-11-24 05:47:03 +00:00
2025-11-24 06:07:09 +00:00
#### Interface definition
```waddle
2025-11-24 05:47:03 +00:00
@Mammal {
// Interface methods
}
2025-11-24 06:07:09 +00:00
```
2025-11-24 05:47:03 +00:00
2025-11-24 06:07:09 +00:00
#### Interface implementation
```waddle
2025-11-24 05:47:03 +00:00
Animal/Dog -> [Mammal, Domesticated] {
// Multiple interface support
}
```
2025-11-26 20:26:17 +00:00
### Variables
Variables are always Protected scoped.
There is no way to make them Public or Private.
This is by design.
#### Variable Declaration
##### Declare Now, Set later
```waddle
Integer num;
fn on_create(Integer my_num) -> [None] {
my.num.set(my_num);
}
```
##### Declare and Set at same time
```waddle
Integer num.set(1000);
```
2025-11-24 05:47:03 +00:00
### Functions
2025-11-24 06:07:09 +00:00
#### Function declaration
2025-11-25 04:31:34 +00:00
##### Public function (+fn)
2025-11-24 05:47:03 +00:00
```waddle
2025-11-25 04:31:34 +00:00
+fn calculateArea(Integer width, Integer height) -> [Integer] {
2025-11-24 05:47:03 +00:00
rtn width.multiply(height);
}
2025-11-24 06:07:09 +00:00
```
2025-11-24 05:47:03 +00:00
2025-11-25 04:31:34 +00:00
##### Protected Function (fn)
2025-11-24 06:07:09 +00:00
```waddle
2025-11-25 04:31:34 +00:00
fn calculateArea(Integer width, Integer height) -> [Integer] {
2025-11-24 05:47:03 +00:00
rtn width.multiply(height);
}
2025-11-24 06:07:09 +00:00
```
2025-11-24 05:47:03 +00:00
2025-11-25 04:31:34 +00:00
##### Private Function (-fn)
2025-11-24 06:07:09 +00:00
```waddle
2025-11-25 04:31:34 +00:00
-fn calculateArea(Integer width, Integer height) -> [Integer] {
rtn width.multiply(height);
}
```
#### Default Values
```waddle
fn calculateArea(Integer width.default(0), Integer height.default(0)) -> [Integer] {
2025-11-24 05:47:03 +00:00
rtn width.multiply(height);
}
2025-11-24 06:07:09 +00:00
```
2025-11-24 05:47:03 +00:00
2025-11-24 06:07:09 +00:00
##### Lambda expression
```waddle
2025-11-25 04:31:34 +00:00
areaCalculator = fn(Integer width, Integer height) -> [Integer] {
2025-11-24 05:47:03 +00:00
rtn width.multiply(height);
}
```
2025-11-25 04:31:34 +00:00
#### Concurrency Function (async)
```waddle
+proc fetchData(String url) -> [String] {
rtn my.network.get(url);
}
proc fetchData(String url) -> [String] {
rtn my.network.get(url);
}
-proc fetchData(String url) -> [String] {
rtn my.network.get(url);
}
```
2025-11-24 05:47:03 +00:00
### Error Handling
2025-11-25 04:31:34 +00:00
#### Try/Catch (attempt->[ok, error])
2025-11-24 05:47:03 +00:00
```waddle
result = riskyOperation().attempt {
ok {
// Successful execution
my.output.print("Operation successful");
}
ValueError {
// Handle specific value errors
my.logger.log(error.getMessage());
}
error {
// Catch-all error handling
my.criticalLogger.alert("Unexpected error");
}
}
2025-11-25 04:31:34 +00:00
```
#### Custom error type declaration
```waddle
MathError {
message: String;
errorCode: Integer;
}
```
#### Function with explicit error handling
```waddle
+fn divide(Integer a, Integer b) -> [Decimal] fails with MathError {
if (b.eq(0)) {
my.error.fail(MathError("Division by zero", 1));
}
rtn a.divide(b);
}
```
### Resource Management / Context Management
```waddle
using DatabaseConnection db.set(connectionString) {
db.execute(query);
}
2025-11-24 05:47:03 +00:00
```
### Iteration
2025-11-24 06:07:09 +00:00
#### Forward iteration
2025-11-24 05:47:03 +00:00
```waddle
loop(i, 0->10) {
my.output.print(i);
}
2025-11-24 06:07:09 +00:00
```
2025-11-24 05:47:03 +00:00
2025-11-24 06:07:09 +00:00
#### Foward iteration, with step
```waddle
2025-11-24 05:47:03 +00:00
loop(i, 0->10, 2) {
my.output.print(i); // outputs 0, 2, 4, 6, 8, 10
}
2025-11-24 06:07:09 +00:00
```
2025-11-24 05:47:03 +00:00
2025-11-24 06:07:09 +00:00
#### Reverse iteration
```waddle
2025-11-24 05:47:03 +00:00
rloop(i, 10->0) {
my.output.print(i);
}
2025-11-24 06:07:09 +00:00
```
2025-11-24 05:47:03 +00:00
2025-11-24 06:07:09 +00:00
#### Reverse iteration, with step
```waddle
2025-11-24 05:47:03 +00:00
rloop(i, 10->0, 2) {
my.output.print(i); // outputs 10, 8, 6, 4, 2, 0
}
2025-11-24 06:07:09 +00:00
```
#### Foreach loop on arrays
```waddle
Integer< > nums.set(< 1 , 2 , 3 , 4 > );
nums.each(
i -> {
if(i.mod(2).eq(0)){
my.output.print(i); // outputs 2, 4
}
}
);
2025-11-24 05:47:03 +00:00
```
2025-11-25 04:31:34 +00:00
### Boolean Expressions
#### Explicit Boolean Checks
```waddle
result = Boolean.and(
my.age.gt(18),
my.status.is(Verified)
);
```
#### Object Method Boolean Checks
```waddle
if(my.age.gt(18).and(my.status.is(Verified))){
2025-11-26 20:26:17 +00:00
// Pass check
2025-11-25 04:31:34 +00:00
}
```
### Explicit Type Conversion
```waddle
String myString.set(my.number.set(42).as(String));
```
2025-11-24 05:47:03 +00:00
## Type System
### Primitive Types
- `String`
- `Integer`
- `Decimal`
- `Boolean`
### Advanced Types
- Arrays: `Type<>`
- Custom types
- Interface types
## Unique Language Constructs
### Dot Notation Methods
- All objects have built-in methods
- Chainable method calls
- Explicit operations
```waddle
my.text.set("Hello")
.concat(" World")
.length();
```
### Object Lifecycle
- Explicit constructors: `on_create`
- Explicit destructors: `on_destroy`
### Planned Features
- Enhanced concurrency support
- Expanded standard library
- Advanced module system
## Installation
_Detailed installation instructions will be added as the language develops_
## Contribution
Interested in contributing to Waddle?
- Report issues on this repository
- Submit pull requests
- Provide feedback and suggestions
## License
Read the LICENSE.md file
## Current Status
Waddle is currently in active development.
The language specification and implementation are evolving.