Why didn't languages such as C end up being using for web dev? Surely the speed increases from being compiled would be useful for heavy load sites?
Advantages of interpreted languagesInterpreted languages tend to be more flexible, and often offer features like dynamic typing and smaller program size. Also, because interpreters execute the source program code themselves, the code itself is platform independent.
Scripting languages are typically not compiled. Instead, the code is fed directly into an interpreter at runtime. The interpreter reads and executes the program on-the-fly. Because the code is loaded and executed in tandem, scripting language environments sometimes do things that compiled languages cannot.
Interpreter Vs Compiler Scans the entire program and translates it as a whole into machine code. Interpreters usually take less amount of time to analyze the source code. However, the overall execution time is comparatively slower than compilers. Compilers usually take a large amount of time to analyze the source code.
The source code is passed through a program called a compiler, which translates it into bytecode that the machine understands and can execute. In contrast, JavaScript has no compilation step. Instead, an interpreter in the browser reads over the JavaScript code, interprets each line, and runs it.
Another good reason is that on a big server execution speed is not so much an issue as the connection speed anyway. Most of the time is spent sending and receiving data, not number crunching. And actually in certain web services which do a lot of computations, the hard crunching is probably run as a compiled program.
Plus interpreted languages don't need compiling (which on a large project can take time), thus it's more suited for the typically agile development of web solutions.
Most web applications talk to a database. The overwhelming majority of these apps spend almost all of their time communicating with the database. So, for any given request to the application, there is a tiny amount of processing in the application server and then a long pause while waiting for the database. Since such a small percentage of any request's time is spent in actual application server code, optimizing that code by writing it in C/C++ will gain only a tiny, likely not noticeable, improvement in response time.
So, rather than focusing on C/C++ and saving every last CPU cycle, it makes more sense to worry about developer productivity. Developers are very expensive. And, they're typically much more productive in a scripting language or even in Java than they are in C/C++.
Of course, there are exceptions to this. And if some requests to your application are CPU or memory intensive, they should be written in C/C++. But, for the rest of your application, you're better off focusing on optimizing your algorithms, data structures, communication with the database, and developer productivity than in optimizing your language.
Scripting languages have the following advantages over C:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With