Worst ideas/features in programming languages?

Q. Schroll qs.il.paperinik at gmail.com
Mon Nov 15 16:20:07 UTC 2021


* Worst features implemented in a non-toy language?
* Worst features (in your opinion) in D
* Features you'd like to see in D

Undisputed first place: Reference types (ptrs, function ptrs, 
arrays, classes, etc.) are nullable by default in Java and many 
others, including D. D could have had `int*` and `int*?`, `int 
function()` and `int function?()`, `int[]` and `int[]?`, `Object` 
and `Object?`.

`std.typecons.Nullable` is basically a type constructor, and 
faking one via templates only works half-way (for example, 
`const(int)?` and `const(int?)` are the same type). 
Distinguishing nullable types is very useful documentation-wise. 
If you do this, enable nullable for every type, even if `int?` is 
implemented by a plain bool-int pair.

For me, second place for bad D feature: function types. Not 
function *pointer* types but mere function types. They aren't 
even documented, so it's technically a bug that they exist.

---

A few other nuisances that are just unnecessary to work around 
and have absolutely no justification existing:
1. Cannot initialize an empty AA by `[ ]`. Especially a nuisances 
when wanting to pass an empty AA as an argument to a function.
2. The `new` keyword is needed to allocate class objects. Makes 
meta-programming annoying, and one cannot have a literal pointer 
like `new int(1)` for, say, `Object`.
3. One cannot express every type (not counting encapsulation, 
i.e. Voldemort types) directly: Notably, one cannot express a 
function pointer returning by reference in a function argument 
list.


More information about the Digitalmars-d mailing list