Show HN: Yaksha Programming Language (yakshalang.github.io)
I have been working on this for a while. Main goal was to build a usable programming language. I even end up building few tools for this such as IntelliJ plugin, etc.
I also plan on building some games with it in future.
Main use case would be: small games (raylib), tools (static linux binaries with musl-libc) and recreational programming (wasm4). Works in Windows also. If you have emscripten in path you can even build these games/tools (raylib) to WASM.
Please have a look. Thank you.
-------------------------------------
Main Repo: https://github.com/YakshaLang/Yaksha
Doc: https://yakshalang.github.io/documentation.html
Library: https://yakshalang.github.io/library-docs.html
Tutorials: https://github.com/orgs/YakshaLang/discussions/categories/tu...
----------------------------------------
Started after a comment from WalterBright here https://news.ycombinator.com/item?id=28929840
88 comments
[ 2.8 ms ] story [ 152 ms ] thread----------------------------------
Tech stack: Code is written in C++ for the compiler
carpntr - which acts as the builder is built using Yaksha itself. (I use a python script to bootstrap and carpntr to build carpntr as a second step)
hammer - cross compiler for C/C++ projects written in Yaksha (I'm building Linux version of Yaksha compiler on Windows box leveraging `zig c++`)
Yaksha comes with zig to use zig cc.
Runtime: this is written in C. (There are no .dlls involved, things get built statically, only subset will be built and linked)
Standard library: written in Yaksha.
YakshaIntelliJ - written in Java
Various scripts - Python.
https://www.reddit.com/r/ProgrammingLanguages/comments/11vnm...
Since you mentioned wasm, I think it would be great to have a REPL on the website in the future.
REPL I have been thinking for a while, I'm not sure how I would do it unless there is a way to run zig cc in browser.
Would be harder without having a backend at the moment as it needs to run a C compiler to generate the final executable. (Not an interpreter)
[1]: https://en.wikipedia.org/wiki/Yakshagana
You have my greatest appreciation for building proper responsive websites in all those links, with proper CSS styles and sizing (rem units)!
I use a 40" 4K screen (no HiDPI) and almost any other website, including the most popular ones (I just checked github, google, bing) do not really follow responsible principles, use px units, and end up using just a tiny column of the screen... and they are not even consistent: bing and google use the left 1/3rd of the screen, github the central 1/3rd.
Other CSS are probably just luck ;)
[1] Full size: https://i.imgur.com/R0I6Vxs.png
[2] Half size: https://i.imgur.com/tQ6KpR4.png
Not sure if huge text is just the style these days, though. Probably looks great on a huge screen.
The weird silver lining is that most sites are also using fonts a bit too far on the small side for me, and don't respond too well if you jack them up much. But that unused 2/3s of the screen ends up allowing most websites to take a fair bit of zoom without any changes in layout.
I really don't get modern website design.
1) Easy to parse (less ambiguous) 2) We like Python
C type/variable declarations are an expression that transforms the type/variable into a primitive type, which is then annotated on the left of the expression. Why not on the right?
IMHO the existence of "cdecl" is evidence that it might not have been the right choice.
It probably helped that I just parse to an AST that’s generated so experiments like this are trivial.
If I'd had to guess, the syntax might be inspired by math notation such as x ∈ ℝ
I think the readability argument is pretty subjective. Personally I find declarations in for instance Rust a lot easier to quickly scan than C++. For one thing the names of functions are all at the same offset, which to me is actually the most important thing. I can see at a glance whether it's a function or variable being declared. I've never found the fact that the return type is at the end to be a problem - why would it be?
fn first_function(...) -> i32 { ... }
fn second_function(...) -> Vec<i32> { ... }
const X: i32 = 0;
vs
int first_function(...) { ... }
vector<int> second_function(...) { ... }
int X = 0;
Also, some people say that it makes for easier (less ambiguous?) parsing.
But the -> part is a bit weird. It "shouldn't" be
but it "should" be Maybe it's that way because of Python?The arrow syntax meshes better with the idea that there's a difference between the types of values, and the meaning of a function signature. "foo: t" declares a name "foo" as having a type "t", but functions are abstractions — what is the "type" of factorial()? It's not "int".
The type of factorial() could be written:
or just: If you look at the ML family as well as Haskell, that's exactly how they express it.They do that for other reasons, too; those languages follow lambda calculus, which only has single-argument functions, so all functions are simply mappings between a single value to another value.
Why do you care about the return type before the name?
The structure 'term: definition' is pretty common in many natural languages and has a lot of advantages: all terms are aligned, you can sort them, you can grep the term you're looking for, etc.
I even think it should be extended to functions, too. That 'def' ruins the harmony. Instead of
it should be You trade a keyword ('def') for another ('fn') but open the way to lambdas (just the part after the colon).I agree that the -> serves no purpose, it could be made optional. Alternatively one could require the -> and dismiss the 'fn' keyword, like this:
It's slightly harder for the parser who has to wait until the -> to understand what it's reading, but it's doable.About putting the return type after the parameters, that absolutely reflects how I reason about functions: I will want to first examine its input, and then its output. Even the man pages for common functions and commands explain the parameters first, and leave the return value last.
Its surprising how fun programming can be when you eschew unneeded syntactical complexity! Though personally I prefer having memory management and lifetimes handled automatically by default, but with the option for manual management when desired.
I use Nim at work (I'm lucky) so I'd love to see that comparison in particular, it also being a transpiled-to-C language. I also use it to build static binaries with musl-libc and it's quite easy and clean.
I wanted to see following:
1) Does manual memory management become easier when you use python-esque syntax? 2) OpenCL with @device like syntax so you can mix kernel code and client code in same .yaka file. - Not even started (Not sure if achievable with my time constraints)
It has a C#-like syntax.
Why make a new instrument that sounds the same as another instrument? You would expect new instruments to make different sounds, not just have a different control scheme.
zig wraps things up to a nicer package, so I thought might as well use zig cc.