The issue with D...

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Feb 7 21:47:07 UTC 2019


On Thu, Feb 07, 2019 at 09:27:47PM +0000, Jordan Wilson via Digitalmars-d wrote:
> On Thursday, 7 February 2019 at 20:49:31 UTC, Ecstatic Coder wrote:
[...]
> > Stupid simple :
> > 
> > void main()
> > {
> >     import vibe.d;
> >     listenHTTP(":8080", (req, res) {
> >         res.writeBody("Hello, World: " ~ req.path);
> >     });
> >     runApplication();
> > }
> > 
> > Not stupid simple :
> > 
> > #!/usr/bin/env dub
> > /+ dub.sdl:
> > name "hello_vibed"
> > dependency "vibe-d" version="~>0.8.0"
> > +/
> > void main()
> > {
> >     import vibe.d;
> >     listenHTTP(":8080", (req, res) {
> >         res.writeBody("Hello, World: " ~ req.path);
> >     });
> >     runApplication();
> > }
[...]
> Is it pure cosmetics? I thought the whole point of the dub comment was
> so that you could just run "dub server.d" and it would just work?
> 
> In your super simple example, it won't just work, you need to do to
> the whole dub fetch/build thing. Not saying it's a bad thing, but we
> are talking about first impressions, and I can see pros/cons to both
> approaches.
[...]

I think his point is that whatever effect is triggered by the dub
comment should be made the *default* behaviour, such that you don't need
to type out any of it explicitly and the compiler/toolchain/whatever
will just Do It(tm), whatever It may be.  The current default is that it
will not work if the dub comment isn't there.  His argument is that this
default should be changed so that it *does* work.  In theory, dub
"should" be able to detect the "import vibe.d" line and from there
figure out what to do "automatically".

I'm unsure whether I agree with him, though.  In order to pull this off,
dub will have to implement heuristics for detecting VibeD imports and
somehow map that to the requisite vibe-d dependency declaration.  I'm
uncertain I'm entirely comfortable with this kind of IMO hackish
implementation that may end up interacting badly with other things once
you get beyond trivial projects.

But regardless, he certainly has a point in making things work
out-of-the-box with minimal effort, even if we may disagree on just how
minimal this minimal effort should be.  Not everyone is a masochistic
programmer like myself who would shun such niceties and prefer manually
compiling and linking stuff on the command-line. (This is why it'd
probably be a bad idea to put me on the marketing / UI design team.
:-P)


T

-- 
Those who don't understand Unix are condemned to reinvent it, poorly.


More information about the Digitalmars-d mailing list