www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - More D & Rust

reply "bearophile" <bearophileHUGS lycos.com> writes:
It seems D comes up often in Rust threads :-)

http://www.reddit.com/r/programming/comments/11j38z/mozilla_and_the_rust_team_announce_version_04_of/

I still think D and Rust should join forces to design a single GC 
usable for both languages :-) Their GC needs are not _that_ 
different.


A question in that thread:
 My question is, what are the advantages of Rust over D? How do 
 you think they compare?

An answer by ssylvan:
For me, the memory management of Rust (the three pointer types, 
per-task GC), as well as the additional safety (in particular, D 
still has nulls all over the place - IME the by far most common 
remaining "real world" crash seen in so called "memory safe" 
languages - it's unfortunate because we know that they can be 
statically eliminated). Also, not a fan of the class/struct 
distinction in D, I think it encourages heap allocations, 
whereas Rust drastically prefers big chunky objects that mostly 
stay on the stack or inside another object with only the 
extremely rare allocation, and even then most of those can be 
unique (no GC/RC).<

Bye, bearophile
Oct 15 2012
next sibling parent Marco Leise <Marco.Leise gmx.de> writes:
Am Tue, 16 Oct 2012 04:48:07 +0200
schrieb "bearophile" <bearophileHUGS lycos.com>:

 It seems D comes up often in Rust threads :-)

And you are here to remedy that situation? No offense, I started to keep an eye on Rust myself. I'm pretty sure it will eventually have to cater to the people who use it and tack some features on, like D2 that make it look less carefully designed. New features lead to language WATs. Also thanks for the strawman citation about not-null types. ;) Since I don't write compilers I don't worry about their complexity, and I think they are supposed to be a language feature. Library solutions are clumsy to use and lack the static flow analysis that is possible inside a compiler. This three pointer types stuff also sounds effective to keep the GC heap slim. I can't tell without personal experience though, if all they implemented is an advantage in practice. I agree with them, that it would be nice if D classes could naturally be placed on the stack. Again I think it's a language feature, just as 'ref' parameters are. Otherwise, as long as I don't need polymorphism, I never missed anything from structs, so I get along fine most of the time. -- Marco
Oct 15 2012
prev sibling next sibling parent "Kagamin" <spam here.lot> writes:
Well, it's true non-null types can be statically checked. But if 
you try to code without nulls, what is the chance to run into 
null pointer?
Oct 16 2012
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Kagamin:

 Well, it's true non-null types can be statically checked. But 
 if you try to code without nulls, what is the chance to run 
 into null pointer?

