Re: Verbosity in D

2022-08-08 Thread bauss via Digitalmars-d-learn

On Monday, 8 August 2022 at 00:11:33 UTC, pascal111 wrote:


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.


Yeah I don't think this is true. The only clear difference 
between D and Python is the vast amount of libraries that Python 
has and that D is a static-typed language, Python is not (by 
default)


You generally don't write much more code.

Loops, ranges etc. are all just as pleasant to work with in D as 
they are in Python.


I'd argue it's even easier to work with classes in D than in 
Python, and even easier to work with metadata in D than any other 
language.


Python has an unnecessary amount of verbosity when it comes to 
OOP (because it really isn't an OOP language.)


I think D only looks verbose to people who don't really 
understand its metaprogramming capabilities, templates and/or are 
new to the language and perhaps come from dynamic typed languages.


But I don't think D is in particular more verbose than Python, 
you can write very similar expressions and some code are almost 
1:1 in Python and D when you only consider syntax.


Re: Verbosity in D

2022-08-07 Thread Siemargl via Digitalmars-d-learn

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?



In most cases this is a false statement.
Just see examples on frontpage of dlang site.

Or try write and compare concrete programs.

Python have a good expressiveness, but up to 100 times slower.


Re: Verbosity in D

2022-08-07 Thread Dom Disc via Digitalmars-d-learn

On Monday, 8 August 2022 at 00:40:11 UTC, TTK Ciar wrote:
On the other hand, I've noticed that D's idiomatic brevity can 
be diluted by the extremely verbose function names used in the 
standard library.


For long function names you can define short aliases, for syntax 
you can't. So having short and efficient language constructs is 
by far more important than short function names.
Especially a standard-library is much better off having 
descriptive and unique names - which sort of requires them to be 
long.


Re: Verbosity in D

2022-08-07 Thread TTK Ciar via Digitalmars-d-learn

On Monday, 8 August 2022 at 00:11:33 UTC, pascal111 wrote:
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.


There is definitely a spectrum of programming language practical 
expressiveness (the opposite of verbosity), with the dynamic 
languages (python, perl, ruby) on the "most expressive" end, and 
static languages (C, C++, Java) on the "most verbose" end.


D is somewhere in the middle of that spectrum, much more 
expressive than C but not as expressive as python.


The trade-off is much better run-time performance and lower 
memory overhead compared to the dynamic languages.


I've been writing C, Perl and Python for a living for a while, 
following the common practice of writing a solution in Perl or 
Python first, for shortest possible development time, and then 
rewriting performance-intensive bits in C when more performance 
is needed.


The appeal of D, to me, is that it gives me something akin to the 
same approach with just one language.  I can write very concise, 
expressive D when performance doesn't matter, and then write more 
verbose C-like D when I need C-like performance, all in the same 
source file, with the same language.


Having a sane and useful threading model is an added bonus.  
Neither python nor perl nor nodejs have useful threads, whereas D 
gives us real, concurrent threads with a fraction of the 
boilerplate -- 
https://tour.dlang.org/tour/en/multithreading/synchronization-sharing


On the other hand, I've noticed that D's idiomatic brevity can be 
diluted by the extremely verbose function names used in the 
standard library.  Sure, foreach loops can be just as concise as 
python's -- foreach(i; arr) -- but then you end up getting carpal 
tunnel syndrome anyway from typing out  
"AllImplicitConversionTargets" or "filterBidirectional" or 
"levenshteinDistanceAndPath".


My impression is that brevity is more important to the language 
developers than it is to the phobos developers.


Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn

On Monday, 8 August 2022 at 00:18:12 UTC, Emanuele Torre wrote:

On Monday, 8 August 2022 at 00:11:33 UTC, pascal111 wrote:

[...]


You are just sounding like a troll now...


"troll" :) I like it!


That makes no sense:

 "I assume that there are some special tasks D can do, while 
Python can't do"

 How?

 "Take Python as in example, the same program in Python doesn't 
cost much code as D code"
 What same program are you talking about? Why did you mention 
python as if you showed me an example I can see?


What am I supposed to say if can't even explain or show an 
example of how D is more verbose?


Maybe I'm wrong, your words sound that Python isn't verbose-less.


Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn

On Monday, 8 August 2022 at 00:15:48 UTC, pascal111 wrote:

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
```C++
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.
```C++
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.


D does not have it. You have already been told that when they 
have been mentioned.
If you want more information about it in C++, you could read 
https://en.cppreference.com/w/cpp/language/structured_binding or, 
for javascript, 
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment.


That was just meant to be a simple example to show what jfondren 
meant with "destructing bindings".


Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn

On Monday, 8 August 2022 at 00:11:33 UTC, pascal111 wrote:

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.


You are just sounding like a troll now...

That makes no sense:

 "I assume that there are some special tasks D can do, while 
Python can't do"

 How?

 "Take Python as in example, the same program in Python doesn't 
cost much code as D code"
 What same program are you talking about? Why did you mention 
python as if you showed me an example I can see?


What am I supposed to say if can't even explain or show an 
example of how D is more verbose?




Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn

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
```C++
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.
```C++
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.


Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn

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.


Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn

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?


Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn

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 };` =)



Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn

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.


```C++
#include 

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
```C++
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.
```C++
int[] arr = { 10, 12, 14 };
const auto [x, y, z] = arr;
/* x=10 y=12 z=14 */
```
A lot of programming languages have this.


Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn

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.


```C++
#include 

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 :)


Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn

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

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


```C++
#include 

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';
}
```


Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn

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.


Re: Verbosity in D

2022-08-07 Thread jfondren via Digitalmars-d-learn

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.


Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
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