dlang website design

Wulfklaue via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 24 15:16:11 PDT 2017


On Saturday, 24 June 2017 at 20:29:23 UTC, Sönke Ludwig wrote:
> /++ dub.sdl
>     name "webserver"
>     dependency "vibe-d:http" version="~>0.7.31"
> +/
> module main;
>
> import vibe.core.core;
> import vibe.http.fileserver;
> import vibe.http.server;
>
> void main()
> {
>     listenHTTP(new HTTPServerSettings, serveStaticFiles("./"));
>     runApplication();
> }
>
> $ dub main.d
>
> Although of course vibe.d is not included with the compiler, 
> this works out of the box for a standard DMD/LDC installation.

No it does not...

Attempt 1:
=========

Create main.d file, insert code. dub main.d

> readPackageRecipe called with filename with unknown extension: 
> + dub.sdl
>      name "webserver"
>      dependency "vibe-d

Attempt 2:
=========

Dub init xxxxx
-> enter sdl
-> ...

Update xxxxx/src/app.d, insert code. Run dub ...

> Performing "debug" build using dmd for x86.
> webser ~master: building configuration "application"...
> source\app.d(7,8): Error: module core is in file 
> 'vibe\core\core.d' which cannot be read
> import path[0] = source
> import path[1] = C:\D\dmd2\windows\bin\..\..\src\phobos
> import path[2] = C:\D\dmd2\windows\bin\..\..\src\druntime\import
> dmd failed with exit code 1.

Attempt 3:
=========

dub init xxxxx
-> enter sdl
-> ...

Insert dependency into xxxxx/dub.sdl.
Update file xxxxx/src/app.d, insert code. Run dub ...

Works

Attempt 4:
=========

Place dub.sdl into main project root directory.

Add the dependency information into the file.

workspaces-d ( Visual Studio Code ) crash, crash, crash, crash. 
Reason. Already a folder called Webserver present and this 
creates a conflic.

Attempt 5:
=========

Place dub.sdl into main project root directory.

Add the dependency information into the file ( now with different 
project file ).

Create WebTest2.d file, insert code. dub WebTest2.d

> dub .\WebTest2.d
> readPackageRecipe called with filename with unknown extension: 
> + dub.sdl
>      name "webserver"
>     dependency "vibe-d

Conclusion:
===========

 From 5 different attempt, only one works. All the rest are how 
people may attempt it and will run into a crash or other 
non-working issues.

It requires knowledge of dub.
It requires selecting the correct sdl format, when running dub 
init
It requires knowing that the dependency needs to be in a dub.sdl 
file, in a actual project.
...

Go idiomatic it is not unfortunately.

As Ecstatic Coder pointed out. The Go http is a default core 
package of Go. For D it means depending on a 3th party solution. 
Currently vibe.d 0.8 is undergoing a rewrite. This breaks some 
basic functionally with the more module design. A issue if a user 
had installed a 0.7.30 or earlier version.

There is this bad habit with assuming that people will understand 
how to run the samples posted or provided on there first attempt 
at using D. As seen above, its very easy to make mistakes. A 
programming language is like a drug. If people like there first 
experience, they may get hooked. If its a bad "trip", most will 
not mention a word and simply not try again.


More information about the Digitalmars-d mailing list