Re:
by cedws on Saturday August 24, 2024 @12:27AM
(#41335637)
Jesus, 78MB is still a lot for such a simple program.
[ Parent
| on HN ]
Re:
by ComputerGuru on Saturday August 24, 2024 @12:43AM
(#41335712)
That’s not the size of the program but the size of the build artifacts folder that includes all the intermediate files like .o in a C project and more.
That still seems like a lot of build artifacts for a 10 line program?
Re:
by commodoreboxer on Saturday August 24, 2024 @01:39AM
(#41335906)
A 10 line program with two dependencies and all their transitive dependencies.
It deserializes a unicode string to a custom structure. Do not mistake it with C character-shuffling hello-world-programs.
Edit: s/to JSON/to a custom structure/
I’m on mobile so I can’t check at the moment. But I’d be shocked if the equivalent go binary was anywhere near as big, or took anywhere near as long to build.
I’ll check later
I don't know what you consider big and long, but on my computer (Ryzen 5700X) it took 7 seconds to build, and the resulting binary is 556 kB.
I'm on an M1 mac, and I followed the instructions above (cargo build --release && du -sh target) and it took 6 seconds, and the target dir is 35MB. I ran it twice to make sure I wasn't pulling the remote dependencies
go.mod
module json-test
go 1.21.1
main.go
package main import (
"encoding/json"
"fmt"
)
type Foo struct {
Bar string `json:"bar"`
}
func main() {
var foo Foo
json.Unmarshal([]byte(`{"bar": "Hello, World!"}`), &foo)
fmt.Println(foo.Bar)
}
time go build && du -sh . go build 0.07s user 0.11s system 348% cpu 0.051 total
2.4M .
I'd say 15x larger and 12x slower "bigger and longer" at least.