Jump to page: 1 2
Thread overview
Verbosity in D
Aug 07, 2022
pascal111
Aug 07, 2022
jfondren
Aug 07, 2022
pascal111
Aug 07, 2022
Emanuele Torre
Aug 07, 2022
pascal111
Aug 07, 2022
Emanuele Torre
Aug 07, 2022
Emanuele Torre
Aug 08, 2022
pascal111
Aug 08, 2022
Emanuele Torre
Aug 07, 2022
Emanuele Torre
Aug 08, 2022
pascal111
Aug 08, 2022
Emanuele Torre
Aug 08, 2022
pascal111
Aug 08, 2022
TTK Ciar
Aug 08, 2022
Dom Disc
Aug 08, 2022
bauss
Aug 08, 2022
Siemargl
August 07, 2022

It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean verbosity from D?

Quote: "In terms of functionality, Pascal is pretty much exactly the same as C, except with some sanity-conserving restrictions on one hand, and more verbose syntax on the other. It was an okay language for the time when it was popular, and I would give it kudos just for having the common sense to make the assignment operator := instead of =, and not allowing it to be chained, but verbosity back then was still something to be avoided if possible, so C was naturally seen as superior."

https://www.quora.com/Is-there-a-value-learning-Pascal-now-Are-there-actually-any-parts-where-Pascal-is-better-than-C-Is-this-language-worth-investing-time-into-What-would-the-added-value-be-if-I-learn-it

August 07, 2022

On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote:

>

It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean verbosity from D?

That's not clear to me at all, and your Pascal example about a feature that C and D both have, that doesn't help either. Post some code that seems particularly verbose to you. I think 'library code' tends to grow attributes like mushrooms, and that D gets longer when you try to avoid the GC, but casual use of D isn't more verbose than scripting languages. With competitors like Rust and C++ Go and and Zig, D usually wins pretty significantly in this respect. The only consistently less verbose language in this space is Nim, IMO.

With that said, dmd previews =in and =shortenedMethods both allow shorter expressions in D. And there are some C++ (and even C) convenience features that D doesn't have, like destructuring binds, or doesn't like, like anonymous struct literals with named fields.

August 07, 2022

On Sunday, 7 August 2022 at 16:45:15 UTC, jfondren wrote:

>

On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote:

>

It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean verbosity from D?

That's not clear to me at all, and your Pascal example about a feature that C and D both have, that doesn't help either. Post some code that seems particularly verbose to you. I think 'library code' tends to grow attributes like mushrooms, and that D gets longer when you try to avoid the GC, but casual use of D isn't more verbose than scripting languages. With competitors like Rust and C++ Go and and Zig, D usually wins pretty significantly in this respect. The only consistently less verbose language in this space is Nim, IMO.

Do consider Go and Rust languages in the same level of C++ to make this comparison? I didn't use these languages before but I think they are just new languages which has no real history like C++ to compare with!!!

>

With that said, dmd previews =in and =shortenedMethods both allow shorter expressions in D. And there are some C++ (and even C) convenience features that D doesn't have, like destructuring binds, or doesn't like, like anonymous struct literals with named fields.

What destructuring binds? I didn't hear about that before.

August 07, 2022

On Sunday, 7 August 2022 at 20:15:05 UTC, pascal111 wrote:

>

What destructuring binds? I didn't hear about that before.

#include <iostream>

struct Point {
    int x, y;
};

Point add_points(const Point& a, const Point& b)
{
    return { a.x + b.x, a.y + b.y };
}

int main()
{
    const auto [x, y] = add_points({ 1, 10 }, { -60, 40 });
    std::cout << "x is: " << x << '\n';
    std::cout << "y is: " << y << '\n';
}
August 07, 2022

On Sunday, 7 August 2022 at 22:16:55 UTC, Emanuele Torre wrote:

>

On Sunday, 7 August 2022 at 20:15:05 UTC, pascal111 wrote:

>

What destructuring binds? I didn't hear about that before.

#include <iostream>

struct Point {
    int x, y;
};

Point add_points(const Point& a, const Point& b)
{
    return { a.x + b.x, a.y + b.y };
}

int main()
{
    const auto [x, y] = add_points({ 1, 10 }, { -60, 40 });
    std::cout << "x is: " << x << '\n';
    std::cout << "y is: " << y << '\n';
}

