Using D

Chris via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 4 08:21:41 PDT 2014


On Thursday, 4 September 2014 at 14:19:02 UTC, Bruno Medeiros 
wrote:
> On 26/08/2014 09:46, Chris wrote:
>> The problem was that Java didn't behave as expected on 
>> Windows. Things
>> that worked fine on Linux and OS X didn't work on Windows 
>> (even simple
>> things like deleting files). User reported all sorts of 
>> problems, one of
>> them being that the Java Access Bridge didn't work. Why, 
>> nobody knows.
>> The lack of a proper sound API / library. Then there was the 
>> versioning
>> hell with JRE/JVM and having to tell users what version they 
>> had to
>> download (the non tech savvy crowd). I know that MS doesn't 
>> make it easy
>> for Java either. Well, I could have sorted the problems out 
>> with Java
>> web start, SWT and all that kind of stuff. Instead, I learned 
>> D which I
>> can compile and run on each platform without a problem.
>
> The promise of "Write once run everywhere" is still pretty much 
> accurate if you stick to core Java code and libraries. Of 
> course once you start using OS/implementation specific code you 
> will have to code more carefully, and are more likely to 
> encounter cross-platform problems. That's just the nature of 
> things, you can't say it's a failure of Java.
> It's like coding in D using lots of malloc/free in your code, 
> and then when your program breaks, you complain that "the D GC 
> doesn't work!". Of course the GC only is only guaranteed to 
> work if you stick to GC-managed memory.

I can expect the Java Access Bridge to work, because Java offers 
it as a built-in technology. If it does not work, it's a broken 
promise. Simple as that.

> To be honest I smell a load of Java-biased *BS* here, 
> especially because of this sentence:
> "Instead, I learned D which I can compile and run on each 
> platform without a problem."

Which is true. I could compile it on Linux, OS X and Windows. It 
was almost trivial to write a DLL that third party software can 
use. Try that with Java and tell me if it's trivially easy. I 
think what you meant was _anti_-Java *BS*. I'm only writing about 
my experience with the two languages. The one worked for me, the 
other didn't.

> Actually virtually all other languages, including D, are just 
> as bad as Java (if not worse) in the aspects mentioned above. 
> For example, if you write code which heavily interacts with the 
> filesystem, you are bound to encounter platform/OS-specific 
> problems no matter what language. I'd bet money those "even 
> simple things like deleting files", you'd have in D as well. At 
> least in Java the APIs they are usually careful to specify 
> which aspects of behavior are implementation-specific.

Well, my statement refered to the fact that Java f**ked up big 
time there, which clearly breaks the promise "write once, run 
everywhere", especially because dealing with files is a feature 
one would expect to be part and parcel of a programming language. 
Deleting files should not give you a headache. Basically what 
you're saying is "Java is cross-platform but it's not, but hey, 
other languages are just as bad!". Well, then they should stop 
using the word "cross-platform" when advertising their language.

> In other cases, such as the sound library or accessibility 
> library, most other cross-platform language don't even have 
> those!, so how can you be saying that D runs better on each 
> platform that Java?..
> (Does a non-existent library run perfectly on every conceivable 
> platform? one could say yes...)

D interfaces to existing audio / sound libraries in C 
(libsndfile, portaudio). All you have to do is to include those 
libs and call the functions you need. Doing this with Java is a 
bit more complicated (you'll probably need tools).

You are welcome to report on any serious issues you've 
encountered when porting D programs to various platforms. Maybe 
it can be fixed in the core of the language and it would help to 
make D even more portable. A lot of cross-platform issues can be 
dealt with by including "version(Windows/Posix ...)" in your code.


More information about the Digitalmars-d mailing list