www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Reasons to use D (over alternatives like Rust)

reply RaycatWhoDat <rmperry09 gmail.com> writes:
Hi.

Disclaimer: This thread isn't specifically a "this vs. that" 
thread but more of a "help me articulate reasons" post.

For the last three or so years, I've been on a bit of a journey 
to find two or three languages that I can really dive into and 
specialize in. I came upon D by accident about a year or so ago 
and I really enjoyed the productivity I felt when writing it. 
Specifically, I liked the way it felt to write and refactor and 
optimize. I'm big on what the semantics and syntax of a language 
feels like. This is where the problem starts.

I can tell people how I feel writing the language but I can't 
give them exact reasons as to why they'd pick D over alternatives 
like Rust. I was hoping I could get some opinions from the people 
here and maybe you guys can help me solidify some of my own 
understandings.

Thanks in advance.
Feb 04
next sibling parent JN <666total wp.pl> writes:
On Tuesday, 4 February 2020 at 19:57:53 UTC, RaycatWhoDat wrote:
 I can tell people how I feel writing the language but I can't 
 give them exact reasons as to why they'd pick D over 
 alternatives like Rust. I was hoping I could get some opinions 
 from the people here and maybe you guys can help me solidify 
 some of my own understandings.

 Thanks in advance.
If you prefer GC to borrow checker. If you have a C++ codebase you want to interact with (D works hard on C++ interop, Rust doesn't even try). If you have a C++ codebase you'd like to convert to another language - most C++ constructs map easily to D, with Rust you'd have to reorganize most of the application to make borrow checker happy.
Feb 04
prev sibling next sibling parent bachmeier <no spam.net> writes:
On Tuesday, 4 February 2020 at 19:57:53 UTC, RaycatWhoDat wrote:
 I can tell people how I feel writing the language but I can't 
 give them exact reasons as to why they'd pick D over 
 alternatives like Rust. I was hoping I could get some opinions 
 from the people here and maybe you guys can help me solidify 
 some of my own understandings.
Why did I pick D? Probably the biggest reason was because writing D code didn't lock me into the D ecosystem. I can run my D code from any language with a C FFI. I could collaborate with someone and they don't have to know anything about D to run my code. Why did I pick it over Rust? Because it has a GC, I didn't have to read a dissertation on memory management to get started. I don't want to care about memory management. I also thought the syntax was an atrocity. Things may have changed in recent years, because I haven't been watching Rust. Why did I pick it over Go? I found Go to be extremely restricted, by design, along pretty much every dimension. That might work well for a large enterprise, but it's not something I wanted. D is about the exact opposite in that regard. Why did I pick it over C++? Because C++ is C++. Having written all this, I don't think there are any arguments that will get you very far. There are lots of languages that can do the job. It's hard to make a case for language A over language B in 2020. It's not 2005 where Rails made it obvious that you should have been using Ruby or 1998 where Java could replace C++ in places no other language could do the job.
Feb 04
prev sibling next sibling parent Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Tuesday, 4 February 2020 at 19:57:53 UTC, RaycatWhoDat wrote:
 Hi.
[...]
 I really enjoyed the productivity I felt when writing it. 
 Specifically, I liked the way it felt to write and refactor and 
 optimize. I'm big on what the semantics and syntax of a 
 language feels like.
D is the one-stop shop for all your programming needs. From build scripts to quick prototypes to profiled systems. From compile time generated parsers via web servers to high performance computing. I am confident that whatever problem I am professionally confronted with in the future, it’ll be solvable with D. Bastiaan.
Feb 04
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 2/4/2020 11:57 AM, RaycatWhoDat wrote:
 Hi.
 
 Disclaimer: This thread isn't specifically a "this vs. that" thread but more
of 
 a "help me articulate reasons" post.
 
 For the last three or so years, I've been on a bit of a journey to find two or 
 three languages that I can really dive into and specialize in. I came upon D
by 
 accident about a year or so ago and I really enjoyed the productivity I felt 
 when writing it. Specifically, I liked the way it felt to write and refactor
and 
 optimize. I'm big on what the semantics and syntax of a language feels like. 
 This is where the problem starts.
 
 I can tell people how I feel writing the language but I can't give them exact 
 reasons as to why they'd pick D over alternatives like Rust. I was hoping I 
 could get some opinions from the people here and maybe you guys can help me 
 solidify some of my own understandings.
 
 Thanks in advance.
It's simply easier to write code in D. Working with the borrow checker often means refactoring the algorithms and data structures, which takes time and effort. On the other hand, you can port borrow-correct code to D without changing algorithms and data structures. In fact, I recommend learning how to write borrow-correct code, and using such as a matter of course. But D won't make you do it.
Feb 04
next sibling parent reply RaycatWhoDat <rmperry09 gmail.com> writes:
On Wednesday, 5 February 2020 at 05:32:42 UTC, Walter Bright 
wrote:
 On the other hand, you can port borrow-correct code to D 
 without changing algorithms and data structures. In fact, I 
 recommend learning how to write borrow-correct code, and using 
 such as a matter of course. But D won't make you do it.
Thank you all for chiming in on that. You've given me a solid direction on how to both address conversations of that nature and how to not worry about FOMO between programming languages (which I fear is the real crux of the problem). I will look into borrow-correct code as you mentioned, Walter, and continue to work with D because it's a joy to write. Cheers.
Feb 05
parent reply IGotD- <nise nise.com> writes:
On Wednesday, 5 February 2020 at 16:29:15 UTC, RaycatWhoDat wrote:
 On Wednesday, 5 February 2020 at 05:32:42 UTC, Walter Bright 
 wrote:

 Thank you all for chiming in on that.

 You've given me a solid direction on how to both address 
 conversations of that nature and how to not worry about FOMO 
 between programming languages (which I fear is the real crux of 
 the problem). I will look into borrow-correct code as you 
 mentioned, Walter, and continue to work with D because it's a 
 joy to write.

 Cheers.
Borrow correct code isn't that hard to learn. It's when you need multiple mutable references and interior mutability hell starts to break loose in Rust. This is also why I think the memory model of Rust is the wrong way to go. D has a more liberal memory model which suits people accustomed to C++ better. I hope that D isn't going to adopt any more of these memory model features from Rust. I'm not sure how much the live feature will be used in D, maybe it will just gather dust, we will see. BTW, I'm not sure if you have noticed, Firefox has become quite buggy lately. Can't say if it is the fault of Rust though. Chromium based browsers seem to work well in those situations Firefox behaves badly. I've read somewhere in a Rust forum "if it compiles it works" which is a hilarious comment.
Feb 05
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Wed, Feb 05, 2020 at 08:17:46PM +0000, IGotD- via Digitalmars-d wrote:
[...]
 BTW, I'm not sure if you have noticed, Firefox has become quite buggy
 lately. Can't say if it is the fault of Rust though. Chromium based
 browsers seem to work well in those situations Firefox behaves badly.
[...] What kind of bugs, though? If it's not memory-related bugs I'm highly skeptical it has any connection with the language of choice. T -- He who does not appreciate the beauty of language is not worthy to bemoan its flaws.
Feb 05
parent reply IGotD- <nise nise.com> writes:
On Wednesday, 5 February 2020 at 20:51:39 UTC, H. S. Teoh wrote:
 On Wed, Feb 05, 2020 at 08:17:46PM +0000, IGotD- via 
 Digitalmars-d wrote: [...]
 BTW, I'm not sure if you have noticed, Firefox has become 
 quite buggy lately. Can't say if it is the fault of Rust 
 though. Chromium based browsers seem to work well in those 
 situations Firefox behaves badly.
[...] What kind of bugs, though? If it's not memory-related bugs I'm highly skeptical it has any connection with the language of choice. T
Behavioral bugs like page not rendered correctly, sometimes tab is completely blank. I just wanted to connect to how some people think that Rust we lead to bug free programs which is a fantasy.
Feb 05
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Wed, Feb 05, 2020 at 08:55:34PM +0000, IGotD- via Digitalmars-d wrote:
 On Wednesday, 5 February 2020 at 20:51:39 UTC, H. S. Teoh wrote:
 On Wed, Feb 05, 2020 at 08:17:46PM +0000, IGotD- via Digitalmars-d
 wrote: [...]
 BTW, I'm not sure if you have noticed, Firefox has become quite
 buggy lately.
[...] What kind of bugs, though? If it's not memory-related bugs I'm highly skeptical it has any connection with the language of choice.
[...]
 Behavioral bugs like page not rendered correctly, sometimes tab is
 completely blank. I just wanted to connect to how some people think
 that Rust we lead to bug free programs which is a fantasy.
Logic bugs have nothing to do with language. You can write wrong programs in any language! :-P (Well, maybe except that esolang where there's a directive called "do what I mean, not what I say". That might be the only exception to this.) T -- There are three kinds of people in the world: those who can count, and those who can't.
Feb 05
parent bauss <jj_1337 live.dk> writes:
On Wednesday, 5 February 2020 at 21:20:51 UTC, H. S. Teoh wrote:
 On Wed, Feb 05, 2020 at 08:55:34PM +0000, IGotD- via 
 Digitalmars-d wrote:
 On Wednesday, 5 February 2020 at 20:51:39 UTC, H. S. Teoh 
 wrote:
 On Wed, Feb 05, 2020 at 08:17:46PM +0000, IGotD- via 
 Digitalmars-d wrote: [...]
 BTW, I'm not sure if you have noticed, Firefox has become 
 quite buggy lately.
[...] What kind of bugs, though? If it's not memory-related bugs I'm highly skeptical it has any connection with the language of choice.
[...]
 Behavioral bugs like page not rendered correctly, sometimes 
 tab is completely blank. I just wanted to connect to how some 
 people think that Rust we lead to bug free programs which is a 
 fantasy.
Logic bugs have nothing to do with language. You can write wrong programs in any language! :-P (Well, maybe except that esolang where there's a directive called "do what I mean, not what I say". That might be the only exception to this.) T
Those bugs could be memory bugs tho since it has to do with rendering so it could easily have to do with missing allocations and/or freeing of memory that shouldn't happen.
Feb 05
prev sibling parent Arine <arine123445128843 gmail.com> writes:
On Wednesday, 5 February 2020 at 05:32:42 UTC, Walter Bright 
wrote:
 On the other hand, you can port borrow-correct code to D 
 without changing algorithms and data structures. In fact, I 
 recommend learning how to write borrow-correct code, and using 
 such as a matter of course. But D won't make you do it.
That'd be like saying, why use safe, you can port all safe code to system and it'll be easier to write. Just learn how to write safe code without safe. The user can't be trusted to write correct safe code, that's why the compiler has to be able to check it. If you are using the GC, then there's no point to writing borrow-correct code. You are just wasting your time. The whole purpose of borrow-correct code is to not use a GC. A GC solves the same problems, it just has it's own downsides. It does take time and effort, but the result is usually better performance and safety. https://blog.discordapp.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f That's not the only company that's switched to rust that has seen it's benefits either.
Feb 05
prev sibling parent German Diago <germandiago gmail.com> writes:
On Tuesday, 4 February 2020 at 19:57:53 UTC, RaycatWhoDat wrote:
 Hi.

 Disclaimer: This thread isn't specifically a "this vs. that" 
 thread but more of a "help me articulate reasons" post.

 For the last three or so years, I've been on a bit of a journey 
 to find two or three languages that I can really dive into and 
 specialize in. I came upon D by accident about a year or so ago 
 and I really enjoyed the productivity I felt when writing it. 
 Specifically, I liked the way it felt to write and refactor and 
 optimize. I'm big on what the semantics and syntax of a 
 language feels like. This is where the problem starts.

 I can tell people how I feel writing the language but I can't 
 give them exact reasons as to why they'd pick D over 
 alternatives like Rust. I was hoping I could get some opinions 
 from the people here and maybe you guys can help me solidify 
 some of my own understandings.

 Thanks in advance.
The practical reasons (compared to other new languages): - Ease of use: You can write code in an almost-python way - Yet you can scale and tweak parts when needed - The ecosystem is more mature than alternatives like Nim and Rust - C/C++ interfacing is easy: use whatever libs you need in that area. The social reasons: - It is easier to mix with C++ than most alternatives than Rust or Nim. I was excited about Rust until I saw that the borrow checker can get a lot in the way. About Nim, it is super nice, yes, but I think they took the flexibility maybe too far, but that is not the problem actually. I think the main problem I detect is how weird and non-standard its OOP is. At the end, having interfaces, classes and structs is classes. C++ has them (poly and non-polymorphic depending on virtual functions). Kotlin has them, Swift has them. Later you look at Nim and Rust and you waste part of your time relearning all these things in their native language. But you (override style, etc.) at the end they are similar enough so that you get an idea of what you have to do and will focus on writing code and libraries, not on learning the tool.
Feb 06