221 karma · joined April 1, 2014
If you want the benefits of `new` without exposing your interface, you should totally wrap it.
But if you're going to have boilerplate like that for code that not's performance critical (and most of it is not), why not just go for Object.create() and returning the instance yourself. Less action at a distance.
Object creation has not yet caused my any performance issues, so I've not seen a reason to personally use `new`.
``` var yourClass = require('your-class');
var myInstance = yourClass(); ```
If I create an interpreter that changes `new Foo` to `$new(Foo)` where $new is a JS function that uses Object.create to do what the `new` operator does in spec (e.g., treat it as syntactic sugar) then it's unlikely that `new Foo` would outperform `Object.create(FooProto)`. Just because the current interpreters are hyperfocusing on `new` doesn't mean they can't make `Object.create` faster in the future.
All requiring `new` does is add an implicit requirement that the name of your function is actually `new X` instead of `X` with the added requirement that all aliases of the function be prefixed with `new `, which is not composable.
Yeah, `new` might be faster than not using it right now, but that's a bug in the interpreters. And for a lot of objects, your inner loop is not going to be in creation.
I saw that the Command pattern has JS snippets and Prototype talks about JS, but most patterns don't seem to talk about JS.
BTW, JS is a prototypical language wrapped in classical syntax. That syntax exists because of Sun & Java's intervention. I find that using most of the language constructs there lead to more brittle code than writing it yourself. Object.create() might not have been in the language since the beginning, but it's here now, and it's what should be used.
"You don’t see many games where each monster is a unique snowflake, like “sort of halfway between a troll and a goblin with a bit of snake mixed in”."
You don't see many games where that's the case because classical programming makes it hard to do that. Programming with classes makes you think of homogenous classes of stuff, and that leads to homogenous stuff.
It seems to me though, that due to bitcoin's relative newness and grey market status, you're going to see a lot of scammers and bad businessmen related to it. It's high risk in that sense, and you need to do your research. Give it time, and the bad business practices will be weeded out, and stability will come. This is the pain of early adoption.
Likewise, having functions have their own private global state is not on the table, and seems to me to actually be unsafe since the function could be called at the same time in two different threads overwriting the operations done to them.
For not warning when returning non-unit values for unit returning functions, a lint could probably help there.
Type inference isn't changing. The rule is that items need to be explicitly declared and expressions are inferred. Closures are expressions while most (all?) functions are items. It's a purposeful limitation on inference based on experience with prior languages.
also on the extra terrestrial influence side, there's direct hits by gamma rays that could wipe out Earth in an instant.