I think there are many useful ideas in OOP languages and I still struggle with purely functional languages, I think/hope we'll see increasingly mixed model languages.
I'd be interested to see a language like C# but with:
+ Immutable by default.
+ 'Free' functions, so they don't have to be in classes.
+ No inheritance.
+ Some sort of distinction, and I'm not clear how it would work yet, between data objects (immutable fields/properties and pure functions) and service objects (functions only, but with the ability to constructor inject dependencies).
+ Purity to be a method signature level contract, enforced by the compiler.
+ C# 8 approach to nullability, e.g. Maybe types.
+ Data 'shapes' as well as/rather than interfaces. So you can require that a method parameter must have some shape, e.g. some property or method, rather than having to implement the interface/inherit.
I think parts of these exist in lots of other languages, or are on C#'s roadmap, but every other language I've tried feels, to me, like it's missing the amazing productivity of C# (and I'd guess Java) where the available IDEs, packages and core libraries are still way ahead of many other languages.
I guess the described language might be closer to F#, but when I tried F# it felt like it was missing the obvious "here's how you actually build a thing" part. A lot of functional language material talks about avoiding state, or not changing state, but that's the point where most the applications I build actually do something useful. So for me it was missing obvious on-ramps for building a website, or a desktop application, perhaps things have changed more recently?
Agree about immutability (I would love to have “readonly” to be applicable to classes), but I like the current static classes approach.
It’s a single keyword, the language guarantee you won’t have any instance fields or methods in these classes.
Global functions pollute namespaces, and auto-complete index. Static classes provide local namespaces for these functions, they also hide implementation details. I sometimes implement moderately complex pieces of functionality as a static class with just a single public method, the rest of the code is in private methods. These private methods don’t show in auto-complete in outside code, even if they’re extension methods. If such class grows too large for a single source file, C# has partial classes.
It's a good point about auto-complete I hadn't considered, maybe globals could have some obvious name thing going on, I hate this suggestion but for example an underscore prefix.
Some examples of where global functions might make sense, the Main function of a console application doesn't need to be in a class, or the general Utils and Helpers approach soon becomes cumbersome, you end up having to name things that don't really need names. While static classes can help organise these global functions you also end up playing the naming game when you don't need to. It might not be any improvement but it's an interesting thought exercise to imagine functions living in just a namespace, not a class.
I think in C# static still doesn't give you enough guarantees at either the class or member level. A static class can still have public static mutable members which is a horrible code smell. C# contains enough flexibility to do the things I want, e.g. make things static and readonly, but it's a lot of additional typing and I'd be interested in seeing the model reversed, e.g. immutable defaults with something like `public mutable class Foo` which I remember having seen in other places (F#?).
> you end up having to name things that don't really need names.
Strictly speaking namespaces don’t need names, either. But for medium to large projects they’re still useful, and enforced by the IDE.
> to imagine functions living in just a namespace, not a class.
You can place them into a namespace on the consumer side of the API, with `using static`. While not the same, might be good enough in practice: you normally have multiple `using` statements on top, for namespaces.
> I'd be interested in seeing the model reversed, e.g. immutable defaults with something like `public mutable class Foo`
I wouldn’t want immutable defaults, but I do want readonly classes and structures, with readonly being part of the type system.
BTW, the new value tuples with named fields is a step in the right direction https://blogs.msdn.microsoft.com/mazhou/2017/05/26/c-7-serie... Useful but limited, I would prefer real immutable classes & structures. Currently I have to create them manually, mark all fields public readonly, implement the constructor, that’s more typing than I’d like.
I'd be interested to see a language like C# but with:
+ Immutable by default.
+ 'Free' functions, so they don't have to be in classes.
+ No inheritance.
+ Some sort of distinction, and I'm not clear how it would work yet, between data objects (immutable fields/properties and pure functions) and service objects (functions only, but with the ability to constructor inject dependencies).
+ Purity to be a method signature level contract, enforced by the compiler.
+ C# 8 approach to nullability, e.g. Maybe types.
+ Data 'shapes' as well as/rather than interfaces. So you can require that a method parameter must have some shape, e.g. some property or method, rather than having to implement the interface/inherit.
I think parts of these exist in lots of other languages, or are on C#'s roadmap, but every other language I've tried feels, to me, like it's missing the amazing productivity of C# (and I'd guess Java) where the available IDEs, packages and core libraries are still way ahead of many other languages.
I guess the described language might be closer to F#, but when I tried F# it felt like it was missing the obvious "here's how you actually build a thing" part. A lot of functional language material talks about avoiding state, or not changing state, but that's the point where most the applications I build actually do something useful. So for me it was missing obvious on-ramps for building a website, or a desktop application, perhaps things have changed more recently?