English vs C #: is there a common thing in learning a foreign language and programming language

Today we want to talk with you about comparing learning a foreign language with learning a new programming language. We will compare the English and programming on the brainchild of the well-known company Microsoft - C #. Meditates on our expert Anton.

A little bit about the background

I learned 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.

Elements of the language

What usually starts learning a language? With the inspection of its atomic units. In a foreign language, these are letters and sounds , in the case of a programming language, 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 yourself:

Mary is a girl.
Mary has a green dress.

Let's look at it from the point of view of programming: there is a variable “Mary” of the 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. Yes, we take even broader: a complete program can be compared with a story that follows the same rules. We begin by describing the characters in the story and describing classes and methods in programming, then proceed to the development of the plot and the basic logic, respectively, and end with the conclusions of the story and on the screen.

Let's try to consider the "Three Little Pigs" from this angle. We have a class “pig” with the properties “name” and “house”. There are instances of the class “first pig”, “second pig” and “third pig”. Then it is necessary to assign values ​​to the properties “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 is the Nif-Nuf and the third one is the Naf-Nif.

What is in one thing, that in the other case, we designated three copies of the “piglet” class, and then each of them was assigned the values ​​of the properties “name” and “home”.

Now that we have covered the overall 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. Having learned to express elementary constructions in C #, you can study the rules for constructing sentences in English and 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 be for. How to describe it 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 get happiness.
Now we’ll write this in English:

If Dobrynya walks to the right, his horse will die.
He will lose his head.
He will be safe and happy.

As you can see, the same description of condition blocks and a description of changes in properties of objects.
Knowing a 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, learning new words. Compare this with reading MSDN and TechNet. To make the studied words in phrases and sentences, and sentences already dock with each other. It is like writing a logic in a programming language. And in general, that programming is a dialogue between a machine and a person, or a machine with a machine, that human language is communication between two people. Both there and there, the linguistic elements are subject to laws and rules that it is not difficult for a person with a technical mindset to systematize and put into practice in his own favor.

Of course, these are only reflections on the topic: this article does not call for the study of English by just this method, but it shows that he has the right to life.

Bonus readers

On our site you can learn English for free, but with restrictions. For unlimited access there is a subscription, giving him a discount of 500 rubles via this link (the discount is available after registration).

Source: https://habr.com/ru/post/407789/

All Articles