While learning a new language it is important to identify what to reuse and what to unlearn. I experienced some funny moments while learning languages and interacting with others. Here are a some of them.
One of my friends, who has been a C follower, is learning Python and we keep discussing what he has discovered and how I had handled some things when I had started learning it. Like many, he started programming alongside reading and probably skipped some parts unintentionally. One fine day he called me and felt very satisfied when he said, “Man, Python supports pointers!” I was surprised and confused until he told me the line of code he came across.
def my_func(*params):
He digs pointers in C and has felt handicapped when he has tried to learn languages without them. Out of wishful thinking and habit, the first thing that came to his mind was that it is a pointer that he could use for manipulation. Only on some discussion did he come back on earth to realize that it was more about variable length parameter list for positional parameters. To make it worse for him Python also had **params, which meant a dictionary. Of course he hated Python and me for a couple of hours after that, and then was back on the track.
This example made me realize how important it is to leave something behind while taking in something new. And it is critical to realize what to leave behind, which unfortunately does not have a generic formula. Only out of experience can you truly know what to apply and what to not.
To think of, asterisks mean so many things in so many languages:
* is used as the multiplication operator in many languages * is used as Kleene star, used in regular expressions ** is used for exponentiation in Fortran ** is used for list subtraction in Haskell (* ... *) is used for comments in Pascal and Prolog /* ... */ is used for comments in C, C++ and Java
It is important to consciously think of * as an asterisk not as a pointer when you start learning something new, even if you have been programming in C for your whole life. The same symbol gets used for something else across languages and this can cause a nighmare if the syntax is not learnt with a fresh mind. I had such a experience because Python uses { ... } for dictionaries and Erlang uses it for tuples. Whereas Python uses ( ... ) for tuple.
Arrow (->) is another symbol that gets various meanings in different languages. It was difficult for a colleague of mine to accept that it was a block separator in Erlang, and again, not a way of
accessing member data or methods. Just like asterisks they get different meanings. Haskell uses ->
in type signatures. Similarly | has also surprised me many times.
Ethymology of symbols is a good place to look at how various symbols get used.
I am sure we can go on and on about this. But importantly this tells me that
unless I learn the new syntax afresh, it is going to cause problems. It is necessary to rollback to
asterisks and brackets and arrows before we start learning a new programming language.
[ Datum/Zeit: ]
Fri, 10 Aug 2007 08:41:22 +0000
[ Quelle: ]
Abhijit Nadgouda
http://feeds.feedburner.com/ifacethoughts/entries
[ Verweis - Nachrichtenkanal ]
http://feeds.feedburner.com/~r/Ifacethoughts/entries/~3/142668142/
[ Verweis - Eintrag ]