flat assembler
Message board for the users of flat assembler.

flat assembler > High Level Languages > D

Author
Thread Post new topic Reply to topic
Maverick



Joined: 07 Aug 2006
Posts: 251
Location: Citizen of the Universe
OzzY wrote:
Plus, I'm testing the D language which seems nice with features of C# without targeting the stupid .NET.
D looks very nice, but the presence (and near-enforcing) of the Garbage Collector makes me run away of it for anything really serious.

_________________
Greets,
Fabio
Post 15 Nov 2006, 09:03
View user's profile Send private message Visit poster's website Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
Quote:
D looks very nice, but the presence (and near-enforcing) of the Garbage Collector makes me run away of it for anything really serious.


I'm trying D, looks really nice.
The Garbage Collector is optional to use. You just turn it on if you want. You still have "new" and "delete", pointers and so on...
Plus, D have a nice standard library able to manipulate files, streams, strings, sockets, zip files, base64 enconding, and there are some GUI libraries available.
The only downside at my point of view is that the language isn't too popular yet.
Post 18 Nov 2006, 21:30
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
Quote:

Torus Trooper is written in the D Programming Language(ver. 0.110).


EDIT: Here's some announcements of other D stuff (and no, I don't program in D, but it looks nice ...)
Post 18 Nov 2006, 23:45
View user's profile Send private message Visit poster's website Reply with quote
Maverick



Joined: 07 Aug 2006
Posts: 251
Location: Citizen of the Universe
Has anyone peeked at the produced machine code yet? How does it compare to e.g. VC2005 quality in this regard?
Post 19 Nov 2006, 12:11
View user's profile Send private message Visit poster's website Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
I'd like to see a comparison for code quality too.
Although as I've seen, all test programs I wrote are quite fast (looks faster than GCC).
Even when using Garbage Collector it runs fast (I think the GC is manually invoked).

A comparion for language features can be found here: http://www.digitalmars.com/d/comparison.html

One thing I really like are the automatic sized arrays.
I've never got a segfault since I started using D.

Also unittest together with assert helps finding errors even before running the code for the "real thing".
Post 19 Nov 2006, 22:46
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
i browsed few articles on D site... looks like good replacement for Java or C#, with fixing some C++ design problems.

Anyway, i wouldn't see it as alternative for C. If I understood those texts right, all arrays are always dynamic, and that means D arrays are somewhat slower than C static arrays. It practically enforces very dynamic programming style.
Post 27 Mar 2007, 14:55
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
vid: I don't see D as an alternative for C, but for C++, C# and Java.
You still have the OOP and other (lots of) features, but with native compilation.
You can still see D more or less as a native compiled C#.
But I see D as a "compiled scripting language". It's really easy as scripting, and powerful as C++. You can even run the code without compiling, like a real scripting language! Plus, digital mars compilers are the fastest I've seen.

You can do things like:
Code:
PhoneNumberOf[ "John" ] = 24234353252;
AddressOf[ "John" ] = "Street 123...";
SexOf[ "John" ] = "Male";
    

And you can keep adding, sorting, and manipulating these arrays very easily. Like if I want to add another person I just do:
Code:
PhoneNumbeOf[ "Peter" ] = 3443434434;
    

and so on...
D manages the arrays for me. You gain in development speed and source beauty and don't lose too much compared to C++, and it's also faster than if you used Python for example, which is interpreted.
OK. You can do these arrays manipulations in C++. But you have to use STL, and D have it in the core language.

Give it a try! I don't use C++ anymore (only if I'm forced to, in a company for example).


Quote:

It practically enforces very dynamic programming style.

Wrong.
This is a static array:
Code:
int x[3];
    


And this is a dynamic array:
Code:
int x[];
    

See: http://www.digitalmars.com/d/arrays.html
Post 27 Mar 2007, 15:55
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
Quote:
You can do things like: PhoneNumberOf[ "John" ] = 24234353252;

What does resulting code looks like? How exactly does this work? O(N), or O(1)?

Quote:
This is is static array: int x[3];

