Why we chose not to use D for our Linux project

Bill Lear rael at zopyra.com
Wed May 28 14:44:14 PDT 2008


Sean Kelly Wrote:
[...]
> I agree with your comment on tools and libraries in general, but D does already have a solid
> install/update/build tool in DSSS/rebuild.  With it, installing supported packages is as simple
> as "dsss net install blah", which I believe is roughly equivalent to ruby gems or whatever you
> used there instead.  Regarding DB support, I think some branch of DDBI may actually build
> with the current version of D, but you're right that it doesn't receive a lot of attention.
> Unfortunately, D is still very much a language for self-starters, and the overarching focus
> on newer and more features rather than building a solid base for development probably
> doesn't help things either.  Overall, the trend seems to be a churn of new users rather than
> a growing group of serious professionals--likely for these reasons.  That said, there are
> more than a few professional developers which have found a development environment
> which suits them--from my experience it tends to be DMD/Linux and Tango with either
> makefiles or DSSS for building and GDB with the demangling patch for debugging.

Thanks to all for the (mostly) thoughtful comments on this issue.  I have tried again, this time documenting my steps, to more thouroughly illustrate what I am going through.  Here is a more-or-less verbatim run of my efforts to get dbi compiled and installed.  To say the least, the results are less than satisfying:
Download and install d 1.030.

Go to D web site to find OBI component.  Look for something that
indicates "tools", or "libraries" for D.  See "Tools" section.
Look in "More Tools" link.  Nothing there, so back to the
main page.  Look under "Community"/"D links".  Looks good.
Using Firebugs, search for "Database" on the page.  Find D DBI.
Ok, click it.

Look for "downloads".  Find "Recommended" is "Version 0.2.5", so
download that to my build directory and unzip the zip file.

Look for and find doc on "HowToBuild".  It says:

The current recommended way to build dbi.lib is to use buildme.d. It comes
in the directory below dbi.

To build a release version of D DBI with every module, use any of
the following:

    dmd -run buildme.d all

So, I try the first command:

% cd tags/0.2.5
% dmd -run buildme.d all
buildme.d: module buildme cannot read file 'buildme.d'

So, it fails because it cannot read the file.  So, I figure out why:

ls -l
total 28
----------  1 rael rael 4478 2007-02-03 01:21 buildme.d
drwxr-xr-x 10 rael rael 4096 2008-05-28 15:02 dbi
drwxr-xr-x  3 rael rael 4096 2008-05-28 15:02 docs

It has unzipped things with no read permissions.  So, I fix it and try
again:

% chmod +rw buildme.d
% dmd -run buildme.d all
buildme.d(42): module FileConst cannot read file 'tango/io/FileConst.d'

