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

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024

ความคิดเห็น • 29

  • @Tobiky
    @Tobiky 3 หลายเดือนก่อน +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!

  • @LarryGarfieldCrell
    @LarryGarfieldCrell 3 หลายเดือนก่อน +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  3 หลายเดือนก่อน

      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  3 หลายเดือนก่อน

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

    • @LarryGarfieldCrell
      @LarryGarfieldCrell 3 หลายเดือนก่อน +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.

  • @kgibbershnoxss
    @kgibbershnoxss 3 หลายเดือนก่อน +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  3 หลายเดือนก่อน

      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  3 หลายเดือนก่อน

      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 3 หลายเดือนก่อน +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  3 หลายเดือนก่อน

      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!

  • @mikolmisol6258
    @mikolmisol6258 3 หลายเดือนก่อน +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  3 หลายเดือนก่อน +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  3 หลายเดือนก่อน +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.

  • @JosephOziel
    @JosephOziel 3 หลายเดือนก่อน +1

    I love where this is going!

  • @jmstevers
    @jmstevers 3 หลายเดือนก่อน +1

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

    • @contextfree
      @contextfree  3 หลายเดือนก่อน

      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 3 หลายเดือนก่อน +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  3 หลายเดือนก่อน

      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  3 หลายเดือนก่อน

      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 3 หลายเดือนก่อน +2

    Any reason for using wasmi_cli instead of wasmtime?

    • @contextfree
      @contextfree  3 หลายเดือนก่อน +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 3 หลายเดือนก่อน +2

    Why is call it rio?

    • @contextfree
      @contextfree  3 หลายเดือนก่อน +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  3 หลายเดือนก่อน +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  3 หลายเดือนก่อน +3

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

    • @contextfree
      @contextfree  3 หลายเดือนก่อน +5

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

    • @jonas1ara
      @jonas1ara 3 หลายเดือนก่อน +1

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