Stuff I do.

Which One Do You Think Is More Readable?

While randomly chatting with my friend, we started fighting on Ruby’s syntax and how readable it is. I, ofcourse, was defending Ruby to be the most readable.

I’ve been writing Ruby and Python equally for a good amount of time and have started exploring Scala and pure functional languages like Haskell.

Anyways, which of the following do you think is the most readable?

My personal take would be something like Ruby> Scala > Python == Haskell.

Hierarchial Casting

While working on one of my projects, I found myself having to typecast all the elements in a list into their appropriate data type. To give more prespective.

1
_list=["1","foo","3.5"]

I wanted them to be converted into an int,float and string as opposed to all strings. One of the hacky ways would be to use a regular expression to match the digits and type cast them.

However, It is not elegant and the regular expression may or may not cover all the cases. That set me thinking as to what would the idiomatic way to do such hierarchial casting.

Here is what I did.

  • First tries to convert it to int.
  • If the attempt to convert to int fails then it tries float, even if that fails it returns the actual string.

It is one of the nicities of python that it allows excepts to be passed, i.e the interpreter simply ignores the exception and moves on to the next instruction.

Devlog 2012-09-22 to 2012-09-29

Box:Get Up and Running With Rails

A couple of my friends who are learning to code have been lamenting about how much they had to go through before they could get a proper installation of ruby and rails up and running. Though,there are a lot of blog posts or tutorials out there that try to help them,I don’t see them to be solving the problem. Infact there are packages like Rails installer which litrelly provides an one click installation,however the installers seems only to be available for Mac OS X and Windows.

Hence,I wrote a quick script which downloads rvm,git,ruby,rails and other dependencies that are required. Let me warn you,it is very rudimentary,feel free to let me know if something didn’t work or something that I was stupid enough to miss. You can fork/clone Box here.

Hello World!

After a long struggle and a lot of convincing myself,I have decided to start blogging seriously there by documenting the ideas,problems that I come across and how I go about solving them,my perspectives of different things and ofcourse rants.I still haven’t decided how often I would blog,it is still a debate going on with in me. Blogging as when and I do stuff seems to be a good way to go about it,let us see how that works out.

Let me sign of with those customary two words “Hello,World!”

KTHXBAI