16 ms·
Show HN: Yaksha Programming Language
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 https://github.com/YakshaLang/Yaksha
Doc: https://yakshalang.github.io/documentation.html https://yakshalang.github.io/documentation.html
Library: https://yakshalang.github.io/library-docs.html https://yakshalang.github.io/library-docs.html
Tutorials: https://github.com/orgs/YakshaLang/discussions/categories/tutorials https://github.com/orgs/YakshaLang/discussions/categories/tu...
----------------------------------------
Started after a comment from WalterBright here https://news.ycombinator.com/item?id=28929840 https://news.ycombinator.com/item?id=28929840
- teo_zero 4y agoI think the Language Grammar section doesn't correctly report the grammar you have implemented. For example the "if" and "while" statements lack the condition!
- JaDogg 4y agoHey, thank you. good catch
- nrivoli 4y agoBeautiful.
- JaDogg 4y agoThank you
- lukemerrick 4y agoI'm late to the party, but I want to say thank you for sharing this. It's inspiring to look at how much you've built and (hopefully) enjoyed the process of building! I'm loving everything -- your site, your language design, your docs, your builtin libraries, your dev tools. Beyond impressive. People like you are the ones who make HN one of my best places on the internet. For context on where I'm coming from, about two weeks ago I picked up Crafting Interpreters [1] for fun. I'm finding your clear-yet-concise Compiler internals [2] to be particularly compelling reading, and jumping back and forth between those "how this all works" docs and the live example of this language you actually built do a WASM-compiled tree-blowing-in-the-wind animation is just... just wow. So freaking cool! I also enjoyed reading the comment thread that inspired you to start on Yaksha and seeing how this project has a wholesome start as inspiration-by-programming-hero. I hope you recognize that a few years later you've now ascended from inspiree to inspirer. I also hope you're still having tons of fun building out Yaksha! [1] https://www.craftinginterpreters.com/ https://www.craftinginterpreters.com/ [2] https://yakshalang.github.io/documentation.html#compiler-internals https://yakshalang.github.io/documentation.html#compiler-int...
- deleted 4y ago[deleted]
- JaDogg 4y agoIt is a rather large project. So here is some information about tech stack. ---------------------------------- 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.
- gatane 4y agoThere are no pointers?
- JaDogg 4y agoyes there are pointers. See some samples here: https://github.com/YakshaLang/Yaksha/blob/e72d7984a4c8d49e4ddaf766739b0b1a306d510a/libs/libs/argparse.yaka#L88 https://github.com/YakshaLang/Yaksha/blob/e72d7984a4c8d49e4d...
- Aisen8010 4y agoIt's probably in your plans, but it would be nice a page showing the syntax (for example, control flow and variable declaration).
- JaDogg 4y agoThere are some samples. But yes this is a good idea.
- eps 4y agoShow it to /r/ProgrammingLanguages when you have a chance.
- JaDogg 4y agodone. Thank you! https://www.reddit.com/r/ProgrammingLanguages/comments/11vnm65/hey_i_made_a_new_programming_language_called/ https://www.reddit.com/r/ProgrammingLanguages/comments/11vnm...
- chaosprint 4y agoThat's really lots of work from a one-man band. I can empathise as I am also developing https://github.com/chaosprint/glicol https://github.com/chaosprint/glicol Since you mentioned wasm, I think it would be great to have a REPL on the website in the future.
- JaDogg 4y agoI had help with the landing page. However, rest is mostly me. But I'm using lot of third-party stuff also. 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)
- chaosprint 4y agoperhaps refer to the tech behind rust playground: https://play.rust-lang.org/help https://play.rust-lang.org/help
- JaDogg 4y agoThank you.
- alwaysbeconsing 4y agoThe Compiler Explorer aka Godbolt also would be a good example: https://c.godbolt.org https://c.godbolt.org Source: https://github.com/compiler-explorer/compiler-explorer https://github.com/compiler-explorer/compiler-explorer
- raible 4y agoPerhaps https://github.com/TinyCC/tinycc https://github.com/TinyCC/tinycc would be useful? I've had success using it to implement a repl for my language.
- JaDogg 4y agoBTW glicol looks & sounds really good. I have always day dreamed how I would DJ but instead of using traditional tools, I'd be using a programming language to do it. I never had guts to do it in real life tho! :)
- pacifika 4y agoLooks like gdscript. Not a bad thing!
- JaDogg 4y agoThank you.
- realworldperson 4y ago[dead]
- yazzku 4y agoVery nice. I had experimented with transpiling Python to C straight from the AST in Python itself. Does this plan to add type inference or "generics"? Currently it appears everything must be explicitly typed.
- JaDogg 4y agoyes it is in my local repo. but it is not done yet.
- hsfzxjy 4y agoA great job! But I found the docs too formal and techincal, which is more like a lang spec. It would be more appealing if some tutorials added.
- JaDogg 4y agoYes very good point, I started this by writing a spec. However I already started a tutorial section in github discussions: https://github.com/orgs/YakshaLang/discussions/categories/tutorials https://github.com/orgs/YakshaLang/discussions/categories/tu.... I should add a link to it in main page.
- mshockwave 4y agoAre you planning to add alternative backends in addition to transpiling to C99?
- JaDogg 4y agoYes I originally wanted to add support for OpenCL style C code too. Time will tell if I figure out how to implement it.
- abhayhegde 4y agoNice. Is it named after the folklore Yakshagana[1]? The logo does resemble the face of a Yaksha. [1]: https://en.wikipedia.org/wiki/Yakshagana https://en.wikipedia.org/wiki/Yakshagana
- JaDogg 4y agoLogo is based on a Sri Lankan traditional mask for Fire Devil (Gini Yaka). https://uk.lakpura.com/pages/raksha-masks https://uk.lakpura.com/pages/raksha-masks
- FraaJad 4y agoyes, indirectly.. likely named after Yakshas themselves - https://en.wikipedia.org/wiki/Yaksha https://en.wikipedia.org/wiki/Yaksha
- rlupi 4y agoThis is totally unrelated to the language itself, but... 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.
- JaDogg 4y agoHome page was actually built by my wife. https://github.com/tashvit https://github.com/tashvit. Other CSS are probably just luck ;)
- aka878 4y agoA+ family
- drusepth 4y agoI had to scale down the design to 50% scale to get it to fit on my screen without everything looking huge and wrapping, but after that everything looked usable. [1] Full size: https://i.imgur.com/R0I6Vxs.png https://i.imgur.com/R0I6Vxs.png [2] Half size: https://i.imgur.com/tQ6KpR4.png 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.
- topaz0 4y agoMy experience is that tiny text is the style. I'm much more likely to have to scale something up than down. I can't remember the last time I scaled something down, but I scale things up every day. (I also liked the size choices of the OP... honestly wouldn't have minded slightly bigger).
- JaDogg 4y agoSorry, not so good with CSS. Home page should look better I think. :) Will fix it at some point
- blakerandall 4y agoWhat's with newer languages putting types after variable/function names? Then you need an extra symbol : or -> and a function keyword. It also breaks readability of long function headers as you have to read the name skip to the end to read the return type then back to the first argument. Is there a good reason for this trend?
- teo_zero 4y agoIf you had never heard about C and its legacy, and were to create your own programming language, would you come up with a syntax like C's? 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 def factorial(int) -> int it should be factorial: fn(int) -> int 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: factorial: (int) -> int 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.
- JaDogg 4y agoI think mainly 1) Easy to parse (less ambiguous) 2) We like Python
- Yujf 4y agoIt is easier to parse and you don't get the abomination that is C function pointers
- MathMonkeyMan 4y agoIt makes me wonder why C put the ultimate type on the left and not on the right. 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?
- elcritch 4y agoReminds me of Nim, but with more Python influence on the standard library and overall syntax. It does share the ideal that a Python-esque syntax can be nice for system's programming. 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.
- JaDogg 4y agoYes I agree. Time will tell how it will grow. Hopefully it will have a good use.
- netbioserror 4y agoDo you mind having a "Why a new language?" primer with some deeper philosophy on your choices? I will never question anyone's desire to make a language for learning or hobby. However, when presenting it to the world for practical use, there has to be some persuasion to move people off of existing tools. 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.
- JaDogg 4y agoSure, main goal was fun. But I should have a write up some time. 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)
- 29athrowaway 4y agoAnother language that compiles to C: Vala. It has a C#-like syntax.
- DeathArrow 4y agoObvious question: why a new low level programming language when we have C, Zig, Nim? What are its strengths over these?
- UncleEntity 4y agoWhy did anyone make an album after the Beatles Rubber Soul ?
- imtringued 4y agoA programming language is closer to an instrument, not actual music. 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.
- UncleEntity 4y agoIDK, ergonomics?
- bjornasm 4y agoSay that to the plethora of custom made guitars with different necks, different amount of strings, type of strings etc.
- DeathArrow 4y agoWhy aren't you using the LLVM infrastructure?
- JaDogg 4y agoI did not want to use that because LLVM was just too big! I tried building a sample and it gave me > 1GB debug .exe file. zig wraps things up to a nicer package, so I thought might as well use zig cc.
- WoodenChair 4y agoWhat's wrong with compiling to C? By using C as an intermediate language LLVM can be a backend through Clang, but so can GCC, MSVC, Intel C, etc. It's actually a pretty common choice (see Nim, Chicken Scheme, etc.).
- dom96 4y agoNice! My initial take: love Python-inspired languages but I think manual memory management is distinctly anti-Python so not sure how well that works together.
- JaDogg 4y agoThat is the point!
- Boxxed 4y agoLooks pretty cool! What happens if a program attempts a use-after-free? If this is "memory safe" (aside from leaks) then I think it sits in a pretty interesting space!
- JaDogg 4y agoBoom! it is an unsafe language. Hence the fire devil logo.
- thatxliner 4y agoExactly what I always wanted
- JaDogg 4y agoNice !
- matheusmoreira 4y agoReally nice language. Would you mind describing the modules/libraries system? I see you have a Python-style import and I'm curious how you implemented this in a language that compiles to C.
- JaDogg 4y agoEverything compiles to a big .c file. capntr - tool that acts as builder knows which part of runtime to compile and link. Imports are not dynamic like python. Does not have all the features of Python import also.
- callinyouin 4y agoI wish every programming language website was like this. First thing you see is a short description the language, with an image on the side showing example code. Beneath that, a short example program that does something non-trivial. This is the way.
- JaDogg 4y agoGlad you liked it.
- peefy 4y agoI'm very surprised that this is actually a single person's workload. "Because I am also a programming language designer and developer, I have worked in it for approximately 3 years, and it also supports compiling to WASM." https://github.com/KusionStack/KCLVM https://github.com/KusionStack/KCLVM
- peefy 4y agoI have seen its language design and compiler implementation, and I am sure I will continue to follow and watch the development of Yaksha Programming Language. If possible, I would like to contribute.
- hestefisk 4y agoNice job. Is the name a pun on “yak shaving”?
- JaDogg 4y agoHad no idea this was a thing. Yaksha - https://en.wikipedia.org/wiki/Yaksha https://en.wikipedia.org/wiki/Yaksha. Logo is based on traditional Sri Lankan Yaka/Yaksha/Raksha mask.
- frhack 4y agoNo lambda ?
- JaDogg 4y agonot yet that is.