On Monday, 11 October 2021 at 15:59:10 UTC, Atila Neves wrote:
> I'm brainstorming about what I'll talk about at DConf, and during a conversation with Walter I thought it might be cool to talk about:
- Worst features implemented in a non-toy language
- Worst features (in your opinion) in D
- Features you'd like to see in D
Ideas? Examples?
Thanks!
Worst features in a non-toy language. This is going to be controversial, but templates. They start innocent enough, just a way for functions to work with generic arguments. But then you build templates upon templates, and suddenly IDEs get lost, auto-refactoring stops becoming a possibility because most code doesn't exist yet, and you have to read documentation to understand what the return types and input types are of method T doStuff(T, U)(T val, U min, U max);
I wouldn't say worst, but I feel like D has many features which just don't get much use. For example contracts. Sure, they sound nice in principle, and I am sure there are some users of that feature. There's nothing wrong with that, but every feature adds more complexity and bugs to fix.
Features I'd like to see in D? Named arguments and struct/associative array initializers working outside of initialization, e.g. as function arguments.
Some syntactic sugar I like from other languages:
Named constructors as a replacement for factory static methods:
class Angle {
this.fromDegrees(float deg) { ... }
this.fromRadians(float rad) { ... }
}
Angle a = new Angle.fromDegrees(90.0f);
Initializer fields:
class Person
{
string firstName, lastName;
int age;
this(this.firstName, this.lastName, this.age);
}
Person p = new Person("Michael", "Schumacher", 52);