Thread overview
[Issue 24299] The dmd's command line option "-run" should prefer dynamic linking with the Phobos library by default
Dec 23, 2023
Siarhei Siamashka
Dec 23, 2023
ryuukk_
Dec 23, 2023
Adam D. Ruppe
Dec 24, 2023
Siarhei Siamashka
December 23, 2023
https://issues.dlang.org/show_bug.cgi?id=24299

--- Comment #1 from Siarhei Siamashka <siarhei.siamashka@hotmail.com> ---
For comparison, here's a similar test with Go (~143 ms):

```Go
package main
import "fmt"
func main() {
    fmt.Println("hello world")
}
```

$ go version
go version go1.21.4 linux/amd64

$ echo " " >> helloworld.go && time go run helloworld.go hello world

real    0m0.143s


The status quo is that `go run` is significantly faster today and getting closer to its 143 ms should be a target for `dmd -run` as well.

--
December 23, 2023
https://issues.dlang.org/show_bug.cgi?id=24299

ryuukk_ <ryuukk.dev@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ryuukk.dev@gmail.com

--- Comment #2 from ryuukk_ <ryuukk.dev@gmail.com> ---
You mention go, but go does statically link everything

So you are not matching go in your comparison, you are doing something different to pretend it runs faster

The solution is to make phobos less bloated, let us not put the problem under the carpet to pretend it's clean

--
December 23, 2023
https://issues.dlang.org/show_bug.cgi?id=24299

Adam D. Ruppe <destructionator@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator@gmail.com

--- Comment #3 from Adam D. Ruppe <destructionator@gmail.com> ---
I think this is actually a pretty good idea. My reservation with dynamic linking in general is that it makes long term functionality and distribution harder; you have a larger sum of data to transfer and have the added difficulty of keeping versions in sync.

But indeed, as you say with -run, you aren't keeping it long-term anyway, so it seems there's no downside to it.

--
December 24, 2023
https://issues.dlang.org/show_bug.cgi?id=24299

--- Comment #4 from Siarhei Siamashka <siarhei.siamashka@hotmail.com> ---
(In reply to ryuukk_ from comment #2)
> You mention go, but go does statically link everything
> 
> So you are not matching go in your comparison, you are doing something different to pretend it runs faster

The DMD compiler doesn't produce any binary for the end users as a result of using "-run" option, so the choice of static or dynamic linking is a hidden internal implementation detail not visible to the end user.

If you think that this kind of "cheating" is unfair to Go, then Go is already "cheating" to an even larger extent by using a custom non-standard format for the object files and relying on its own custom linker to process them. See https://go.googlesource.com/proposal/+/master/design/go13linker.md

> The solution is to make phobos less bloated, let us not put the problem under the carpet to pretend it's clean

There's no such thing as "the solution" here. Compilation time can be reduced by doing multiple independent optimizations. Each of them contributes something. Currently there are many low hanging fruits.

Even if you succeed in making Phobos less bloated, using dynamic linking instead of static linking will be still beneficial.

--