Live data from Hacker News

How does D improve on C++17?

p0nce.github.io

71–77 of 77 posts

Re: How does D improve on C++17?

#71
post #60
post #43

D is a awesome language to work with, it's got many useful language features that make the activity of code writing a pleasure. - I hope this criticism is taking constructively. However not a beat a dead horse, but if you want to process more than a trickle of data in it you run into problems with the GC really quickly. I really feel the language would be better off without the GC. These are not the same issues addre…

As aside: I just discovered that the language authors are converting the std library (phobos) to be "no GC".

It's a little more nuanced than that. Phobos is moving towards a more pipeline style, of which http://dlang.org/phobos/std_algorithm.html is a standout example.

Algorithms, by and large, do not need to dynamically allocate memory. By converting more of Phobos to being algorithms, they become agnostic to whatever allocation method is used. Allocation strategy becomes a high level decision, rather than a low level one.

Re: How does D improve on C++17?

#72
post #64

I'm curious how many people out there on HN actully use D and what for? I don't typically see D based projects here on HN so it would be interesting to find out about any use cases where D was found a perfect fit.

What I'd particularly like to see is an analysis of D vs. Rust. Both have been touted as systems programming languages to replace C/C++, and I'd be curious to see a breakdown of their strengths and weaknesses compared to each other.

It would take an expert in both languages to do it. My knowledge of Rust is fairly limited. In particular, every language has its own idiomatic way of doing things (the D Way, the Rust Way), and to compare one has to be cognizant of those idioms.

Re: How does D improve on C++17?

#73
post #43

D is a awesome language to work with, it's got many useful language features that make the activity of code writing a pleasure. - I hope this criticism is taking constructively. However not a beat a dead horse, but if you want to process more than a trickle of data in it you run into problems with the GC really quickly. I really feel the language would be better off without the GC. These are not the same issues addre…

> I've literally seen 20x or more speedups in multithreaded cases just by making sure I reuse every buffer rather than create new ones. Reuse rather than free and reallocate is a core practice whenever you feel the need for speed, regardless of the memory allocate strategy used. For some very fast D code: https://github.com/facebook/warp Minimizing the amount of heap memory allocated is a core strategy.

"Reuse rather than free and reallocate is a core practice whenever you feel the need for speed"

The problem with this conventional wisdom is that it defeats other optimisations. If you free, use, and deallocate a block of memory within a compilation unit, a compiler can transparently allocate it on the stack, or even keep it in registers

If you use a free-list the objects are always escaped, and the same optimisations can't be applied to them.

This is particularly true for small temporary objects, like an intermediate vector (as in coordinates) object.

Re: How does D improve on C++17?

#74

> D has no need for a preprocessor How does this work, specifically conditional compilation? I have lots of code like this: #if __APPLE__ /* do things the OS X way */ #else /* do things the Linux way */ #endif Where the OS X way calls functions that do not exist on Linux, and vice-versa. How does D handle this?

Check out https://github.com/D-Programming-Language/phobos/blob/master... at line 33 and on. You'll see: version (Windows) { ... } etc. For the specification on how this works: http://dlang.org/version.html The salient point is that conditional compilation in D is not text based, it is AST based. Furthermore, for 'static if', the conditional expression has access to the full symbol table and power of the D language -…

Can it do more complex ifdefs - with or's and and's etc?

Re: How does D improve on C++17?

#75
post #74

Earlier quoted context omitted.

Check out https://github.com/D-Programming-Language/phobos/blob/master... at line 33 and on. You'll see: version (Windows) { ... } etc. For the specification on how this works: http://dlang.org/version.html The salient point is that conditional compilation in D is not text based, it is AST based. Furthermore, for 'static if', the conditional expression has access to the full symbol table and power of the D language -…

Can it do more complex ifdefs - with or's and and's etc?

'static if' can - it has full access to the language.

Re: How does D improve on C++17?

#76
post #41

> D has a package manager. C++ has none that is popular in its community. Therefore, using a third-party library is many times easier. This comes up all the time in reference to C++. C++ doesn't need a package manager because it has excellent support from distro package managers. Most libraries are in the system package manager. And yes, sometimes you need a newer version of a package or one not quite widely-used eno…

Almost every C++ codebase out there vendor all dependencies. Looks like they are not using the system package manager. Windows has no package manager with such library releases. Language package managers have problems, but they do make the work easier. Anyone here unhappy with pip?

It might not be usable/in use - but doesn't nuget support c++? http://blogs.msdn.com/b/vcblog/archive/2013/04/26/nuget-for-...

> Anyone here unhappy with pip?

Pip has (had) a number of issues (mostly related to pypi/availability) -- but pip+virtualenvs is something I use all the time, and am very happy with.

The ease with which one can simply:

  virtualenv some_experiment # --no-site-packages
    # is now standard! yay!
  ./some_experiment/bin/pip install -U pip distribute
    # sadly needed -- but gets us pip list --outated, which
    # is very helpful
  ./some_experiment/bin/pip install 
And then just work with that, without even having to mess around with sourcing the "activate" script etc for most packages is great. No clutter under /usr/local, no broken system tools due to some dependency being pulled in etc.

Re: How does D improve on C++17?

#77

> D has a package manager. C++ has none that is popular in its community. Therefore, using a third-party library is many times easier. This comes up all the time in reference to C++. C++ doesn't need a package manager because it has excellent support from distro package managers. Most libraries are in the system package manager. And yes, sometimes you need a newer version of a package or one not quite widely-used eno…

Speaking of package managers, looks like the ssl-cert for dlang.org is expired (and has been for more than a year) -- which leaves most of us with one less way to try to verify the installer, as: https://dlang.org/gpg_keys.html is only available via a untrusted channels.
Post reply on HN