On Wednesday, 3 March 2021 at 23:30:20 UTC, harakim wrote:
Every time I come back to a D program I wrote over a year ago, it seems like there are numerous breaking changes and it takes me a while to get it to compile again.

I am porting a large code base from Extended Pascal to D and I know that there will be changes in the language in the future that will take an effort to adapt to. Yet, I am still in the camp of wanting these changes to happen because we don't want to port from a dead language to another dead language, we need the language to be alive.

The way I deal with this is to lock down version numbers with the revision number of our code base. By having dub.selections.json under revision control we make sure that the same version of dependencies are used every time until we upgrade, and by having this in dub.json:

```
        "toolchainRequirements": {
                "frontend": "==2.096"
        },
```

we ensure that the code simply refuses to compile with any other language version.

So, if two years from now we were to check out a revision that was two years old, yes we would have to downgrade the compiler but it would still work. Upgrading to a newer language version or dependency version can be done outside of the main development branch, where it can be properly tested before merging.

Ideally I want the build system to automatically install and/or activate the compiler specified in the code base so that a toolchain upgrade becomes just like a regular feature commit, possibly using one of the existing compiler version managers [1, 2] or by extending dub itself. Then, fellow developers will hardly notice compiler upgrades, the build farm doesn't need attention, and bisecting revisions to pin down the occurrence of a regression can be done without complications.

I think it is important that warts in the language and standard library are removed, and luckily we have a proper deprecation mechanism. My advice is, if you pick up a two-year old project and don't want to deal with breakages, you just continue with the versions from that time; Until you choose to use newer features, but you can plan for the work that this requires.

-- Bastiaan.

[1] https://dlang.org/install.html
[2] https://code.dlang.org/packages/dvm

Reply via email to