TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Gravity – An embeddable programming language

234 点作者 marcobambini将近 7 年前

22 条评论

tom_mellior将近 7 年前
&quot;The VM code is about 2K lines long, the multipass compiler code is about 3K lines and the shared code is about 2K lines long.&quot;<p>I was surprised by these numbers so I checked, and this is highly misleading (or very much out of date). The parser alone (<a href="https:&#x2F;&#x2F;github.com&#x2F;marcobambini&#x2F;gravity&#x2F;blob&#x2F;master&#x2F;src&#x2F;compiler&#x2F;gravity_parser.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;marcobambini&#x2F;gravity&#x2F;blob&#x2F;master&#x2F;src&#x2F;comp...</a>) is over 2K lines, and with the lexer and the AST definitions the <i>frontend</i> of the compiler is already comfortably above 3K lines. Also, the VM (<a href="https:&#x2F;&#x2F;github.com&#x2F;marcobambini&#x2F;gravity&#x2F;blob&#x2F;master&#x2F;src&#x2F;runtime&#x2F;gravity_vm.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;marcobambini&#x2F;gravity&#x2F;blob&#x2F;master&#x2F;src&#x2F;runt...</a>) is about 2K lines, but then there is another 3K lines in another &quot;runtime&quot; file (<a href="https:&#x2F;&#x2F;github.com&#x2F;marcobambini&#x2F;gravity&#x2F;blob&#x2F;master&#x2F;src&#x2F;runtime&#x2F;gravity_core.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;marcobambini&#x2F;gravity&#x2F;blob&#x2F;master&#x2F;src&#x2F;runt...</a>).<p>Still, it&#x27;s not a huge project, and it might be interesting as a point of study for people interested in compilers (to bytecode) or bytecode interpreters. The input syntax looks pretty as well.<p>Interestingly, <a href="https:&#x2F;&#x2F;github.com&#x2F;marcobambini&#x2F;gravity&#x2F;blob&#x2F;master&#x2F;src&#x2F;runtime&#x2F;gravity_vm.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;marcobambini&#x2F;gravity&#x2F;blob&#x2F;master&#x2F;src&#x2F;runt...</a> also serves as a nice illustration of the fact that if tabs are allowed in source code, people will <i>mix</i> them with spaces, resulting in code that looks bad unless you have the exact same tab width preferences as the author.
评论 #17376098 未加载
评论 #17374045 未加载
评论 #17375620 未加载
stinos将近 7 年前
For anyone who considers this interesting and&#x2F;or looking for alternatives: apart from the well-known Lua there&#x27;s also MicroPython [1] whos specs actually read a lot like the specs of Gravity but then some more (well, it&#x27;s Python 3.5 minus a couple of features, also compiles with C99 compilers, is fairly small for being a Python, embeddable, more mature at this point, been tested on more platforms&#x2F;architectures, ...).<p>[1] <a href="http:&#x2F;&#x2F;micropython.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;micropython.org&#x2F;</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;micropython&#x2F;micropython&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;micropython&#x2F;micropython&#x2F;</a>
评论 #17374830 未加载
评论 #17374774 未加载
评论 #17375693 未加载
评论 #17374711 未加载
bakery2k将近 7 年前
Is it possible to embed Gravity in my C&#x2F;C++ project and safely run <i>untrusted</i> Gravity code?<p>The Lua implementation supports the creation of sandboxes to run untrusted scripts, but this is a feature that other embeddable languages (e.g. Wren, Python) don&#x27;t seem to support.<p>I feel like this would be a basic requirement - or is it common to embed a scripting language without limiting what scripts are able to do?
评论 #17377057 未加载
评论 #17376873 未加载
评论 #17374827 未加载
评论 #17392587 未加载
creatornator将近 7 年前
A while back I was interested in learning more about programming compilers, so I checked this project out. I actually added array map, filter, reduce, and sort methods to the language, which was fun and a learning process.
评论 #17377824 未加载
评论 #17380002 未加载
vitriol83将近 7 年前
Can anyone suggest a good embedded language with static or at least optional typing ? I feel this is a gap in the market for embedded languages.
评论 #17374981 未加载
评论 #17376751 未加载
评论 #17375004 未加载
评论 #17374820 未加载
inputcoffee将近 7 年前
As a hobbyist I love seeing new languages. I look at their features and a few simple examples and immediately imagine they&#x27;ll solve all the issues I have faced with other languages.<p>I generally appreciate the massive amount work that goes into something like this.<p>But when I want to work on a project, I am wary of using something new. I just know in my heart I&#x27;ll set the wrong flag on the compiler and the binary will end up in a directory I can&#x27;t find and it&#x27;ll take me two days to figure out how to do it.<p>My question is this: if the main strength of this language is that uses Swift-like syntax, and lets you develop native apps in Android and iOS, why not just make an Android compiler for Swift?
评论 #17374229 未加载
pq0ak2nnd将近 7 年前
As an embedded programmer, it is still very hard to displace C and will be for some time. The two main reasons: the compilers are well-behaved, and the debug tools are very, very mature. One thing newcomers overlook is the importance of understanding what the compiler does to the code. C++ is notorious for being painfully unpredictable, and in the embedded world, that is a death sentence. mbed is learning this the hard way. On the other side, debug tools are critical. Unlike the decade long surge of web-related programming with its sophisticated GUI-based debugging, embedded is a completely different beast, and requires much more attention to detail since reprogramming costs are so high. Because C has such a robust hardware debugging ecosystem, it is a clear winner.<p>It&#x27;ll be a long time before anything knocks C down as #1 in the embedded space. Even as the definition of embedded stretches to include *nix variants (like Yocto), there will always be the squeeze to get rid of that and run bare metal with C.
评论 #17377794 未加载
weberc2将近 7 年前
I’m a little bummed about the class-based bit; I generally want structs&#x2F;records, not classes. Specifically, I want to avoid inheritance altogether (yes I know I don’t have to use it, but I still have to interact with it when libraries or coworkers use it). Still, this is a neat little scripting language, and best of luck.
评论 #17374444 未加载
评论 #17375951 未加载
ainar-g将近 7 年前
&gt;null<p>&gt;dynamic typing<p>&gt;naked if-else bodies<p>I&#x27;m sorry, but I just don&#x27;t see how this improves on anything. How will GravLang make me a better, more productive programmer? How will it make my programs more robust?<p>Don&#x27;t get me wrong, as a hobby project it&#x27;s fine, but as a &quot;real&quot; language it doesn&#x27;t have any selling points to me.
评论 #17373978 未加载
评论 #17374472 未加载
评论 #17376136 未加载
bitmapbrother将近 7 年前
&gt;Gravity syntax is designed to be familiar to people coming from C-like languages like Javascript, Swift, C++, C# and many more. We started working on this new language a year before Apple announced Swift and we were happily surprised to discovered how similar both syntax appear.<p>Amusing how the language looks so much like Kotlin - a language released in 2011 and 3 years before Swift.
评论 #17376888 未加载
yoz-y将近 7 年前
Seeing the overall style of the documentation logos and copy, I am kind of surprised that embedding this from Swift is not covered.
评论 #17374606 未加载
cmjqol将近 7 年前
At first look I love how the language is designed.<p>Now I&#x27;m curious about the &quot;embedded&quot; part . Apple doesn&#x27;t allow any VM or JIT to be embedded for iOS application. Either I&#x27;m missing something or else this tech is not compliant with Apple Security Guidelines.
评论 #17377061 未加载
评论 #17376754 未加载
craftoman将近 7 年前
Such an underrated project. IMHO if this one was launched by Facebook or Google now things would be different like 15k+ plus stars on GitHub and tech news sites posting articles with titles like &quot;a new game changer language&quot; and stuff.
bjoli将近 7 年前
Does anyone have numbers on how light it is? How much memory Does it need? How big is the library? Does it compare favourably to Lua or Guile? Guile shouldn&#x27;t be hard to beat for size, but that&#x27;s generally not what they try to achieve.
loa-in-backup将近 7 年前
&quot;Getting started&quot; link from github readme points to 404.<p>Edit: so does &quot;language documentation&quot; link.
mcguire将近 7 年前
&quot;<i>It is a class-based concurrent scripting language with a modern Swift like syntax.</i>&quot;<p>So, it looks like every other language designed in the last 40 years? This is good?
评论 #17374105 未加载
评论 #17375116 未加载
评论 #17375047 未加载
th3iedkid将近 7 年前
anyone using this can illustrate , how they use this ?
评论 #17373867 未加载
amelius将近 7 年前
Sounds not so light-weight.
评论 #17374088 未加载
caspervonb将近 7 年前
Not to rain on your parade here but, in what world is a interpreter &quot;fast and efficient&quot;? Embeddable, minimal footprint and zero external dependencies etc are all excellent real selling points here.
评论 #17373882 未加载
评论 #17374453 未加载
评论 #17373902 未加载
carapace将近 7 年前
Blank page with JS disabled.
PezzaDev将近 7 年前
I don&#x27;t see how a new language can claim to fast and efficient when it does nothing to encourage data-oriented programming.
3rdAccount将近 7 年前
So a language that transpiles to C similar to Nim I guess?<p>Could I use this on Windows and create small binary executables? Any examples of this?
评论 #17373828 未加载