Live data from Hacker News

D 2.069.0 released, compiler automatically ported from C++ to D

dlang.org

41–50 of 131 posts

Re: D 2.069.0 released, compiler automatically ported from C++ to D

#41

Not sure what I do wrong every time I try D again, I wanted to see the new backtraces worked but I still get: /bin/bash: line 1: 82501 Segmentation fault: 11 ./main while I try to call a method on a null variable, which is not that friendly to newcomers. Sample code: import std.stdio; void main() { Greetings g = null; g.hola(); }

Did you compile with debug info (-g I think)? It needs to read the DWARF info to get the line numbers.

Re: D 2.069.0 released, compiler automatically ported from C++ to D

#42

Not sure what I do wrong every time I try D again, I wanted to see the new backtraces worked but I still get: /bin/bash: line 1: 82501 Segmentation fault: 11 ./main while I try to call a method on a null variable, which is not that friendly to newcomers. Sample code: import std.stdio; void main() { Greetings g = null; g.hola(); }

Did you compile with debug info (-g I think)? It needs to read the DWARF info to get the line numbers.

I think so:

  $ dmd -g main.d && ./main
  Segmentation fault: 11
is there anything else I can try?

I'm OSX El Capitan 10.11.1

Re: D 2.069.0 released, compiler automatically ported from C++ to D

#43

How's the memory-safety model in D without a GC, last time I looked at it, it seemed to me that C++ 11/14 has the better model here and now with the C++ core guidelines, it may be even better.

Has the core guidelines Checker tool been released yet? For those that haven't studied the guideline intensely, I'd assume it's necessary to do any kind of real world comparison.

Re: D 2.069.0 released, compiler automatically ported from C++ to D

#46
post #44

[deleted]

Those sorts of transpilers are usually tailored to a specific project, so it would probably not work on bitcoin-core. Of course if bitcoin-core was committed to moving to D they could fork the transpiler and tailor it to their own code base.

Re: D 2.069.0 released, compiler automatically ported from C++ to D

#47
post #5

Earlier quoted context omitted.

I guess D feels more like a better C++ and Rust like a better C, but I may be under the wrong impression.

I disagree. D is an improved C that does a lot of the same things as C++, but in order for it to be a better C++, it would need to start with C++ as a foundation and build on it. D has more of a scripting language feel to me.

> D has more of a scripting language feel to me.

I'm curious about this, although I don't think this is the first time I've heard D described as having a script-y feel to it. It sounds along the same lines as people describing Go as almost a scripting language, or comparing it to them. Neither Go nor D seem especially dynamic, both have compilers for reference implementations, both look more like C than Python. (To my eyes at least; I've never tried either one. Thus this question.)

Is it primarily the speed of the compilers? Both DMD and g6/g7/g8 boast very fast compiles, and Go uses somewhat script-y tools... but #!/usr/local/bin/tcc -run hasn't changed C's reputation. Fast compiling and memory safety, maybe?

Re: D 2.069.0 released, compiler automatically ported from C++ to D

#48
post #26

D is a really amazing language that manages to correct the mistakes of c++ but still retain its good parts. it's a shame that it's not more popular.

To me, while D fixes many warts of C++, D is still too similar to C++ to justify the change. It still has implicit numeric cast, exception unsafety and strange behaviors.[1]

In addition, the D authors are generally opposed to disciplined approaches, e.g. type classes, region-based memory management, which are being added to C++. Especially regarding the former, while "design by introspection" may have its merits (Andrei Alexandrescu's presentation on allocator is worth watching[2]), I think many still prefer explicit interfaces over implicit ones, so I don't see D take off in the near future, at least until the wanted features are added to the language.

[1] http://forum.dlang.org/thread/htmkdnmlqyvkidkrsmri@forum.dla...

[2] https://www.youtube.com/watch?v=mCrVYYlFTrA

Re: D 2.069.0 released, compiler automatically ported from C++ to D

#49

Earlier quoted context omitted.

Did you compile with debug info (-g I think)? It needs to read the DWARF info to get the line numbers.

I think so: $ dmd -g main.d && ./main Segmentation fault: 11 is there anything else I can try? I'm OSX El Capitan 10.11.1

On Unix segfaults by default don't generate stack traces. This makes it work on linux, don't know about OSX (put it in your main module):

  import etc.linux.memoryerror;
  
  shared static this() {
   	static if (is(typeof(registerMemoryErrorHandler)))
   		registerMemoryErrorHandler();
  }

Re: D 2.069.0 released, compiler automatically ported from C++ to D

#50
post #19

Earlier quoted context omitted.

How would you consider Rust's generics as being part of a better C rather than a better C++?

C translates almost 1:1 to Rust, but when converting C++ to Rust you'll run into impedance mismatch between OO hierarchies and traits, and generics being narrower in functionality than templates. In Rust you still can do "clever" things with generics to make them feel like C++, but the rest of the language is still closer to C: errors returned rather than thrown, no inheritance (but the "flat" OO and enums map well t…

> errors returned rather than thrown

WHATT??? did they do the same mistake as Go?

Post reply on HN