I started reading "Kotlin in Action", and as I write this, I'm in the second chapter.
Having used Java for years, what worries me a little is whether type inference impairs readability.
Let's say we take the example in the book,
fun max (a : Int, b : Int) = if (a > b) a else b
For someone reading this code, it's not obviously as to what the return type is, unless they read and understand the implementation (the 'if' expression on the right in this case).
Although the return type of the function is optional only for functions with an expression body like the example above, and not with a block body, it's not totally comforting. For instance,
fun compute(a : Int, b : Int) = if (a > b) xyz(a, b) else abc(a, b)
Also, in the first chapter, there's an example regarding automatic typecasting:
if (value is String) {
// value is now typed as String
println value.toUpperCase()
}
In the example above, the reference 'value' gets casted automatically within the body of the 'if' block to String, which is why you can call toUpperCase without casting it to String explicitly. What this means is that whenever I see a variable in any place in the code, I can't keeps its declaration-time-type in mind while reading the code to know what type it is of; instead, I should always rely on the IDE to tell me what exactly it is. This is quite unsettling as well.
My opinion
Thursday, February 8, 2018
Monday, November 18, 2013
AGN client daemon restart
I use the AT&T network client in my Linux laptop to make VPN connections.
Occasionally, it doesn't connect, and I figured that when it does that, a simple restart of the agnclient daemon fixes the problem.
sudo service agnclientd --full-restart
Occasionally, it doesn't connect, and I figured that when it does that, a simple restart of the agnclient daemon fixes the problem.
sudo service agnclientd --full-restart
Saturday, August 10, 2013
Games and psychology
I like computer games. Not that I play them a lot but they're good if played when in a good mood. And I'll tell you why.
When my mood is good, Angry Birds appear cute and joyful. Temple Run appears a heroic affair and Subway Surfers feels like playing a naughty prank.
But when my mood isn't all that great, all I see in Angry Birds is poor birds getting themselves killed. All I get from Temple Run and Subway Surfers is that you are destined to die - one way or the other. No matter how many coins you collect, no matter how many heroic deeds you pull through, it's only a matter of time before you die a merciless cold death.
Isn't that strange - the exact same game feels vastly different based on your internal state of affairs. The real world is probably similar too. Keep your thoughts clean and joyful and you'll find the world a wonderful place to be in. Keep hatred and sadness inside you and you'll find the whole world conspiring against you.
Well, maybe that's so. God knows.
When my mood is good, Angry Birds appear cute and joyful. Temple Run appears a heroic affair and Subway Surfers feels like playing a naughty prank.
But when my mood isn't all that great, all I see in Angry Birds is poor birds getting themselves killed. All I get from Temple Run and Subway Surfers is that you are destined to die - one way or the other. No matter how many coins you collect, no matter how many heroic deeds you pull through, it's only a matter of time before you die a merciless cold death.
Isn't that strange - the exact same game feels vastly different based on your internal state of affairs. The real world is probably similar too. Keep your thoughts clean and joyful and you'll find the world a wonderful place to be in. Keep hatred and sadness inside you and you'll find the whole world conspiring against you.
Well, maybe that's so. God knows.
Tuesday, August 6, 2013
Fun with DuckDuckGo's RoboDuck
If you haven't heard it yet, duckduckgo is a search engine with an emphasis on privacy. If you're interested, read more of their views here, here, and here.
And today I came across this little chat bot called RoboDuck that they've put up on their community site https://dukgo.com/roboduck. Although there doesn't seem to be any practical use of this RoboDuck thing, one can nevertheless have some some fun with it :-)
(Read it in reverse order. Oldest chat at the bottom, newest on top.)
And today I came across this little chat bot called RoboDuck that they've put up on their community site https://dukgo.com/roboduck. Although there doesn't seem to be any practical use of this RoboDuck thing, one can nevertheless have some some fun with it :-)
(Read it in reverse order. Oldest chat at the bottom, newest on top.)
Monday, July 1, 2013
Tools to keep your javascript clean
Javascript is a special language. You can learn it easily, you can write useful code easily, and more importantly, you can introduce bugs even more easily.
JSLint is a code quality checker that can catch some common bugs in your javascript:
http://www.jslint.com/
A fork of JSLint that can catch fewer bugs, but is more convinient to use if you already have a big buggy code-base:
http://www.jshint.com/
A great site explaining the reasoning behind the errors and warnings flagged by JSLint:
http://jslinterrors.com/
JSLint is a code quality checker that can catch some common bugs in your javascript:
http://www.jslint.com/
A fork of JSLint that can catch fewer bugs, but is more convinient to use if you already have a big buggy code-base:
http://www.jshint.com/
A great site explaining the reasoning behind the errors and warnings flagged by JSLint:
http://jslinterrors.com/
Sunday, March 31, 2013
DB2 Error messages in SquirrelSQL
SquirrelSQL is a great tool for working with databases. However, I had a bit of trouble running queries against DB2 databases. When a query had a syntax problem (or encountered any other error during execution), it would just show me the SQL Error Code, not the human-readable error string.
There's an easy way to fix that:
In the connection alias, add a property that says:
retrieveMessagesFromServerOnGetMessage=true
jdbc:db2://<server>:<port>/<db-name>:retrieveMessagesFromServerOnGetMessage=true;
Excerpt from the DB2 infocenter:
"During a connection to a data server, set the retrieveMessagesFromServerOnGetMessage property to true if you want full message text from an SQLException.getMessage call."
http://pic.dhe.ibm.com/infocenter/db2luw/v10r1/index.jsp
There's an easy way to fix that:
In the connection alias, add a property that says:
retrieveMessagesFromServerOnGetMessage=true
jdbc:db2://<server>:<port>/<db-name>:retrieveMessagesFromServerOnGetMessage=true;
Excerpt from the DB2 infocenter:
"During a connection to a data server, set the retrieveMessagesFromServerOnGetMessage property to true if you want full message text from an SQLException.getMessage call."
http://pic.dhe.ibm.com/infocenter/db2luw/v10r1/index.jsp
Saturday, January 12, 2013
Gorgeous stone carvings
When I was in Tamilnadu last month, I was delighted to see some wonderful stone carvings in the temples there.
Here a sample of what I saw:
Apart from being beautiful from a distance, these stone carvings are a pleasure when observed closely as well. Just look at the beauty here of this stone lion's mane - brilliant!
Here a sample of what I saw:
Apart from being beautiful from a distance, these stone carvings are a pleasure when observed closely as well. Just look at the beauty here of this stone lion's mane - brilliant!
Subscribe to:
Posts (Atom)