Function references in Scala October 17, 2011Posted by CK in Software.
Tags: Languages, Programming, Scala
add a comment
I’m starting to learn Scala, and have some trouble coming to terms with its syntax. Maybe I’m spoiled by Python. In any case, here’s an example of things that I find annoying:
scala> def f(x:Int):Int = x
f: (x: Int)Int
scala> def g(f:Int=>Int, y:Int, b:Boolean):Int = if (b) g(f, y, false) else y
g: (f: (Int) => Int,y: Int,b: Boolean)Int
scala> def h=f
:6: error: missing arguments for method f in object $iw;
follow this method with `_' if you want to treat it as a partially applied function
scala> def h=f _
h: (Int) => Int
So basically, although it is fine to use just f when defining function g, in the definition of function h it is necessary to postfix f with an underscore.
I haven’t read the language reference yet, and there may be good reasons to do it like this (although I can’t think of any right now), but the inconsistency is quite confusing.
Why Google will never lose February 7, 2010Posted by CK in IT.
Tags: Character sets, Google, Google maps, Languages
add a comment
Because they understand what users need.
I just found out that, if I search in Google Maps for “κάρλοβι βάρι” (this is Karlovy Vary, the Czech town written in Greek without any sort of strict/standardized mapping between the two alphabets), I actually get the map I want. I knew if I searched for a Greek street using Greek alphabet I would get the result I wanted, even if it’s in their database in English. But for places outside Greece, I did not expect this. I assume that they normalize between different languages and search for the result of this normalization (which is probably in English). Amazing.
Clojure November 6, 2009Posted by CK in IT, Software.
Tags: Clojure, Jython, Languages, Programming, Python, Scala
1 comment so far
Even before I actually study it in detail, Clojure becomes my latest fixation. A Lisp-based functional, general-purpose language, which produces JVM bytecode and has access to Java libraries? Sounds like a dream come true. I never liked Java, and as a matter of fact, I consider myself a Java-dyslexic. No matter how much I tried in the past, I never got around learning enough of it to use further than “Hello, world”s. Its syntactic resemblance to C, with which I am (was?) quite proficient, didn’t help much. Nevertheless, the breadth and depth of libraries that exist in Java are mind-boggling, and the ability to use them with a different language is just great. I know there are other JVM-based languages, e.g. Scala, but somehow after reading introductory material they never enticed me enough. Also, I really don’t know how come, although a big fan of Python I never tried Jython. I assume I just preferred the real thing — Python also has an extensive and compelling set of libraries.
In any case, I’ll try to get a closer look at Clojure and come back with a more complete opinion.
Python is like cycling May 15, 2008Posted by CK in IT.
Tags: Google Translate, Languages, Python
add a comment
So I’m here in Dortmund for the third day now, and I can tell you that if I didn’t have the help from my local colleagues, it would be totally impossible to get by without speaking German — at least for this first batch of paperwork and house hunting. In the process of looking for a flat to rent, I have been searching in newspapers and web sites, all of which are in German. How to deal with that?
Enters Google Translate. Very efficient and quite correct, as it turns out. But then again, opening a browser and clicking on a bookmark etc all the time is a bit of a hassle.
Enters Python 🙂 My bias towards this language is well known to those who have been working with me in the recent years. I haven’t really written any real code for a long time now, more than 4 years actually, but in less than 30 minutes (also putting WebScarab in use, I managed to have a simple but fully functional command-line client for Google Translate in place.
Clearly, Python is like cycling; Once you learn it, you never forget it.