Jump to page: 1 2
Thread overview
What were some of your biggest breakthroughs while learning D?
Jul 06, 2021
Dylan Graham
Jul 06, 2021
norm
Jul 07, 2021
SealabJaster
Jul 07, 2021
SealabJaster
Jul 07, 2021
Paulo Pinto
Jul 07, 2021
SealabJaster
Jul 07, 2021
Nicholas Wilson
Jul 07, 2021
Max Samukha
Jul 07, 2021
Max Samukha
Jul 07, 2021
Guillaume Piolat
Jul 07, 2021
Dennis
Jul 07, 2021
Dukc
Jul 09, 2021
Dylan Graham
Jul 13, 2021
Jesse Phillips
Jul 19, 2021
Mathias LANG
Jul 19, 2021
solidstate1991
July 06, 2021

Inspiration from this r/C_Programming post

What's something you learnt or realised, a habit you developed, something you read or project you worked on that helped accelerate your understanding and/or productivity in D?

For example, mixin templates finally clicking and you realise how to use them in your code base. Stuff like that.

July 06, 2021

On Tuesday, 6 July 2021 at 20:53:12 UTC, Dylan Graham wrote:

>

Inspiration from this r/C_Programming post

What's something you learnt or realised, a habit you developed, something you read or project you worked on that helped accelerate your understanding and/or productivity in D?

For example, mixin templates finally clicking and you realise how to use them in your code base. Stuff like that.

D really did change how I approach programming tasks in any language.

D templates with CTFE
D syntax; ! for templates, UFCS, optional parenthesis

These features were a game changer for me because I could finally see through the syntax to semantics and I could easily create more fluent and monadic-like interfaces in my own code. C++ never had this clarity and for me personally it was always a muddy quagmire of Type<typename T::SomeVector<etc<etc>>>.

With a better understanding of templates I started thinking in terms of functional types instead of just values and data structures, which was universal to all programming languages, even dynamically typed languages like Python.

July 07, 2021

On Tuesday, 6 July 2021 at 20:53:12 UTC, Dylan Graham wrote:

>

...

How any combination of UFCS, dynamic code generation and introspection, shortened syntax for calling functions, the ability to pass lambdas to templates (which can also be completely inlined by the compiler without sacrificing on code readability), etc can all be used to create and model code almost exactly how you want it to.

I very rarely feel constricted in D like I do in other languages. There's pros and cons to that of course, but when I feel like just tapping out something random, more often than not I can match the code model to my mental model.

e.g. the very existence of UDAs can allow for pretty natural looking code:

@Command("command", "This is a command that is totally super complicated.")
struct ComplexCommand
{
    @CommandArgGroup("Debug", "Arguments related to debugging.")
    {
        @CommandNamedArg("verbose|v", "Enables verbose logging.")
        Nullable!bool verbose;

        @CommandNamedArg("log|l", "Specifies a log file to direct output to.")
        Nullable!string log;
    }
}

The above is doable in C#, but has to be done at runtime (assume the same with JVM languages).

However in C++ you probably have to do weird hacks or use an external tool. C is either the same as C++ or even worse.