hmm... can you demonstrate how to allocate static array of N bytes, store some string there, do several operations on it without any allocation needed? I got feeling that entire array and string handling of D is dynamic.
Post 27 Mar 2007, 16:08
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
Quote:

What does resulting code looks like? How exactly does this work? O(N), or O(1)?

http://www.digitalmars.com/d/arrays.html#associative

It's hashed. This kind of data structure is also known as Dictionary (at least that is the class in SmallTalk Razz)
Post 27 Mar 2007, 16:20
View user's profile Send private message Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
vid: You still have full compatibility with C arrays and strings, because D have pointers too, and has some support to standard C library. You can use printf for example. You could do this like you already do in C. You can still use malloc if you want.

But D was created to be easier and solve some problems from other modern languages.
It's just easier to use it with the dynamic way.
There's no point in not using them if you are using D. If you don't like dynamic things or OOP it's really better to use C.
But if you use C++ or Java a lot, D is perfect.

You can copy arrays with pieces of memory directly:
Code:
x[0..10]=y[10..20]; // copy from 10th element of y to 20th to the first 10 elements of x;
    


You don't even need a for to run through the piece of array to copy. You just need to take a look to the code generated to see how it goes. A benchmark would be nice in this point.
Post 27 Mar 2007, 16:20
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
i've missed link you provided, sorry. After reading more on it, yes, static arrays are provided. But i am still uncertain how to operate strings inside such array
Post 27 Mar 2007, 16:31
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
An example:
Code:
import std.stdio;

void main()
{
        int x[10];
        int y[10];
        int n=0;
        
        while(n<=9)   // Filling array x
        {
                x[n] = n * 2;
                n++;
        }
        
        int len = x.length; // Get size of x
        
        y[0..len]=x[0..len]; // Copying array piece
        
        
        // Printing results
        
        writefln("Listing elements of x:"); 
        foreach(i; x)
                writefln("%d",i);
                
        writefln("Listing elements of y:");
        foreach(i; y)
                writefln("%d",i);
}
    
Post 27 Mar 2007, 16:36
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
another question: how about interoperability with other languages? Does D compiler spit out usual object files (MS COFF, ELF)? How are names decorated? We could provide examples of mixing FASM and D with linking.
Post 27 Mar 2007, 16:50
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
On Windows it uses OMF format. (The DMD compiler).
There is also GDC which uses GCC as backend.
I never tried D on Linux. So I can't tell.

D is object-compatible with C. Which means you can code a function in C and use in D or code in D and use it C.
D is able to create DLL's, and also there are projects for multi-platform way of doing this.

I'll research more and post some example.
Also there is #D on freenode. The community is very helpful.
For me a good community is very important. And both D and FASM have it.


And here is a profiling of the example above on my ultra-slow machine:
Quote:

------------------
__ 0 0 0
------------------
__Dmain 0 111180 111180

======== Timer Is 3579545 Ticks/Sec, Times are in Microsecs ========

Num Tree Func Per
Calls Time Time Call

1 31059 31059 31059 __Dmain
1 0 0 0 __


I'll get some studying now.
Later, when I get some time I'll post something for FASM usage together with D.
Post 27 Mar 2007, 17:04
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
Post 27 Mar 2007, 17:54
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
That coff2omf tool is not free.
I'm having trouble in find a free coff2omf tool.
I only have tried the MS Linker that is able to convert OMF to COFF.
But I need COFF2OMF so I create COFF in FASM, convert to OMF and link with DMD linker to the D library.

When I find some tool to do it, I'll prepare some examples for FASM usage with D. Maybe using D dynamic arrays to manipulate easily data from ASM code.
Post 13 Apr 2007, 14:24
View user's profile Send private message Reply with quote
Ehtyar



Joined: 26 Sep 2006
Posts: 51
Borland's free command-line tools offer a "coff2omf" tool, but i haven't tested it myself. They can be found here but you'll need a login to download it (i'd post it here, but the tools are not redistributable).

Hope this helps, Ehtyar.
Post 13 Apr 2007, 22:39
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.