June 06, 2010
On 06/06/10 18:26, Nick Sabalausky wrote:
> Heh heh. "good reliable code in PHP" *is* a contradiction of terms, after
> all ;)

<?php echo 'Not true! D:', "\n"; ?>
This said, I bet we could find a case where that doesn't work properly :3

> As much as I prefer to write Haxe (and then compile it down to PHP), one of
> the [many] things that bugs me about Haxe is that it doesn't appear to do
> any of those checks automatically. Big missed opportunity there.

I've never really looked into haxe, but I agree, if it doesn't do those checks it's fairly useless - have you made a bug report? Your dreams could come true... Or you could forget and be forced to use D.. Dang!

> I've been positively salivating at the idea of combining D, FastCGI and a
> D-ified rails-like framework. Haven't gotten around to it though.
> Fortunately, I did recently find out that the hosts I'm currently using
> allow custom-made CGI. Unfortunately, I can't use FastCGI on them, although
> I've been getting so fed up with PHP lately (both the PHP language and the
> PHP platform - Haxe only sheilds you from [parts of] the language, not the
> platform), that I think I can live perfectly happily without FastCGI.

I've been toying with the same idea, the framework I've been looking at porting uses a lot of runtime reflection though which I'm not sure is easy enough to do in D1. I've strayed away from D2 now after a couple of unsuccessful attempts at using it.

Robert
June 06, 2010
Am 06.06.2010 14:41, schrieb Alex Makhotin:
> dennis luehring wrote:
>>
>>  with some compiler (like intel/microsoft and borland) related tools,
>>  example what is needed to bring the different object-formats together
>
> I experienced a runtime access violation on Windows when interoperating
> with the DLL created with the MSVC, which attempted to callback DMD
> executable. Mingw32 GCC is doing well, however cannot interoparate with
> XPCOM. Unless I'm doing something wrong, crosscompiler interoperability
> is a problem for me, however such issue have other languages.
>
> If there's a reference on how to face this kind of problems, I would be
> glad to have it, like other people which supposed to work with the D.
>
>

perfekt scenario! can you provide us with some "small" example of working/non-working constructs? that combined with an more real example of the ABI-Usage will have the needed low-level-style for an good article/blog entry - Zarathustra got currently some ABI description problems in the D.learn group under the delegates with C linkage topic
maybe we can all put together nice examples, talking about objs,assembler,call-styles etc.
June 06, 2010
Am 06.06.2010 19:49, schrieb dennis luehring:
> Am 06.06.2010 14:41, schrieb Alex Makhotin:
>>  dennis luehring wrote:
>>>
>>>   with some compiler (like intel/microsoft and borland) related tools,
>>>   example what is needed to bring the different object-formats together
>>
>>  I experienced a runtime access violation on Windows when interoperating
>>  with the DLL created with the MSVC, which attempted to callback DMD
>>  executable. Mingw32 GCC is doing well, however cannot interoparate with
>>  XPCOM. Unless I'm doing something wrong, crosscompiler interoperability
>>  is a problem for me, however such issue have other languages.
>>
>>  If there's a reference on how to face this kind of problems, I would be
>>  glad to have it, like other people which supposed to work with the D.
>>
>>
>
> perfekt scenario! can you provide us with some "small" example of
> working/non-working constructs? that combined with an more real example
> of the ABI-Usage will have the needed low-level-style for an good
> article/blog entry - Zarathustra got currently some ABI description
> problems in the D.learn group under the delegates with C linkage topic
> maybe we can all put together nice examples, talking about
> objs,assembler,call-styles etc.

what about a large (splitted into smaller ones) article about

1. absolute low level
D -> how to call C (maybe also small C++) examples using mingw,gcc,vs (different obj formats) and intel - and back (variables, functions, delegates, strings, etc...)

2. higher abstraction
using Dll-Callbacks, Dll-Calling etc., Win-Api, COM

3. application leven
XPCOM, JNI etc., Dot.Net?

all combined with small "thats the detailed look in assembler, c-style" "what does microsoft, intel, etc. compiler do"

good idea?


June 06, 2010
"Robert Clipsham" <robert@octarineparrot.com> wrote in message news:hugmcq$2e8b$1@digitalmars.com...
> On 06/06/10 18:26, Nick Sabalausky wrote:
>> Heh heh. "good reliable code in PHP" *is* a contradiction of terms, after all ;)
>
> <?php echo 'Not true! D:', "\n"; ?>
> This said, I bet we could find a case where that doesn't work properly :3
>

I was thinking the same thing!

>> As much as I prefer to write Haxe (and then compile it down to PHP), one
>> of
>> the [many] things that bugs me about Haxe is that it doesn't appear to do
>> any of those checks automatically. Big missed opportunity there.
>
> I've never really looked into haxe, but I agree, if it doesn't do those checks it's fairly useless -

