Thread overview
D is a great language, but I've had a bad experience getting started
Dec 14
Renato
Dec 14
Hipreme
Dec 14
Renato
Dec 14
Renato
Dec 14
bachmeier
Dec 14
Renato
Dec 14
Renato
Dec 14
Sergey
December 14

Hi, I have been trying D for the last few days... I am only writing because I really, really like the language! It's absolutely stunning how the features it has are simple, well designed and at the same time incredibly advanced! All with an extremely fast compiler, which is almost unbelievable.

However, I faced a lot of issues which I think could be addressed to make others have a much better time getting started so they don't stop before even being able to appreciate all the great things about D.

First of all, if you have latest MacOS and install DMD (I tried several methods) it just doesn't work due to a linker problem: https://forum.dlang.org/post/asanawokkhqhhvrynngd@forum.dlang.org

Luckily, it seems the issue was fixed 2 weeks ago, but unfortunately that's not released yet (so one less problem for newcomers).

Anyway, the workaround is to use a linker flag to make it work with the current DMD compiler... compiling on the CLI now worked with that, but then I tried to compile a dub project and faced the same issue even after adding the linker flag.

The error was this:

d: warning: pointer not aligned at address 0x1000743BE ('anon' + 958 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o)
ld: warning: pointer not aligned at address 0x1000743FA ('anon' + 1018 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o)
ld: unaligned pointer(s) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
Error /Library/D/dmd/bin/dmd failed with exit code 1.

At this point I had to give up MacOS development and use my Linux machine.

On Linux I like using Nix for package management... when asking the DMD package to install, however, it seems to run the full test suite for the DMD compiler locally... I waited for 30mins before giving up. Would be nice to get instructions on how to install it without running the tests.

I then decided to usg GLC on Linux. That worked fine and installed with apt install gdc in a couple of seconds :).

The other compilers were also easily installable on Kubuntu using snap.

Now, I tried to create a HTTP server using vibe.d. I followed their instructions to run "dub init" and that seemed to be working fine until some error came up.

Here's my terminal output:

➜  dserver dub build
Fetching vibe-core 2.5.1 (getting selected version)...
Fetching memutils 1.0.9 (getting selected version)...
Fetching taggedalgebraic 0.11.22 (getting selected version)...
Fetching vibe-container 1.0.1 (getting selected version)...
Fetching vibe-d 0.9.7 (getting selected version)...
Fetching stdx-allocator 2.77.5 (getting selected version)...
Fetching diet-ng 1.8.1 (getting selected version)...
Fetching openssl 3.3.3 (getting selected version)...
Fetching eventcore 0.9.27 (getting selected version)...
Fetching mir-linux-kernel 1.0.1 (getting selected version)...
Fetching libasync 0.8.6 (getting selected version)...
Fetching openssl-static 1.0.2+3.0.8 (getting selected version)...
Invalid variable: DC
➜  dserver ls
dub.sdl  dub.selections.json  public  source  views
➜  dserver dub build
Invalid variable: DC

Really hard to get stuff working, unfortunately, and the error message is just not helpful.

I also tried the Language Server (serve-d) with emacs and it's not working properly on Linux, but seems to work somewhat (it shows errors but no autocompletions using eglot at least) on Mac.

I was really eager to get a D project and up and running, but due to these issues I am not quite sure I will persist, unfortunately, as even a language like Nim (which is a bit similar to D in its scope) has a much better story getting started.

Anyway, please let me know if you have hints for some of the issues above and hope things like this can get better in the future.

December 14

On Thursday, 14 December 2023 at 12:30:35 UTC, Renato wrote:

>

Hi, I have been trying D for the last few days... I am only writing because I really, really like the language! It's absolutely stunning how the features it has are simple, well designed and at the same time incredibly advanced! All with an extremely fast compiler, which is almost unbelievable.

Yeah, D has a really bad experience in MacOS. If you want to use it on mac, I suggest using LDC. And the package managers doesn't do D justice. You want to get the zip and setup the environment variables yourself, this is the best way to make it work.

The "D recommended way" to install is by using the install.sh script, found at https://dlang.org/install.html

I personally never used GDC since I develop on Windows 99% of the time (the other time is only used on the other platforms when I need to develop specific things for them).

The error you're seeing is related to a DC variable. The D Compiler variable. I would guess this is a problem caused by your package manager when installing D.

I've been developing a game engine which does compiler execution for the user because it can get quite hard to understand depending on the size of the project.

December 14

On Thursday, 14 December 2023 at 12:30:35 UTC, Renato wrote:

>

The other compilers were also easily installable on Kubuntu using snap.

It seems that the Ubuntu "snap"s are not being updated for a few years??

