Update README
This commit is contained in:
88
README.md
88
README.md
@@ -1,75 +1,39 @@
|
|||||||
# The Core Language
|
# The Core Language
|
||||||
|
|
||||||
A compiled language that assumes C as base reality but it also has lots of ideas taken from Jai, Go like type system, order indepent declarations using Ion algorithm. Syntax currently is whitespace significant. Made to practice language development. It has lot's of ideas from modern programming languages that you would not find in any compiler book. It supports **modules** combined with **ordered independent declarations** and **lazy typechecking**. Also **runtime reflection**, **slices** and other standard features you would find in C.
|
A statically typed systems programming language that **you shouldn't use**, I'm NOT joking.
|
||||||
|
The basic premise of the language is simplicity and debuggability,
|
||||||
|
reinforcing already useful ideas from C,C++,Go,Odin,Jai and shaving off round edges. In the future it might become
|
||||||
|
a single/two file, easily embeddable library language with optional fixed-size allocation scheme.
|
||||||
|
|
||||||
The language is currently **very debuggable**. It can produce readable C code with line directives. This allows you to debug the programs with Visual Studio with full source mapping, exactly like you would debug C programs.
|
## Simple drawing to window example
|
||||||
|
|
||||||
## Using Windows API example
|
|
||||||
|
|
||||||
More examples can be found in /examples and /modules:
|
|
||||||
|
|
||||||
``` odin
|
``` odin
|
||||||
#import "KERNEL32.core"
|
#import "Multimedia.core"
|
||||||
#import "Base.core"
|
|
||||||
|
|
||||||
PAGE_SIZE :: 4096
|
main :: (): int
|
||||||
Memory :: struct
|
StartMultimedia(title = "Hello people!")
|
||||||
commit : SizeU
|
for UpdateMultimedia()
|
||||||
reserve: SizeU
|
if Mu.key[Key.Escape].down
|
||||||
data : *U8
|
Mu.quit = true
|
||||||
|
|
||||||
Reserve :: (size: SizeU): Memory
|
|
||||||
// C like compound expressions with named arguments
|
|
||||||
result := Memory{reserve=AlignUp(size, PAGE_SIZE)}
|
|
||||||
|
|
||||||
// Named arguments to function calls
|
|
||||||
result.data = VirtualAlloc(
|
|
||||||
flProtect = PAGE_READWRITE,
|
|
||||||
dwSize = result.reserve,
|
|
||||||
flAllocationType = MEM_RESERVE,
|
|
||||||
lpAddress = 0)->*U8
|
|
||||||
return result
|
|
||||||
|
|
||||||
Commit :: (m: *Memory, size: SizeU): Bool
|
|
||||||
commit_size := AlignUp(size, PAGE_SIZE)
|
|
||||||
total_commit := m.commit + commit_size
|
|
||||||
clamped_commit := ClampTopSizeU(total_commit, m.reserve)
|
|
||||||
adjusted_commit := clamped_commit - m.commit
|
|
||||||
if adjusted_commit != 0
|
|
||||||
result := VirtualAlloc(
|
|
||||||
lpAddress = (m.data + m.commit)->*void,
|
|
||||||
dwSize = adjusted_commit,
|
|
||||||
flAllocationType = MEM_COMMIT,
|
|
||||||
flProtect = PAGE_READWRITE,
|
|
||||||
)
|
|
||||||
Assert(result != 0)
|
|
||||||
m.commit += adjusted_commit
|
|
||||||
return true
|
|
||||||
return false
|
|
||||||
|
|
||||||
Release :: (m: *Memory)
|
|
||||||
result := VirtualFree(m.data->*void, 0, MEM_RELEASE)
|
|
||||||
if result != 0
|
|
||||||
m.data = 0
|
|
||||||
m.commit = 0
|
|
||||||
m.reserve = 0
|
|
||||||
|
|
||||||
|
for y := 0, y < Mu.window.y, y+=1
|
||||||
|
for x := 0, x < Mu.window.x, x+=1
|
||||||
|
Mu.screen[x + y*Mu.window.x] = 0xFFFFFF00
|
||||||
```
|
```
|
||||||
|
|
||||||
## Simple math library example (operator overloading!)
|
## Features
|
||||||
|
|
||||||
``` odin
|
* Debuggers(Visual Studio, Remedybg) fully work with the language, you can step through the program
|
||||||
Vec3 :: struct ;; x: F32; y: F32; z: F32
|
* Compiles to C code, in the future it will also compile to bytecode and hopefully a raw x64 executable
|
||||||
Length :: (a: Vec3): F32 ;; return sqrtf(a.x*a.x + a.y*a.y + a.z*a.z)
|
* Very strict Go like type system with untyped literals
|
||||||
Negate :: (a: Vec3): Vec3 ;; return {-a.x, -a.y, -a.z}
|
* Order independent declarations
|
||||||
Dot :: (a: Vec3, b: Vec3): F32 ;; return a.x*b.x + a.y*b.y + a.z*b.z
|
* Module system, user namespaces the library, only the used library code gets compiled
|
||||||
"*" :: (a: Vec3, b: Vec3): Vec3 ;; return {a.x*b.x, a.y*b.y, a.z*b.z}
|
* Windows and Linux(only tested on Ubuntu) support
|
||||||
"*" :: (a: Vec3, b: F32) : Vec3 ;; return {a.x*b, a.y*b, a.z*b}
|
* Runtime type reflection
|
||||||
"+" :: (a: Vec3, b: Vec3): Vec3 ;; return {a.x+b.x, a.y+b.y, a.z+b.z}
|
* Typesafe variadic arguments
|
||||||
"/" :: (a: Vec3, b: Vec3): Vec3 ;; return {a.x/b.x, a.y/b.y, a.z/b.z}
|
* Operator overloading
|
||||||
"/" :: (a: Vec3, b: F32) : Vec3 ;; return {a.x/b, a.y/b, a.z/b}
|
* Slices
|
||||||
"-" :: (a: Vec3, b: Vec3): Vec3 ;; return {a.x-b.x, a.y-b.y, a.z-b.z}
|
* Multiple return values
|
||||||
```
|
|
||||||
|
|
||||||
## What's missing ?
|
## What's missing ?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user