Why are interpretive languages used in web development?

  • Thread starter Avichal
  • Start date
In summary, interpreters were made specifically for the web because they offer advantages like platform independence and being faster. They are also used for other purposes like creating dynamic code.
  • #1
Avichal
295
0
My first language was C which is a compiled language. Now I'm learning python and I'm wondering what are the uses of interpretive languages? What advantage does compiling line by line offer rather than compiling all at once?

Also I suppose interpretive languages are slower. Why is that? And why for web development we use interpretive languages like php, python etc?
 
Technology news on Phys.org
  • #2
How would you compile client side code in a client-server relationship?
 
  • #3
So interpretive languages were made specifically for the web?
 
  • #4
They are made for all kinds of purposes where you want to execute dynamic code on the fly instead of having to compile it specifically and the dynamic use has advantages that its compiled counter-part does not.

They are also used for platform independence as was a motivation in the development of Java.

Also the language can be specialized and offer more features than another existing platform that needs to compile in their specific way can not.
 
  • #5
Interpretive languages existed long before the web came along. The first popular interpretive language was BASIC from the mid 60's.
 
  • #6
Though not a comment on interpreted languages in general, many specific interpreted languages have the benefit on being comparatively easy to work with, especially when putting together "rough drafts" of programs. I can put together a simulation in an hour in Octave or Python that would take several days or weeks in C (mind you, Python plays very nicely with C if I need it to).
 
  • #7
Avichal said:
So interpretive languages were made specifically for the web?

Interpreted Basic was a major language until 1990. For PCs before that time interpreted BASIC was the main development language on PCs, Apple and small microcomputers.
http://en.wikipedia.org/wiki/Microsoft_BASIC
http://en.wikipedia.org/wiki/Applesoft_BASIC

If you have 64K memory then you can't fit in a compiler.

Just about ALL the early microcomputers came with interpreted BASIC.
 
  • #8
Studiot said:
How would you compile client side code in a client-server relationship?
I'm not sure what you're geting at here. There are some client and server development environments where the client code is compiled, not interpreted.

For the original question, one advantage of interpretive languages is that you can use it like an interactive calculator, without having to go through a compile process, which was lengthy on older computers. You could prototype a function by first experimenting interactively with the code you wanted to create.

My first interactive language was APL, a mathematical language that dates back to the early 1960's (I first used it in 1969 while in high school, then later quite a bit from 1975 to 1978 while tutoring part time at a college (I also had a full time job as a programmer), and still occasionally use it). It's very high level compared to a language like Basic. One of the interesting features was the ability to create a string of characters, then "execute" that string as if you entered it interactively. This was one way to deal with data that had a variable number of dimensions (since the indexing syntax had to be created dynamically). Later versions of APL allow you to dynamically create functions from a matrix composed of strings of characters. There are/were APL compilers, but I'm not sure if they ever got used much.

http://en.wikipedia.org/wiki/APL_(programming_language)

APL is not that popular these days, but matlab, which is also an interpreted high level language, is popular among engineering types.
 
Last edited:
  • #9
There are many reasons for using the interpretive or compiled models, and some languages exist in both formats. The distinction is even blurred in some languages such as Forth.

So chiro has it, yes in some client server situations, notably where the application is repeated many times (ie not 'on the fly'), a precompiled program is placed on the client.
Such an an application would be the Brilliant hotel management system, where client stations run a precompiled UI.
Of course this system illustrates the blurring of the distinction these days between the 'web' and intranets and traditional local networks.
 
  • #10
One HUGE advantage of interpreted languages is that you can debug and modify at run-time.

EDIT: and a huge disadvantage is that they can run slower than mud if you have, for example, nested loops.
 
Last edited:
  • #11
Devils said:
Interpreted Basic was a major language until 1990. For PCs before that time interpreted BASIC was the main development language on PCs, Apple and small microcomputers.
http://en.wikipedia.org/wiki/Microsoft_BASIC
http://en.wikipedia.org/wiki/Applesoft_BASIC

If you have 64K memory then you can't fit in a compiler.

Just about ALL the early microcomputers came with interpreted BASIC.

There were several well-known compilers for FORTRAN, C, and BASIC made for micros with 64K of memory. Digital Research (of CP/M fame) and Microsoft were one-time rivals in early micro language development. Now, with Gbytes of RAM available, code optimization is IMO an all but lost art.
 
  • #12
SteamKing said:
Now, with Gbytes of RAM available, code optimization is IMO an all but lost art.

