GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    Mike 🐧 :fedora: :centos: (omenos@fosstodon.org)'s status on Tuesday, 27-Feb-2024 04:26:17 JST Mike 🐧 :fedora: :centos: Mike 🐧 :fedora: :centos:

    Decided to try and compare the general base program size of several languages. I wrote a handful of Hello World programs, and stripped them of everything. Here's the final results in KiB:

    strip -s -o ${lang}_strip
    du *_strip

    C: 16
    C++: 16
    Go: 1204
    Hare: 220
    Rust: 352

    #programming #compile #c #cpp #go #golang #hare #harelang #rust #rustlang

    In conversation about a year ago from fosstodon.org permalink
    • Embed this notice
      Mike 🐧 :fedora: :centos: (omenos@fosstodon.org)'s status on Tuesday, 27-Feb-2024 04:26:16 JST Mike 🐧 :fedora: :centos: Mike 🐧 :fedora: :centos:
      in reply to
      • Drew DeVault
      • synlogic

      @synlogic @drewdevault You both replied while I was in the middle of writing the followup 😅

      I wanted to test default compiling behavior, which means for at least C and C++ results in dynamically linked binaries.

      In conversation about a year ago permalink
    • Embed this notice
      Drew DeVault (drewdevault@fosstodon.org)'s status on Tuesday, 27-Feb-2024 04:26:16 JST Drew DeVault Drew DeVault
      in reply to
      • synlogic

      @omenos @synlogic gotcha. fwiw I can get down to 14K with a statically linked Hare binary which is a bit contrived:

      use rt;

      export fn main() void = {
      const msg = "Hello world!\n";
      rt::write(1, &(&msg: *[]u8)[0], len(msg))!;
      };

      hare build -Ro main main.ha
      strip main

      In conversation about a year ago permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      Mike 🐧 :fedora: :centos: (omenos@fosstodon.org)'s status on Tuesday, 27-Feb-2024 04:26:17 JST Mike 🐧 :fedora: :centos: Mike 🐧 :fedora: :centos:
      in reply to

      Something to note is that Golang and Hare are the only two actually static binaries of the bunch. C, C++, and Rust are all dynamically linked to some degree (libc, libstdc++, libgcc_s, libm).

      In conversation about a year ago permalink
    • Embed this notice
      Mike 🐧 :fedora: :centos: (omenos@fosstodon.org)'s status on Tuesday, 27-Feb-2024 04:35:17 JST Mike 🐧 :fedora: :centos: Mike 🐧 :fedora: :centos:
      in reply to
      • Drew DeVault
      • synlogic

      @drewdevault @synlogic Haha, yeah. I figured there are clever ways of getting "as close to the metal" as possible, I was only looking at general usage.

      C: printf("Hello, World!\n")

      C++: std::cout << "Hello, World!" << std::endl

      Go: fmt.Println("Hello, World!")

      Hare: fmt::println("Hello, World!")

      Rust: println!("Hello, World!")

      In conversation about a year ago permalink
    • Embed this notice
      Drew DeVault (drewdevault@fosstodon.org)'s status on Tuesday, 27-Feb-2024 04:35:17 JST Drew DeVault Drew DeVault
      in reply to
      • synlogic

      @omenos @synlogic makes sense. I got 117 KiB for that program, but it's probably just a difference in Hare versions. I wouldn't nitpick except that this puts us at under half of the size of Rust and I'll take that W :)

      In conversation about a year ago permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Tuesday, 27-Feb-2024 05:04:49 JST Haelwenn /элвэн/ :triskell: Haelwenn /элвэн/ :triskell:
      in reply to
      • Drew DeVault
      • synlogic
      @drewdevault @omenos @synlogic Meanwhile here looking at C but static (and still stripped).
      x86_64 + glibc:
      - clang: 601K
      - gcc: 593K
      - tcc: fails, undefined symbols when compiling statically

      x86_64 + musl:
      - clang: 7.2K
      - gcc: 18K
      - tcc: 29K
      In conversation about a year ago permalink
    • Embed this notice
      Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Tuesday, 27-Feb-2024 05:17:47 JST Haelwenn /элвэн/ :triskell: Haelwenn /элвэн/ :triskell:
      in reply to
      • Haelwenn /элвэн/ :triskell:
      • Drew DeVault
      • synlogic

      @drewdevault @omenos @synlogic btw about the clang vs. gcc thing on musl, it seems like it's about packing code efficiently as size(1) reports very similar numbers for both while the binary generated by gcc has three large chunks of zeroes which the clang one doesn't have.

      $ size hello-printf-* text data bss dec hex filename 5358 320 1688 7366 1cc6 hello-printf-clang17 5426 288 1696 7410 1cf2 hello-printf-gcc 21046 406 1592 23044 5a04 hello-printf-tcc
      In conversation about a year ago permalink
    • Embed this notice
      Mike 🐧 :fedora: :centos: (omenos@fosstodon.org)'s status on Tuesday, 27-Feb-2024 05:21:44 JST Mike 🐧 :fedora: :centos: Mike 🐧 :fedora: :centos:
      in reply to
      • Haelwenn /элвэн/ :triskell:
      • Drew DeVault
      • synlogic

      @lanodan @drewdevault @synlogic glibc does tend to provide... larger binaries considering how much is going on in the libraries. I'm going to run a quick test comparing GNU libstdc++ to LLVM libc++.

      In conversation about a year ago permalink
      Haelwenn /элвэн/ :triskell: likes this.

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.