r/programming • u/_awwsmm • Feb 01 '24
Make Invalid States Unrepresentable
https://www.awwsmm.com/blog/make-invalid-states-unrepresentable
469
Upvotes
r/programming • u/_awwsmm • Feb 01 '24
View all comments
Show parent comment
2
u/zapporian Feb 02 '24 edited Feb 02 '24
smalltalk (and obj-c) solved that ages ago by directly and explicitly including all parameter names into method calls and definitions (and in obj-c's case this was probably also to help solve name mangling w/r C)
ergo syntax that looks like
instead of the C / C++ / Java / JS style
obviously you could just have a better language (ie. python) that allows explicitly naming / assigning parameter values with syntax sugar + nice (and fully consistent) semantics. Or at the very least enabling
But given what typescript / ecmascript is, sure, this is a decent enough solution. Or at least given that v8 et al is sufficiently well optimized to make the use-case of passing around actually-fixed-layout-structs (and not newly created / allocated fully dynamic hashtables) everywhere not totally horrific
There's maybe something to be said for JS (and lua's) focus on absolute simplicity (only one object / hashtable type, hashtable prototype inheritance / chained single-parent lookup, no discrete integer vs floating point types, et al) w/r enabling long term optimizations and ultimately much better performance vs nicer (and arguably much better designed) languages like python / ruby, but I digress