You can still do the checks yourself. And the language itself, while certainly no D, is at least an improvement over using PHP directly. So it's still a net win, just not as big of a win as it could be.

> have you made a bug report? Your dreams could come true...

Yes, probably worth a shot, but I think I like your other idea below better... ;)

> Or you could forget and be forced to use D.. Dang!
>

>> I've been positively salivating at the idea of combining D, FastCGI and a
>> D-ified rails-like framework. Haven't gotten around to it though.
>> Fortunately, I did recently find out that the hosts I'm currently using
>> allow custom-made CGI. Unfortunately, I can't use FastCGI on them,
>> although
>> I've been getting so fed up with PHP lately (both the PHP language and
>> the
>> PHP platform - Haxe only sheilds you from [parts of] the language, not
>> the
>> platform), that I think I can live perfectly happily without FastCGI.
>
> I've been toying with the same idea, the framework I've been looking at porting uses a lot of runtime reflection though which I'm not sure is easy enough to do in D1. I've strayed away from D2 now after a couple of unsuccessful attempts at using it.
>

Haxe already has a rails-like framework I've been using (Haxe Igniter). It does have room for improvement, though. In fact I ended up hacking up a few things in it. But yea, I've been really itching to make one in D. But hell, with more immediate paid(-ish) work in the way, it's taking me long enough just to get the next version of my Goldie project out.


June 06, 2010
== Quote from Walter Bright (newshound1@digitalmars.com)'s article
> D is an extremely powerful language, but when I read complaints and sighs about
> other languages, few seem to know that these problems are solved with D.
> Essentially, we have a marketing problem.
> One great way to address it is by writing articles about various aspects of D
> and how they solve problems, like
>
http://www.reddit.com/r/programming/comments/cb14j/compiletime_function_execution_in_d/
>   which was well received on reddit.
> Anyone have good ideas on topics for D articles? And anyone want to stand up and
> write an article?
> They don't have to be comprehensive articles (though of course those are
> better), even blog entries will do.

This probably won't be replied to because I'm starting a new sub-thread in a mature discussion, but I wonder if we could write about the advantages and disadvantages of duck typing vs. static typing, comparing Python vs. Java at first, then bring D into the picture to show how, to a greater extent than C++ templates or C#/Java generics, it solves may of the problems of static typing without introducing the pitfalls of duck typing.

Here's a simple example of something that would be awkward to impossible to do efficiently in any other language:

/**Finds the largest element present in any of the ranges passed in.\
 */
CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {
    // Quick and dirty impl ignoring error checking:
    typeof(return) ret = args[0].front();

    foreach(arg; args) {
        foreach(elem; arg) {
            ret = max(elem, ret);
        }
    }

    return ret;
}

Do this in C++ -> FAIL because there are no variadics.  (Yes, C++1x will have them, but I might die of old age by the time C++1x exists.)

Do this in any dynamic language -> FAIL because looping is so slow that you might die of old age before it executes.  Besides, who wants to do computationally intensive, multithreaded work in a dynamic language?

Do this in Java -> FAIL because arrays are primitives, not Objects and variadics only work with Objects.  You can't easily make an array of arrays because the elements of args may be different but related types (e.g. int, float).

Do this in C# -> FAIL because variadics aren't type-safe.  You just get an array of Object, which you have to cast, and w/o some extra information you don't know what to cast them to.
June 07, 2010
"eles" <eles@eles.com> wrote in message news:hufl4b$mkf$1@digitalmars.com...
> but, overall, D is an admirable and well-balanced
> language.

Why?

> And dmd a quite nice compiler.

ech. That's just technical detail.

> I hope it will be on 64-bits asap.

It doesn't seem so hard to do. I am surprised to hear that there was no such forsight. I don't build any 32-bit computers anymore. Win 7 64-bit only.


June 07, 2010
On Sun, 6 Jun 2010 22:42:42 +0000 (UTC), dsimcha <dsimcha@yahoo.com> wrote:
> 
> == Quote from Walter Bright (newshound1@digitalmars.com)'s article
> > D is an extremely powerful language, but when I read complaints and sighs about
> > other languages, few seem to know that these problems are solved with D.
> > Essentially, we have a marketing problem.
> > One great way to address it is by writing articles about various aspects of D
> > and how they solve problems, like
> >
> http://www.reddit.com/r/programming/comments/cb14j/compiletime_function_execution_in_d/
> >   which was well received on reddit.
> > Anyone have good ideas on topics for D articles? And anyone want to stand up and
> > write an article?
> > They don't have to be comprehensive articles (though of course those are
> > better), even blog entries will do.
> 
> This probably won't be replied to because I'm starting a new sub-thread in a mature discussion, but I wonder if we could write about the advantages and disadvantages of duck typing vs. static typing, comparing Python vs. Java at first, then bring D into the picture to show how, to a greater extent than C++ templates or C#/Java generics, it solves may of the problems of static typing without introducing the pitfalls of duck typing.
> 
> Here's a simple example of something that would be awkward to impossible to do efficiently in any other language:
> 
> /**Finds the largest element present in any of the ranges passed in.\
>  */
> CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {
>     // Quick and dirty impl ignoring error checking:
>     typeof(return) ret = args[0].front();
> 
>     foreach(arg; args) {
>         foreach(elem; arg) {
>             ret = max(elem, ret);
>         }
>     }
> 
>     return ret;
> }
> 
> Do this in C++ -> FAIL because there are no variadics.  (Yes, C++1x will have them, but I might die of old age by the time C++1x exists.)
> 
> Do this in any dynamic language -> FAIL because looping is so slow that you might die of old age before it executes.  Besides, who wants to do computationally intensive, multithreaded work in a dynamic language?
> 
> Do this in Java -> FAIL because arrays are primitives, not Objects and variadics only work with Objects.  You can't easily make an array of arrays because the elements of args may be different but related types (e.g. int, float).

