October 27, 2022

On Friday, 21 October 2022 at 15:13:44 UTC, Ola Fosheim Grøstad wrote:

>

On Friday, 21 October 2022 at 13:53:28 UTC, Guillaume Piolat wrote:

>

But building and agreeing on abstractions is what define the ecosystem.

One big weakness in C++ and D is that generic definitions cannot be checked without instantiation.

There aren’t many languages that have both, templates and generics; C++/CLI and C++/CX are the only ones I know and I happen to have some experience with them. (In this nomenclature: template = independent copy of the implementation for every distinct instantiation, cf. C++ or D templates, especially class templates with mutable static variables; generic = one implementation, cf. Java or C#, and static variables cannot depend on the argument types.)

D could introduce generics and it would actually profit more from them than e.g. C++ would because D has first-class reference types and almost no user-defined implicit conversions. Templates are not really a replacement for generics. As an example where generics (would) shine and templates fall flat, consider range interfaces. We have (among others) InputRange and BidirectionalRange. A function taking an InputRange!Base parameter should allow for an argument of type BidirectionalRange!Derived (with Derived and Base classes or interfaces). In D, that is not possible because we cannot express the variance of a type parameter; templates are inherently antithetical to that.

Imagine how much more attractive D would be to OO crowd if it had first-class value type boxing, generics with variance and wildcards, and all the other OO stuff modern OO-fist languages offer. Using Java and C#, it feels like D only has the bare minimum to call itself object-oriented. There was some talk (by Átila, IIRC) that having first-class classes and OO in D was a design error. I have no idea whether there is actually a plan to fade those out improve them to be competitive on that front.

October 27, 2022

On Wednesday, 26 October 2022 at 22:09:46 UTC, Ola Fosheim Grøstad wrote:

>

On Wednesday, 26 October 2022 at 21:17:01 UTC, Don Allen wrote:

>

[...]

Turning off the GC is not an option that will work out as there is no period of time that isn't "realtime", but you can keep GC managed objects on a separate thread. That approach only makes sense if you can separate out and shield significant work suitable for GC from the other work that has to be done.

[...]

I don't understand your argument.
Why wouldn't it be possible to make a browser with a GC?

You mean there are no browsers made in SML, OCaml, Eiffel, D, Go, Haskell, Java, C# etc?

October 27, 2022

On Thursday, 27 October 2022 at 17:37:59 UTC, Quirin Schroll wrote:

>

There aren’t many languages that have both, templates and generics; C++/CLI and C++/CX are the only ones I know and I happen to have some experience with them.

I have found that it is to some extent possible to do such type checks of generics with C++ concepts. I've made some attempts for a generic graphics library I've started on, but it gets tedious quite fast. I would imagine you could do some of the same in D in a more ad-hoc matter, but that would be even more tedious.

It basically involves setting up all the constraints and then test them with a single static assert (which involves instantiation, but in the definition file without explicitly using the instance methods).

The C++ concept-feature is helpful in this regard, but not helpful enough to make it pleasant… which basically limits my eagerness to use of it in practice. Still, a move in the right direction.

D has a chance to learn from C++ and create a better concept-feature. Don't replicate it, look at the use cases where C++ concepts become tedious or difficult to get right, then design something better.

>

D could introduce generics and it would actually profit more from them than e.g. C++ would because D has first-class reference types and almost no user-defined implicit conversions.

This is probably true, but you could instead try to find a way to clearly specify and statically check template requirements.

>

Imagine how much more attractive D would be to OO crowd if it had first-class value type boxing, generics with variance and wildcards, and all the other OO stuff modern OO-fist languages offer. Using Java and C#, it feels like D only has the bare minimum to call itself object-oriented.

That is a reasonable angle given the large number of programmers that have experience with Java and C#, but I think D could take a closer look at how templates are done and find out what is missing. When was the last time a feature was added to support generic programming?

>

There was some talk (by Átila, IIRC) that having first-class classes and OO in D was a design error. I have no idea whether there is actually a plan to fade those out improve them to be competitive on that front.

OO is not a mistake, I agree. I find it quite frustrating to not have inheritance when programming in Go. Just basic things like having a linked list node in the super class makes things much simpler/cost-efficient when you are mixing types in data-structures.

October 27, 2022

On Thursday, 27 October 2022 at 18:32:15 UTC, Imperatorn wrote:

>

I don't understand your argument.
Why wouldn't it be possible to make a browser with a GC?

Modern browsers such as Firefox and Chrome are nothing like NSCA Mosaic or gopher. They are runtimes for application development/games. You cannot make a competitive runtime if your foundation is a source for non-deterministic effects and unnecessary resource consumption.

It is possible, but not workable.

October 27, 2022

On Thursday, 27 October 2022 at 17:37:59 UTC, Quirin Schroll wrote:

>

Imagine how much more attractive D would be to OO crowd if it had first-class value type boxing, generics with variance and wildcards, and all the other OO stuff modern OO-fist languages offer. Using Java and C#, it feels like D only has the bare minimum to call itself object-oriented. There was some talk (by Átila, IIRC) that having first-class classes and OO in D was a design error. I have no idea whether there is actually a plan to fade those out improve them to be competitive on that front.

Go annihilated both Java/C# and became the cloud native language without the OOP features

Rust is becoming the system language of choice without the OOP features

Zig is making a dent without the OOP features

The more OOP you put in a language, the worst it becomes

C# is adding more functional and low features because OOP features doesn't cut it

OOP is nice only when kept very simple and minimal

October 27, 2022

On Thursday, 27 October 2022 at 19:29:15 UTC, ryuukk_ wrote:

>

On Thursday, 27 October 2022 at 17:37:59 UTC, Quirin Schroll wrote:

>

[...]

Go annihilated both Java/C# and became the cloud native language without the OOP features

Rust is becoming the system language of choice without the OOP features

Zig is making a dent without the OOP features

The more OOP you put in a language, the worst it becomes

C# is adding more functional and low features because OOP features doesn't cut it

OOP is nice only when kept very simple and minimal

OOP is amazing when you stay true to it, which basically no languages do. The only good example of it is something like smalltalk. Or maybe Erlang if you think of each process as an object

(Yes, of course there are other languages, but to name some)

October 27, 2022
On Thu, Oct 27, 2022 at 07:29:15PM +0000, ryuukk_ via Digitalmars-d wrote:
> On Thursday, 27 October 2022 at 17:37:59 UTC, Quirin Schroll wrote:
> > Imagine how much more attractive D would be to OO crowd if it had first-class value type boxing, generics with variance and wildcards, and all the other OO stuff modern OO-fist languages offer. Using Java and C#, it feels like D only has the bare minimum to call itself object-oriented.

IMO, D doesn't really need any of the heavyweight OO features because typical idiomatic D code doesn't rely heavily on OO, but on other idioms like structs for by-value exchange of data, ranges, and DbI.  When the entire language is predicated on OO, like in Java, then you need all the advanced machinery to make OO more tolerable.  But when you can simply step outside of the OO box and solve things with other tools, then there isn't a big need for heavy OO machinery.


> > There was some talk (by Átila, IIRC) that having first-class classes and OO in D was a design error. I have no idea whether there is actually a plan to fade those out improve them to be competitive on that front.

I think it's a bit extreme to call OO support a design error... but I'd say it's true that in most of my D code, I find little need for OO. D-centric idioms like structs, ranges, DbI, metaprogramming, CTFE, already cover most of the areas that languages like Java use OO for; as a result, the role of OO in D is much narrower than in Java.


> Go annihilated both Java/C# and became the cloud native language without the OOP features
> 
> Rust is becoming the system language of choice without the OOP features
> 
> Zig is making a dent without the OOP features
> 
> The more OOP you put in a language, the worst it becomes

I disagree.  OOP itself isn't bad; it has its place.  For certain things, like programming widget hierarchies, OO totally makes sense, and I'd even recommend using OO idioms for that.

What's bad is the fallacious philosophy that OO is the be-all and end-all of programming paradigms (the fanboy attitude that unfortunately permeated the scene in the early days of Java), where you try to shoehorn OO into everything else where it doesn't fit, ending up with ridiculous things.  Like static singleton "classes" with static methods, whose sole purpose of existence is to give you bragging rights that your code is fully OO-certified, without "bad" things like global functions and global variables. (Spoiler: you just used them, only under a different name.) Sometimes, I daresay even oftentimes, an in-register int or by-value struct is good enough (or even better); there is no need to carry around that excess baggage needed for runtime polymorphism and inheritance, just so you can brag that "everything is an object" and OO-approved and certified.


> C# is adding more functional and low features because OOP features doesn't cut it
> 
> OOP is nice only when kept very simple and minimal

I'd say OOP works very well -- within its own niche. There are many more things in programming than are in the little garden of OO.


T

-- 
Two wrongs don't make a right; but three rights do make a left...
October 27, 2022

On Thursday, 27 October 2022 at 17:37:59 UTC, Quirin Schroll wrote:

>

On Friday, 21 October 2022 at 15:13:44 UTC, Ola Fosheim Grøstad wrote:

>

On Friday, 21 October 2022 at 13:53:28 UTC, Guillaume Piolat wrote:

>

But building and agreeing on abstractions is what define the ecosystem.

One big weakness in C++ and D is that generic definitions cannot be checked without instantiation.

There aren’t many languages that have both, templates and generics; C++/CLI and C++/CX are the only ones I know and I happen to have some experience with them. (In this nomenclature: template = independent copy of the implementation for every distinct instantiation, cf. C++ or D templates, especially class templates with mutable static variables; generic = one implementation, cf. Java or C#, and static variables cannot depend on the argument types.)

[snip]

Timon argued on the C++ pattern matching thread [1] that we need "a way to parameterize functions and aggregates that is completely erased at runtime (generally useful, not only for lifetimes; e.g., this is how to fix inout.)". This bears some similarity with generics.

[1] https://forum.dlang.org/post/tj633h$1g4e$1@digitalmars.com

October 27, 2022
On 10/27/22 11:50, Ola Fosheim Grøstad wrote:

> Modern browsers such as Firefox and Chrome are nothing like NSCA Mosaic
> or gopher.

Ok.

> They are runtimes for application development/games.

Ok.

> You
> cannot make a competitive runtime if your foundation is a source for
> non-deterministic effects and unnecessary resource consumption.

Your argument seems to be based on finding a narrow case where your point is true and then concluding that some other related thing is false. Here, just because we can imagine a case where "non-deterministic effects and unnecessary resource consumption" can be harmful, D is not usable.

That kind of argumentation was used before:

- "There are corner cases where ranges are inferior to iterators, so ranges must be bad." This logic is proven to be wrong because we know from experience that ranges are very useful.

- "There are corner cases where 'static if' does not make sense, so 'static if' is bad." This conclusion is proven to be wrong because we have tons of experience that 'static if' is very useful. (Some "considerate" C++ "experts" failed on this one.)

Now, to break your logic, I present Weka.IO, world's fastest file system, written in D. Period.

Having that example in front of me, I bet even I can write a browser that would be considered "modern".

> It is possible, but not workable.

As I've shown above, it is possible and workable.

Ali

October 27, 2022

On Thursday, 27 October 2022 at 20:54:32 UTC, Ali Çehreli wrote:

>

Your argument seems to be based on finding a narrow case where your point is true and then concluding that some other related thing is false. Here, just because we can imagine a case where "non-deterministic effects and unnecessary resource consumption" can be harmful, D is not usable.

No. The argument was whether it makes sense to use Rust for building the core engine of Firefox or not. The position I argued against was that you could just as well do it with a standard freeze-the-world GC or Go with full GC. The argument isn't strictly related to D, that is something you brought to the table.

99% of all languages use some kind of GC, most of the programs written are done using some kind of GC. Having automatic memory management is the norm, not the outlier.

That does not mean that non-GC applications can be replaced with a run-of-the-mill GC solution and be competitive. It makes sense to use languages like Rust for even mundane things like cloud web services where you want to conserve memory.

I am not a Rust user at this point, but I also don't assume that people who use it don't understand the tradeoffs.

>

Now, to break your logic, I present Weka.IO, world's fastest file system, written in D. Period.

Do they use the regular D GC all the way?

>

As I've shown above, it is possible and workable.

I have absolutely no idea what you are referring to here.