Jump to page: 1 24  
Page
Thread overview
September 19

Just know this.

September 19

On Tuesday, 19 September 2023 at 04:34:30 UTC, Vitaliy Fadeev wrote:

>

...

I like foreach.
I like templates.
I like ranges.

Just look at this SDL event pool implementation:

        foreach( e; pool )
            process( e );

I love short text blocks, like this:

// using pool
struct Game
{
    static
    Pool    pool;
    Sensors sensors;

    void go()
    {
        foreach( d; pool )
            sensors.sense( d );
    }
}

Nice:

void main()
{
    game.go();	
}

I love structured types, like this:

// event pool
import bindbc.sdl;
import types;


struct Pool
{
    D front;

    void popFront()
    {
        if ( SDL_WaitEvent( cast( SDL_Event* )&this.front ) == 0 )
            throw new SDLException( "Pool.popFront: " );
    }

    bool empty()
    {
        return ( front.type == SDL_QUIT );
    }

    void opOpAssign( string op : "~" )( SDL_EventType t )
    {
        SDL_Event event;
        event.type = t;
        SDL_PushEvent( &event ); // The event is copied into the queue.
    }
}

September 19

On Tuesday, 19 September 2023 at 04:34:30 UTC, Vitaliy Fadeev wrote:

>

Just know this.

+1 😍

SDB@79

September 20
On Tue, Sep 19, 2023 at 04:34:30AM +0000, Vitaliy Fadeev via Digitalmars-d wrote:
> Just know this.

Me too!

One of my favorite parts:

	// Slow
	auto myData = iota(1_000_000).array;
	foreach (data; myData) {
		doSomething(data);
	}

	// Instant speedup:
	auto myData = iota(1_000_000).array;
	foreach (data; myData.parallel) {
		doSomething(data);
	}

D r0x0rs!

No, D boulders! :-D


T

-- 
Старый друг лучше новых двух.
September 20
On 9/20/2023 4:01 PM, H. S. Teoh wrote:
> D r0x0rs!
> 
> No, D boulders! :-D

Love it!
September 21
On Tuesday, 19 September 2023 at 04:34:30 UTC, Vitaliy Fadeev wrote:
> Just know this.

One thing that I like about D is... it has the performance of a System/compiled language at at same time supports GC.

I'm not a language expert but coming from C that was very cool.

Matheus.
September 21
On Thursday, 21 September 2023 at 01:07:30 UTC, matheus wrote:
> On Tuesday, 19 September 2023 at 04:34:30 UTC, Vitaliy Fadeev wrote:
>> Just know this.
>
> One thing that I like about D is... it has the performance of a System/compiled language at at same time supports GC.
>
> I'm not a language expert but coming from C that was very cool.
>
> Matheus.

Nice to see some praise to D for a change. We need more people like this
September 21

On Tuesday, 19 September 2023 at 04:34:30 UTC, Vitaliy Fadeev wrote:

>

Just know this.

One thing I really love, personally, is how expressive you can get with APIs in D.
In C I expect stuff like this:

/*
 bla bla ... is deprecated and should not be used ... bla bla
*/
void run(const Data* val, unsigned char* msg, const void* usr);

Whereas, in D I can write:

deprecated("should not be used ... bla bla")
noreturn run(U)(scope const(Data)* val, string msg, in U usr) nothrow pure;

(without -preview=in: swap in for auto ref const)

The specificity that D offers, particularly with pure, and scope, and scope's derivatives, becomes really useful when you have to declare a public API with interfaces & classes. You can make sure that when you call something inheriting from a public interface that the call won't have side-effects, or that the foreign function won't store a pointer passed to it (that it doesn't own) anywhere.

September 21
On Thursday, 21 September 2023 at 16:29:43 UTC, Imperatorn wrote:

> Nice to see some praise to D for a change. We need more people like this

Then you aren't talking to me. The internet culture (right or wrong) promotes criticism over praise.
September 24

On Tuesday, 19 September 2023 at 04:34:30 UTC, Vitaliy Fadeev wrote:

>

Just know this.

I wonder why D isn't more popular.

Also we have arsd, so it's an automatic win.

« First   ‹ Prev
1 2 3 4