Jump to page: 1 2 3
Thread overview
D code length vs other languages
Dec 05, 2019
Walter Bright
Dec 05, 2019
Adam D. Ruppe
Dec 06, 2019
Paolo Invernizzi
Dec 06, 2019
Craig Dillabaugh
Dec 06, 2019
Jonathan Marler
Dec 06, 2019
Paolo Invernizzi
Dec 07, 2019
Jesse Phillips
Dec 10, 2019
Jesse Phillips
Dec 10, 2019
norm
Dec 10, 2019
Jesse Phillips
Dec 07, 2019
Tobias Pankrath
Dec 07, 2019
mipri
Dec 07, 2019
Tobias Pankrath
Dec 07, 2019
Paul Backus
Dec 11, 2019
German Diago
Dec 06, 2019
Jab
Dec 06, 2019
Gregor Mückl
December 05, 2019
https://danuker.go.ro/programming-languages.html

I'm unsure of the accuracy of the methodology of determining this, but D does fairly well in it. It wasn't designed to be a particularly terse language, and personally I find that excessive terseness makes for a hard-to-understand language as well as making typos more likely to produce buggy programs.

(Taken to its logical extreme, for a language with no redundancy, any random sequence of bytes would be a valid program. It would be impossible for a compiler to diagnose any errors.)

D being about a third less code than C++ is consistent with my unscientific experience with it.

I'm a little surprised that D is significantly more compact than Rust.
December 05, 2019
On Thursday, 5 December 2019 at 22:21:13 UTC, Walter Bright wrote:
> D being about a third less code than C++ is consistent with my unscientific experience with it.

Indeed, I actually frequently do even less. A lot of repetition in other languages I find myself able to automate pretty well in D. Whole blocks of 1,000 lines of glue code in other languages can be replaced with 30 lines of CT reflection stuff.
December 06, 2019
On Thursday, 5 December 2019 at 22:21:13 UTC, Walter Bright wrote:
> https://danuker.go.ro/programming-languages.html
>
> I'm unsure of the accuracy of the methodology of determining this, but D does fairly well in it.

It is probably better to look at the examples on the Rosetta website. Seems to me that some try to be terse, yet others try to show off language features. So, for the same language you have sometimes very verbose low level and very terse high level solutions (some are clearly cheating).

December 06, 2019
On Friday, 6 December 2019 at 00:26:14 UTC, Ola Fosheim Grøstad wrote:
> On Thursday, 5 December 2019 at 22:21:13 UTC, Walter Bright wrote:
>> https://danuker.go.ro/programming-languages.html
>>
>> I'm unsure of the accuracy of the methodology of determining this, but D does fairly well in it.
>
> It is probably better to look at the examples on the Rosetta website. Seems to me that some try to be terse, yet others try to show off language features. So, for the same language you have sometimes very verbose low level and very terse high level solutions (some are clearly cheating).

They also use different (non-standard) libraries, which really depends on what they implement and what kind of interface they provide. Some of the C++ code examples have variables defined at the start in old C-style. With multiple variables just being declared on 7+ more lines. The examples weren't intended to be used a means to measure number of lines of code. Even on the page it points out that comments weren't taken into consideration. This data is extremely unreliable and should be taken with a huge grain of salt.
December 06, 2019
On Thursday, 5 December 2019 at 22:28:53 UTC, Adam D. Ruppe wrote:
> On Thursday, 5 December 2019 at 22:21:13 UTC, Walter Bright wrote:
>> D being about a third less code than C++ is consistent with my unscientific experience with it.
>
> Indeed, I actually frequently do even less. A lot of repetition in other languages I find myself able to automate pretty well in D. Whole blocks of 1,000 lines of glue code in other languages can be replaced with 30 lines of CT reflection stuff.

Yesterday happened to me to translate a modest size python script into D, to incorporate it in a product, and it was a pleasant experience.

The port was really really easy ... but I'm starting to miss list comprehension ...

Anyway, point taken!
December 06, 2019
On Friday, 6 December 2019 at 05:44:31 UTC, Jab wrote:
> provide. Some of the C++ code examples have variables defined at the start in old C-style. With multiple variables just being declared on 7+ more lines. The examples weren't intended to be used a means to measure number of lines of code.

Yes, I think there are too many tasks in Rosetta as well. Many of the code examples states that it is translated from the C example.

That clearly makes a lot of the code "unnatural" for any given language. Probably the D code too.

C++ is more verbose than D. In part because the C++ std lib requires more syntax and also because C++ code often use explicit namespaces. C++ is gradually getting less verbose by newer features like for-each, lambdas and constexpr.

December 06, 2019
On Friday, 6 December 2019 at 09:58:28 UTC, Ola Fosheim Grøstad wrote:
> C++ is more verbose than D. In part because the C++ std lib requires more syntax and also because C++ code often use explicit namespaces. C++ is gradually getting less verbose by newer features like for-each, lambdas and constexpr.

Also, the need for headers. That alone can add considerably to a codebase.
December 06, 2019
On Friday, 6 December 2019 at 10:16:59 UTC, Gregor Mückl wrote:
> Also, the need for headers. That alone can add considerably to a codebase.

True, you that you have to specify the signature of all class members that is implemented in a .cpp file. So you often have to write a lot of code twice, once for the .hpp file and once for the .cpp file.

Kinda made sense before C++ added templates as the .hpp file was slim and easy to read, now it is quite the opposite.

December 06, 2019
On Friday, 6 December 2019 at 08:47:59 UTC, Paolo Invernizzi wrote:
> On Thursday, 5 December 2019 at 22:28:53 UTC, Adam D. Ruppe
clip
>
> Yesterday happened to me to translate a modest size python script into D, to incorporate it in a product, and it was a pleasant experience.
>
> The port was really really easy ... but I'm starting to miss list comprehension ...
>
> Anyway, point taken!

Wouldn't it be fairly easy to write some sort simple library that gives you list comprehensions in D.  It wouldn't be a nice as the python syntax, but it should be doable no?
December 06, 2019
On Friday, 6 December 2019 at 18:25:20 UTC, Craig Dillabaugh wrote:
> On Friday, 6 December 2019 at 08:47:59 UTC, Paolo Invernizzi wrote:
>> On Thursday, 5 December 2019 at 22:28:53 UTC, Adam D. Ruppe
> clip
>>
>> Yesterday happened to me to translate a modest size python script into D, to incorporate it in a product, and it was a pleasant experience.
>>
>> The port was really really easy ... but I'm starting to miss list comprehension ...
>>
>> Anyway, point taken!
>
> Wouldn't it be fairly easy to write some sort simple library that gives you list comprehensions in D.  It wouldn't be a nice as the python syntax, but it should be doable no?

You could do that, or you could use a UFCS chain as well.  More flexible than list comprehensions.
« First   ‹ Prev
1 2 3