I feel like anything that can be developed using OO/functional languages can be generally made 'better' using a prototype based language, because they appaer to have the best of them all: high order functions, flexibility to simulate any OO structure, productivity (low verbosity) and scalability because of concurrency. But it seems like they are avoided for the creation of executable applications and of bigger projects in general. Why that?
But it seems like they are avoided for the creation of executable applications and of bigger projects in general. Why that?
I don't know, but the assumption is false.
Larger projects use prototypical languages:
- Broadway doesn't do much, just decodes h.264 natively in your browser without codex.
- One of the best video games of all time was written in Lua.
- Lua is used in a lot of places.
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.
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.
A second reason is because classical inheritance is what most programmers know and have been trained on, and prototypal inheritance is too weird for them. Never underestimate how much "popularity" factors into technical decisions.
I've done a lot of coding in Lua. Re-inventing the class wheel every time was not my idea of a good time. Now I work in C++ out of choice.
Flexibility is slow and unsafe.
To those that complain about speed and scalability ask these questions:
- How fast does it need to be. I'm talking requirements here, not generalities (full page must respond in 1s kind of detail)
- How many users are going to use this sytstem now, how many in 5 years.
- Will it interface with other systems and if so how.
The answers to the above questions will greatly influence your decision. You don't need C++ speeds for probably 95% of applications out there, maybe more. As for scalability. Less than 1/10000 of 1% of applications will ever scale to google/ebay/amazon levels. Most, probably less than 1% will scale to the point that you have more than 100 requests per second, even in enterprise.
Now if you work for say AOL or Google, then by all means speed and scalability likely matter, for the rest of us, not so much so, it's a lot more important to get it done and get it done fast at the lowest possible cost.
Encapsulation is weak: it very easy for any other code to inspect and modify any other code. This allows some powerful things, but it can also lead to problems in large projects. Hard to find bugs can happen if you accidentally step on some code that isn't yours.
convenience over security: js has features like arguments.callee which allows any function to call all the way up the stack and access the root (window in a browser) object. This means that you really need to trust any third party code you call. This isn't an issue for every application, but it does constrain what you can do (strict mode fixes this, but can't be relied upon in a browser context)
anything numeric is extremely awkward: every number is a float, which is probably the right choice if you're only going to have one number type, but makes dealing with binary data and integer arithmetic awkward.