Seems like that example could be done fairly easily with Objective-C. Granted, it won't have the raw performance of D, but it might be worthwhile to point it out, since it (or rather, its superset on top of C) is duck typed.

If someone were to create Objective-D, I think I'd die of happiness.
June 07, 2010
"dsimcha" <dsimcha@yahoo.com> wrote in message news:huh892$agk$1@digitalmars.com...
>
> /**Finds the largest element present in any of the ranges passed in.\
> */
> CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {
>    // Quick and dirty impl ignoring error checking:
>    typeof(return) ret = args[0].front();
>
>    foreach(arg; args) {
>        foreach(elem; arg) {
>            ret = max(elem, ret);
>        }
>    }
>
>    return ret;
> }
>

I clearly haven't been following D2 closely enough. Or maybe I'm just more
tired than I think... Can you explain that function signature?:
CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {

> Do this in C++ -> FAIL because there are no variadics.  (Yes, C++1x will
> have
> them, but I might die of old age by the time C++1x exists.)
>

C++0x^H^H1x is starting to remind me of Duke Nukem Forever. (Except I actually gave a rat's ass about Duke ;) )

> Do this in any dynamic language -> FAIL because looping is so slow that
> you might
> die of old age before it executes.  Besides, who wants to do
> computationally
> intensive, multithreaded work in a dynamic language?
>

I bet there's a lot of people who wouldn't bat an eye at that idea. Unfortunately.

> Do this in Java -> FAIL because arrays are primitives, not Objects and
> variadics
> only work with Objects.  You can't easily make an array of arrays because
> the
> elements of args may be different but related types (e.g. int, float).
>

I actually find that funny. Something in Java that isn't an Object? I remember "Everything's an object!" being paraded around as a selling point.


June 07, 2010
On Mon, Jun 7, 2010 at 06:58, Nick Sabalausky <a@a.a> wrote:

> "dsimcha" <dsimcha@yahoo.com> wrote in message news:huh892$agk$1@digitalmars.com...
> >
> > /**Finds the largest element present in any of the ranges passed in.\
> > */
> > CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {
> >    // Quick and dirty impl ignoring error checking:
> >    typeof(return) ret = args[0].front();
> >
> >    foreach(arg; args) {
> >        foreach(elem; arg) {
> >            ret = max(elem, ret);
> >        }
> >    }
> >
> >    return ret;
> > }
> >
>
> I clearly haven't been following D2 closely enough. Or maybe I'm just more
> tired than I think... Can you explain that function signature?:
> CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {
>
>
T is a typetuple, with ranges as elements (types). These ranges may have different element types.  staticMap!(ElementType, T) will map the ElementType template on each type in T and from this typetuple create another typetuple:the application of ElementType on each of them:

say you have T == (int[], byte[], ulong[])

then staticMap!(ElementType, T) is (int,byte,ulong)

Then, CommonType is a template that takes a typetuple and finds the common type among them. Then any element from any of the input ranges can be cast to this type. If CommonType finds no common type, it returns 'void'. Then, he use typeof(return) to create a variable with this type he just obtained.

I really like this compile-time calculations on types: as David said, it
allows you to stay generic while having well-defined behavior.
Of course, in a real application, you would put a constraint on this
template, testing for CommonType not to be void. That way, calling largest
element on (string[], double[][]) wouldn't even compile.


Hmm, in fact it could be put in this example, because it shows this kind of function can be safe.


Philippe


June 07, 2010
Nick Sabalausky wrote:
> I actually find that funny. Something in Java that isn't an Object? I remember "Everything's an object!" being paraded around as a selling point.
> 
	Yes, in Java, everything is an object except where that bothered
the language "designers". There are several such design decisions in
Java...

		Jerome
-- 
mailto:jeberger@free.fr
http://jeberger.free.fr
Jabber: jeberger@jabber.fr