It seems complex, I didn't get it yet, I wished I didn't ask about it :)

August 07, 2022

On Sunday, 7 August 2022 at 23:31:45 UTC, pascal111 wrote:

>

On Sunday, 7 August 2022 at 22:16:55 UTC, Emanuele Torre wrote:

>

On Sunday, 7 August 2022 at 20:15:05 UTC, pascal111 wrote:

>

What destructuring binds? I didn't hear about that before.

#include <iostream>

struct Point {
    int x, y;
};

Point add_points(const Point& a, const Point& b)
{
    return { a.x + b.x, a.y + b.y };
}

int main()
{
    const auto [x, y] = add_points({ 1, 10 }, { -60, 40 });
    std::cout << "x is: " << x << '\n';
    std::cout << "y is: " << y << '\n';
}

It seems complex, I didn't get it yet, I wished I didn't ask about it :)

It's really trivial.
auto [x, y] = getpoint(); is equivalent to

auto _p = getpoint();
auto x = _p.x /* first element of the struct */;
auto y = _p.y /* second element of the struct */;`

Also works with arrays.

int[] arr = { 10, 12, 14 };
const auto [x, y, z] = arr;
/* x=10 y=12 z=14 */

A lot of programming languages have this.

August 07, 2022

On Sunday, 7 August 2022 at 23:44:26 UTC, Emanuele Torre wrote:

>

int[] arr = { 10, 12, 14 };

Oops, this is C++, not D: int arr[] = { 10, 12, 14 }; =)

August 07, 2022
On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote:
> It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean verbosity from D?
>
> Quote: "In terms of functionality, Pascal is pretty much exactly the same as C, except with some sanity-conserving restrictions on one hand, and more verbose syntax on the other. It was an okay language for the time when it was popular, and I would give it kudos just for having the common sense to make the assignment operator := instead of =, and not allowing it to be chained, but verbosity back then was still something to be avoided if possible, so C was naturally seen as superior."
>
> https://www.quora.com/Is-there-a-value-learning-Pascal-now-Are-there-actually-any-parts-where-Pascal-is-better-than-C-Is-this-language-worth-investing-time-into-What-would-the-added-value-be-if-I-learn-it

Regaring this, I don't understand what you mean either.
How is D unnecesarily verbose?
Do you have any specific example?
August 08, 2022
On Sunday, 7 August 2022 at 23:53:36 UTC, Emanuele Torre wrote:
> On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote:
>> It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean verbosity from D?
>>
>> Quote: "In terms of functionality, Pascal is pretty much exactly the same as C, except with some sanity-conserving restrictions on one hand, and more verbose syntax on the other. It was an okay language for the time when it was popular, and I would give it kudos just for having the common sense to make the assignment operator := instead of =, and not allowing it to be chained, but verbosity back then was still something to be avoided if possible, so C was naturally seen as superior."
>>
>> https://www.quora.com/Is-there-a-value-learning-Pascal-now-Are-there-actually-any-parts-where-Pascal-is-better-than-C-Is-this-language-worth-investing-time-into-What-would-the-added-value-be-if-I-learn-it
>
> Regaring this, I don't understand what you mean either.
> How is D unnecesarily verbose?
> Do you have any specific example?

I don't have specific code but it was a general notice. Take Python as in example, the same program in Python doesn't cost much code as D code, and of course by putting in accounts that that I assume that there are some special tasks D can do, while Python can't do.
August 08, 2022

On Sunday, 7 August 2022 at 23:44:26 UTC, Emanuele Torre wrote:

>

On Sunday, 7 August 2022 at 23:31:45 UTC, pascal111 wrote:

>

On Sunday, 7 August 2022 at 22:16:55 UTC, Emanuele Torre wrote:

>

[...]

It seems complex, I didn't get it yet, I wished I didn't ask about it :)

It's really trivial.
auto [x, y] = getpoint(); is equivalent to

auto _p = getpoint();
auto x = _p.x /* first element of the struct */;
auto y = _p.y /* second element of the struct */;`

Also works with arrays.

int[] arr = { 10, 12, 14 };
const auto [x, y, z] = arr;
/* x=10 y=12 z=14 */

A lot of programming languages have this.

Really, I'm not sure I'm understanding this syntax auto [x, y] = getpoint();, if you have the name of term of it in D or an explaining link.

« First   ‹ Prev
1 2