It seems some of my problems are related to the very old versions I got with snap :(

dub - 1.19.0 (seems to be from Oct 2020)
ldc2 - 1.24.0 (seems to be from Oct 2020)
dmd - v2.090.1 (Feb 2020)

I feel stupid for choosing snap (I don't use snaps, just felt like a convenient thing to try this time!).

I will try using latest of everything on Linux (on Mac I think I was already fine on latest) and hope it works better.

December 15
Welcome!



Regarding the problems with dub on OSX, that'll be due to separate build + link steps.

It should work ok if you build and link in a single step with the workaround applied.



DC is an environment variable that should point to the D compiler.

As a variable this particular one has some sort of story with it, I just can't remember it.

We'd need to know what is requesting it to find out how to resolve it. Please try again with ``-v`` that should tell us what is wanting it.
December 14
On Thursday, 14 December 2023 at 12:59:34 UTC, Richard (Rikki) Andrew Cattermole wrote:
> Welcome!
>
>
>
> Regarding the problems with dub on OSX, that'll be due to separate build + link steps.
>
> It should work ok if you build and link in a single step with the workaround applied.
>
>
>
> DC is an environment variable that should point to the D compiler.
>
> As a variable this particular one has some sort of story with it, I just can't remember it.
>
> We'd need to know what is requesting it to find out how to resolve it. Please try again with ``-v`` that should tell us what is wanting it.

That output was already with -v enabled. It just didn't show anything else relevant.

But I found an issue from a few years ago about that:

https://github.com/vibe-d/vibe.d/issues/2677

That's why I figured out I was using very old versions of everything on Linux.

How do you tell dub to "build and link in a single step"?
December 15
On 15/12/2023 2:02 AM, Renato wrote:
> How do you tell dub to "build and link in a single step"?

This should do it:

``--combined --build-mode=allAtOnce``
December 14

On Thursday, 14 December 2023 at 12:59:04 UTC, Hipreme wrote:

>

Yeah, D has a really bad experience in MacOS. If you want to use it on mac, I suggest using LDC. And the package managers doesn't do D justice. You want to get the zip and setup the environment variables yourself, this is the best way to make it work.

The "D recommended way" to install is by using the install.sh script, found at https://dlang.org/install.html

Thanks for letting me know! It's good to have other's perspectives. Hope your game engine is coming along nicely :)

Looks like I got it working with the overly complicated Ubuntu instructions (I used snap instead before because it was just "snap install dmd" rather than 5 large shell commands!)... if that still gives me trouble I will stick with the sh file you've linked (there were so many options for installing the compilers and I had to pick the worst one I suppose).

December 14

On Thursday, 14 December 2023 at 13:12:06 UTC, Richard (Rikki) Andrew Cattermole wrote:

>

On 15/12/2023 2:02 AM, Renato wrote:

>

How do you tell dub to "build and link in a single step"?

This should do it:

--combined --build-mode=allAtOnce

I run this:

dub build --combined --build-mode=allAtOnce

Still got an error:

cc /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o -o /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject -g -m64 -Xlinker -no_compact_unwind -ld_classic -L/Library/D/dmd/lib -lphobos2 -lpthread -lm
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: pointer not aligned at address 0x1000741C9 ('anon' + 457 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o)
ld: warning: pointer not aligned at address 0x1000741E6 ('anon' + 486 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o)
ld: warning: pointer not aligned at address 0x1000742C9 ('anon' + 713 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o)
ld: warning: pointer not aligned at address 0x100074311 ('anon' + 785 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o)
ld: warning: pointer not aligned at address 0x100074367 ('anon' + 871 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o)
ld: warning: pointer not aligned at address 0x1000743A2 ('anon' + 930 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o)
ld: warning: pointer not aligned at address 0x1000743BE ('anon' + 958 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o)
ld: warning: pointer not aligned at address 0x1000743FA ('anon' + 1018 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o)
ld: unaligned pointer(s) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
Error /Library/D/dmd/bin/dmd failed with exit code 1.

cc version:

cc --version
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: x86_64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Not sure that the options are correct: "-Xlinker -no_compact_unwind -ld_classic -L/Library/D/dmd/lib -lphobos2 -lpthread -lm".

My build options are currently:

    "dflags-dmd": [ "-v"],
    "lflags": ["-ld_classic"]

I tried some variations but nothing worked.

December 14

On Thursday, 14 December 2023 at 13:27:29 UTC, Renato wrote:

>

On Thursday, 14 December 2023 at 13:12:06 UTC, Richard (Rikki)

My build options are currently:

    "dflags-dmd": [ "-v"],
    "lflags": ["-ld_classic"]

I tried some variations but nothing worked.

Previously for macOS it was required to write “export MACOSX_DEPLOYMENT_TARGET=11”

Also remove dmd/dub first. Then try to use LDC from official GitHub Release. And update the PATH variable. Maybe script from the official download page is doing the same - idk.

At least this is what I’m using on macOS (but M1). DMD just doesn’t exist for me anymore)

December 14

On Thursday, 14 December 2023 at 12:59:32 UTC, Renato wrote:

>

On Thursday, 14 December 2023 at 12:30:35 UTC, Renato wrote:

>

The other compilers were also easily installable on Kubuntu using snap.

It seems that the Ubuntu "snap"s are not being updated for a few years??

It seems some of my problems are related to the very old versions I got with snap :(

dub - 1.19.0 (seems to be from Oct 2020)
ldc2 - 1.24.0 (seems to be from Oct 2020)
dmd - v2.090.1 (Feb 2020)

I feel stupid for choosing snap (I don't use snaps, just felt like a convenient thing to try this time!).

I will try using latest of everything on Linux (on Mac I think I was already fine on latest) and hope it works better.

What's worked for me on Ubuntu is to download the .deb from the downloads page and sudo apt install ./dmd_2.106.0-0_amd64.deb. Always have the latest release and never have problems.