Skip to content

Commit 98bba2b

Browse files
AntiHerotshemsedinov
authored andcommitted
tranlation(en): 1-2-Examples.md
1 parent b1fff80 commit 98bba2b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

content/en/1-2-Examples.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## 1.2. Examples in JavaScript, Python and C languages
22

3-
No translation
3+
We will write code examples in different languages, but preference will not be given to the best, beautiful and fast, but to those that cannot be avoided. We will take `JavaScript` as the most common, `Python`, because there are areas where it is impossible to live without it and `C`, as a language close enough to assembly language, which is still very relevant and has had the significant influence on modern languages ​​in terms of syntax and ideas it contains. All three are very far from the language of my dreams, but this is what we have. At first glance, `Python` is very different from `JavaScript` and other C-like languages, although this is only at first glance, we will show that it is very similar to `JavaScript` since the type system, data structures and especially the built-in collections are very similar in them. Although syntactically the difference in the code blocks organization using indentation and curly brackets `{}` is striking the eye, in reality, such a difference is not so significant, and there is much more in common between `JavaScript` and `Python` than between any of them and the language `C`.
4+
5+
We will not start by learning the syntax but immediately by reading bad code and searching for errors in it. Let's take a look at the following snippets, the first one will be in `JavaScript`:
46

57
```js
68
let first_num = 2;
@@ -9,6 +11,8 @@ let sum = firstNum + secondNum;
911
console.log({ sum });
1012
```
1113

14+
Try to understand what is written here and where there may be errors. And then compare this code with its translation to `C`.
15+
1216
```c
1317
#include <stdio.h>
1418

@@ -20,9 +24,13 @@ int main() {
2024
}
2125
```
2226

27+
The errors here are the same, they can be easily identified by a person, who does not even know the basics of programming, if he examines the code. And the next piece of code will be in `Python`, it does exactly the same and contains the same errors.
28+
2329
```py
2430
first_num = 2;
2531
secord_num = 3;
2632
sum = firstNum + secondNum;
2733
print({ 'sum': sum });
2834
```
35+
36+
Further, we will often compare code examples in different languages, search for errors and fix them, optimize the code, primarily improving its readability and understandability.

0 commit comments

Comments
 (0)