Archive

Tags

Recent Posts

A Receipt for Learning a new Programming Language

In the past few years I've found myself learning a bunch of new programming languages – Javascript (with some frameworks like Angular, React, Meteor and Node), Kotlin, Python and more. Being an experienced programmer, I always looked for the quickest way that will get me on the run with the new language. I must admit that sometimes it wasn't easy. Sometimes I didn't know where to begin.

I don't like to read the beginners tutorials because they full with explanations for, well, beginners. Things like what is a variable, what is a boolean expression and why when you iterate from zero to ten exclusively, it makes 10 iterations. I have to read a lot and waste a lot of time till I get to see the syntax I need. It's tiresome and boring.

But unfortunately, there is a real shortage in tutorials for experienced developers. I guess no one really bothers to write those based on the (indeed true) assumption that an experienced developer would probably manage to find his way through the formal API's without too much help.

After struggling with the same questions in every language, I've made a small list of useful exercises that I now write in every new language I learn. It's really a short list, but it leads me to the right places in the language and the exercises in it always help me understand the basic syntax of the new language.

So here is first part of my list. It's not complete, and there are cons, but for a starter – give it a try next time you want to learn a new language.

Exercise 1: Print "Hello World" on the screen.

Yeah, yeah, I know, it's banal, boring and oh so seventies, but I like the tradition. Besides, this small exercise will help you understand the following things:

  • How to compile and run a program.

  • How the simple output goes.

  • Is there a new line in the end?

  • Are there any special characters, like commas or semi-colon needed?

And while you're there, try printing some other stuff like the current date, your name and age and so on. You'll be amazed how much one can learn from some simple printings.

Exercise 2: Write a program that gets from the user the radius of a circle, and outputs the circle's area and perimeter. If the radius is not positive, make an error message.

This will help you to understand:

  • How input is done? Does it require casting?

  • How the conditionals are done.

  • How the simple arithmetic looks like.

  • How do you print strings and variables?

  • Are there constants in the language, and how do you write them?

And while you're there, try to make some more calculations. Calculate the square roots of an equation, generate a random number in some range or anything involving some math functions and floating-point arithmetic.

Exercise 3: Write a program that gets from the user a number, and prints how many even digits are in the number.

This is a great simple exercise that will teach you the loop's syntax and some other things:

  • How does the division work in this language?

  • Does this language have a modulus operator?

  • Which kind of loops are there?

And why not writing a loop that determines if each digit is unique in the number, or even to sort the number by its digits? It will get your hands used to the syntax (and sometimes to the oddities) of a new language.

Ok, so those are three exercises to begin with, in the future I'll write the rest. From my experience, they give you the right focus without bother you with beginners' stuff.

If you have your own ideas about useful coding exercises for migrating to a new language, or you like (or don't like) my examples, I'll be glad to hear.

  • Facebook
  • Twitter

©2018 by Shay Tavor Tutorials. Proudly created with Wix.com

This site was designed with the
.com
website builder. Create your website today.
Start Now