With no clue as to what this means, I read the source file buildme.d,
and discover that it appears to support two versions, Phobos, and
something else, presumably Tango.  So, I read the dmd doc to see how
to set this flag (dmd -Dversion=Phobos didn't work).  Finding that,
I try again, and fail again:

% dmd -version=Phobos -run buildme.d all
sh: bud: command not found

So, I try to find bud.  I go back to the dlinks page and find it
and download it, and attempt to build IT:

% cd bud-3.04

The instructions say:

If you have no existing binary, the executable must be built with
the makefile first:

make -f Makefile.unix

So, I try that:

% make -f Makefile.unix
make: Makefile.unix: No such file or directory
make: *** No rule to make target `Makefile.unix'.  Stop.

Ah, ok.  Let's see what's wrong now:

% ls
Source

Ok, would have been nice to document that, but forging ahead...

% cd Source
% make -f Makefile.unix
dmd -op -release -inline -ofbuild build.d util/pathex_bn.d util/pathex.d source_bn.d util/str.d build_bn.d util/booltype.d util/fdt_bn.d util/str_bn.d source.d util/fdt.d util/fileex.d util/fileex_bn.d util/linetoken.d util/linetoken_bn.d util/macro.d util/file2.d
build.d(56): Identifier expected following package
build.d(56): ';' expected
build.d(634): identifier expected following '.', not 'macro'
build.d(3348): identifier expected following '.', not 'macro'
source.d(55): Identifier expected following package
source.d(55): ';' expected
source.d(105): Identifier expected following package
source.d(105): ';' expected
source.d(483): identifier expected following '.', not 'macro'
util/macro.d(38): Identifier expected following package
make: *** [build] Error 1

So, the build tool itself advertised to build the tool I want to use
fails to build.  Irony...

So, I discover after a long set of searches and guess on my part that
'util.macro' should perhaps be 'util.Macro'.  I make those substitutions
in the bud source code and the build of it finally works:

% make -f Makefile.unix
dmd -op -release -inline -ofbuild build.d util/pathex_bn.d util/pathex.d source_bn.d util/str.d build_bn.d util/booltype.d util/fdt_bn.d util/str_bn.d source.d util/fdt.d util/fileex.d util/fileex_bn.d util/linetoken.d util/linetoken_bn.d util/macro.d util/file2.d

Noting that the bud build instructions also say:

It is still imperative to build a final binary with the utility itself:

    ./build build -full -op
    ln -s build bud

So:

% ./build build -full -op
Source.d(55): module Macro cannot read file 'util/Macro.d'

Of course not.  So, I move util/macro.d to util/Macro.d:

% mv util/macro.d util/Macro.d

try again:

% ./build build -full -op
/usr/bin/ld: skipping incompatible /usr/lib/libphobos.a when searching for -lphobos
/usr/bin/ld: cannot find -lphobos
collect2: ld returned 1 exit status

Usure how a freshly installed libphobos.a from the freshly installed dmd
package could be a problem:

% which dmd
/opt/dmd/bin/dmd
% ls -l /opt/dmd/lib/libphobos.a
-rw-r--r-- 1 rael rael 1344630 2008-05-16 23:01 /opt/dmd/lib/libphobos.a
% ls -l /usr/lib/libphobos.a
-rw-r--r-- 1 root root 1344630 2008-05-28 14:17 /usr/lib/libphobos.a
% cmp /opt/dmd/lib/libphobos.a /usr/lib/libphobos.a
% echo $?
0

So, the files are identical...

Oh, and here's another cool thing:

% ls -l build
ls: cannot access build: No such file or directory

So, the build failure erases the build file itself.  Very, very cool.

So, rebuild from makefile:

% make -f Makefile.unix
make: *** No rule to make target `util/macro.d', needed by `build'.  Stop.

Of course.  So, I link util/Macro.d to util/macro.d:

% cd util/
% ln -s Macro.d macro.d
% cd ..
% make -f Makefile.unix
dmd -op -release -inline -ofbuild build.d util/pathex_bn.d util/pathex.d source_bn.d util/str.d build_bn.d util/booltype.d util/fdt_bn.d util/str_bn.d source.d util/fdt.d util/fileex.d util/fileex_bn.d util/linetoken.d util/linetoken_bn.d util/macro.d util/file2.d

And now, move build to something else, perhaps?:

% mv build buildit
% ./buildit build -full -op
/usr/bin/ld: skipping incompatible /usr/lib/libphobos.a when searching for -lphobos
/usr/bin/ld: cannot find -lphobos
collect2: ld returned 1 exit status

And now I discover that since I have a 64-bit machine, perhaps I am
just totally hosed?

dmd itself seems to work fine:

% cd /opt/dmd/samples/d/
% dmd wc.d
% echo "Hello world" | ./wc
% ./wc wc.d
   lines   words   bytes file
      45      80     810 wc.d

So, what the hell, I'll try with the version of bud built from the makefile
and see if that is good enough:

% cp buildit ~/bin
% cd /build/tags/0.25
% dmd -version=Phobos -run buildme.d all
Error: dbi/all.d: Permission denied

Lovely, more permissions errors:

% ls -l dbi/all.d
---------- 1 rael rael 250 2007-02-03 01:21 dbi/all.d

So, fix them:

% find . -type f | xargs chmod +rw

and try again:

%  dmd -version=Phobos -run buildme.d all
dbi/oracle/imp/orl.d(1147): found 'ref' when expecting ')'
dbi/oracle/imp/orl.d(1147): semicolon expected following function declaration
dbi/oracle/imp/orl.d(1147): Declaration expected, not ')'
dbi/oracle/imp/orl.d(1188): found 'ref' when expecting ')'
dbi/oracle/imp/orl.d(1188): semicolon expected following function declaration
dbi/oracle/imp/orl.d(1188): Declaration expected, not ')'
dbi/oracle/imp/orl.d(1200): found 'ref' when expecting ')'
dbi/oracle/imp/orl.d(1200): semicolon expected following function declaration
dbi/oracle/imp/orl.d(1200): Declaration expected, not ')'
dbi/oracle/imp/orl.d(1216): found 'ref' when expecting ')'
dbi/oracle/imp/orl.d(1216): semicolon expected following function declaration
dbi/oracle/imp/orl.d(1216): Declaration expected, not ')'
dbi/oracle/imp/orl.d(1231): found 'ref' when expecting ')'
dbi/oracle/imp/orl.d(1231): semicolon expected following function declaration
dbi/oracle/imp/orl.d(1231): Declaration expected, not ','
dbi/oracle/imp/ori.d(404): found 'ref' when expecting ')'
dbi/oracle/imp/ori.d(404): semicolon expected following function declaration
dbi/oracle/imp/ori.d(404): Declaration expected, not ')'
dbi/oracle/imp/ori.d(1106): found 'ref' when expecting ')'
dbi/oracle/imp/ori.d(1106): semicolon expected following function declaration
dbi/oracle/imp/ori.d(1106): Declaration expected, not ')'

Ok, it's building oracle.  I don't really want oracle.  The code
says I can pass '-mysql'.  Try that:

% dmd -version=Phobos -run buildme.d -mysql
Error: Invalid argument "-mysql."  "mysql" isn't on the list of DBDs to build.

Try again:

% dmd -version=Phobos -run buildme.d mysql

Hmm, no errors, no nothing.  What did it do?

% ls -lt
total 36
drwxr-xr-x 10 rael rael 4096 2008-05-28 16:03 dbi
drwxr-xr-x  2 rael rael 4096 2008-05-28 16:03 libddbi.a
drwxr-xr-x  3 rael rael 4096 2008-05-28 15:52 docs
-rw-r--r--  1 rael rael 4478 2007-02-03 01:21 buildme.d

% ls -l libddbi.a/
total 0
% ls -lt dbi/
total 264
-rw-r--r-- 1 rael rael 124890 2008-05-28 16:03 all.a
drwxr-xr-x 2 rael rael   4096 2008-05-28 15:52 ib
drwxr-xr-x 2 rael rael   4096 2008-05-28 15:52 msql
drwxr-xr-x 2 rael rael   4096 2008-05-28 15:52 mssql
drwxr-xr-x 2 rael rael   4096 2008-05-28 15:52 mysql
drwxr-xr-x 2 rael rael   4096 2008-05-28 15:52 odbc
drwxr-xr-x 3 rael rael   4096 2008-05-28 15:52 oracle
drwxr-xr-x 2 rael rael   4096 2008-05-28 15:52 pg
drwxr-xr-x 2 rael rael   4096 2008-05-28 15:52 sqlite
-rw-r--r-- 1 rael rael    250 2007-02-03 01:21 all.d
-rw-r--r-- 1 rael rael   5813 2007-02-03 01:21 Database.d
-rw-r--r-- 1 rael rael   2658 2007-02-03 01:21 DBIException.d
-rw-r--r-- 1 rael rael   2500 2007-02-03 01:21 ErrorCode.d
-rw-r--r-- 1 rael rael   1192 2007-02-03 01:21 Result.d
-rw-r--r-- 1 rael rael   4194 2007-02-03 01:21 Row.d
-rw-r--r-- 1 rael rael   6736 2007-02-03 01:21 Statement.d

Hm, ok, we have an 'all.a' file and some .d files, so presumably
we'll have to install these somewhere.  No clue if it actually
built what I wanted ... There is no install
target, it appears (thank goodness we're not using make!).  So, we
look for example code on the web site:

Another recommended way to learn how to use D DBI is to look at the
unittests in the SqliteDatabase file.

When I click on the link:

Internal Server Error

500 Internal Server Error (No node /trunk/dbi/sqlite/sqlitedatabase.d at
revision 91<br><p>You can <a
href="/projects/ddbi/log/trunk/dbi/sqlite/sqlitedatabase.d?rev=91&amp;mode=path_history">search</a>
in the repository history to see if that path existed but was later
removed.</p>)

Oops...

So, I try to run the unit test code.  Guessing:

% dmd -version=Phobos -run dbi/mysql/MysqlDatabase.d dbi/all.a -lmysqlclient
[big fat failure]

Try again:

%  dmd -version=Phobos -unittest dbi/mysql/MysqlDatabase.d dbi/all.a -lmysqlclient
Error: unrecognized switch '-lmysqlclient'

and again:

% dmd -version=Phobos -unittest dbi/mysql/MysqlDatabase.d dbi/all.a
[... vast spewage ...]

Well, ok, try again:

% dmd -version=Phobos -unittest dbi/mysql/MysqlDatabase.d dbi/all.a -L'-L/usr/lib/mysql -lmysqlclient'

and more failures.

Try again:

% dmd -version=Phobos -unittest dbi/mysql/MysqlDatabase.d dbi/all.a /usr/lib/mysql/libmysqlclient.a

Well, it gets by the undefined references to mysql internals, but of course
new undefined errors show up.

[More tail chasing elided here for sake of space.]

At this point, I've wasted, not "20 minutes" as claimed here, but a solid
2 1/2 hours of my time.

I do hope others realize that I have gone to the trouble to document this not to impugn anyone's motives, but to provide what I think is a valuable service to the D community, while at the same time declining to join said community due to professional and personal time constraints.

Perhaps I'll return to this effort tomorrow and see if I can kick it along any further, but I rather doubt I will, as even if I do get the thing to compile, my confidence in the entire body of code is so low that I am loathe to recommend that our development group even consider it for production-ready code.

Some observations:

1) Using "yet another make system" to build dbi seems of dubious benefit.

2) Even the most basic issues do not go well --- the source code wouldn't even unzip properly.

3) If users are to adopt D, then the support universe around it needs to be strengthened.  Anything more than a few keystrokes' to install something is going to turn away potential legions of followers.  I'd like to see this:

% dinstall dbi
DBI is now installed for D.  Have fun.

And I think that is a reasonable goal to aim for.

As I said, I just don't have the time presently to contribute any more than I have to this, and I hope this will help the D community in some way.

Thanks.


Bill



More information about the Digitalmars-d mailing list