Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Why interpretive languages?

  1. Jan 4, 2013 #1
    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?
     
  2. jcsd
  3. Jan 4, 2013 #2
    How would you compile client side code in a client-server relationship?
     
  4. Jan 4, 2013 #3
    So interpretive languages were made specifically for the web?
     
  5. Jan 4, 2013 #4

    chiro

    User Avatar
    Science Advisor

    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.
     
  6. Jan 5, 2013 #5

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Interpretive languages existed long before the web came along. The first popular interpretive language was BASIC from the mid 60's.
     
  7. Jan 5, 2013 #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).
     
  8. Jan 5, 2013 #7
    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.
     
  9. Jan 5, 2013 #8

    rcgldr

    User Avatar
    Homework Helper

    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: Jan 5, 2013
  10. Jan 5, 2013 #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.
     
  11. Jan 5, 2013 #10

    phinds

    User Avatar
    Gold Member
    2016 Award

    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: Jan 5, 2013
  12. Jan 5, 2013 #11

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    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.
     
  13. Jan 5, 2013 #12

    Borek

    User Avatar

    Staff: Mentor

    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.
     
  14. Jan 5, 2013 #13

    jhae2.718

    User Avatar
    Gold Member

    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.

    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. :)
     
  15. Jan 5, 2013 #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.
     
  16. Jan 11, 2013 #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.
     
  17. Jan 12, 2013 #16
    I have noticed that interpretive languages have more features than compiled languages?
    Is it more easy do build more features in interpretive languages?
     
  18. Jan 12, 2013 #17

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    By features, you mean ... ?
     
  19. Jan 12, 2013 #18

    phinds

    User Avatar
    Gold Member
    2016 Award

    I think you have that exactly backwards. Compiler environments tend to come with HUGE built-in libraries whereas interpreters do not.
     
  20. Jan 12, 2013 #19

    chiro

    User Avatar
    Science Advisor

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Why interpretive languages?
  1. Assembly language (Replies: 5)

  2. Computer language (Replies: 4)

  3. New Language? (Replies: 1)

  4. Programming languages (Replies: 16)

Loading...