Another example would be ranges, which we all know about (taken from D's main page):

import std.stdio, std.array, std.algorithm;

void main()
{
    stdin
        .byLineCopy
        .array
        .sort!((a, b) => a > b) // descending order
        .each!writeln;
}

Or maybe I want to design a UI system where, with a small bit of descriptive boiler plate, I can automatically enable new controls to be used within a UI definition file:

@DataBinding
struct MyControlBinding
{
    @BindingFor("stringVal")
    string someString;

    @BindingFor("intVal")
    @Name("number")
    int someInt;
}

@UsesBinding!MyControlBinding
class MyControl : UIBase
{
    public string stringVal;
    public int intVal;
}
UI:view {
    name "Some sexy custom UI"

    MyControl {
        someString "Hey"
        number 69
    }
}

Or literally even just simple things like custom error messages:

struct Vector(size_t dims)
{
    static assert(dims <= 4, "The dimension is too large!")
}

Then there's things like pegged, vibe-d's diet templates, etc... All of this is possible within a single language, using standard tooling.

Once I learned about how to introspect code and to generate code, the amount of possibilities really opened up to me.

D's expressiveness and modeling power is probably the biggest thing I'd say it has over most over languages. I feel even dynamic languages fail to do some of these things as elegantly.

July 07, 2021

On Wednesday, 7 July 2021 at 00:13:44 UTC, SealabJaster wrote:

>

...

There's also cool shenanigans with things like this: https://dlang.org/blog/2017/02/13/a-new-import-idiom/

July 07, 2021

On Tuesday, 6 July 2021 at 20:53:12 UTC, Dylan Graham wrote:

>

Inspiration from this r/C_Programming post

What's something you learnt or realised, a habit you developed, something you read or project you worked on that helped accelerate your understanding and/or productivity in D?

For example, mixin templates finally clicking and you realise how to use them in your code base. Stuff like that.

UFCS + ranges made me how algorithms are supposed to compose

You can make useful but really horrible interfaces (i.e. OpenCL) rather nice with reflection and CTFE

July 07, 2021

On Tuesday, 6 July 2021 at 20:53:12 UTC, Dylan Graham wrote:

>

Inspiration from this r/C_Programming post

What's something you learnt or realised, a habit you developed, something you read or project you worked on that helped accelerate your understanding and/or productivity in D?

For example, mixin templates finally clicking and you realise how to use them in your code base. Stuff like that.

For me, it is the indirect value I reaped by lurking in D's forums. There used to be some interesting discussions by language theorists that pushed me to learn and appreciate quite a bit of "abstract nonsense" and shown how many of what I thought was a cool new thing was just a hackish reincarnation of an old and well explored concept (including mixin templates).

July 07, 2021

On Wednesday, 7 July 2021 at 08:41:05 UTC, Max Samukha wrote:

>

shown
showed, etc

I wish I could edit.

July 07, 2021

On Wednesday, 7 July 2021 at 00:13:44 UTC, SealabJaster wrote:

>

On Tuesday, 6 July 2021 at 20:53:12 UTC, Dylan Graham wrote:

>

...

How any combination of UFCS, dynamic code generation and introspection, shortened syntax for calling functions, the ability to pass lambdas to templates (which can also be completely inlined by the compiler without sacrificing on code readability), etc can all be used to create and model code almost exactly how you want it to.

I very rarely feel constricted in D like I do in other languages. There's pros and cons to that of course, but when I feel like just tapping out something random, more often than not I can match the code model to my mental model.

e.g. the very existence of UDAs can allow for pretty natural looking code:

@Command("command", "This is a command that is totally super complicated.")
struct ComplexCommand
{
    @CommandArgGroup("Debug", "Arguments related to debugging.")
    {
        @CommandNamedArg("verbose|v", "Enables verbose logging.")
        Nullable!bool verbose;

        @CommandNamedArg("log|l", "Specifies a log file to direct output to.")
        Nullable!string log;
    }
}

The above is doable in C#, but has to be done at runtime (assume the same with JVM languages).

Not really, in Java you can do it with annotation processors and compiler plugins at compile time, whereas in C# you can do it with code generators or T4 templates.

July 07, 2021

On 7/6/21 4:53 PM, Dylan Graham wrote:

>

Inspiration from this r/C_Programming post

What's something you learnt or realised, a habit you developed, something you read or project you worked on that helped accelerate your understanding and/or productivity in D?

For example, mixin templates finally clicking and you realise how to use them in your code base. Stuff like that.

Learning to not care about using the GC.
Learning to have the compiler write code the way I would write it. vibe.d was immensely inspiring for this!

-Steve

July 07, 2021

On Tuesday, 6 July 2021 at 20:53:12 UTC, Dylan Graham wrote:

>

Inspiration from this r/C_Programming post

What's something you learnt or realised, a habit you developed, something you read or project you worked on that helped accelerate your understanding and/or productivity in D?

For example, mixin templates finally clicking and you realise how to use them in your code base. Stuff like that.

  • writing D explanations to solidify knowledge
  • using DUB and Semver really augmented the amount of software I could build, as you can maintain lazily
  • that led to learning to better isolate public APIs in order to stay topdown and reduce breakage
  • (minor) learning what the D GC actually does
« First   ‹ Prev
1 2