Bog – small, strongly typed, embeddable language

  • Somewhat related is yesterday's post about the Cyber programming language, also built on Zig and also embeddable: https://news.ycombinator.com/item?id=34553236

    (Not affiliated with either, just can be easy to miss stories on here sometimes, and I figured anyone interesting in Bog might also be interested in Cyber)

  • Pretty interesting. I'm a professional user of Lua, and while I love it, I really get frustrated at a lot of aspects of it, especially how loose the typing is. I've long wished there were more strongly typed alternatives, but just nothing compares to the performance, stability, and quality of documentation of Lua.

    I'm not sure how I would embed this in a non-Zig project, though.

  • Thank you for posting this.

    > let {print} = import "std.io"

    An idea obvious in hindsight that I hadn't thought before - if import returns an environment and let can destructure, then a pattern match can bind an explicit subset of that import. Something like:

    `(let {print read} (import io) (print (read)))`

    Further down I find essentially that example (with input instead of read) and destructuring assignment within function arguments:

    `let add = fn ((a,b)) a + b`

    though the grammar suggests that {} is initialisation and not a map/dict/hash/assoc/environment style thing, so you probably don't have `fn ({key value}) value + 4` or similar for taking maps apart as they are passed to a function. Thus I think import is special cased.

    The bytecode layer knows what maps are though, so maybe they're just missing from the syntax

  • So this is from my particular bias, but any language that touts itself as embedded, I really want to understand it's memory allocation model and approach! I see it's built on Zig, but does it support custom allocators within Bog itself? I'd love to use embeddable languages like this in embedded firmware, but a lot of them have issues with heap fragmentation when actually used in-anger, I've found.

    Aside from my biased nitpick, it looks pretty neat!

  • Interesting to see so many languages implemented in Zig pop up suddenly.

  • Thought this was statically typed for a moment... Shame.

    I don't think you need to call out strong typing. Who would make a weakly typed language in 2023?

  • Can match return value? It is not clear from the example since it has many duplicated print functions instead.

  • I am glad to see coroutines.

    How are coroutines scheduled?

    Can suspend return a value?

  • Love how this language is explained with code only.

  • What is the performance of this language? Does its performance resemble that of any popular language?

  • Do they offer it in multiple versions, the most common one being called "standard"?

  • Neat!

    Looks like a LuPyrby language.

  • It's a pity people don't know the history of the comma in python syntax, and thus think it's totally unnecessary (in a CS sense it is)...

  • Is it my imagination or is the most embedded language in the world C# these days? Which doesn’t really look anything like a classic language designed for embedding.