Update
This commit is contained in:
parent
7507412954
commit
5ba31daf43
12 changed files with 1850 additions and 1789 deletions
|
@ -1,11 +1,13 @@
|
|||
# Programming Language
|
||||
|
||||
Programming language is an artificial [formal](formal_language.md) (mathematically precise) language created in order to allow humans to relatively easily write [algorithms](algorithm.md) for [computers](computer.md). It basically allows a human to very specifically and precisely but still relatively comfortably tell a computer what to do. We call a program written in programming language the program's **[source code](source_code.md)**. Programming languages often try to mimic some human language -- practically always [English](english.md) -- so as to be somewhat close to humans but programming language is actually MUCH simpler so that a computer can actually analyze it and understand it precisely (as computers are extremely bad at understanding actual [natural language](natural_language.md)), without ambiguity, so in the end it all also partially looks like [math](math.md) expressions. A programming language can be seen as a middle ground between pure [machine code](machine_code.md) (the computer's native language, very hard to handle by humans) and natural language (very hard to handle by computers).
|
||||
Programming language is an artificial [formal](formal_language.md) (mathematically precise) language created in order to allow humans to relatively easily write [algorithms](algorithm.md) for [computers](computer.md). It basically allows a human to very specifically and precisely but still relatively comfortably tell a computer what to do. We call a program written in programming language the program's **[source code](source_code.md)**. Programming languages often try to mimic some human language -- practically always [English](english.md) -- so as to be somewhat close to humans but programming language is actually MUCH simpler so that a computer can actually analyze it and understand it precisely (as computers are extremely bad at understanding actual [human language](human_language.md)), without ambiguity, so in the end it all also partially looks like [math](math.md) expressions. A programming language can be seen as a middle ground between pure [machine code](machine_code.md) (the computer's native language, very hard to handle by humans) and natural language (very hard to handle by computers).
|
||||
|
||||
For beginners: a programming language is actually much easier to learn than a foreign language, it will typically have fewer than 100 "words" to learn (out of which you'll mostly use like 10) and once you know one programming language, learning another becomes a breeze because they're all (usually) pretty similar in basic concepts. The hard part may be learning some of the concepts.
|
||||
|
||||
A programming language is distinct from a general computer language by its purpose to express algorithms and be used for creation of [programs](program.md). This is to say that there are computer languages that are NOT programming languages (at least in the narrower sense), such as [HTML](html.md), [json](json.md) and so on.
|
||||
|
||||
We write two basic types of programs in these languages: executable programs (programs that can actually be directly run) and [libraries](library.md) (code that cannot be run on its own but is supposed to be used in other programs, e.g. library for mathematical functions, networking, [games](game.md) and so on).
|
||||
|
||||
A **simple example** of source code in the [C](c.md) programming language is the following:
|
||||
|
||||
```
|
||||
|
@ -55,6 +57,13 @@ A computer language consists from two main parts:
|
|||
- **[syntax](syntax.md)**: The grammar rules and words, i.e. how the language "looks", what expressions we are allowed to write in it. Syntax says which words can follow other words, if indentation has to follow some rules, how to insert comments in the source code, what format numbers can be written in, what kinds of names variables can have etc. Syntax is the surface part, it's often considered not as important or hard as semantics (e.g. syntax errors aren't really a big deal as the language processor immediately catches them and we correct them easily), but a good design of syntax is nevertheless still very important because that's what the programmer actually deals with a great amount of time.
|
||||
- **[semantics](semantics)**: The meaning of what we write, i.e. semantics says what the syntax actually stands for. E.g. when syntax says it is possible to write `a / b`, semantics says this means the mathematical operation of division and furthermore specifies what *a* and *b* can actually be, what happens if *b* is zero etc. Semantics is the deeper part as firstly it is more difficult to define and secondly it gives the language its [features](feature.md), its power to compute, usability, it can make the language robust or prone to errors, it can make it efficient or slow, easy and hard to compile, optimize etc.
|
||||
|
||||
We also commonly divide a language to two main parts:
|
||||
|
||||
- **core language**: The basis of programming language is formed by a relatively small "pure" language whose words and rules are all built-in and hard-wired. They include the most elementary mechanisms such as basic arithmetic operators, elementary [data types](data_type.md) such as numbers and strings, control structures such as *if-then-else* branching and loops, the ability to define [functions](function.md) etc. This core language is like an "engine" of the language, it should be simple and well optimized because everything will be built on top of it. Higher level languages often include in their core what in lower level languages is provided by libraries, e.g. sorting functions, dynamic data types and so on.
|
||||
- **[standard library](stdlib.md)** (*stdlib*): The language standard traditionally also defines a standard library, i.e. a library that has to come with the language and which will provide certain basic functionality such as user [input/output](io.md), working with files, basic mathematical functions like [square root](sqrt.md) or [sine](sin.md) and so on. These are things that are usually deemed too complex to be part of the language core, thing that can already be implemented using the core language and which are so common that will likely be needed by majority of programs, so the standard will guarantee to programmers that they will always have these basic libraries at hand (with exactly specified [API](api.md)) available. How complex the standard library is depends on each languages: some languages have huge standard libraries (which makes it very hard to implement them) and, vice versa, some languages have no standard library.
|
||||
|
||||
Besides the standard library there will also exist many third party [libraries](library.md), but these are no longer considered part of the language itself, they are already a products of the language.
|
||||
|
||||
**What is the best programming language and which one should you learn?** (See also [programming](programming.md).) These are the big questions, the topic of programming languages is infamous for being very [religious](holy_war.md) and different people root for different languages like they do e.g. for [football](football.md) teams. For [minimalists](minimalism.md), i.e. [suckless](suckless.md), [LRS](lrs.md) (us), [Unix](unix.md) people, [Plan9](plan9.md) people etc., the standard language is **[C](c.md)**, which is also probably the most important language in [history](history.md). It is not in the league of the absolutely most minimal and objectively best languages, but it's relatively minimalist (much more than practically any [modern](modern.md) language) and has great advantages such as being one of the absolutely fastest languages, being extremely well established, long tested, supported everywhere, having many compilers etc. But C isn't easy to learn as a first language. Some minimalist also promote [go](golang.md), which is kind of like "new C". Among the most minimal usable languages are traditionally [Forth](forth.md) and [Lisp](lisp.md) which kind of compete for who really is the smallest, then there is also our [comun](comun.md) which is a bit bigger but still much smaller than C. To learn programming you may actually want to start with some ugly language such as [Python](python.md), but you should really aim to transition to a better language later on.
|
||||
|
||||
**Can you use multiple programming languages for one project?** Yes, though it may be a burden, so don't do it just because you can. Combining languages is possible in many ways, e.g. by embedding a [scripting](scripting.md) language into a compiled language, linking together object files produces by different languages, creating different programs that communicate over network etc.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue