Jump to page: 1 210  
Page
Thread overview
What are (were) the most difficult parts of D?
May 11, 2022
Ali Çehreli
May 11, 2022
bauss
May 11, 2022
jmh530
May 11, 2022
matheus
May 11, 2022
H. S. Teoh
May 11, 2022
Tejas
May 11, 2022
Paul Backus
May 11, 2022
H. S. Teoh
May 11, 2022
templatedperson
May 11, 2022
Ali Çehreli
May 11, 2022
Guillaume Piolat
May 12, 2022
H. S. Teoh
May 12, 2022
Guillaume Piolat
May 13, 2022
H. S. Teoh
May 13, 2022
Adam D Ruppe
May 13, 2022
H. S. Teoh
May 13, 2022
Christopher Katko
May 13, 2022
max haughton
May 14, 2022
zjh
May 14, 2022
zjh
May 14, 2022
Ali Çehreli
May 14, 2022
zjh
May 14, 2022
zjh
May 14, 2022
H. S. Teoh
May 14, 2022
zjh
May 14, 2022
frame
May 14, 2022
zjh
May 14, 2022
Guillaume Piolat
May 11, 2022
Ali Çehreli
May 12, 2022
Christopher Katko
May 12, 2022
Adam D Ruppe
May 12, 2022
Ali Çehreli
May 12, 2022
H. S. Teoh
May 12, 2022
Paul Backus
May 12, 2022
Ali Çehreli
May 12, 2022
Chris Katko
May 13, 2022
zjh
May 12, 2022
H. S. Teoh
May 12, 2022
zjh
May 12, 2022
zjh
May 12, 2022
zjh
May 12, 2022
Ali Çehreli
May 12, 2022
Siemargl
May 12, 2022
Basile B.
May 12, 2022
Alain De Vos
May 12, 2022
Basile B.
May 12, 2022
Basile B.
May 12, 2022
jmh530
May 12, 2022
Tejas
May 12, 2022
Basile B.
May 12, 2022
Adam D Ruppe
May 12, 2022
jmh530
May 12, 2022
H. S. Teoh
May 12, 2022
Arjan
May 12, 2022
Basile B.
May 12, 2022
Guillaume Piolat
May 12, 2022
Ali Çehreli
May 12, 2022
Guillaume Piolat
May 12, 2022
Anonymouse
May 12, 2022
Adam D Ruppe
May 12, 2022
Anonymouse
May 12, 2022
H. S. Teoh
May 12, 2022
Anonymouse
May 13, 2022
Salih Dincer
May 14, 2022
eugene
May 14, 2022
rikki cattermole
May 14, 2022
eugene
May 14, 2022
rikki cattermole
May 14, 2022
eugene
May 16, 2022
cc
May 16, 2022
H. S. Teoh
May 17, 2022
cc
May 17, 2022
zjh
May 17, 2022
zjh
May 17, 2022
bauss
May 21, 2022
eugene
May 21, 2022
eugene
May 17, 2022
Dom Disc
May 21, 2022
Johan
May 21, 2022
max haughton
May 16, 2022
max haughton
May 22, 2022
Chris Piker
May 22, 2022
rikki cattermole
May 22, 2022
Chris Piker
May 22, 2022
rikki cattermole
May 22, 2022
Chris Piker
May 22, 2022
rikki cattermole
May 22, 2022
Chris Piker
May 22, 2022
rikki cattermole
May 22, 2022
max haughton
May 10, 2022
What are you stuck at? What was the most difficult features to understand? etc.

To make it more meaningful, what is your experience with other languages?

Ali
May 11, 2022
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:
> What are you stuck at? What was the most difficult features to understand? etc.
>
> To make it more meaningful, what is your experience with other languages?
>
> Ali

dip1000
May 11, 2022
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:
> What are you stuck at? What was the most difficult features to understand? etc.
>
> To make it more meaningful, what is your experience with other languages?
>
> Ali

