Programming Linguistics: an approach to learning new programming languages

Emiko N-P.
3 min readSep 13, 2021

--

Learning a new programming language can be a bit intimidating, with all its syntax and rules and data structures. In order to help new programmers have more confidence jumping into coding I wanted to share how I approach learning a new programming language, and some of the ideas and tools I use to help me pick up tricky concepts quickly.

One of the things that helped me the most with quickly picking up new languages was to think of them as, well, languages. A programming language is simply a language that the computer speaks. Going along with that idea, we can think of programming syntax as the ‘grammar’ of the language. Like grammar in a real language, it has certain rules that must be followed or you will wind up with a sentence that is unintelligible. For example in English “I am going to the store.” is perfectly valid sentence, but “The store to I am going.” doesn’t make any sense. Similarly in Ruby

def go_to_storeputs ‘I am going to the store’end

is totally valid

end go_to_store‘I am going to the store’ putsDef

Makes no sense to the computer and will throw an error. At the same time, this also means there can (and usually are) multiple ways of saying the same thing. For example “Is this container is empty?” and “Does this container have nothing inside?” both amount to the same question, and will receive the same information in the answer. This holds true in programming languages too:

array.empty?

and

array.length == 0

Are both asking going to return the same answer. Something really important to keep in mind when learning programming is that both of the examples above are totally valid and neither is inherently better than the other, just like in English there is no inherently right or wrong way to ask if a container is empty. This means that in programming there is no ‘right’ way to write a program, so don’t worry if your code doesn’t look exactly like someone else’s so long as it works.

Another thing you have to take into account when programming is how the computer will interpret the code you are writing. I like to think of it as being a bit like giving instructions to a Vulcan. The computer is completely logical and has no feelings, so it’s going to do exactly what you ask it to do in precisely the order you ask it. This means that it can’t understand anything that’s out of order or not quite right. Going back to our previous example, if we were to write “I ma gong to the store” most English speakers would notice that this sentence have typos but would still be able to understand what is being conveyed. On the other hand, the computer reads the typos literally and can’t understand them since they aren’t words, so if we were to write:

Df go_to_storePut ‘ I am going to  the store’End

We would see a syntax error because the computer can’t understand the word df or put, only def and puts.

If we put all the ideas we’ve discussed above together, we know we need to give the computer logical instruction in order, and with correct spelling and grammar. Ideally, we also want those instructions to be as easy and clear for humans to read too, so that other programmers can easily read and understand our code and so that it is easier to debug.

So, there are my approaches to learning new programming languages! I hope that these analogies and concepts will be helpful to other programmers who are daunted by approaching a whole new language. Happy coding!

--

--

Emiko N-P.
Emiko N-P.

Written by Emiko N-P.

0 Followers

Hello, my name is Emiko. I am an aspiring Software Engineer and student at Flatiron School.

No responses yet