Show HN: Bolt – A super-fast, statically-typed scripting language written in C
261 points| beariish | 6 months ago |github.com
I've felt like most embedded languages have been moving towards safety and typing over years, with things like Python type hints, the explosive popularity of typescript, and even typing in Luau, which powers one of the largest scripted evironments in the world.
Bolt attempts to harness this directly in the lagnauge rather than as a preprocessing step, and reap benefits in terms of both safety and performance.
I intend to be publishing toys and examples of applications embedding Bolt over the coming few weeks, but be sure to check out the examples and the programming guide in the repo if you're interested!
haberman|6 months ago
I also love the focus on performance. I'm curious if you've considered using a tail call design for the interpreter. I've found this to be the best way to get good code out of the compiler: https://blog.reverberate.org/2021/04/21/musttail-efficient-i... Unfortunately it's not portable to MSVC.
In that article I show that this technique was able to match Mike Pall's hand-coded assembly for one example he gave of LuaJIT's interpreter. Mike later linked to the article as a new take for how to optimize interpreters: https://github.com/LuaJIT/LuaJIT/issues/716#issuecomment-854...
Python 3.14 also added support for this style of interpreter dispatch and got a modest performance win from it: https://blog.reverberate.org/2025/02/10/tail-call-updates.ht...
beariish|6 months ago
debugnik|6 months ago
summerwant|6 months ago
perlgeek|6 months ago
> import abs, epsilon from math
IMHO it's wrong to put the imported symbols first, because the same symbol could come from two different libraries and mean different things. So the library name is pretty important, and putting it last (and burying it after a potentially long list of imported symbols) just feels wrong.
I get that it has a more natural-language vibe this way, but put there's a really good reason that most of the languages I know that put the package/module name first:
With Typescript being the notable exception:jasonjmcghee|6 months ago
Though I almost never manually type out imports manually anymore.
bbkane|6 months ago
See https://guide.elm-lang.org/webapps/modules (scroll down to "Using Modules") for examples
beariish|6 months ago
vhodges|6 months ago
"In case of conflict or convenience, you can give modules an alias as well."
Tokumei-no-hito|6 months ago
MobiusHorizons|6 months ago
beariish|6 months ago
RossBencina|6 months ago
conaclos|6 months ago
devmor|6 months ago
megapoliss|6 months ago
jeroenhd|6 months ago
johnisgood|6 months ago
That said, somehow I do not believe it is faster than LuaJIT. We will see.
amai|6 months ago
ModernMech|6 months ago
JonChesterfield|6 months ago
Compile to register bytecode is legitimate as a strategy but its not the fast one, as the author knows, so probably shouldn't be branding the language as fast at this point.
It might be a fast language. Hard to tell from a superficial look, depends on how the type system, alias analysis and concurrency models interact. It's not a fast implementation at this point.
> This means functions do not need to dynamically capture their imports, avoiding closure invocations, and are able to linearly address them in the import array instead of making some kind of environment lookup.
That is suspect, could be burning function identifiers into the bytecode directly, not emitting lookups in a table.
Likewise the switch on the end of each instruction is probably the wrong thing, take a look at a function per op, forced tailcalls, with the interpreter state in the argument registers of the machine function call. There's some good notes on that from some wasm interpreters, and some context on why from luajit if you go looking.
phire|6 months ago
Embedded interpreters are that designed to be embedded into a c/c++ program (often a game) as a scripting language. They typically have as few dependencies as possible, try to be lightweight and focus on making it really easy to interopt between contexts.
The comparison hits many of the major languages for this usecase. Though it probably should have included mono's interpreter mode, even if nobody really uses it since mono got AoT
banginghead|6 months ago
cookiengineer|6 months ago
What about memory management/ownership? This would imply that everything must be copy by value in each function callsite, right? How to use references/pointers? Are they supported?
I like the matchers which look similar to Rust, but I dislike the error handling because it is neither implicit, and neither explicit, and therefore will be painful to debug in larger codebases I'd imagine.
Do you know about Koka? I don't like its syntax choices much but I think that an effect based error type system might integrate nicely with your design choices, especially with matchers as consumers.
[1] https://koka-lang.github.io/koka/doc/index.html
driggs|6 months ago
Functions do have a return signature.
It looks like the author chose to show off the feature of return type inference in the short example README code, rather than the explicit case.
https://github.com/Beariish/bolt/blob/main/doc/Bolt%20Progra...
zygentoma|6 months ago
freeopinion|6 months ago
We read here a couple days ago about Q which is compiled. Bolt claims to "plow through code at over 500kloc/thread/second". Q claims to compile in milliseconds--so fast that you can treat it like a script.
Bolt and Q are both newborns. Perhaps you could include each other in your benchmarks to give each other a little publicity.
themonsu|6 months ago
IAmLiterallyAB|6 months ago
eqvinox|6 months ago
eulgro|6 months ago
My main concern about a new language is not performance, syntax, or features, but long term support and community.
brabel|6 months ago
01HNNWZ0MV43FF|6 months ago
At this point it is too early to know. Even JavaScript took like 20 years to catch on
slmjkdbtl|6 months ago
cdaringe|6 months ago
wk_end|6 months ago
thrance|6 months ago
beariish|6 months ago
jitl|6 months ago
tekkk|6 months ago
npn|6 months ago
make me instantly lost interest in the language.
nativeit|6 months ago
1. Ask - the author is very much available, right here in this comment section they made specifically for such a prospect. 2. Contribute - Code the change you wish to see in the world. Follow the OP’s example, and do something about it.
childintime|6 months ago
so it seems to me you're hung up on the current limitations of the language server, which is an implementation detail.
if what you want is actually important, the syntax should have been `import yyy.xxx as xxx` or similar, with optional `as xxx`, instead of a Cobol inspired syntax detail to remember.
naasking|6 months ago
Dynamically typed languages have more difficulties with autocomplete in general, Bolt is statically typed so you shouldn't automatically assume the same difficulties carry over.
cdaringe|6 months ago
This cannot be a reasonable factor in lang selection.
Fraterkes|6 months ago
beariish|6 months ago
As for writeups, I'm working on putting out some material about the creation of Bolt and my learnings now that it's out there.
memophysic|6 months ago
On the feature side, is there any support for breakpoints or a debugging server, and if not is it planned?
beariish|6 months ago
tayistay|6 months ago
I noticed that `let`-declared variables seem to be mutable. I'd strongly recommend against that. Add a `var` keyword.
mdaniel|6 months ago
https://github.com/Beariish/bolt/blob/0.1.0/doc/Bolt%20Progr...
sureglymop|6 months ago
astatine|6 months ago
beariish|6 months ago
merksoftworks|6 months ago
Warwolt|6 months ago
Usually I feel like that's bare minimum before I'd like to try and play around with a language
je42|6 months ago
Quickly scanned the programming guide - but wasn't able to find it. Did i miss a section?
progx|6 months ago
https://github.com/Beariish/bolt/blob/main/examples/error_ha...
kiririn|6 months ago
(https://www.compuphase.com/pawn/pawn.htm)
grodriguez100|6 months ago
beariish|6 months ago
Forgret|6 months ago
Vandash|6 months ago
beariish|6 months ago
IshKebab|6 months ago
capyba|6 months ago
acron0|6 months ago
truekonrads|6 months ago
boffinAudio|6 months ago
k__|6 months ago
Is it deterministic like Lua?
amai|6 months ago
[deleted]