I don't know if this will be helpful but here it goes, my user case is different since I use D as C on steroids.

My first language was C and I have projects in this language which I still maintain and my brain is used to it, but depending the project I'll use D instead of C to use features like: GC, AA, Strings, Modules and maybe Classes if I feel like it, but I don't go to far from these and one reason is sometimes in a rich language with lots of features like D It gets hard to stay up to date.

Now I know they must be useful to many others, but one thing that I don't like are the Attributes part, for me there are so many and this is a bit overwhelming (Again to me), for example need to think about: "@safe, @trusted, @system" while still prototyping may be a cumbersome, and if it's giving me trouble I'll just get rid of it. :)

Again I should sit and read the documentation or your book again but it's hard to keep up-to-date sometimes with work and so on.

By the way I used to program in C# at work too, but I stopped on whatever was the version that runs with .Net 4.6, again this is another case of language changing or adding so many features that I decided not to go on with it, since it's not required where I work (Occasionally I write a few batch programs here and there), and I'm current doing more database business at the company these days,

Sorry for any English mistakes,

Matheus.
May 11, 2022
On Wed, May 11, 2022 at 01:37:21PM +0000, matheus via Digitalmars-d-learn wrote:
> On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:
> > What are you stuck at? What was the most difficult features to understand? etc.
> > 
> > To make it more meaningful, what is your experience with other languages?
[...]
> Now I know they must be useful to many others, but one thing that I don't like are the Attributes part, for me there are so many and this is a bit overwhelming (Again to me), for example need to think about: "@safe, @trusted, @system" while still prototyping may be a cumbersome, and if it's giving me trouble I'll just get rid of it. :)
[...]

My suggestion is: when prototyping, don't even think about attributes. Just templatize your functions and let the compiler infer the attributes for you.

I myself rarely bother with attributes; I only write them when I want to be 100% sure that a particular piece of code has that attribute. Otherwise I just templatize it and let the compiler figure it out for me.  Auto-inference is the way to go; life is too short to be fiddling with attributes in every single declaration manually.


T

-- 
People walk. Computers run.
May 11, 2022

On Wednesday, 11 May 2022 at 14:20:07 UTC, H. S. Teoh wrote:

>

On Wed, May 11, 2022 at 01:37:21PM +0000, matheus via Digitalmars-d-learn wrote:

> >

[...]
[...]
[...]
[...]

My suggestion is: when prototyping, don't even think about attributes. Just templatize your functions and let the compiler infer the attributes for you.

I myself rarely bother with attributes; I only write them when I want to be 100% sure that a particular piece of code has that attribute. Otherwise I just templatize it and let the compiler figure it out for me. Auto-inference is the way to go; life is too short to be fiddling with attributes in every single declaration manually.

T

That'll be true the day when @safe becomes the default... Until then, I'll atleast do @safe: on top of every module :)

May 11, 2022

On Wednesday, 11 May 2022 at 15:10:28 UTC, Tejas wrote:

>

That'll be true the day when @safe becomes the default... Until then, I'll atleast do @safe: on top of every module :)

@safe: is actually a bad idea if you're writing templated code, because it turns inference of @system into a compile-time error:

@safe:

auto map(alias fun, T)(T[] arr)
{
    auto result = arr.dup;
    foreach (ref e; result) e = fun(e);
    return result;
}

int safeDouble(int n) @safe { return 2*n; }
int systemDouble(int n) @system { return 2*n; }

void main() @system
{
    int[] a = [1, 2, 3];
    // ok
    auto b = a.map!safeDouble;
    // Error: `@safe` function `map!systemDouble` cannot call `@system` function `systemDouble`
    auto c = a.map!systemDouble;
}

Without @safe: at the top, map!systemDouble would have been inferred as @system, and calling it from a @system main function would have been allowed.

