3 ms·
Looks neat. Some obvious basic questions that I imagine most people would wonder: 1. Is it value based (C++, Rust, Go, TCL) or reference based (basically every
by IshKebab 3y ago
Looks neat. Some obvious basic questions that I imagine most people would wonder:
1. Is it value based (C++, Rust, Go, TCL) or reference based (basically everything else).
2. How is memory freed? GC?
3. If GC how do you deal with the fact that Wasm GC is still in progress?
4. What about concurrency? Is it single threaded?
5. How does error handling work?
6. Does it support modern type features - Option<>, sum types, etc.
7. It's imperative, does that mean things that should be expressions (e.g. if/else) are statements?
- norir 3y ago8. What does blazingly-fast build times mean quantitatively? How does it scale with project size?
- brendanfh 3y agoThe largest project I have in Onyx is currently around 30000 lines (not all that large I know). That project on my Intel i7-1165G7 laptop compiles in about 80ms. There are currently no large Onyx projects that can really test how this number scales, but I would guess the growth is not linear. So for an off the cuff estimated, I would say a million line project could compile in about 4-5 seconds. Also worth noting that the entire compiler is currently single-threaded. So that number could get much better.
- titzer 3y agoThat's impressively fast. Well done!
- brendanfh 3y agoThose are all great questions. I will add to the docs to explain more details later, but for now: 1. It is value based, like C. There is obviously passing by pointer, but you do that explcitly. 2/3. Memory is manually managed. To make this easier, like Zig and Odin, everything that allocates should take an allocator as a parameter. This allocator can be the general purpose heap allocator, or it can be an arena, ring buffer, or even tracked allocations that can be freed all at once. More details on that to follow in the documentation. 4. It does have multi-threading support, thanks to the atomics WASM proposal. The standard library currently has support for basic multi-threaded primitives like mutexes, semaphores, and condition variables. Note, there is currently not async/await or any kind of concurrent execution. 5/6. It does have modern type features like sum types. It has Optional(T) and Result(Ok, Err) out of the box. That is the preferred method of error handling. 7. It is mostly statement oriented, but there are features like Elixir's pipe operator (|>) and if/else (value if condition else otherwise) expressions.
- cutemonster 3y agoAbout 2/3, does the compiler / language somehow help me remember to free memory I've allocated, or avoid double frees? Are there smart pointers or sth like that? (I've been coding lots of C/C++ :-))