Hardmath123 (talk | contribs) |
Hardmath123 (talk | contribs) |
||
Line 26: | Line 26: | ||
*Procedure calls | *Procedure calls | ||
*Special forms: certain specialized procedures which cannot be created using the language itself, for example, IF/ELSE. | *Special forms: certain specialized procedures which cannot be created using the language itself, for example, IF/ELSE. | ||
+ | |||
+ | The syntax of a programming language gives rules about how to do each of the above. For example: | ||
+ | |||
+ | *Assignments: | ||
+ | **Squeak: <code>var _ val</code> | ||
+ | **JavaScript: <code>var = val</code> | ||
+ | **Scheme: <code>(SET! var val)</code> | ||
+ | *Procedure calls | ||
+ | **Squeak: <code>obj proc: arg</code> | ||
+ | **JavaScript: <code>proc(arg);</code> | ||
+ | **Scheme: <code>(proc arg)</code> | ||
+ | *Special forms (if, in this case) | ||
+ | **Squeak: <code>bool ifTrue: [something] ifFalse: [something].</code> | ||
+ | **JavaScript: <code>if (bool) {something;} else {something;}</code> | ||
+ | **Scheme: <code>(if bool something something)</code> | ||
==Programming languages relevant to Scratch== | ==Programming languages relevant to Scratch== |
Revision as of 06:43, 30 April 2013
This article is about programming languages in general. For the project type, see Programming Language (Project Type).
A programming language is a set of rules and functions that let us use a computer. Programming languages are designed to make it easy for humans to write complex instructions. They function a lot like human languages: they have explicit grammars and a primitive vocabulary. Scratch is a programming language.
Syntax and grammar
Programming languages are generally either interpreted or compiled, which means they are either executed directly, or translated into another language. For example, C and Java are compiled while Python and JavaScript are interpreted.
![]() | Java and JavaScript are two completely different programming languages with no relation whatsoever in grammar, semantics, creation, or uses. |
Languages usually consist of the following parts:
- A parser: this converts a string of text into a data structure (Array or Object) that can easily be interpreted.
- An interpreter or compiler: this "understands" the data structure and interprets it.
- Primitives: these are built-in functions and values.
Languages usually have various primitive data types which can be expanded with OOP:
- Numbers, which are parsed as numbers
- Some languages consider integers, floating-point numbers, and doubles to be different data types.
- Strings, which are parsed as text
- Arrays, which are lists of elements
- Objects, which are dictionaries of key-value pairs.
- Functions, which are pieces of code which can be executed with Arguments.
In essence, a programming language just provides a framework where a function can be executed with arguments—the rest can be worked around. Usually, the grammar of a language consists of "statements", which are either:
- Assignments: binding some value to a name (variable)
- Procedure calls
- Special forms: certain specialized procedures which cannot be created using the language itself, for example, IF/ELSE.
The syntax of a programming language gives rules about how to do each of the above. For example:
- Assignments:
- Squeak:
var _ val
- JavaScript:
var = val
- Scheme:
(SET! var val)
- Squeak:
- Procedure calls
- Squeak:
obj proc: arg
- JavaScript:
proc(arg);
- Scheme:
(proc arg)
- Squeak:
- Special forms (if, in this case)
- Squeak:
bool ifTrue: [something] ifFalse: [something].
- JavaScript:
if (bool) {something;} else {something;}
- Scheme:
(if bool something something)
- Squeak:
Programming languages relevant to Scratch
Squeak
Squeak was used to program the 1.x series of Scratch. It is a simple language designed to be human-readable and concise. See Squeak Tutorial for a simple introduction.
Flash
Adobe's Flash was used to program Scratch 2.0. It is programmed in ActionScript, which was based on ECMAScript.
Python
Python is a simple interpreted scripting language that is used in the Scratch 2.0 back-end (server-side code). The forums run on DjangoBB, a Python library. Python is also used in many Scratch add-ons, including Kurt.
PHP
PHP is another server-side language which was used to build the Scratch 1.x server system (ScratchR).
JavaScript
JavaScript is a scripting language based on ECMAScript. It is used to add interactivity to webpages. Snap! is written in JavaScript, as is the front-end of the Scratch website. It is used with HTML and CSS.