May 11, 2022
On Wed, May 11, 2022 at 03:34:12PM +0000, Paul Backus via Digitalmars-d-learn wrote:
> On Wednesday, 11 May 2022 at 15:10:28 UTC, Tejas wrote:
> > That'll be true the day when `@safe` becomes the default... Until then, I'll atleast do `@safe:` on top of every module :)
> 
> `@safe:` is actually a bad idea if you're writing templated code, because it turns inference of `@system` into a compile-time error:

Yeah, for templated code, what you want is a @safe unittest that ensures that the code is @safe when whatever you instantiate it with is @safe:

	auto myTemplateFunc(Args...)(Args args)
		/* N.B.: no attributes */
	{
		return ...;
	}

	@safe unittest {
		// This ensures that myTemplateFunc is callable from
		// @safe when instantiated with @safe arguments.
		auto result = myTemplateFunc(... /* @safe arguments */);
	}

This way, it's possible to instantiate myTemplateFunc with @system arguments (you get a @system instantiation).


T

-- 
Life is unfair. Ask too much from it, and it may decide you don't deserve what you have now either.
May 11, 2022
On Wednesday, 11 May 2022 at 09:06:52 UTC, bauss wrote:
> On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:
>> What are you stuck at? What was the most difficult features to understand? etc.
>>
>> To make it more meaningful, what is your experience with other languages?
>>
>> Ali
>
> dip1000

Ha, I just mentioned this on another thread...
https://dlang.org/spec/function.html#ref-return-scope-parameters
May 11, 2022

On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:

>

What are you stuck at? What was the most difficult features to understand? etc.

No singular feature, but the overall cognitive load if you use the language sporadic. Which could be most users that don't use it for work or have it as their main hobby.

As with all languages, cognitive load increases when things do not work as one would intuitively expect or if a feature is incomplete in some specific case. D has some of the same issues as C++, you either deal with details or you can choose to go more minimalistic in your usage.

If you read other people's D code you can easily (IMO) see that there is no unified style or usage of features, so it seems like people stick to their own understanding of «good code», which can make it tiresome to read D code by others (e.g. standard library). I guess some good coherent educational material is missing, people are finding their own way. There are no obvious codebases that highlight «best practice». I suspect meta-programming is pushed too much and that this has a negative effect on legibility of code bases.

You basically increase the cognitive load further if you choose to be slightly different from other languages, and focus on special cases. Examples: the proposal for interpolated strings, dip1000, certain aspects of D's generics syntax etc.

When you already have high cognitive load you should be very careful about not adding more "slightly unusual/unexpected" semantics/syntax.

>

To make it more meaningful, what is your experience with other languages?

I believe what makes Python a favoured language by many is that you can use it sporadically without relearning. Spending less time reading documentation is always a win.

To do things right in C++ you have to look things up all the time, this is only ok for people who use it many hours every week.

In general I think the ergonomics would be much better if the historical baggage from C/C++ had been pushed aside in favour of a more intuitive clean approach. I am not sure if many new users have a good understanding of C/C++ anyway.

Of course, this perspective is highly irrelevant as it is clear now that the current direction of language evolution is to continue to absorb C and not really be provide a clean improvement over C, but more like an extension. (More like C++ and Objective-C than Rust).

I think it will be difficult to attract young programmers with this approach as they are less likely to be comfortable with the peculiarities of C.

May 11, 2022

On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:

>

What are you stuck at? What was the most difficult features to understand? etc.

I don't know if this counts as a feature, but reading the standard library documentation was especially difficult. There are a ton of autos everywhere and function signatures are hard to read because of that. I got used to confusing function signatures in a week or two, but it made me consider not using D.

>

To make it more meaningful, what is your experience with other languages?

Rust does a better job at this. Generics are strongly-typed with traits. In D, we have to type-check structs ourselves by adding if (is(T == SomeType)) etc. after the function declaration. In Rust, you can create a trait and use that as the parameter type in a function.

In D we can have this with interfaces when we're using classes but we can't have this for structs. Actually, I'd appreciate if we could get static interfaces or something, so that people won't need to type-check manually.

« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10