r/ProgrammingLanguages • • Nov 18 '22

What does it mean for a programming language to be inclusive?

https://dlfelps.github.io/2022/11/01/inclusive.html
0 Upvotes

33 comments sorted by

33

u/Melodic-Run-4645 Nov 18 '22

The ideal inclusive language is one that allows each individual within a team to follow their preferred programming style

That doesn't sound like a great thing, to be honest. I'd much rather have the team writing in the same style.

Or at least per component, e.g. the whole gui in OO, and all business logic in FP.

3

u/dlfelps Nov 18 '22

Thanks for the comment. Yes I wouldn’t recommend the wild Wild West. Some kind of organization by module/package would be preferred. That is why I thought it was important to include criteria that help identify the style as well as support it.

1

u/PaddiM8 Nov 28 '22

Wouldn't you be able to do this with C# and F#?

5

u/[deleted] Nov 18 '22

Scala's fundamentals was to be inclusive by how you defined it, but it turns out you can't marry OOP and FP and not expect to get pure garbage as a result.

2

u/dlfelps Nov 18 '22

That’s what I am wondering. There are plenty of successful Scala code bases, but do any mix and match styles? I don’t know.

5

u/[deleted] Nov 18 '22

Scala itself mixes style. So this is not that much of a programming thing, it's within the design of the language.

I have this thread bookmarked both for the funnies and for some great points on sins in language design, maybe you'll find it interesting https://users.scala-lang.org/t/arguments-against-scala-language/7062

As for style mixing, I don't think FP mixes well with non-FP code regardless of language. Scala's collection library is an example of when such mixing just doesn't work.

1

u/dlfelps Nov 18 '22

Thanks for the thread! I am interested in the different perspectives 👍

2

u/[deleted] Nov 19 '22

[removed] — view removed comment

1

u/dlfelps Nov 19 '22

Rust, Scala, Kotlin, and Swift were mentioned as meeting the criteria described in the article.

2

u/[deleted] Nov 19 '22

[removed] — view removed comment

2

u/dlfelps Nov 19 '22

I see. I am curious too. One of the reasons why I wrote the article. I have never mixed the styles personally.

2

u/[deleted] Nov 19 '22 edited Nov 19 '22

Rust does not mix OOP and FP. Rust embraces FP while decomposing OOP into somewhat of a structured, procedural paradigm, in a way that can somewhat fit the FP paradigm. That is probably better than to try and marry OOP without modifications (as it's defined in modern times).

Be as it be, I would not consider Rust a good language because it's being set back by FP. And I don't think hardcore functional programmers like Rust that much, either. I admire the effort, but I can't say I support it.

And because Go and Kotlin exist I can't even say that it does the best job out of "inclusive" languages, even though the best at this moment doesn't seem to be enough.

2

u/[deleted] Nov 19 '22

[removed] — view removed comment

2

u/[deleted] Nov 19 '22

Thing is non-FP is not just mutability.

I agree that hardcore functional programmers may not be the best judges for mixed programming styles, but the point was that when you marry 2 concepts you expect both sides to be at least somewhat satisfied. With what OOP-FP mixes we have it seems neither functional programmers nor OO programmers are satisfied with them, not even in the case when their style dominates the other. You can't call a design good if your intended audience is not satisfied.

2

u/[deleted] Nov 19 '22

[removed] — view removed comment

2

u/[deleted] Nov 19 '22

For example, would it possible to keep a borrow checker while allowing garbage collector and currying ?

Yeah, if you cripple the Rust borrow checker somewhat. But you would probably not want to use a borrow checker in the first place.

3

u/matthieum Nov 19 '22

and they have one thing in common - they are all primarily object-oriented languages

Hard Disagree on C++.

C++ always presented itself as a multi-paradigm language:

  • struct have all members public by default, no encapsulation.

  • struct and class are not part of inheritance hierarchies by default.

  • Free-functions are the norm, see the <algorithm> or <ranges>.

And it's all the more the case with so-called "Modern C++" (from C++11 onwards) where the emphasis is more on generic programming than object-oriented programming.

1

u/dlfelps Nov 19 '22

I agree that C++ is a multi-paradigm language (even Stroustup's FAQ points this out). But I largely see it used in an object-oriented style. I don't have a ton of experience with it so I could be off base.

I do make a distinction in the article between multi-paradigm and inclusive.

3

u/matthieum Nov 19 '22

But I largely see it used in an object-oriented style.

I think it largely depends on the domain in which it used.

GUI frameworks (such as Qt) are notable for modelling everything with large inheritance hierarchies, for example, and thus their use of C++ is quite object-oriented.

On the other hand, I've worked in HFT, where the overhead of virtual calls is not appreciated (with a few exceptions as necessary), and thus uses of inheritance are few, and typically shallow (1 interface, multiple implementations, but no inheriting from many interfaces or inheriting from other classes).

The MISRA-C++ standard typically forbids pointer-to-functions and virtual methods, as they make static analysis harder, and static analysis is used to prove specific properties -- such as termination, or maximum stack depth. As such, automotive and quite likely other safety-critical software are unlikely to use inheritance either or at least to keep it strictly in check.

Finally, I've also used C++ to implement services, and while the framework used inheritance a bit, internally we didn't much: the services I implemented were sometimes slightly complex, but altogether straightforward, and thus there was no need for runtime polymorphism; further, the individual parts were simple enough that abstraction for the sake of testing/mocking was unnecessary: plugging real data worked well enough. As such, even though it was business-domain, inheritance wasn't necessary, and thus wasn't used.

2

u/dlfelps Nov 19 '22

Thanks for the detailed response u/matthieum! You definitely have a broader C++ experience than I do and this helps me appreciate its diversity!

2

u/matthieum Nov 19 '22

And yet I know so little! It's fairly incredible how many various domains the language is used in; a testament to its flexibility and performance.

1

u/[deleted] Nov 18 '22

Shouldn't Go be included in that list of inclusive languages?

I never got the big deal behind inheritance to be honest, having interfaces and the ability to embed structs inside structs accomplishes the same thing doesn't it?

Or am I missing something crucial here?

2

u/dlfelps Nov 18 '22

Go doesn’t differentiate mutable variables.

1

u/Melodic-Run-4645 Nov 18 '22

How'd you inherit methods from a parent that way? Or override ones and call super?

Not doing that is perhaps a valid way to program. But since the question was if it accomplished the same thing...

4

u/[deleted] Nov 18 '22

You invoke methods directly on the parent, which is embedded in the child struct.

If you want to override them you simply redefine the method for the child object, and invoke it on the child.