D is a great language, but I've had a bad experience getting started
Renato
renato at athaydes.com
Thu Dec 14 12:30:35 UTC 2023
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.
More information about the Digitalmars-d-learn
mailing list