I presume then the probability becomes lower (but I don't have statistics to support this opinion.) Bye, bearophile
Oct 16 2012
prev sibling next sibling parent Ziad Hatahet <hatahet gmail.com> writes:
--bcaec50162332a88c504cc325586
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Oct 16, 2012 at 3:35 AM, Kagamin <spam here.lot> wrote:

 Well, it's true non-null types can be statically checked. But if you try
 to code without nulls, what is the chance to run into null pointer?

You mean by calling external (potentially unsafe) code that contains null pointers? -- Ziad --bcaec50162332a88c504cc325586 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, Oct 16, 2012 at 3:35 AM, Kagamin <span dir=3D"ltr">&lt;<a href=3D"m= ailto:spam here.lot" target=3D"_blank">spam here.lot</a>&gt;</span> wrote:<= br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"ma= rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Well, it&#39;s true non-null types can be statically checked. But if you tr= y to code without nulls, what is the chance to run into null pointer?<br> </blockquote></div><div><br></div>You mean by calling external (potentially= unsafe) code that contains null pointers?<div><br><div>--<br>Ziad<br></div=
</div>

--bcaec50162332a88c504cc325586--
Oct 16 2012
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Ziad Hatahet:

 You mean by calling external (potentially unsafe) code that 
 contains null pointers?

This is *not* a significant problem for a language with a well designed non-null system. See how ATS language removes similar problems. Bye, bearophile
Oct 16 2012
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Marco Leise:

 I agree with them, that it would be nice if D classes could
 naturally be placed on the stack.

Allocating D class instances in-place (on the stack or inside other structs/class instances) is not hard, but in practice I never do it (Like I never use Rebindable or Typedef. I sometimes use Nullable or AssumeUnique). But to make it safe enough you probably need a smarter type system, that they have mostly finished designing in Rust. Avoiding most heap allocations is positive because it reduces the amount of garbage, reduces pressure on the GC, gives good performance even if you use a not too much refined GC, avoids GC precision troubles, helps use less levels of indirection, and generally helps keep the code faster. Another thing Rust team is doing is (I think) having the reference compiler based on LLVM. This means saving time to develop only the front-end and designing the language. Scala development was quick because the "back-end" and the GC was already done (but of course it introduced some limitations. Now they are porting Scala to the LLVM, removing most or all of the limitations, but they keep all layers of the compiler but the last one, so they have to translate stack-based code to the infinite-number-of-registers-based IR of LLVM, and I think this is sub-optimal, but they will have time to fix this problem later removing one more stage in the middle). Bye, bearophile
Oct 16 2012
prev sibling next sibling parent Ziad Hatahet <hatahet gmail.com> writes:
--14dae934071b037bae04cc34be56
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Oct 16, 2012 at 1:16 PM, bearophile <bearophileHUGS lycos.com>wrote:

 Now they are porting Scala to the LLVM, ...

to not have been updated in a while though. -- Ziad --14dae934071b037bae04cc34be56 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, Oct 16, 2012 at 1:16 PM, bearophile <span dir=3D"ltr">&lt;<a href= =3D"mailto:bearophileHUGS lycos.com" target=3D"_blank">bearophileHUGS lycos= .com</a>&gt;</span> wrote:<br><div class=3D"gmail_quote"><blockquote class= =3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd= ing-left:1ex"> <div class=3D"im">Now they are porting Scala to the LLVM, ...</div> <br><br></blockquote></div><div><br></div><div>This Scala to LLVM port ( <a= href=3D"http://greedy.github.com/scala-llvm/">http://greedy.github.com/sca= la-llvm/</a> )? It seems to not have been updated in a while though.</div> <div><br></div><div><br></div><div>--<br>Ziad<br></div> --14dae934071b037bae04cc34be56--
Oct 16 2012
prev sibling next sibling parent reply "Michael" <pr m1xa.com> writes:
I can't compile even hello world on both Win 7 and Win XP.

rust 0.4, latest mingw.
Oct 17 2012
parent Nick Treleaven <ntrel-public yahoo.co.uk> writes:
On 17/10/2012 18:14, Michael wrote:
 I can't compile even hello world on both Win 7 and Win XP.

 rust 0.4, latest mingw.

The announcement seems to suggest you might need an older mingw: https://mail.mozilla.org/pipermail/rust-dev/2012-October/002489.html Also if you had 0.3 you need to uninstall it before installing 0.4.
Oct 18 2012
prev sibling next sibling parent "DypthroposTheImposter" <mcbracket gmail.com> writes:
  I guess D doesn't support unique_ptr like behavior, humm.. I 
like this in C++, is it possible in D?
Oct 17 2012
prev sibling next sibling parent "thedeemon" <dlang thedeemon.com> writes:
On Wednesday, 17 October 2012 at 18:38:25 UTC, 
DypthroposTheImposter wrote:
  I guess D doesn't support unique_ptr like behavior, humm.. I 
 like this in C++, is it possible in D?

http://dlang.org/phobos/std_typecons.html#Unique ?
Oct 17 2012
prev sibling next sibling parent "Paulo Pinto" <pjmlp progtools.org> writes:
On Wednesday, 17 October 2012 at 17:14:59 UTC, Michael wrote:
 I can't compile even hello world on both Win 7 and Win XP.

 rust 0.4, latest mingw.

Try it out in Linux. Windows support is still shaky due to LLVM, which also has Windows issues. If you check Rust mailing list there are a few posts about not so good Windows support. I had to endure the same thing with Go, as Go team only cared about Linux & Mac OS X, leaving any other operating system support to the community. -- Paulo
Oct 17 2012
prev sibling parent "Michael" <pr m1xa.com> writes:
 The announcement seems to suggest you might need an older mingw:
 https://mail.mozilla.org/pipermail/rust-dev/2012-October/002489.html

 Also if you had 0.3 you need to uninstall it before installing 
 0.4.

Yes. I read it. It is annoying.
Oct 18 2012