Why CGO is Dangerous

Поделиться
HTML-код
  • Опубликовано: 2 янв 2025

Комментарии • 43

  • @tashima42
    @tashima42 3 дня назад +9

    Working with CGO I had some crazy bugs where just changing the order of seemingly random things would make code compile or not, just madness

    • @rachellettuce
      @rachellettuce  3 дня назад

      Yeah, CGO can be a real head-scratcher sometimes. 😩

  • @roboto_
    @roboto_ 3 дня назад +13

    more like cno

  • @bitmasked
    @bitmasked 3 дня назад +6

    In Star Trek terms: If C land is regular space, Go land is fluidic space; CGO, the interdimensional rift connecting them, is hostile and unstable.

    • @rachellettuce
      @rachellettuce  3 дня назад +2

      @@bitmasked exactly!
      Also I love your username

    • @bitmasked
      @bitmasked 3 дня назад

      @@rachellettuce Thank you! Awesome channel - exactly my kind of ✨Content™✨

  • @kassiusklei
    @kassiusklei 2 дня назад +2

    Can you please elaborate on your points. I would be interested in examples and specific things. I now learned nothing that prepares me to mitigate or even recognize possible problems. Just: cgo bad, trust me bro

  • @raghav9000
    @raghav9000 3 дня назад +5

    I am learning how to make webserver in C.

    • @paca3107
      @paca3107 3 дня назад

      build your own http implementation

    • @rachellettuce
      @rachellettuce  3 дня назад +2

      Hell yeah! Definitely a great exercise

    • @-aexc-
      @-aexc- 3 дня назад

      ​@@paca3107you have to do that when writing a webserver right? it was way easier than i expected not gonna lie

  • @motazabdelazeem3533
    @motazabdelazeem3533 3 дня назад +1

    yesterday i had to disable CGO (CGO_ENABLED=0) because of missing library error message in deployment server, but my question is: why this isn't by default?

  • @brandondcruz9778
    @brandondcruz9778 3 дня назад +15

    I thought this was gonna be about CS GO 🔫

    • @rachellettuce
      @rachellettuce  3 дня назад +1

      Sorry :(

    • @deafharp8944
      @deafharp8944 3 дня назад +1

      I thought it was just a typo of CGI lol

    • @rachellettuce
      @rachellettuce  3 дня назад

      @@deafharp8944 high-key not a bad idea for a video 🤣

  • @zombiiju4465
    @zombiiju4465 3 дня назад +2

    why is debugging hard, i can debug cgo code with breakpoints with vscode without a complex setup?

    • @rachellettuce
      @rachellettuce  3 дня назад

      Working with C in this way with a layer of Go in front of it means that there's an extra layer of complexity.
      For example, Go has a default way of handling memory alignment. In C, it's free rein. When you debug this, it is hard to figure out exactly what's happening, especially if it seems like a green flag all the way through.

  • @AK-vx4dy
    @AK-vx4dy 3 дня назад +2

    Maybe Go shouldn't integrate but run them as separate process and only communicate with them in safe ways

    • @rachellettuce
      @rachellettuce  3 дня назад +2

      Yeah I agree! I'm not sure how, or what's the best approach, but I feel like right now we have a duct tape solution that needs work.

    • @bitmasked
      @bitmasked 3 дня назад

      ​@@rachellettuce I've seen a number of Go shops end up ditching cgo and the "plugin" package for IPC.
      My preference so far is where the parent spawns the child "library" process that exposes an RPC interface over stdin/stdout. gRPC is great for this as it multiplexes the stdio connection out of the box.
      It's probably the worst thing about Go - ABI interop with anything that wasn't built into the binary is just not stable.

  • @yy84869
    @yy84869 2 дня назад +1

    I'm planning to spend my new year converting my python upscaling code to c++

    • @rachellettuce
      @rachellettuce  2 дня назад +1

      @@yy84869 oof, I hope you like C++ at least 🤣

    • @yy84869
      @yy84869 2 дня назад

      @rachellettuce is it worth it?, I am doing it for performance, even few ms will count.

    • @rachellettuce
      @rachellettuce  2 дня назад +1

      @@yy84869 oh yeah definitely

    • @yy84869
      @yy84869 2 дня назад

      @@rachellettuce thanks a lot, I really appreciate it.

    • @rachellettuce
      @rachellettuce  2 дня назад +1

      halimshams.medium.com/python-vs-c-speed-comparison-48187511c595
      Check this out!

  • @mr.shredder5430
    @mr.shredder5430 2 дня назад +1

    great content you have a nice way of explaining things

  • @juillotine
    @juillotine 3 дня назад +1

    ok this explains why my code sucks when i work with tdlib

  • @stroiman.development
    @stroiman.development День назад

    Go is garbage collected, and C is not … Then try throwing in a v8 engine that hosts another garbage collected language by a non-garbage collected language, embedded in a garbage collected language 😅

  • @-aexc-
    @-aexc- 3 дня назад +1

    go could have been so good :/

  • @nellfs
    @nellfs 3 дня назад +1

    The CGo ghost

  • @AK-vx4dy
    @AK-vx4dy 3 дня назад +1

    Deranged cousins 🤣

  • @haras-unicorn
    @haras-unicorn 3 дня назад +1

    go L

  • @technovikingnik
    @technovikingnik День назад

    🌹