Making a language: Structs as Named Args (and also some recursion)

Sdílet
Vložit
  • čas přidán 6. 07. 2024
  • Code: github.com/contextfreeinfo/rio/
    - I still haven't fully implemented nested structs yet, either.
    - I might still change the term from struct to record.
    - I'll probably change multi-value Text ranges to memory-based struct-like storage.
    - I plan a fixed size struct-like thing also in the future that can't reference "heap" allocated RC things.
    0:00 Intro
    0:17 Recursion
    1:53 Structs / records
    3:14 Structs as named args
    4:03 Deep punning
    4:33 Keywords vs punctuation
    6:36 Parse tree vs normed AST
    7:33 Analyzed tree
    8:34 Wasm (WebAssembly)
    10:30 Outro
  • Věda a technologie

Komentáře • 29

  • @LarryGarfieldCrell
    @LarryGarfieldCrell Před měsícem +7

    You've already done more to show how to work with Wasm than every other tutorial I've ever seen, because you showed how strings work. Every other tutorial stops at integers, which is kinda useless. So, thank you!
    One of these days I want to try building a Wasm language, but I really don't have the time for figuring out all the little details like that.

    • @contextfree
      @contextfree  Před 29 dny

      Glad the videos are helpful to you! And yeah, life balance is tricky. Gotta make the decisions that are right for your situation, whatever those are.

    • @contextfree
      @contextfree  Před 29 dny

      And I still need to study wit (wasm interface types) sometime.

    • @LarryGarfieldCrell
      @LarryGarfieldCrell Před 29 dny +1

      @@contextfree I'd love a video on those and how to use them! Really, any walk through of how you've done what you've done would be helpful.

  • @Tobiky
    @Tobiky Před měsícem +10

    Man I love this channel so much. You have actually inspired me into taking college courses in the formal logic of programming languages (such as lambda calculus) and I have been absolutely loving it. Thank you!

  • @kgibbershnoxss
    @kgibbershnoxss Před 29 dny +2

    It’s fun seeing this project progress. Also, it would be funny if you optimized tail calls by emitting a “return_call” instruction

    • @contextfree
      @contextfree  Před 29 dny

      I missed that that's standardized in wasm already. I'll have to see the support for that. And I'd want to have explicit tail call indicator of some sort in Rio for that, I think. And I'd eventually want to verify it in the Rio compiler if so. But yeah, I think tail calls are great when verifiable.

    • @contextfree
      @contextfree  Před 29 dny

      And thanks for drawing my attention to it! And I'm not yet sure exactly how I'd want to indicate it in Rio syntax yet.

  • @dunkyl
    @dunkyl Před měsícem +2

    The structure arg running kinda reminds me of "the other side" of struct decomposition patterns in a function definition, like in JS or F#. Cool idea

    • @contextfree
      @contextfree  Před měsícem

      And I hope to have destructuring definitions and pattern in matching in Rio also. If I allow those in arg position for ad hoc arg struct types, it would look just like defining named args also, but I'm not yet sure if I want ad hoc structs like that. And I'm moving slow here, clearly, so we'll see what gets done. Thanks for the comment!

  • @JosephOzielComposer
    @JosephOzielComposer Před měsícem +1

    I love where this is going!

  • @mikolmisol6258
    @mikolmisol6258 Před 29 dny +2

    I love seeing the progress on Rio! I'm assuming it has structural typing, judging by the fact you can create anonymous records using the struct function?

    • @contextfree
      @contextfree  Před 29 dny +1

      Thanks for the encouragement! I'm actually leaning toward nominal typing, and it's actually nominal right now. I should have mentioned that in the video. The = is a fixed definition, then I track it as a distinct thing. I love structural, but nominal is easier to code in the compiler and easier to report in messages (although I don't have messages yet). Maybe easy spread syntax will get some of the advantages of structural also. But I also need to see how it goes. Some people want design set in stone in advance, but I'm still winging it some.

    • @contextfree
      @contextfree  Před 29 dny +1

      I do also plan separate "packed" (somewhat like Rust "Copy" trait) and "class" types from "struct", where packed and struct act like C# record types also in ways, but classes are opaque abstractions. And might still say "record" instead of "struct". Thinking about that.

  • @haddihamood
    @haddihamood Před měsícem +1

    have you looked into algebraic effects? ive been researching them and just wanted to know what you think of the idea

    • @contextfree
      @contextfree  Před měsícem

      I've played with Koka some, but I still don't feel super familiar with them. For Rio, I plan to indicate in effects in some fashion, maybe even just by required args, but I probably won't go full algebraic effect handling or anything.

    • @JohnnySacc
      @JohnnySacc Před měsícem +1

      Just looked it up and read a blog post on it. Is it not just dependency injection? I get that it goes up the stack to find the closest 'handler' for a certain effect, but similarly you can pass dependencies down.

    • @contextfree
      @contextfree  Před měsícem

      By "required args", I effectively meant dependency injection. Some languages make effect handling a primary language feature though, and maybe combined with coroutines and such, they get more low-level flow control out of it. But I can't speak authoritatively on the subject at all.

    • @contextfree
      @contextfree  Před měsícem

      I have some videos on effects and also dynamic scope where I explore the subjects in a limited way, but that's as far as I've gone.

  • @glebbash
    @glebbash Před měsícem +2

    Any reason for using wasmi_cli instead of wasmtime?

    • @contextfree
      @contextfree  Před měsícem +4

      I've often used wasmer for cli execution in past videos, but I like to check on at least some variety of wasm engines, and wasmi is a lightweight and performant interpreter that's well maintained. I haven't done it yet, but I'm inclined to automate running of all my test/example programs using wasmi. I regularly manually check on wasmer as well. And wasmer is surprisingly fast startup for being a compile-to-native engine. And yeah, I probably should be checking wasmtime also.

  • @jonas1ara
    @jonas1ara Před měsícem +2

    Why is call it rio?

    • @contextfree
      @contextfree  Před měsícem +5

      I've been calling my hobby language plans Rio for decades, even though the specific language plans have changed over time. It's had more meaning for some of those language variations than others (in the "river" sense of the word). But it's primarily named for my fond (and sometimes not so fond) memories of Río Blanco, San Marcos, Guatemala.

    • @contextfree
      @contextfree  Před měsícem +4

      Rio conveniently also might remind people of Lua, which is nice because I aim to be small in implementation and feels like Lua is. If the R reminds people of Ruby, that's also not so bad. Even though Rio is statically typed unlike default Lua or Ruby.

    • @contextfree
      @contextfree  Před měsícem +3

      And might remind people of Lua since that comes from a more famous place with Rio in its name.

    • @contextfree
      @contextfree  Před měsícem +5

      And sorry for the spam, but maybe only 10-15 years of using that name for projects and ideas.

    • @jonas1ara
      @jonas1ara Před 29 dny +1

      @@contextfree and Rio languages it will only be a hobby or plans that are something real?