Jai Compiler Demo: Macros and Iteration
Posted Aug 18, 2019, 8:16 AM UTC
Posted Aug 18, 2019, 8:16 AM UTC
Code is my new favorite data type in Jai.
There's a hack in c where you can manually fill a function pointer with machine code at runtime and execute it (provided you jump through a bunch of syscalls to allow it). I always wanted some language to implement that in an official way.
Thats what like every dynamic recompiler/vm does.
Yeah, but its not an intended feature of the language is my point, nobody explicitly created syntax for you to do that.
There is function eval and module ast in python.
Well these don't work at runtime either, they're macros.
But the code you pass into those macros can be decided at runtime.
How does that work when the macros are expanded at compile time?
(provided you jump through a bunch of syscalls to allow it)
Only on a modern platform, if you run your cpu without the training wheels (also known as real mode), you can do everything without any annoying syscalls.
Sounds similar to a C# expression tree. But C# expression trees do not support statements. And they have explicit parameters. And the types of these parameters (and the "return" value of the expression) is explicitly part of the expression's type (e.g. Expression<Func<int, bool>>).
There are some great ideas here that are being explored.
Very excited to see where this goes!
an hour and a half long video about a closed source programming language
cool
Unreleased programming language.
It's unreleased because it's unfinished.
When it's released, it'll be open sourced.
Will the source code be released in a youtube video?
No it will be posted on pastebin :)
I've seen this sub rip apart other people who post WIP projects, but because it's Blow it seems to be okay with these. He's been publishing these for several years and there's still nothing to actually play with. He doesn't even incorporate feedback from what I can tell. I don't really see the point, especially when he's mostly just making no-GC Lisp... But with some syntax sugar.
At one point I considered Jai to be really cool, but for me it's worn it's welcome and until I see a release I generally just consider it vaporware.
Of course, feel free to disagree! In a few more years I may be proven to be a big idiot and we'll all be using it!
Sorry but he is right.
I don't think any of us should debate this.
Either open source a language - OR DON'T RELEASE IT AT ALL.
I think Jonathan is cool, but closed source shit is simply unacceptable. We don't live in 1980 anymore.
Even if the source code sucks, so what? I don't think Jai is a good language from a design (and C++ is designed by cthulhu-worshipping clowns) - but it simply should be a STANDARD to publish, at all times, open source, without delay and without other excuses.
So many other languages manage to do so.
I guess jai is only intended as a self-promo self-patting on the shoulder for ego boosting if it remains closed source.
[deleted]
Honestly I think shevy-ruby is just a troll. They show up in almost every language related thread to shit on any language that's not Ruby.
[deleted]
The comment you are replying to literally says it’s going to be open sourced, what are you even talking about?
Going to is a promise though. If the guy gets run over by a bus he can't fulfill the promise. It's closed source until it's open. It's not open yet so it's by definition closed. There is no quantum super position of open/closed.
TL/DW:
0:00:00:
forloops have special features:<for reversing,*for dereferencingdefer~0:12:00:
#expand. So all features of function are available to macros (variable parameter count, overloading, baking, ...)~0:33:00:
Codefor syntax trees.#code ...literal#insertinsertsCodeinto the body of a macro, using the expanded / caller / target scope.#insert_internalinsertsCodeinto the body of a macro, using the macro scope.~0:45:00:
forloops using macros:for_expansionbreakandremovesupport~1:00:00:
~1:15:00:
Sounds like CL's
loopandunwind-protectrespectively.I'm queasy about defer or context managers in non-GC'd languages (which Jai supposedly is, in my understanding): in a GC'd language memory is assumed to be plentiful (relatively speaking) and the runtime wants to manage its allocation and deallocation for reasons of throughput and latency and everything, and object destruction (if any) is hooked into the "memory resource" handling, so it makes sense that you need a second separate resource-management system for other types of resources which tend to be less plentiful and / or less automatable (e.g. sockets, fds, locks, …).
For languages without GCs however it seems like a mistake on multiple levels:
RAII fixes all that, it provides a uniform resource-management system across memory and non-memory resources, and does the right thing whether you're the creator, and intermediate user or the final user of a given resource. The main sticking point is fallible destruction but IME defer / context managers don't usually solve that either beyond raising some sort of fault themselves, and I'd think opt-in linear (rather than affine) RAII would be a much better fix from a non-distributed reliability POV.
here's an old video from Jon that talks about RAII: https://www.youtube.com/watch?v=TH9VCN6UkyQ&t=1740
I hope I'm representing his thoughts well:
I don't quite follow why non-GC and
deferdon't mix well.What are linear / affine RAII? Related to affine & linear types? "An affine resource can be used at most once, while a linear one must be used exactly once."
What does that mean?
It's not that they don't mix well, it's that defer seems suboptimal in that context.
Yes. Most RAII is affine, in the sense that once you stop using an RAII resource it gets automatically collected for you at the end of the scope (more or less). The issue with that things get wonky if the dtor/collector needs to report an error (exception / panic is the only option).
A "linear" RAII would require explicitly collecting resources which would allow for error reporting (so you'd have an affine system for non-faillible collection and a linear one for faillible), and the compiler requires explicitly cleaning up linear resources.
Note that "linear" RAII doesn't solve the case of needing to report errors while unwinding (with both C++ and Rust have issues with, IIRC in both it'll lead to the process just aborting entirely) but it should make the issue less likely as dtors would have little to no reason to throw / panic anymore.
Erlang is conceptually centered around the idea that distribution is required to achieve reliability (because if you have a single thread / process / machine and it dies you've got nothing left, so you need at the very least an other one to act as supervisor). In that view, faults are rarely or never handled synchronously up the stack, instead the faulting process dies and the fault is asynchronously reported to its supervisor (possibly indirect) which decides what to do.
"Linear" RAII doesn't do anything for this conception of reliability.
Thanks for the explanations.
I'm not too familiar with CL. Is the
loopmacro extensible? Google didn't turn up anything about that. In what way is it similar?Not so much extensible, as it is that it'll do everything you could ever want ever, and many things you never thought you'd want, from a loop construct:
http://www.lispworks.com/documentation/lw51/CLHS/Body/m_loop.htm
Personally, I'm of the belief that it's an overengineered mess that is essentially as complex as the rest of the common lisp spec.
OK, thanks. So CL
loopis similar to Jaiforbecause "< for reversing, * for dereferencing" also sounds like it has (too) many built-in special features.But they are not similar because CL
loopis not extensible? I could not write a new data structure and then extendloopto iterate over the elements of that data structure?