This commit is contained in:
Miloslav Ciz 2024-11-30 16:57:38 +01:00
parent 232c0266bf
commit de269368a9
21 changed files with 1906 additions and 1867 deletions

View file

@ -2,11 +2,11 @@
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.
For beginners: a programming language is actually much easier to learn than a [foreign language](human_language.md), 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 if you encounter them for the first time. This is not to say programming is easy -- it is hard, but not because learning the language would be difficult; learning the language is relatively the easier part of programming, the hard parts are for example designing the program's architecture well, designing good protocols and interfaces, learning the math behind the problems you're solving, creating good mathematical models, optimizing and debugging your program well and so on.
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.
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). In other words: 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. So you shouldn't be calling yourself a programmer if you're just manually writing a website in HTML, people will laugh at you.
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).
We use programming languages to write two basic types of programs: 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 reused in other programs, e.g. library with 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:
@ -43,7 +43,7 @@ We divide programming languages into different groups. Perhaps the most common d
- **compiled** languages: Meant to be transformed by a [compiler](compiler.md) to a [native](native.md) (directly executable) binary program, i.e. before running the program we have to run it through the process of compilation into runnable form. These languages are typically more efficient but usually more difficult to program in, less flexible and the compiled programs are non-portable (can't just be copy-pasted to another computer with different [architecture](isa.md) and expected to run; note that this doesn't mean compiled languages aren't [portable](portability.md), just that the compiled EXECUTABLE is not). These languages are usually [lower level](low_level.md), use static and strong [typing](typing.md) and more of manual [memory management](memory_management.md). Examples: [C](c.md), [C++](cpp.md), [go](go.md), [Haskell](haskell.md) or [Pascal](pascal.md).
- **interpreted** languages: Meant to be interpreted by an [interpreter](interpreter.md) "on-the-go", i.e. what we write we can also immediately run; these languages are often used for **[scripting](scripting.md)**. To run such program you need the interpreter of the language installed on your computer and this interpreter reads the [source code](source_code.md) as it is written and performs what it dictates (well, this is actually simplified as the interpreter normally also internally does a kind of quick "lightweight" compilation, but anyway...). These languages are generally less efficient (slower, use more RAM) but also more flexible, easier to program in and [independent of platforms](platform_independent.md). These languages usually [higher-level](high_level.md), use weak and dynamic [typing](typing.md) and automatic [memory management](memory_management.md) ([garbage collection](garbage_collection.md), ...). Examples: [Python](python.md), [Perl](perl.md), [JavaScript](js.md) and [BASH](bash.md).
Sometimes the distinction here may not be completely clear, for example Python is normally considered an interpreted language but it can also be compiled into [bytecode](bytecode.md) and even native code. [Java](java.md) is considered more of a compiled language but it doesn't compile to native code (it compiles to bytecode). [C](c.md) is traditionally a compiled language but there also exist C interpreters. [Comun](comun.md) is meant to be both compiled and interpreted etc.
Sometimes the distinction between compiled and interpreted languages is not completely clear, for example Python is normally considered an interpreted language but it can also be compiled into [bytecode](bytecode.md) and even native code. [Java](java.md) is considered more of a compiled language but it doesn't compile to native code (it compiles to bytecode). [C](c.md) is traditionally a compiled language but there also exist C interpreters. [Comun](comun.md) is meant to be both compiled and interpreted etc. So calling a language interpreted vs compiled is more about what it was designed for, what its priorities are, if the designers made it highly flexible and friendly for interpreting or if they rather intended the code to be efficiently compiled into fast and compact native code.
Another common division is by **level of [abstraction](abstraction.md)** roughly to (keep in mind the transition is gradual and depends on context, the line between low and high level is extremely fuzzy):