The border between a fundamental type and an object is blurred and often artificially introduced. For example, In C a struct is just a bunch of records, just a derived non-object type. In C++, a struct is a class with all fields public, an object. Still, C++ is almost totally backwards compatible with C... the border is really soft here.
For prototype-based programming you need to have objects mutable at runtime. They MUST be soft-typed because each changes at runtime, a class of one kind changes into another - its type changes.
You might keep fundamental and derived non-object types as static though. But this introduces a weird disparity, objects are soft-typed, non-objects are static-typed, and a hard barier must be established between the two. Should you be able to morph a structure? A String? Should Number be a class or a fundamental type, or a set of fundamental types, int/float/bignum/etc?
It is just more natural and easy to learn, use and write to have this uniform, all types are mutable or no types are mutable at runtime. If you declare only one type (Object) is mutable, you end up with headaches and problems of both worlds.
Static-typed is:
- easier to implement
- faster / more efficient
- safer
- easier to maintain/document big systems due to abstraction.
Dynamic-typed is:
- faster to write in,
- more concise
- language easier to learn
- more forgiving for design errors.
By blending the two, you sacrifice a lot.
- Implementation becomes harder than any of the previous two.
- speed depends if you use the soft types or not... If you do, it's low, if you don't, why pick the language at all?
- type safety is out the window for all object types.
- following how one type morphs into another is a pretty difficult task. Documenting it - very hard.
- You still need to do all the bookkeeping with fundamental types, which kills conciseness and writing speed
- The language complexity is higher (more difficult to learn) than any of the "specific" ones,
- "forgiving" of a dynamic-typed is replaced by tendency to some very tricky errors at mismatching attribute types.
That's not how the prototype works. The prototype is used in the prototype chain.
Whenever you try to get a property on an object it will check the object for that property name. If it does not exist it will look in the prototype.
Example:
var o = {
"foo": "bar",
"method": function() { ... }
};
var o2 = Object.create(o);
var o3 = Object.create(o);
console.log(o2.hasOwnProperty("foo")); // false
console.log(o2.foo); // "bar"
console.log(o2.__proto__ === o); // true
o.baz = "foobar";
console.log(o2.baz); // "foobar"
So the point of the prototype is simply code re-use and inheritance.
Best Answer
I don't know, but the assumption is false.
Larger projects use prototypical languages:
How much "bigger" do you want? Are you expecting someone write code that emulates a computer and can just take a linux ISO and run a whole operating system out of your browser and you can start writing code from a linux command-line in C++... or something ridiculous like that? Okay, we have that too.
Seriously, what's "bigger?"
Again, you have the most proliferated language on github that has lead to an IDE, a webserver, a 3d graphics engine, a pdf document rendering tool, video decoder, encryption library and x86 emulator.
I'm not even going to bother linking to the endless slew of webapps and stuff in the chrome store, frameworks of all shapes and sizes, static code analysis tools, or other 'trivial' projects that nobody uses because the language is just so painfully slow and we can't be sure of how to write code in it.
Oh wait, we can be sure how to write quality code in JavaScript. It's called reading the funny manual, writing unit tests, static code analysis, and other fun things you do in every other language if you're competent in that language also.
It's not "risky" because it's got a prototype, it just means you need to know what you're doing, the same way you need to know how to program in whatever paradigm you enjoy. It's not "slow" because it's a prototype, languages out there that I haven't mentioned run at near-C speeds. You can find more information on your local search engine.
Good day.