Thursday, December 23, 2010

C retains the basic philosophy that programmers know what they are doing; it only requires that they state their intentions explicitly. - K&R

Similar statement was made by DHH in one of his recent keynotes about Ruby.

Thursday, June 19, 2008

On outsourcing

Outsourcing hurts innovation when people aren’t able to communicate frequently and casually. Frequent and casual conversations are impossible across nine time zones.

Farming out development to legions of programmers overseas will not create a differentiation advantage. When a software company outsources development, that company loses its capacity to innovate and its competitive advantage.

If you’re building an innovative software company, you need to retain your best and brightest programmers internally. Software companies entirely based in India can successfully innovate over the long term, as can U.S. companies or companies based anywhere else.

- From Joel Spolsky's 'The Best Software Writing I'

Monday, June 02, 2008

Woking with multiple rails versions on same machine

If you have multiple rails versions installed like this -

rails (1.2.6, 1.2.0, 1.1.6)
Web-application framework with template engine, control-flow layer,
and ORM.

And you want to create 3 applications using 3 different versions of rails, then here is the command -


$ rails _<railsversion>_ <app name>


To create rails application using rails-1.2.0
$ rails _1.2.0_  r120


To create rails application using rails-1.2.6
$ rails _1.2.6_  r126


To create rails application using rails-1.1.6
$ rails _1.1.6_  r116



Is this documented anywhere?

Tuesday, January 15, 2008

Concurrency starts now!

Reached chapter 7 of programming erlang. Concurrency starts now.
Let see how my brain-system handles this :)

Tuesday, January 01, 2008

3 liner list reversal

-module(mylist).
-export([reverse/1]).

reverse(L) -> reverse(L, []).

reverse([H|T], Rl) -> reverse(T, [H|Rl]);
reverse([], Rl) -> Rl.

Thats it!

Here is the usage -
mylist:reverse([0, 1, 2, 3, 4, 5]).

should give -
[5, 4, 3, 2, 1, 0]

Sunday, December 30, 2007

3 liner quicksort


qsort([]) -> [];
qsort([Pivot|T]) ->
qsort([X || X <- T, X < Pivot]) ++ [Pivot] ++ qsort([X || X <- T, X >= Pivot]).


Here is some explanation of above code.
- When the input list is empty, output empty list.
- Otherwise, divide the input list into 2 lists such that, one list will have all the elements whose value are less than Pivot and the other list will have all the elements having values greater than or equal to Pivot. 1st element from input list is a Pivot.
- Do above steps recursively on all the lists that you create and then join them keeping Pivot in middle of lists.

I think the explanation is way too complicated than the code itself ;)

Day by day, I have started realizing the power of pattern matching, list data structure and functional programming.

Note: Above code is taken from Programming Erlang. Similar code is possible with other FP languages like haskell.

Enjoy!

Thursday, December 27, 2007