English vs C #: is there anything in common in learning a foreign language and a programming language
Today we want to talk with you about comparing learning a foreign language with learning a new programming language. We will compare English and programming on the brainchild of the well-known Microsoft company - C #. Our expert Anton reflects on the topic.
I mastered English before I started learning C #. He studied both independently and at school. At the moment, my level is enough to watch TV shows without translation and read professional literature. First I programmed in Turbo Pascal, then in Borland Delphi, and then in PHP. Now in C #. I also write PowerShell scripts for basic tasks.
What does language learning usually begin with? From inspection of its atomic units. In a foreign language, these are letters and sounds ; in the case of a programming language, they are variables .
Further in the language we begin to study the construction of words, and from words we build phrases. In programming, we first learn elementary operations, which then turn into functions and procedures.
Compare for yourself:
Mary.
Mary is a girl.
Mary has a green dress.
Let's look at this from the point of view of programming: there is a variable “Mary” of type “girl” with the property “dress”, which has the value “green”.
The syntax of a programming language is very similar in structure to the construction of a phrase in English. Let’s take it even more broadly: a completed program can be compared with a story that obeys similar rules. We start with a description of the heroes of the work in the story and with a description of the classes and methods in programming, then we proceed to the development of the plot and the main logic, respectively, and end with the conclusions of the story on the screen.
Let's try to consider the "Three Little Pigs" from this angle. We have a “piggy” class with the properties “name” and “house”. There are instances of the class “first pig”, “second pig” and “third pig”. Next, you need to assign the values “name” and “house” of each piglet. How to program described?
Let's say it in English:
There are three little pigs.
The first pig's name is Nif-Nif, the name of the second pig is Nuf-Nuf and the third one is Naf-Naf.
Nif-Nif lives in a house made of straw, Nuf-Nuf lives in a wooden house and Naf-Naf lives in a stone house.
That in one thing, in another case, we designated three instances of the “piggy” class, and then each of them was assigned the values of the “name” and “house of residence” properties.
Now that we have considered the general structure, let's move on to the smaller parts. Above, I mentioned letters and phrases in a foreign language and variables and expressions in programming. By learning to express elementary constructions in C #, you can, after studying the rules for constructing sentences in English, try to build complete phrases.
Imagine that our hero stands in front of a guiding stone and reads where to go and what he will do for it. How to describe this with machine code?
Here we see the consequences of his actions: if Dobrynya goes to the left, he will lay down his head, if to the right, he will lose his horse, and if he is straight, he will receive happiness.
Now let's write it in English:
If Dobrynya walks to the right, his horse will die.
If Dobrynya walks to the left, he will lose his head.
If Dobrynya goes forward, he will be safe and happy.
As you can see, the same description of condition blocks and a description of changes in the properties of objects.
Knowing the programming language, you can learn the grammatical rules for constructing phrases in a foreign language.
And then everything is like in programming: we increase the vocabulary by memorizing new words. Compare this to reading MSDN and TechNet. Compose the learned words into phrases and sentences, and the sentences already dock together. It is like writing logic in a programming language. Anyway, that programming is a dialogue between a machine and a person or a machine with a machine, that human language is a communication between two people. Both there and there, language elements obey laws and rules that it would not be difficult for a person with a technical mentality to systematize and put into practice to their advantage.
Of course, this is only a reflection on the topic: this article does not call for the study of English in this way, but shows that he has the right to life.
On our site you can learn English for free, but with limitations. For unlimited access, there is a subscription, we give a discount of 500 rubles on this link (the discount is available after registration).
A bit about the background
I mastered English before I started learning C #. He studied both independently and at school. At the moment, my level is enough to watch TV shows without translation and read professional literature. First I programmed in Turbo Pascal, then in Borland Delphi, and then in PHP. Now in C #. I also write PowerShell scripts for basic tasks.
Language Elements
What does language learning usually begin with? From inspection of its atomic units. In a foreign language, these are letters and sounds ; in the case of a programming language, they are variables .
Further in the language we begin to study the construction of words, and from words we build phrases. In programming, we first learn elementary operations, which then turn into functions and procedures.
Compare for yourself:
Mary.
Mary is a girl.
Mary has a green dress.
Let's look at this from the point of view of programming: there is a variable “Mary” of type “girl” with the property “dress”, which has the value “green”.
Syntax
The syntax of a programming language is very similar in structure to the construction of a phrase in English. Let’s take it even more broadly: a completed program can be compared with a story that obeys similar rules. We start with a description of the heroes of the work in the story and with a description of the classes and methods in programming, then we proceed to the development of the plot and the main logic, respectively, and end with the conclusions of the story on the screen.
Let's try to consider the "Three Little Pigs" from this angle. We have a “piggy” class with the properties “name” and “house”. There are instances of the class “first pig”, “second pig” and “third pig”. Next, you need to assign the values “name” and “house” of each piglet. How to program described?
public Class Pig
{
public string Name {get; set;}
public string House {get; set;}
}
Pig pig1 = new Pig();
Pig pig2 = new Pig();
Pig pig3 = new Pig();
pig1.Name = “Nif-Nif”;
pig1.House = “Straw”;
pig2.Name = “Nuf-Nuf”;
pig2.House = “Wood”;
pig3.Name = “Naf-Naf”;
pig3.House = “Stone”;Let's say it in English:
There are three little pigs.
The first pig's name is Nif-Nif, the name of the second pig is Nuf-Nuf and the third one is Naf-Naf.
Nif-Nif lives in a house made of straw, Nuf-Nuf lives in a wooden house and Naf-Naf lives in a stone house.
That in one thing, in another case, we designated three instances of the “piggy” class, and then each of them was assigned the values of the “name” and “house of residence” properties.
Now that we have considered the general structure, let's move on to the smaller parts. Above, I mentioned letters and phrases in a foreign language and variables and expressions in programming. By learning to express elementary constructions in C #, you can, after studying the rules for constructing sentences in English, try to build complete phrases.
Imagine that our hero stands in front of a guiding stone and reads where to go and what he will do for it. How to describe this with machine code?
Switch (Dobrynya.Walk)
{
Case “Left”:
Dobrynya.Head = false;
Break;
Case “Right”:
Horse.Life = 0;
Break;
Case “Forward”:
Dobrynya.Happy = true;
Break;
}Here we see the consequences of his actions: if Dobrynya goes to the left, he will lay down his head, if to the right, he will lose his horse, and if he is straight, he will receive happiness.
Now let's write it in English:
If Dobrynya walks to the right, his horse will die.
If Dobrynya walks to the left, he will lose his head.
If Dobrynya goes forward, he will be safe and happy.
As you can see, the same description of condition blocks and a description of changes in the properties of objects.
Knowing the programming language, you can learn the grammatical rules for constructing phrases in a foreign language.
And then everything is like in programming: we increase the vocabulary by memorizing new words. Compare this to reading MSDN and TechNet. Compose the learned words into phrases and sentences, and the sentences already dock together. It is like writing logic in a programming language. Anyway, that programming is a dialogue between a machine and a person or a machine with a machine, that human language is a communication between two people. Both there and there, language elements obey laws and rules that it would not be difficult for a person with a technical mentality to systematize and put into practice to their advantage.
Of course, this is only a reflection on the topic: this article does not call for the study of English in this way, but shows that he has the right to life.
Reader Bonus
On our site you can learn English for free, but with limitations. For unlimited access, there is a subscription, we give a discount of 500 rubles on this link (the discount is available after registration).