What's the Difference Between a Programming Language and a Scripting Language?

What's the Difference Between a Programming Language and a Scripting Language?

This is a discussion on What's the Difference Between a Programming Language and a Scripting Language? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; From what I've gathered...a programming language is something that can be compiled? I'm really not so sure what the difference ...

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.

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.

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.

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.

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.

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.

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.

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.

Originally Posted by LuckY

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.

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.