-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a19ec45
commit 0e770a5
Showing
5 changed files
with
70 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |