Jule is an open source programming language created in 2021 by Mertcan Davulcu.
#719on PLDB | 3Years Old |
git clone https://github.com/julelang/jule
Jule is the simple, efficient, statically typed and compiled system programming language.
fn quicksort(mut s: []int) {
if s.len <= 1 {
ret
}
let mut i = -1
let last = s[s.len-1]
for j in s {
let mut x = &s[j]
if (unsafe{ *x <= last }) {
i++
let mut y = &s[i]
unsafe { *x, *y = *y, *x }
}
}
quicksort(s[:i])
quicksort(s[i+1:])
}
fn main() {
let mut my_slice = [1, 9, -2, 25, -24, 4623, 0, -1, 0xFD2]
outln(my_slice)
quicksort(my_slice)
outln(my_slice)
}
fn main() {
outln("Hello World")
}
use std::math::{PI}
trait Shape {
fn area(self): f32
}
struct Rectangle {
width: int
height: int
}
impl Shape for Rectangle {
fn area(self): f32 {
ret self.width * self.height
}
}
struct Circle {
r: f32
}
impl Shape for Circle {
fn area(self): f32 {
ret PI * self.r * self.r
}
}
fn main() {
let rect: Shape = Rectangle{90, 5}
let circ: Shape = Circle{90.5}
outln(rect.area())
outln(circ.area())
}
fn pub struct enum unsafe const let mut self match if else for in impl trait break continue goto cpp i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 str int uint type any true false bool ret fall nil uintptr co
Feature | Supported | Example | Token |
---|---|---|---|
hasReservedWords | โ | ||
hasSelfOrThisWord | โ | self | |
File Imports | โ | use std::fs use std::sys::{self, open, O_RDWR} use std::math::* | use |
Multiline Strings | โ | `Multiline strings is available in Jule with raw strings` | |
hasStringConcatOperator | โ | + | |
Disk Output | โ | use std::fs::{open, O_WRONLY} fn main() { let (mut f, _) = open("myfile.txt", O_WRONLY, 0) let bytes = ([]byte)("Text to write") f.write(bytes) f.close() } | |
Static Typing | โ | ||
Increment and decrement operators | โ | ++ -- | |
Conditionals | โ | if BOOLEAN_EXPRESSION { outln(""Condition is true) } | |
Manual Memory Management | โ | use std::mem::c::{malloc, free} fn main() { let mut ptr = malloc(8) free(ptr) ptr = nil } | |
Type Casting | โ | let x = (int)(3.14) | |
hasArraySlicingSyntax | โ | sliceable_expression[start_index:to_index] | |
Duck Typing | โ | fn lock_object[T](obj: T) { obj.lock() } | |
Switch Statements | โ | match X { | Y: outln("X is Y") | Z: outln("X is Z") | A | B | C: outln("X is A, B, or C") |: outln("X is not Y, Z, A, B and C") } | |
hasMemberVariables | โ | ||
Access Modifiers | โ | pub | |
Type Annotations | โ | let x: f64 = 89 | |
Assignment | โ | let mut x = 0 x = 20 | = |
Threads | โ | fn my_thread() { outln("Hello from thread") } fn main() { co my_thread() } | |
Statements | โ | ||
hasStatementTerminatorCharacter | โ | ; | |
hasBoundedCheckedArrays | โ | let arr: [5]byte = ['a', 'b', 'c', 'd', 'e'] | |
hasRequiredMainFunction | โ | fn main() {} | |
Gotos | โ | goto a_label | |
Labels | โ | a_label: | |
hasDynamicSizedArrays | โ | let mut a_slice = [1, 2, 3, 4, 5, 6] a_slice = append(a_slice, 7, 8, 9, 10) | |
hasIfElses | โ | ||
hasIfs | โ | ||
Doc comments | โ | // Documentation comment for a_function fn a_function() {} | |
While Loops | โ | for my_condition { // ... } | |
hasForLoops | โ | // Jule has for loops with while-next iterations let mut i = 0 for i < 10; i++ { // ... } | |
hasForEachLoops | โ | for x, y in my_enumerable { // ... } | |
canReadCommandLineArgs | โ | use std::os::{ARGS} fn main() { outln(ARGS) } | |
Case Sensitivity | โ | ||
hasFnArguments | โ | ||
Dependent types | โ | int uint uintptr | |
Unary Operators | โ | * & - + ^ ! | |
Variadic Functions | โ | fn average(x: ...f64): f64 { // ... } | |
Assert Statements | โ | use std::debug use std::debug::assert::{assert} fn main() { std::debug::ENABLE = true let x = 200 assert(x < 200) } | |
Bitwise Operators | โ | & | ^ << >> | |
Directives | โ | ||
hasValueReturnedFunctions | โ | fn get_pi(): f64 { ret 3.14159265359 } | |
hasGlobalScope | โ | ||
Scientific Notation | โ | 1E2 .12345E+6 1.e+0 0x15e-2 0x2.p10 0X.8p-0 0x1.Fp+0 0x1fffp-16 0x1p-2 | |
hasVoidFunctions | โ | fn a_void_function() { // ... } | |
Binary Literals | โ | 85 | |
Decimals | โ | 12345 | |
Octals | โ | 455 | |
Hexadecimals | โ | 917392 | |
Structs | โ | struct Employee { first_name: str last_name: str salary: f32 } | |
Integers | โ | 12345 0b0001010101 0455 0xDFF90 | |
Floats | โ | 3.14 32.60 032.60 3. 0.3 1E2 .12345E+6 1.e+0 0x1p-2 0x2.p10 0x1.Fp+0 0X.8p-0 0x1fffp-16 0x15e-2 | |
Enums | โ | enum ExitCode { Success = 0, Failure = 1 } | |
hasContinue | โ | continue continue a_label | |
hasBreak | โ | break break a_label | |
Anonymous Functions | โ | let anonymous = fn() { outln("Anonymous Function") } anonymous() | |
Null | โ | nil | |
Constants | โ | const PI = 3.14159265359 | |
Booleans | โ | true false | true false |
Generics | โ | fn generic_function[T](s: []T) { // ... } | |
Traits | โ | trait Person { fn get_full_name(self): str fn get_age(self): byte } | |
Maps | โ | let my_map: [int:str] = { 0: "Key 0", 1: "Key 1", 2: "Key 2", } | |
Methods | โ | impl MyStruct { fn my_method(self) {} } | |
Functions | โ | fn a_function() { // ... } | |
Pointers | โ | let ptr: *int = nil | |
Print() Debugging | โ | outln | |
MultiLine Comments | โ | /* A multi line comment */ | /* */ |
Comments | โ | // A comment /* A comment */ | |
Line Comments | โ | // A comment | // |
Strings | โ | "Jule String Literal" `Jule Raw String Literal` | " |
Regular Expression Syntax Sugar | X | ||
hasTryCatch | X | ||
Async Await | X | ||
canUseQuestionMarksAsPartOfIdentifier | X | ||
Ternary operators | X | ||
hasUserDefinedOperators | X | ||
Operator Overloading | X | ||
Polymorphism | X | ||
Garbage Collection | X | ||
hasMethodOverloading | X | ||
Function Overloading | X | ||
Semantic Indentation | X |