Skip to content

Commit

Permalink
Scratching new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
OJarrisonn committed May 27, 2024
1 parent a19ec45 commit 0e770a5
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 57 deletions.
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
# Aura

Aura is a programming language for application development.
Aura tries to bring functional programming and OOP features together to create high-level applications.
Aura is a functional parallelizable multitarget programming language. It means it's meant to be functional first, be easy to run in multicore and in multiple platforms by transpiling to other languages.

Aura also uses lazyzess and multi-threading to improve performance of applications. Every value in Aura is lazily copied, it means, just the necessary parts are actually copied when modified. Also, pure and independent code execution is delegated to parallel threads.
## Features

### Immutability

There are no variables in Aura, you may give aliases to values, and that's it.

### Lazyness

Computations are not done until it's absolutely required. This may increase memory usage, but gives Aura superpowers.

### Functional

Aura implements several functional programming features such as:

- Functions as values
- Purity and side-effect management
- Pattern matching

### Type Safe

Aura uses a dynamic type system that ensures operations validity is checked during compile time

### Static vs Dynamic*

Aura atempts to make several compile time operations available in runtime while enforcing proper compile time treatment
50 changes: 20 additions & 30 deletions examples/car.aura
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
decl static Category = union {
SUV,
Hatch,
Sedan,
Sport
};
type Category enum (:suv :hatch :sedan :sport)

decl static Car = cons object {
name: String,
value: Int,
read category: Category
} impl {
new = (name: String, value: Int, category: Category) -> Self {
// Casts a compound into a Car
Self <$ (name, value, category)
};

adulterate = @self (value: Int) self.value = value;

is_suv = &self void -> Bool {
match self.category {
Category::SUV ~> true,
_ ~> false
}
}
} impl #eq<Self> {
eq = &self (other: &Self) -> bool {
self.name == other.name
&& self.value == other.value
&& self.category == other.category
type Car obj (
String .name
Int .value
Category .category
) impl (
::new (String name Int value Category category) -> Self obj (name value category)

:adulterate (Int value) -> Self obj (self.name value self.category)

:is_suv () -> Bool match self {
Category:suv => true
_ => false
}
}
) impl #eq<Self Self> (
:eq (Self other) -> Bool :(
self.name == other.name &&
self.value == other.value &&
self.category == other.category
)
)
21 changes: 10 additions & 11 deletions examples/cli_app.aura
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
Args = object {
filename: String,
output: ?String,
age: Int
};
use aura/io

main = (args: Args) -> {
println(`The filename is ${args.filename}, ${
when (args.output)
null => "no output file",
output => `the output file is ${output}`
}, ${args.age} years old.`);
type Args obj (String filename ?String output Int age)

main act (Args args) {
(io/println `The filename is ${args.filename}, ${
match args.output {
Void => "no output file",
String output => `the output file is ${output}`
}
}, ${args.age} years old.`)
}
24 changes: 13 additions & 11 deletions examples/greeter.aura
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
use aura/io

// The main function may crashes
main = ! {
decl name: String = {
println("What is your name? ");
main act -> !Void {
let name = {
(io/println "What is your name? ");
// Read a line from the stdin and crashes if an error happens
readln()!;
};
!(io/readln)
}

decl age: Int = {
println("How old are you? ");
let age = {
(io/println "How old are you? ")
// Reads a line, crashes if on error and assigns it to `age`
decl age: String = readln()!;
let age !(io/readln)
// Parses the string to an Int and crashes if not parseable
age:parse<Int>()!;
};
!(age:parse Int)
}

println(`Hello, ${name}! You're ${age} years old, right?`);
(io/println `Hello, ${name}! You're ${age} years old, right?`)
}
4 changes: 2 additions & 2 deletions examples/hello_world.aura
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
decl static println = link "std"!::println;
use aura/io

main = println("Hello world");
main act () (io/println "Hello world")

0 comments on commit 0e770a5

Please sign in to comment.