Sadly, when I talk with young developers, they always seem to be thinking "if it is too slow, we are going to use a faster computer". I am from a completely different school of thinking - sometimes I have to fight my instincts to not spend time on saving few kbytes as it is not worth my time these days.
 
  • #13
Besides the key points already hit above (easier to use, prototyping of algorithms, etc.), a major use of interpreted languages is writing scripts for systems administration. They're fast enough to run, and if you need to make changes it's a lot easier to make a quick edit in vim.

Another point is that interpreter languages can achieve similar performance to compiled language with a good Just-In-Time (JIT) compiler. PyPy is a JIT version of Python you may find interesting.

If you really want speed, it's pretty easy to embed C in Python with something like Cython.

Borek said:
Sadly, when I talk with young developers, they always seem to be thinking "if it is too slow, we are going to use a faster computer". I am from a completely different school of thinking - sometimes I have to fight my instincts to not spend time on saving few kbytes as it is not worth my time these days.

I'm not a computer scientist by any means, but it seems to me that a lot of people don't really do much low-level stuff anymore, outside of embedded development. I can rant all day at the poor quality of software and software developers, but this isn't the place. :)
 
  • #14
The main advantage of interpreted languages is, that you can drop things like type safety. You can write c=a+b and you don't need to care what a,b, and c are as long as the + operator is defined. With python you can even define object.member_function on the fly and duck typing allows you to "abuse" routines that were written with completely different object types in mind. Putting mixed types in lists is a non issue. Lots of things that you would need templates for in C++ or at least type casts.
Then we have the magic of the eval and execute statements where you can make self modifying code and even define a function say from the output of a mysql database.

It speeds up a lot of code writing, if you don't need to give the compiler hints all over the place, what a certain object is so it can preallocate the memory that is necessary.
 
  • #15
They are used for web and other applications were performance in terms of execution speed doesn't matter much. In case of the web, this is because I/O is the main bottleneck. That is, your web server will be waiting many orders of magnitudes longer for the database to spit out the data need than it will take to parse, render and shoot back the web page to the client. So, given that there are some advantages to interpreted languages, it makes sense to use them for the web.

Another reason why they make so much sense for a website back-end is that they are most often cross platform i.e. they can run as is on more than one type of OS or hardware. This allows for easy migration should you ever need to and also allows for a bigger choice when you come to choose your host server to run you website on.
 
  • #16
I have noticed that interpretive languages have more features than compiled languages?
Is it more easy do build more features in interpretive languages?
 
  • #17
By features, you mean ... ?
 
  • #18
Avichal said:
I have noticed that interpretive languages have more features than compiled languages?
Is it more easy do build more features in interpretive languages?

I think you have that exactly backwards. Compiler environments tend to come with HUGE built-in libraries whereas interpreters do not.
 
  • #19
Once you have a decent and flexible code base the answer is typically yes.

In fact it is one of the reasons why many interpretive languages and platforms exist: so whatever feature is needed can be added and implemented in the language and the run-time.
 

FAQ: Why are interpretive languages used in web development?

Why are interpretive languages important in scientific research?

Interpretive languages, such as Python and R, are important in scientific research because they allow for rapid prototyping and easy data manipulation. These languages also have extensive libraries and packages available for statistical analysis and visualization, making them useful tools for analyzing and interpreting data.

What is the difference between an interpretive language and a compiled language?

An interpretive language, such as Python, is a high-level programming language that is executed line by line, converting each line of code into machine code at runtime. On the other hand, a compiled language, such as C++, is converted into machine code before execution. This makes interpretive languages more flexible and easier to use for scientific research, while compiled languages are typically faster and more efficient for large-scale applications.

Can interpretive languages handle big data?

Yes, interpretive languages can handle big data. With the use of specialized libraries and packages, interpretive languages can efficiently process and analyze large datasets. However, compiled languages may be more suitable for extremely large datasets due to their faster processing speed.

Are there any drawbacks to using interpretive languages in scientific research?

One potential drawback of using interpretive languages in scientific research is their slower execution speed compared to compiled languages. This may not be a significant issue for smaller datasets, but for larger and more complex analysis, it may lead to longer processing times. Additionally, interpretive languages may require more memory to run, which can be a limitation for some applications.

Are interpretive languages suitable for all types of scientific research?

While interpretive languages have a wide range of applications in scientific research, they may not be suitable for all types of research. For instance, some fields, such as high-performance computing, may require the use of compiled languages for their speed and efficiency. Additionally, some specialized software and tools used in certain fields may only be available in compiled languages, making them necessary for certain types of research.

Back
Top