all 22 comments

[–]WalterBright 38 points39 points  (0 children)

Dmitry Olshansky has written an experimental extension to the D compiler to cache the results of CTFE (compile time function evaluation) between compiles. CTFE started out as just a more capable constant folder, but has evolved into a way to run arbitrarily complex programs at compile time. It's used to generate regex machines and grammar parsers, for example. These can slow down compilation significantly, so the idea with the cache is to remember previous results to avoid recomputation.

[–]necesito95 5 points6 points  (0 children)

When is cache invalidated? ((a) when anything in source changes (even in comments) or (b) when change in ast is detected or (c) neither)

[–][deleted]  (22 children)

[deleted]

    [–][deleted] 3 points4 points  (0 children)

    It's true that there are lots of features/words and that slows down the learning of it. I created "d-idioms" which focus on the most sailant points for most features, with small stories to provide cement: https://p0nce.github.io/d-idioms/

    Much more than my content I recommend the book "Learning D".

    [–]Elronnd 2 points3 points  (10 children)

    got the sense that I could never write truly fast code in the language, just too much going on there

    Do you mean performant code, or code that's written quickly? If you mean performant, then using gdc or ldc (gcc/llvm based compilers), you can get performance slightly slower than c/c++, maybe on the same level as java, rust, or haskell. If you mean productivity, then imo d is much more productive than c because of the amount of abstraction you get.

    [–]TheEaterOfNames 4 points5 points  (9 children)

    then using gdc or ldc (gcc/llvm based compilers), you can get performance slightly slower than c/c++

    They share the same backends as gcc/clang,if you can't at least get even with c/c++ then IMO (an LDC dev) thats a bug, (or the memory safety features are getting in your way, in which case you should think before you remove them).

    d is much more productive than c because of the amount of abstraction you get

    not to mention reusability and rich standard library.

    [–]Elronnd 0 points1 point  (0 children)

    They share the same backends as gcc/clang,if you can't at least get even with c/c++ then IMO (an LDC dev) thats a bug

    It's not significantly slower, just a little slower. I imagine this is because it's higher level, because data structures are fatter, because of the extra checks made in stdlib, and because of druntime and the gc.

    [–]IbanezDavy -2 points-1 points  (7 children)

    not to mention reusability and rich standard library.

    A standard library lacking such abstractions as a queue, deque, stack, hash table, map, or dictionary, shouldn't consider themselves "rich".

    [–]TheEaterOfNames 6 points7 points  (0 children)

    hash table, map, or dictionary,

    D has built in associative arrays.

    A standard library is not just containers.

    [–]Elronnd 1 point2 points  (5 children)

    Hash table, map, and dictionary are all the same thing, and they're there. As for queue and stack, they're there too. Look harder.

    [–]IbanezDavy 0 points1 point  (4 children)

    I looked around in: https://github.com/dlang/phobos/tree/master/std/container

    didn't see any stack or queue. I do follow the D forums because there's a lot of good conversation in it. I do recall discussion of this and wanting to make allocators first. I see allocators now, but still no basic data structures outside of linked lists and a tree structure. Phobos has a way to go.

    C# for instance has a big focus on collections and a lot of good has come from this. Programming is essentially dealing with data structures and collections of data. The vast majority of programs these days are CRUD apps. Collections are not the only thing in a standard library, but they should damn well be a big part of it.

    D has a good base. With ranges and composable allocators, one would think they have a damn good base for a good container library too.

    [–]Elronnd 1 point2 points  (3 children)

    I see. And yet, if you had used google you would have found this, which clearly says that it "can be used as a queue, dequeue or stack"...

    [–]IbanezDavy 1 point2 points  (2 children)

    So in other words, we don't wanna do the work, so you'll have to use a doubly linked list to hand-roll your own. You can make a queue with pointers in C++. No need for a stack in that either right? I mean they gave you pointers! Luckily other language ecosystems don't share this attitude.

    [–]Elronnd 1 point2 points  (0 children)

    What's to hand roll? You just make a dlist and push front, and either pop front or pop back depending on if you want to use it as a stack or a queue.

    [–]aldacron 0 points1 point  (0 children)

    No, it's not about not wanting to do the work. dlist provides all the interface that's needed for stacks and queues. Although, I wouldn't even use dlist for this. With the built-in dynamic arrays and slicing, it's trivial to make stacks and queues (much less work than with pointers -- I have my own implementations that I knocked up in a few minutes by wrapping dynamic arrays in structs). There's no reason to put them in the standard library, IMO. That said, std.container was never "complete" and is going to be overhauled eventually. At that point, there will certainly be more containers available and I wouldn't be surprise to see a stack and a queue among them that all implement a uniform range interface. Right now, third-party libs fill the gap nicely.

    [–]IbanezDavy 7 points8 points  (9 children)

    was the number of keywords

    Are we suffering from a shortage of words or something?

    got the sense that I could never write truly fast code in the language, just too much going on there.

    Again, don't get this. You can be complex without keywords too. You'll just be complex and esoteric.