PDA

View Full Version : What's the Difference Between a Programming Language and a Scripting Language?



Krak
07-13-2005, 11:17 AM
From what I've gathered...a programming language is something that can be compiled? I'm really not so sure what the difference is.

ober
07-13-2005, 11:35 AM
That's pretty much the main difference. Although some fit into both categories (Perl, for example).

Scripting languages also don't usually require a "main" function of any sort.

dpro
07-13-2005, 12:16 PM
Most (if not all) scripting languages are interpreted as well. This is why there can be generic variable types, such as $var being a string, a number etc. I don't know about every single language out there, but from my experience the biggest difference is being able to throw a variable in without casting. Probably my favorite feature out of these languages is that the type can represent many things at one time.

LuckY
07-13-2005, 01:37 PM
Executable source code is compiled into the binary instructions that will be interpreted by the target CPU when it is run. Script code (at differing levels for different languages, e.g., it would be compiled byte code in Java) contains instructions that are read then performed by an external application.

Perspective
07-13-2005, 01:40 PM
Executable source code is compiled into the binary instructions that will be interpreted by the target CPU when it is run. Script code (at differing levels for different languages, e.g., it would be compiled byte code in Java) contains instructions that are read then performed by an external application.

are you saying Java is a scripting language? Id have to disagree here. when the scripted source can be interpreted, its a scripting language. If it requires some compilation (whether it be to native, or byte code) than its not a scripting language.

adrianxw
07-13-2005, 01:44 PM
You need to split the language from what happens to the language after it is written. You are discussing implementation, not the language itself.

It would be possible to write interpreters for languages normally compiled to source code, similaly it would be possible to compile some script languages to source code.

LuckY
07-13-2005, 01:46 PM
Let me correct myself because I clearly confused myself along with you. Java is an interpreted language in which an application runs compiled byte code, but there exists no compiled executable code. Scripting languages operate in the same manner, but directly from the source code and not any intermediate compiled code of any kind.

cboard_member
07-13-2005, 01:46 PM
The Java Virtual Machine does exactly what it says 'on the box'; provides a virtual machine. Java bytecode is effectively machine code, just not for your machine per sť.

I guess this makes Java a compiled langauge, not interpreted.

