‹ BackHN Continuity

Thread

Goose Programming Language

54 points · 69 comments · bobbydigitales

  1. backlands · · focus · HN ↗
    > Goose looks familiar like C or Rust, and is built on one idea: there is no heap

    So it looks like it restricts the memory management to 100% scope based. I expect that makes a lot of designs for programs not translate to it as well as they fit in Rust or Java (for example). There are a bunch more constraining design choices they list further down:

    > - Nothing ever moves

    > - ... A string, an array of strings, a record with variable-size fields and an array of those records are each one contiguous block with no pointer in it

    I'll have to look a bit deeper to decide if it's feasible to write many things in this language.

    1. bobbydigitales · · focus · HN ↗
      What kinds of things do you think might not translate well?
      1. tombert · · focus · HN ↗
        Not the OP, but I'm thinking about like closures?

        Say you wanted to make a Node.js framework with callbacks that react to an event. The callback might be a closure that captured some of its surrounding variables. At that point, any of the captured variables are not trivially stack-allocated.

        You might be able to do something similar to what Rust does with moving though.

        1. skew-aberration · · focus · HN ↗
          You could predefine your event handlers within your context, then call 'enter framework' and pass your event handlers as arguments. this is continuation passing style
          1. cmrx64 · · focus · HN ↗
            it is, but more specifically it’s an eliminator for a coinductive step.
        2. com2kid · · focus · HN ↗
          Nah we did something similar on Microsoft Band. I wrote about how - <a href="https:&#x2F;&#x2F;meanderingthoughts.hashnode.dev&#x2F;cooperative-multitasking-on-microsoft-band" rel="nofollow">https:&#x2F;&#x2F;meanderingthoughts.hashnode.dev&#x2F;cooperative-multitas...

          The tldr is you had to preallocate a struct with anything you wanted captured ahead of time.

        3. jandrewrogers · · focus · HN ↗
          Typically you would construct this state in statically allocated memory. A lot of systems work this way. Dynamic heap allocation isn’t the only alternative to stack allocation.
      2. thayne · · focus · HN ↗
        Say you wanted a map of some key to growable arrays (or maps), where the number of keys isn&#x27;t known until runtime. It I understand correctly, you can&#x27;t really do that because the number of growable stacks nees to be known at compile time.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.