Ian Cropper

developer

Getting better at your language by learning a new one

When I was 14, I somehow convinced my parents that it was a good idea for me to be an exchange student in Brazil. To that point in my life, it was the biggest and most monumentous thing I had ever done. I had never flown alone, I had never learned a new language, aside from Canada, I had never even been out of the country. Looking back, I had no idea what I was thinking.

I guess I just never actually expected there to be so many....Brazilians.

Arriving in Brazil and meeting my host family, my easy-going nature helped me to keep calm, but I was scared. I know going in that my host parents didn't speak English, but the realization of it finally hit me and I had no idea what I was going to do.

It took me 3 months before I finally had enough of a grasp on the language to hold a conversation and understand what they hell people were saying, and that was the point that I really started seeing that I didn't even understand English.

In order to learn Portuguese, or any Latin-based language, you must spend a lot of time learning verb conjugation.

"Verb What"?

Verb Conjugation.

It's like understanding when to use "I saw" vs " he sees" or "I am going" vs "We are going". Growing up having spoken English, I had never realized that there were similar rules in English. I just spoke English. I never thought about conjugation, I never even thought that such rules existed. When I spoke, I wasn't asking "I wonder why sometimes I say "I eat" and other times I say "we have eaten".

During that time in Brazil, I learned more about the English language than I ever did from and "Language Arts" class in school. I could speak English, but I didn't understand it.

"Umm, Isn't this more of a programming based blog?"

Damn right it is.

A while ago I had an interview. I was very excited about the prospect of working for this company. Since I claimed that I was an expert in JavaScript, the interviewer over the phone said it would be fine if we did some programming questions in JavaScript. The question he asked was as follows.

"Write me a function that when used as such:


sayHello("why")("hello")("there")("friend");

I get the following output:

"why hello there friend"

Now I had studied up on currying functions and understood that in javascript, it was totally valid (and awesome) to have something like this

sum(3)(5); //=> 8.

All you had to do was return a function that accepted another parameter.


function sum(a){
	return function(b){
		return a + b;
 	}
}

But I had never looked into how to do this indefinitely.

I didn't get the job, but that question stayed with me for years. I researched how to do it online and the best solution I found was this.


function curry(fn) {
    return function() {
        var args = arguments[0];
        if(!args)
            return fn.apply(this);
        var child = fn.bind(fn, args + " ");
        return curry(child);
     };
}
curry(console.log)("Hello")("web")("dev")("team!")();

But even that wasn't exactly what the interviewer was asking for.

The moment.

A while back, I started teaching myself Scala. Not just how to program OO stuff in Scala, but actual Scala programming. If you don't know, Scala is a programming language that is very well known and widely used for it's awesome functional-programming capabilities.

It was during one particular lesson about higher-order functions that I had that same moment as I had in Brazil when I realized "I'm learning so much about English". But in this case, "I'm finally understand JavaScript!".

Remember that interview question? Lets solve it again now that we understand more about JavaScript.


function curry(word) {
    console.log(word, " ");
    return curry;
}
curry("hello")("web")("dev")("team!"); //=> hello web dev team!

So what are you trying to tell me?

Even if you have been programming in some language for 5 years solid and you think you understand it, you will understand it more if you teach yourself a new language. And I don't mean just learning the new syntax, I mean really learn the language.

Already know Java? Learn Lisp.

Already know C#? Learn Python.

Already know JavaScript? Learn C++.

If you're that person that has been using primarily a single language for the past 5 years, then you're me as a kid: just speaking English because you've always spoken English, not knowing why the rules exist or that they even do exist but speaking it anyway.

Truly learning a new language will teach you more about the languages you already code in faster and deeper than any course on that language..