LuckY
07-13-2005, 01:51 PM
I guess this makes Java a compiled langauge, not interpreted.
Java is classified as an "interpreted language." That is the term used to define the category of language to which Java belongs. It is not a "compiled language," but if it makes you feel better I guess you can call it whatever you want. In any case, it is an interpreted language. (The bytecode is interpreted by Java's bytecode interpreter.)

[edit]

Java bytecode is effectively machine code
No, it actually is not. It is merely a set of Java instructions in binary form. Nothing is "effectively" machine code; either it is machine code or it is not, and Java's bytecode is not.

CornedBee
07-13-2005, 02:44 PM
And the machine code is interpreted by the CPU, so I guess C is an interpreted language as well. Or perhaps you're using an Amiga emulator to play old games - since it interprets the compiled code of those games, that would make the languages the games were written in interpreted as well.
ahluka is entirely right. The JavaVM is actually a CPU emulator. It's also wrong to say that Java bytecode is Java instructions in a different form - Jython compiles to bytecode, NetRexx does, several other technologies do as well.


Anyway, the distinction between programming languages and scripting languages is a bad one, because it doesn't divide languages in two groups. The difference between programming and scripting lies only in application. Take Visual Basic for example. There's Visual Basic, which is undoubtedly used for application programming; that would make it a programming language. But then there's Visual Basic for Applications (VBA) - the same language really, but considered a scripting language because it's used to write macros for various apps. Or Visual Basic Scripting Edition (VBScript) - another scripting language although it's the same as VB. As of VB6, you can choose to have your VB as interpreted bytecode or compiled machine code - which is it then?
What about JavaScript? Is it a scripting language? But large parts of Mozilla - obviously an application - are written in JavaScript.
PHP? Are you telling me that phpGroupWare or vBulletin are not applications as well?
Application programming and script/macro programming are two use cases of languages, but it doesn't split languages into groups. Languages can be used for either - some languages are more suited for application programming, some more for scripting, but the distinction is extremely blurry, especially as you'll be hard pressed to find a proper boundary between scripts and applications, and because applications can be written in more than one language. (Mozilla uses four in the actual application and another three in the build system.)

Similarly, the distinction between compiled languages and interpreted languages is blurred, because some languages are hybrids (VB5, Java if you will, ActionScript), and you can generally write interpreters for any language at all, and compilers for most, so the distinction is really one of available technology, not language.

major_small
07-13-2005, 02:48 PM
http://en.wikipedia.org/wiki/Scripting_language#Description


However, the boundary between scripting languages and regular programming languages tends to be vague, and is blurring ever more with the emergence of new languages and integrations in this fast-changing area... in general, it is possible to write a script in any language (including C or assembly language). In most modern systems, the latter case is very seldom recommendable, since one or more suitable script languages is usually available.

dpro
07-13-2005, 03:09 PM
I suppose I should retract my earlier less informed statement, wikipedia is much more knowledgable than I :(

Rashakil Fol
07-13-2005, 05:51 PM
It's accurate to consider "scripting" languages to be a category of programming language.

Practically all programming languages (including Perl, Javascript, Java, et al) are compiled. They certainly don't reparse every line over and over again when traversing a while loop, do they? (No.) The only languages which could realistically be left uncompiled are esoteric ones like Brain........, which is essentially written by the programmer in compiled form.


No, it actually is not. It is merely a set of Java instructions in binary form. Nothing is "effectively" machine code; either it is machine code or it is not, and Java's bytecode is not.

There are microprocessors that directly understand Java bytecode.

major_small
07-13-2005, 05:54 PM
when is Perl or JavaScript ever compiled?

Rashakil Fol
07-13-2005, 06:08 PM
The Perl interpreter compiles Perl to bytecode it before it interprets. Then it takes that bytecode and builds the program's parse tree (because executing directly from bytecode would be slow), and then it executes.

The meaning of the word 'compile' as generally defined doesn't imply machine code.

major_small
07-13-2005, 06:37 PM
heh... I forgot about that... I haven't used Perl in quite a while, and forgot that it's a compiled language... but what about JavaScript?

ILoveVectors
07-13-2005, 08:10 PM
Let just agree that its a compiled langauge the code itself is used
to create an application, and let call it a scripting language
when something else is needed to do anything with the langauge.

So if you compile VB then its a compiled language at that point
and time, if you use it as a script, then it a script for
that point in time.

I would say that all langauge fall into both categorys,
because a interpretor can be written for all languages
and a compiler could be written for all langauges.

Granted some of the lagnauge wouldnt be as powerful
as others. But i think this topic is pointless if unless you look
at it in black in white. Because there always exceptions.


So incase i lost anyone, every language is a compiled language
and a scripting language (has the ability to be anyways).

CornedBee
07-13-2005, 11:51 PM
heh... I forgot about that... I haven't used Perl in quite a while, and forgot that it's a compiled language... but what about JavaScript?

The Rhino JavaScript engine compiles scripts to Java bytecode.

major_small
07-14-2005, 01:07 AM
The Rhino JavaScript engine compiles scripts to Java bytecode.I mean under normal conditions.

I agree with wikipedia and ILoveVectors... all languages can be both a compiled and interpreted language, and the line is fading as we move on... eventually, it won't make sense to seperate the two groups.

as ILV said, when you compile it, it's a compiled language. when you interpret it, it's an interpreted language. if you do both, then it's both. it depends on the way the language is used, not the language.

CornedBee
07-14-2005, 02:15 AM
I mean under normal conditions.
What ARE normal conditions? There's quite a lot of Java applications scriptable using the Rhino engine. There's also quite a few apps using the SeaMonkey engine, which is purely interpreting. Which of them is normal?

major_small
07-14-2005, 02:28 AM
wow... you're reading into this way too much...

JavaScript was made to be a script. hence the name. therefore under 'normal' conditions (you write the script into HTML and let a browser take care of it), it's an interpreted language.

sheesh...

CornedBee
07-14-2005, 02:40 AM
What I'm trying to make clear is that there is no definite correlation between a language being for scripts and being interpreted.

major_small
07-14-2005, 02:47 AM
What I'm trying to make clear is that there is no definite correlation between a language being for scripts and being interpreted.that's pretty much exactly what I said in my next-to-last post...

Mister C
07-15-2005, 04:46 PM
Does is answer the question:


To compile your first java application, enter the following (assuming that the java directory is in your path) :

javac myfirstjavaprog.java

Javac is a compiler included with Sun's JDK. It translates the source file into Java byte-codes. While Java is an interpreted language, it is reduced into byte-codes which are interpreted by a Java virtual machine (in much the same way assembly language / machine code for older computing systems can be executed by emulator software). The compiler stores these byte-codes in a ' .class ' file. To execute the application, the Java interpreter will run this ' .class ' file.

java myfirstjavaprog

If everything goes according to plan, the message "Hello World!", followed by a newline should appear on your terminal/screen. You've just compiled and executed your first application.

How about this

http://www.artima.com/underthehood/bytecode.html

http://cgibin.erols.com/ziring/cgi-bin/cep/cep.pl?_key=Java

Java is typically compiled to platform-independent byte-codes. These byte-codes must be interpreted by a Java Virtual Machine (JVM), which may choose to compile the byte-codes further into native machine instructions. There is a strict definition of the Java byte-code file format, the .class file format, which ensures portability of compiled Java classes