from Hacker News

Bog – small, strongly typed, embeddable language

by tsujp on 1/29/23, 1:18 PM with 50 comments

  • by latch on 1/29/23, 3:24 PM

    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)

  • by Taywee on 1/29/23, 2:58 PM

    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.

  • by JonChesterfield on 1/29/23, 1:44 PM

    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

  • by girvo on 1/29/23, 11:05 PM

    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!

  • by dom96 on 1/29/23, 4:14 PM

    Interesting to see so many languages implemented in Zig pop up suddenly.
  • by IshKebab on 1/29/23, 3:50 PM

    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?

  • by timeon on 1/29/23, 2:19 PM

    Can match return value? It is not clear from the example since it has many duplicated print functions instead.
  • by samsquire on 1/29/23, 2:19 PM

    I am glad to see coroutines.

    How are coroutines scheduled?

    Can suspend return a value?

  • by detrites on 1/29/23, 4:50 PM

    Love how this language is explained with code only.
  • by odedbend on 1/29/23, 2:00 PM

    What is the performance of this language? Does its performance resemble that of any popular language?
  • by Titan2189 on 1/30/23, 3:44 AM

    Do they offer it in multiple versions, the most common one being called "standard"?
  • by sitkack on 1/29/23, 3:57 PM

    Neat!

    Looks like a LuPyrby language.

  • by boxed on 1/29/23, 8:44 PM

    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)...
  • by moomin on 1/29/23, 4:44 PM

    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.