Live data from Hacker News

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

dlang.org

61–70 of 131 posts

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

#61

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(); }

That code won't compile because Greetings is undefined. Hence, you may be running some other program which seg faults.

ohh, yeah, I omitted the definition of the class because I thought it'd be obvious, here it is:

  $ cat main.d
  import std.stdio;

  class Greetings {
	void hello() {
		writeln("hello");
	}
  }

  void main()
  {
	Greetings g = null;
	g.hello();
  }
  $ dmd -g main.d && ./main
  Segmentation fault: 11
  $ uname -a
  Darwin Johan-Ride-Mac.local 15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
  $ dmd --version
  DMD64 D Compiler v2.069.0
  Copyright (c) 1999-2015 by Digital Mars written by Walter Bright
(EDIT: added osx and dmd versions)

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

#62
post #3

I'm wondering, is there an advantage of using D over Rust?

Some things D has that Rust doesn't: compiler-checked function purity annotations, higher-kinded types, variadic functions/generics, types parameterised by numbers, compile-time function evaluation, mixins, a fast compiler (the reference DMD compiler), powerful and convenient compile-time reflection (I think technically Rust can do anything D can at compile time, but it requires writing a syntax extension to do so).…

> higher-kinded types

Well, not really. Higher-kinded type parameters are something that requires a kind (typeclass) system in the first place, which D intentionally doesn't have (as D's authors are opposed in principle).

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

#63

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(); }

1) Where is Greetings defined ? 2) Spanish ?

replied here https://news.ycombinator.com/item?id=10507821

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

#64
post #27

Earlier quoted context omitted.

On the nontechnical side I would add that since D is a lot older, keeping up with changes is a whole lot less challenging. Its stable enough that one can put it near the money without worrying too much about breaking changes.

Since 1.0 last May, we have a strong commitment to backwards compatibility as well. Stability should not be an issue any longer.

GP is actually the second post in a week I've seen where someone mentions tracking rust changes, but rust has been 1.0 for a while now. Have there actually any backwards incompatible changes since 1.0, or are people really complaining about a problem that's been fixed for close to six months and even then was specific to beta versions?

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

#65
post #50
post #19

Earlier quoted context omitted.

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?

[deleted]

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

#66

Earlier quoted context omitted.

Some things D has that Rust doesn't: compiler-checked function purity annotations, higher-kinded types, variadic functions/generics, types parameterised by numbers, compile-time function evaluation, mixins, a fast compiler (the reference DMD compiler), powerful and convenient compile-time reflection (I think technically Rust can do anything D can at compile time, but it requires writing a syntax extension to do so).…

Rust and D are both great. The difference is that Rust has a hugely powerful hype train, which happens to be operating at 1,000% capacity somehow since the beginning of Rust.

As someone who's been following the hype, but not really jumped on yet, the difference (whether real or imagined) seems to be that rust is trying to do something new, and D looks to be (and I've seen it aggressively marketed as) C++ with some better choices and cool features. Personally, I'm not really interested in C++, but I am interested in getting for familiar with a systems language, so rust interests me.

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

#67
post #64

Earlier quoted context omitted.

Since 1.0 last May, we have a strong commitment to backwards compatibility as well. Stability should not be an issue any longer.

GP is actually the second post in a week I've seen where someone mentions tracking rust changes, but rust has been 1.0 for a while now. Have there actually any backwards incompatible changes since 1.0, or are people really complaining about a problem that's been fixed for close to six months and even then was specific to beta versions?

There haven't been backwards-incompatible changes in practice, no.

That is to say: there have been technically backwards-incompatible changes, but every compiler and language, including those of C++ and Java, make technically backwards-incompatible changes in point releases (e.g. defining new functions in the libraries and modifying undefined behavior). Rust doesn't make changes that violate the stability guarantee. It goes further than that, in fact—any change that is not breaking according to the public guidelines but is thought possibly breaking in practice is tested against crates.io and feedback is solicited from those who have any private crates that might be affected to make sure it doesn't break them either.

(Unfortunately this policy is often misunderstood—for example, it's been claimed that Rust will make breaking changes as long as they don't break anything on crates.io, which is very much not an accurate description of it.)

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

#68

Earlier quoted context omitted.

That code won't compile because Greetings is undefined. Hence, you may be running some other program which seg faults.

ohh, yeah, I omitted the definition of the class because I thought it'd be obvious, here it is: $ cat main.d import std.stdio; class Greetings { void hello() { writeln("hello"); } } void main() { Greetings g = null; g.hello(); } $ dmd -g main.d && ./main Segmentation fault: 11 $ uname -a Darwin Johan-Ride-Mac.local 15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64…

Replace: Greetings g = null; with: auto g = new Greetings();

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

#69

Earlier quoted context omitted.

> It still has implicit numeric cast, Implicit numeric casts that lose bits are not allowed anymore. > exception unsafety ??

> Implicit numeric casts that lose bits are not allowed anymore. That's good to hear, but I want implicit conversion to be forbidden unconditionally (even int * float -> float). I've been bitten by even widening conversions, so I just want to let them go away. It might be great if such an option could be applied to module level. > ?? Sorry if my understandings or my words were wrong, but I got the impression that D a…

> I want implicit conversion to be forbidden unconditionally

Not going to happen in a language with 11 integer types.

> (double-throw)

Exceptions are chained together.

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

#70

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(); }

I had the same problem with D. As an example of what I feel stack traces should look like, compare it to the stack traces that Nim gives.

  ~/temp_code » ./greetings
  Traceback (most recent call last)
  greetings.nim(9)        greetings
  greetings.nim(6)        hola
  SIGSEGV: Illegal storage access. (Attempt to read from nil?)
For the code:

  type
    Greetings = ref object
      name: string

  proc hola(g: Greetings) =
    echo g.name

  var g: Greetings
  g.hola()
Post reply on HN