TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Lua/LuaJIT with C/C++/Java/JavaScript syntax

77 pointsby mingodadover 6 years ago

5 comments

coder543over 6 years ago
Saying C&#x2F;C++&#x2F;Java&#x2F;JavaScript makes me think you&#x27;ve created 4 different syntax frontends for LuaJIT, when there is really only one here.<p>It seems to me that you&#x27;re really trying to express a concept that could be referred to as &quot;C-like syntax&quot; or &quot;JavaScript-like syntax,&quot; with the latter probably being more accurate. It would certainly be less confusing than repeating &quot;C&#x2F;C++&#x2F;Java&#x2F;JavaScript syntax&quot; over and over.
mingodadover 6 years ago
Author here if you have any question.<p>Also if you have done any enhancement to Lua&#x2F;LuaJIT and want help or talk about it I&#x27;m glad to hear from you.<p>There is an parser&#x2F;transpiler using lemon&#x2F;re2c that can transpile almost any Lua source to LJS see here <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljs&#x2F;tree&#x2F;master&#x2F;lua2ljs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljs&#x2F;tree&#x2F;master&#x2F;lua2ljs</a> .<p>Here are some non trivial projects converted to LJS:<p>ljsjit at <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljsjit" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljsjit</a><p>ljs-5.1 at <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljs-5.1" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljs-5.1</a><p>ZeroBraneStudio port at <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ZeroBraneStudioLJS" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ZeroBraneStudioLJS</a><p>raptorjit-ljs at <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;raptorjit-ljs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;raptorjit-ljs</a><p>snabb-ljs at <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;snabb-ljs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;snabb-ljs</a><p>premake5-ljs at <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;premake-core&#x2F;tree&#x2F;ljs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;premake-core&#x2F;tree&#x2F;ljs</a><p>The next steps that I have in mind now is to add the remaining syntax sugar like:<p>-C&#x2F;C++&#x2F;Java&#x2F;Javascript for loop<p>-Switch statement<p>-Class statement<p>-const declarations<p>- type checking (actually <a href="https:&#x2F;&#x2F;fascinatedbox.github.io&#x2F;lily&#x2F;" rel="nofollow">https:&#x2F;&#x2F;fascinatedbox.github.io&#x2F;lily&#x2F;</a> has those and it seems a good one to port&#x2F;add)<p>-Understand and make it easier for other people understand the implementation of LuaJIT.
评论 #18791202 未加载
评论 #18790634 未加载
评论 #18790894 未加载
评论 #18790740 未加载
评论 #18790339 未加载
评论 #18793230 未加载
sifoobarover 6 years ago
I like a lot of things about Lua, the focus on embedded use and keeping the implementation nimble among others. LuaJIT is very impressive, but it&#x27;s already drowning in its own complexity.<p>I spent the last two years more or less full time trying out ways of making interpreters of similar complexity go faster without making the same mistake.<p>One method that seems really promising so far is AOT tracing [0], making guarantees and removing redundant code ahead of time based on incomplete semantic models. It&#x27;s different from a full compiler in that it only tries to improve the situation and will back out and leave code alone where the semantic model is insufficient. And since it acts as a transformation on VM code, it&#x27;s fairly transparent and easy to debug. The complexity of the models is a three way compromise between faster tracing, faster code and implementation complexity.<p>Once the VM code is reasonably optimal, further compiling to C by generating the interpreter code inline becomes even more attractive. Which also leads to native executables as a bonus feature.<p>[0] <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;sifoo&#x2F;snigl#tracing" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;sifoo&#x2F;snigl#tracing</a>
评论 #18791687 未加载
alextooterover 6 years ago
Thanks for sharing this.This is what I want use for embedded in C projects,the same syntax.
sdinsnover 6 years ago
This looks like JS, and JS does not look like C&#x2F;C++&#x2F;Java
评论 #18792488 未加载