Also do some cleanup and refactoring of the thread, sync and time APIs. - remove 'semaphore_release' because 'post' and 'wait' is easier to understand - change 'semaphore_wait' to '*_wait_for' to match Condition - pthreads can be given a stack, but doing so requires the user to set up the guard pages manually. BE WARNED. The alignment requirements of the stack are also platform-dependant; it may need to be page size aligned on some systems. Unclear which systems, however. See 'os.get_page_size', and 'mem.make_aligned'. HOWEVER: I was unable to get custom stacks with guard pages working reliably, so while you can do it, the API does not support it. - add 'os.get_page_size', 'mem.make_aligned', and 'mem.new_aligned'. - removed thread return values because windows and linux are not consistent; windows returns 'i32' and pthreads return 'void*'; besides which, if you really wanted to communicate how the thread exited, you probably wouldn't do it with the thread's exit code. - fixed 'thread.is_done' on Windows; it didn't report true immediately after calling 'thread.join'. - moved time related stuff out of 'core:os' to 'core:time'. - add 'mem.align_backward' - fixed default allocator alignment The heap on Windows, and calloc on Linux, both have no facility to request alignment. It's a bit of hack, but the heap_allocator now overallocates; `size + alignment` bytes, and aligns things to at least 2. It does both of these things to ensure that there is at least two bytes before the payload, which it uses to store how much padding it needed to insert in order to fulfil the alignment requested. - make conditions more sane by matching the Windows behaviour. The fact that they were signalled now lingers until a thread tries to wait, causing them to just pass by uninterrupted, without sleeping or locking the underlying mutex, as it would otherwise need to do. This means that a thread no longer has to be waiting in order to be signalled, which avoids timing bugs that causes deadlocks that are hard to debug and fix. See the comment on the `sync.Condition.flag` field. - add thread priority: `thread.create(worker_proc, .High)`
A fast, concise, readable, pragmatic and open sourced programming language.
The Odin Programming Language
The Odin programming language is fast, concise, readable, pragmatic and open sourced. It is designed with the intent of replacing C with the following goals:
- simplicity
- high performance
- built for modern systems
- joy of programming
Website: https://odin-lang.org/
package main
import "core:fmt"
main :: proc() {
program := "+ + * 😃 - /";
accumulator := 0;
for token in program {
switch token {
case '+': accumulator += 1;
case '-': accumulator -= 1;
case '*': accumulator *= 2;
case '/': accumulator /= 2;
case '😃': accumulator *= accumulator;
case: // Ignore everything else
}
}
fmt.printf("The program \"%s\" calculates the value %d\n",
program, accumulator);
}
Documentation
Getting Started
Instructions for downloading and install the Odin compiler and libraries.
Learning Odin
Overview of Odin
An overview of the Odin programming language.
Frequently Asked Questions (FAQ)
Answers to common questions about Odin.
The Odin Wiki
A wiki maintained by the Odin community.
Odin Discord
Get live support and talk with other odiners on the Odin Discord.
References
Language Specification
The official Odin Language specification.
Articles
The Odin Blog
The official blog of the Odin programming language, featuring announcements, news, and in-depth articles by the Odin team and guests.
Setup
Odin only supports x86-64 at the moment (64-bit), relies on LLVM for code generation and an external linker.
In addition, the following platform-specific steps are necessary:
-
Windows
- Have Visual Studio installed (MSVC 2010 or later, for the linker)
- Have a copy of
opt.exeandllc.exeinOdin/bin. Pre-built Windows binaries can be found here and must be explicitly copied - Open a valid command prompt:
- Basic: run the
x64 Native Tools Command Prompt for VS2017shortcut bundled with VS 2017, or - Advanced: run
vcvarsall.bat x64from a blankcmdsession
- Basic: run the
-
MacOS
- Have LLVM explicitly installed (
brew install llvm) - Have XCode installed (version X.X or later, for linking)
- Make sure the LLVM binaries and the linker are added to your
$PATHenvironmental variable
- Have LLVM explicitly installed (
-
GNU/Linux
- Have LLVM installed (opt/llc)
- Have Clang installed (version X.X or later, for linking)
- Make sure the LLVM binaries and the linker are added to your
$PATHenvironmental variable
Then build the compiler by calling build.bat (Windows) or make (Linux/MacOS). This will automatically run the demo program if successful.
Notes for Linux:: The compiler currently relies on the core and shared library collection being relative to the compiler executable. Installing the compiler in the usual sense (to /usr/local/bin or similar) is therefore not as straight forward as you need to make sure the mentioned libraries are available. As a result, it is recommended to simply explicitly invoke the compiler with /path/to/odin in your preferred build system, or add /path/to/odin to $PATH.
Please read the Getting Started Guide for more information.
Requirements to build and run
Please read the Getting Started Guide.
-
Windows
- x86-64
- MSVC 2010 installed (C++11 support)
- LLVM binaries for
opt.exe,llc.exe, andlld-link.exe - Requires MSVC's link.exe as the linker
- run
vcvarsall.batto setup the path
- run
-
MacOS
- x86-64
- LLVM explicitly installed (
brew install llvm) - XCode installed (for the linker)
-
GNU/Linux
- x86-64
- Build tools (ld)
- LLVM installed
- Clang installed (temporary - this is Calling the linker for now)
Warnings
- This is still highly in development and the language's design is quite volatile.
- Syntax is not fixed.
Demonstrations:
- First Talk & Demo
- Composition & Refactorability
- Introspection, Modules, and Record Layout
- push_allocator & Minimal Dependency Building
- when, for & procedure overloading
- Context Types, Unexported Entities, Labelled Branches
- Bit Fields, i128 & u128, Syntax Changes
- Default and Named Arguments; Explicit Parametric Polymorphism
- Loadsachanges
- Packages, Bit Sets, cstring