3 ms·
It's missing bugs that most developers consider features. I know that sounds snarky, but its roughly accurate. Haskell is great for not only what features the l
by malandrew 13y ago
It's missing bugs that most developers consider features. I know that sounds snarky, but its roughly accurate. Haskell is great for not only what features the language has but also what features the language does not have. It's practically impossible to shoot yourself in the foot with it.
Assuming widespread adoption was a goal, I think Haskell could stand to learn from the Rust community. They could force you to explicitly declare when you want to write unsafe code. Rust does something like this with pointers. You need to go out of your way to use an unsafe pointer, but you can do so in the name of expediency.
I would love it if more language chose to gently coerce me into writing better code than one that doesn't allow me to write bad code. The former reduces the learning curve that normally kills adoption. A language you never adopt is a language you never learn from.
Coding in any language really should be a conversation. Besides executing the instructions you give it, languages should also be designed to teach you to code more intelligently and using its idioms.
Just the other day I was thinking about how you would take an abstract syntax tree and analyze functions to determine which ones are extremely similar and could be reduced to a fewer lines of code. Take this code from sequelize/sequelize for example:
https://github.com/sequelize/sequelize/blob/master/lib/hooks.js#L143 https://github.com/sequelize/sequelize/blob/master/lib/hooks...
Any sufficiently smart static analyzer should be smart enough to highlight the reduncy and highlight duplication to make you aware of it and make you think about how to reduce it. That could could be reduced to this pattern:
[ 'beforeValidate',
'afterValidate',
'beforeCreate',
'afterCreate',
'beforeDestroy',
'afterDestroy',
'beforeDelete',
'afterDelete',
'beforeUpdate',
'afterUpdate',
'beforeBulkCreate',
'afterBulkCreate',
'beforeBulkDestroy',
'afterBulkDestroy',
'beforeBulkUpdate',
'afterBulkUpdate'
].forEach(function(methodName) {
Hooks[methodName] = Hooks.addHook.call(this, methodName, name, fn);
});
129 lines down to 16; Even the generation of that array could be reduced to one that constructs that array from individual words. That would probably be excessive code deduplication though.