Everything you need to know about FFI in Gleam

Поділитися
Вставка
  • Опубліковано 11 лис 2024

КОМЕНТАРІ • 42

  • @IsaacHarrisHolt
    @IsaacHarrisHolt  4 місяці тому +5

    ERRATA:
    6:45 - Gleam lists use a custom type for JS which can be switched to/from using custom `toList` and `fromList` functions
    NOTES:
    - You can FFI into Elixir, too! Just specify the `erlang` target and use the module name as you would in Erlang (thanks @JLarky!)

  • @zakariabenhadi4637
    @zakariabenhadi4637 4 місяці тому +3

    Nice video again. Do you plan on doing one about hosting a gleam backend app? I struggle with finding info about that - I suppose a server running erlang vm is enough but a deep dive would be so nice

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому +3

      Ooh good idea! Yeah any Erlang server would do, and I believe there are also some deployment guides on the Gleam website

    • @zakariabenhadi4637
      @zakariabenhadi4637 4 місяці тому +3

      @@IsaacHarrisHolt Oh my god you're right, thanks !

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому

      No worries!

  • @JLarky
    @JLarky 4 місяці тому +3

    Fun fact, you can also ffi into Elixir :)

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому +1

      Yes! This is true, but I managed to miss it out of the video

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому +1

      I've added this to the pinned comment :)

    • @JLarky
      @JLarky 4 місяці тому +1

      @@IsaacHarrisHolt yeah, the best part is that it allows you to install Elixir dependencies from hex, which makes it really easy to use

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому +1

      Yes! Though I've been informed that you can just use the Elixir module name :)

  • @nomadtrails
    @nomadtrails 2 місяці тому

    Can gleam call JS when the compilation target is Erlang?

  • @costinel57
    @costinel57 4 місяці тому

    But how are js classes represented by gleam? 🤔

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому +2

      They're generally not. You shouldn't be writing enough JS to the point where you need classes, honestly. However, if you NEED to return a class instance, you can, but you shouldn't try to introspect it on the Gleam side.
      In this case I would create a type with 0 constructors, like I did with the Date type.

    • @costinel57
      @costinel57 4 місяці тому

      @@IsaacHarrisHolt I guess that makes sense, thanks!

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому

      No worries!

  • @prethammuthappabs2241
    @prethammuthappabs2241 4 місяці тому +1

    Thinking of getting into gleam , the syntax kinda looks look like rust and i kinda had a bit tough time with it , so is gleam easy? Or same as rust?

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому +5

      Syntax and language difficulty are not correlated! Gleam is really easy to pick up, and I'd recommend giving it a go

  • @devyb-cc
    @devyb-cc 4 місяці тому

    man, i wish python ffi is coming next...

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому +1

      That's kinda unlikely. Gleam doesn't compile to Python, so it wouldn't make a lot of sense. You'd have to spin up a whole new Python process just to execute the code

    • @devyb-cc
      @devyb-cc 4 місяці тому

      @@IsaacHarrisHolt fair enough hhh

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому

      What's the reason for wanting a Python backend?

    • @devyb-cc
      @devyb-cc 4 місяці тому

      @@IsaacHarrisHolt no particular reason, but i do some research on fastapi this week

    • @devyb-cc
      @devyb-cc 4 місяці тому

      tbh it's still better to use a microservice approach if the project needs to be written in multi language

  • @lpil
    @lpil 4 місяці тому +14

    First!

  • @raccoonteachesyou
    @raccoonteachesyou 4 місяці тому +1

    Fifth ?

  • @renefrusco2691
    @renefrusco2691 4 місяці тому

    nth!

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 місяці тому

      I wonder if people ever leave real comments these days...

  • @xfldiazx
    @xfldiazx 4 місяці тому

    Fourth!

  • @TheddunTOSS
    @TheddunTOSS 4 місяці тому

    Third!

  • @johtso1
    @johtso1 4 місяці тому

    Second!