Life, programming etc.

First baby steps towards DSL nirvana

July 7, 2009 · Leave a Comment

I am sure, you must have come across this term, DSL – Domain Specific Language, if you read blogs from some well known industry experts. Well, I read this term long back, and got interested in it, and even bought the MEAP version of Ayende’s excellent book (and the only available, at the time, in the market on the subject) on Writing DSLs in Boo.

Obviously, I tried to write a DSL after reading the book. Maybe, I didn’t read it thoroughly, or for some other reason, but I couldn’t write one. And then I read this quote by Richard Feynman – “What I cannot create, I do not understand.” Obviously I was thoroughly disappointed, and felt bad and what not, but somehow I couldn’t perform the DSL magic.

Then I came across this excellent article on Lisp and it’s melleability for doing magic (read bending the language at will) and I was convinced about the power of the language. Then somehow, I came across Clojure and started learning it only because it’s a Lisp variant for JVM. And, then suddenly, one day, after spending not a very substantial time with it, the light bulb did glow for me :)

So, a few of the basic characteristics which make a language suitable for DSL development are -

1) The language should have a very minimal syntax; yes, no semi-colons, no curly braces ;-) [ I mean, these are noise ]
2) There should be some way by which the language supports lazy evaluation

Enough rambling and time for some code. Look at the following C# code -


public string [] GetPathsOfAllFiles(string folderName, string extension)
{
    return Directory.GetFiles(folderName, String.Format("*.{0}", extension));
}

And now look at this code (please try to imagine the context behind this code; I’ll post more on this later) -


(defmacro source-files-of-type [file-filter from folder]
    (list 'GetPathsOfAllFiles folder file-filter))

And yes, the above is valid code, which will run on .Net :) by way of Clojure’s port on CLR. So instead of -


SomeClassOrObject.GetPathsOfAllFiles("C:\\abc", "*.txt);

one can write -


(source-files-of-type "*.txt" from "C:\\abc")

Do you notice a difference in the readability? And as I mentioned before, I’ve started learning Clojure a mere three months back. Sweet :)

I’ll be posting more on this once I am done with a first full implementation of a DSL, so until then, take care.

→ Leave a CommentCategories: Programming

The yield (return) usage

July 7, 2009 · Leave a Comment

The yield keyword is a C# 2.0 feature. It’s been a long time that C# 3.0 is in the market, so much so C# 4.0 is looming over the horizon. Yet so many C# developers are not aware of its usage. Even I was not 100% clear, until I read (long back) this post from Joshua. Obviously, it’s a must read for anyone who can’t explain the usage of yield return.

→ Leave a CommentCategories: Programming

The meaning of life

June 24, 2009 · Leave a Comment

I don’t know why, but looks like I like to read obituaries. Don’t get me wrong – I don’t like people to die, but the ruthless hand of time has snatched away many a beloveds from so many of us and will continue to do so irrespective of what we want / feel. It’s definitely a loss when anyone dies, but there are some, who, for some reason, leave a lasting impression on so many more. Maybe because they are intelligent, or have some other talent, or could be some other trait.

The first obituary I liked was covered in this post of mine. The other one which I read today and liked is about Erik Naggum, and this too contains pearls of wisdom. From whatever little I’ve read about him, it seems he was an extremely intelligent guy who was a Lisp programmer. [ Just a side note: I am also slowly getting convinced that Lisp might be the best computer language designed yet. I am using might because I've just started down the Lisp path and that too, not with Lisp itself, but with one of its variants, Clojure ]

If you too would like to read Erik’s take on the meaning of life, read this. Just wow. May he RIP.

→ Leave a CommentCategories: Spirituality

The art of programming

March 24, 2009 · Leave a Comment

Ok, so you are into software like me and chances are that you are good at one of the mainstream OO languages like Java, C# or C++. And obviously, you love your platform and the language, so much so that you are a fanatic or atleast a fan.

If you want a real good food for your brain, read The Nature of Lisp by Slava. I haven’t digested all of it, but I am shaken. For the past few days, I was unsure of which new language-paradigm to learn – Ruby-dynamic, or F#, Erlang – functional. Based on this article, I feel that I should go for Clojure – precisely because I found the concepts mentioned in the article amazing, and the fact that Clojure is a Lisp dialect, and its dynamic and functional, and last but not the least, it runs on JVM.

Should I say the history repeats itself? I used to be a wannabe Java programmer, who got a life saving .Net / C# drug ;-) which, unfortunately is losing its effect, after 5+ years; not the language, but the platform, for sure.

→ Leave a CommentCategories: Programming

The power of failure

March 24, 2009 · Leave a Comment

You sure must be thinking that recession has had a profound effect on me and I am out of my mind, so how about this -

“Human beings are the only creatures who are allowed to fail. If an ant fails, it’s dead. But we’re allowed to learn from our mistakes and from our failures. And that’s how I learn, by falling flat on my face and picking myself up and starting all over again. If I’m not free to fail, I will never start another book, I’ll never start a new thing.”

These are the words of Madeleine L’Engle, the author of A Wrinkle in Time. I took these from a book I am reading these days called Creativity by Mihaly Csikszentmihalyi. I’ll write a review of this book as and when time permits; needless to say it’s an eye-opener as was his earlier book called Flow.

Our society (the whole system, the education system) puts an undue emphasis on success stories and no-one chronicles (worthwhile) failures – not even media, whose only survival strategy is based on all things -ve ;-) . Sometimes, even our families are a culprit. So we fall prey to this whole ’success’ sutra and with age, fail (and forget and become loathe) to take any risk – why? For the risk of failure. Yet, many successes are based on previous failures.

So go and fail ;-) but don’t fail at the same thing again and again, or maybe even that is acceptable. I am not sure on this last one :)

→ Leave a CommentCategories: General · Spirituality

An easy life doesn’t teach us anything

February 8, 2009 · 3 Comments

There are innumerable such beautiful quotes by Richard Bach -

“An easy life doesn’t teach us anything. In the end it’s learning that matters – what we’ve learned and how we’ve grown.”
“We design our lives through the power of choices.”
“We are each given a block of marble when we begin a lifetime, and the tools to shape it into a sculpture.”

If you want to hear one person’s travails of quitting a comfortable, well-paying job, selling his house and living on savings (even when he was married and had a daughter) and trying to do something on his own, then look no further. That person is Damien Katz, creator of CouchDB and this is his story, in his own words.

As is evident by his talk, his prime reason for doing all this was not money – but an ardent desire to work on some cool stuff, and an equally strong urge to experience life, minus the expected stuff i.e. the routine job, the same endless loops created by consumerist mindset etc.

There are a couple of important points to take away from his talk -

1) Sometimes, we don’t necessarily have to have a clear picture in mind, of what we want to do, if we are trying to create something new – Damien didn’t even know at the time of quitting as to what he wanted to do, but later as he started working, the pieces of jigsaw started getting into places (gradually).

2) Money and fame are not the most important things in life – however much the modern society tells us otherwise, the reality is something else.

3) He will complete what He has begun – it’s true, at least for Damien.

4) We have to have an interesting story of our LIFE (listen to Damien).

So what’s your life-story? :)

→ 3 CommentsCategories: Business · General · Spirituality

The Satyam fiasco

January 13, 2009 · 5 Comments

Well, for the benefit of my friends, who aren’t from Indian sub-continent, and / or who aren’t familiar with one of the Indian languages, the word “Satya” in Hindi (and some other Indian languages too) means “Truth” :) so it seems the founder, B Ramalinga Raju, forgot to append a leading “A” in the name of the company ;-) [ btw, "Asatya" means "False" in Hindi ].

I still vividly remember him (Raju) standing by his Mercedes in one of the popular magazines in IT (maybe Dataquest) a few years back. It was definitely awe-inspiring to someone fresh out of college and starting his career. Hardly did anyone (or me) imagine that this guy (or a “former” CEO of one of the biggest Indian IT companies) would stoop to such levels.

Co-incidentally, but not surprisingly at all, he hails from a community which is already notorious (in India and amongst Indians in US) for doing all kinds of stuff (read cheating) in the IT industry. Hyderabad city, where Satyam’s headquarters are located, also boasts of making (fake) industry certifications like MCSD, Java Sun certification etc. salable. The Times of India, in today’s edition (dated 13 Jan, 2009) carries a report of how Raju duped the APIDC (Andhra Pradesh Industrial Development Corporation) of Rs. 52 Lakh, 25 years ago.

I know of at least one person who would be happier than me after reading all this – my dear friend, Hari Raghava Bhargava; because of the profligacy we’ve seen in the Indian IT industry, and also because we’ve seen in how many different ways, a perfectly good project could be screwed. What more proof is needed than the fact that most of the managers in such Indian IT service providers are either non-technical (came from some other industry, though very rare), or off-technical (a DB guy managing Java or C# projects, very common) or obsolete technically (a PB guy managing, some OO projects, again very common) and they are the ones who are actually drawing fat salaries as compared to the programmers, or the guys who actually get the things done.

Also, what more can one expect from an industry which stands on only one pillar – cost (or to be more precise, lower cost)? Most of the time, I hear people (Project Managers) talking about any project in terms of revenues (x-million dollar contract) or cost (x man-days; which was y man-days lower than what the z company could quote for).

Well, if you think I am talking BS, then please be informed that I’ve worked with one such big (amongst the top-five Indian software service provider) firm for a little more than 3 years.  I once asked my BUH (Business Unit head) that why do you accept such ridiculous time lines (doing a project in x/3 man-days, when reasonably, it should take x man-days)? His terse reply – “So what do you want to say? I should lose business to some other Indian company”?

And I perfectly understand his position. But the sad part is that the US companies, who actually own that piece of software, are ready to accept such code, because, again all they care about is BUDGET!!! So the lowest bidder wins :( Would the guy accepting the proposal of lowest bidder, take the same decision, if he were building his own house?

And once an Indian company gets the project (on such terms), it resorts to all kinds of mis-doings like “ghost-billings” – i.e. billing for a person when he is actually not working on that project. And believe me or not (I don’t care), but I’ve seen it with my own eyes. Yes, I may not be able to prove it, but talk to any Indian (with the condition that his identity won’t be disclosed) if this happens in their own company? You’ll be surprised or shocked, but mostly both :)

I think I should stop this rant, because it is more than evident now, that capitalism (practiced in its extreme) also has its own pitfalls. Need I point you to scores of American companies (like Merrill Lynch, GM etc.) or whole industries (investment banking, auto) ;-) ? US has a true competitor here, India is not far behind…

Of course, what happened (Satyam) is really bad for Indian software industry, but if things don’t improve, like -

1) hiring technically solid people and paying them a lot more than the other average guys
2) dismantling the BS pay-brackets i.e. for x-y years of experience, Rs. a-b salary range, or Programmer Rs. a-b Lakhs, Senior Programmer Rs. c-d Lakhs, where obviously, a < b < c < d and so on…
3) taking proactive steps for corporate governance like zero tolerance (kicking a guy out, if he indulges in any malpractices) and setting up email ids where any employee can anonymously post occurrences of such malpractices
4) taking pride in delivering projects on some other scale than merely, cost and revenue
5) useless yearly reviews, which state that performances of members of every project has to fit the bell curve (exceptionally good or bad performances rare, and average performances common), which is true, but what is also true (and conveniently but purposefully overlooked) is that a programmer doing a good job on a fresh development project is better than a programmer doing an exceptional job on a maintenance project

the day is not far off when this sunrise industry (for India) may be doomed for an early sunset.

I sincerely wish that I may be proven wrong.

→ 5 CommentsCategories: Business · General

The future

January 3, 2009 · Leave a Comment

I am sure you must’ve read that you just can’t wait for the future to happen to you, but you need to create it. To be frank, I don’t take this statement at its face value, but feel that there definitely is some element of truth to it.

I worked in different software companies in India – some were typical service providers, and one of them was a product-based company, where, of course, I enjoyed my stay of 3 and a half years. Do I need to tell you that I won’t like to comment much on the remaining 4 years ;-) although it was a mixed bag, as most of the life is.

Then I came to US in search of the elusive $$$ :) and good work. But guess what, here also, the fight to get both the good work and the money continues. It’s much easier to get only one of them as compared to getting both together. So I’ve started feeling lately, that the solution to my woes could be to start on my own.

Of course, I am fully aware that I haven’t graduated from any ivy-league institution, and I am far from a geek, and I am also taking into account the interesting relationship between work and money as highlighted in Seth Godin’s post (see my previous post for the link). But since I am an optimist, I would like to remember the twist in Seth’s post.

Also, articles such as Start Now: 6 Reasons Why This Economy Is Good For Startups are a great help to keep me motivated toward that lofty goal. I would like to read this daily morning (again, from the above link) -

“If you don’t start, you’re doomed to a life of trudging through jobs, depending on someone else for salary and bonuses and health care and retirement, a life’s work without ownership or upside.

You’re better than that.  That’s why you’re reading this blog.

So go for it.”

Think about it. Have you created something of value in your life so far? Or would you like to create ‘the future’ for you, or atleast create something of value and leave a legacy?

Well, I would love to do so. Hence, if you feel the same, we could join hands.

Wish you A Happy and Prosperous New Year :)

→ Leave a CommentCategories: Business · General

An interesting article on work and money

January 3, 2009 · 1 Comment

Seth Godin has a very interesting post on the relationship between work and money – Maybe you can’t make money doing what you love. And the best part is in the twist at the end. A must read.

→ 1 CommentCategories: General

How the tastes / habits change

December 7, 2008 · Leave a Comment

Circa 2003, I was stuck in a never-ending maintenance (read DEAD) project in good old VB6, and although I had posted my resume on many job sites, obviously there weren’t any takers. While my Java brethren were happily landing plum offers. Enter .Net and my saviour C# – as soon as I came to know about this platform and language, I realized here’s my chance to enter into the mainstream world of OO languages and I chose C# over VB.Net because of my liking to Java, my familiarity with the syntax of C family of languages , as well as the stigma ;-) attached to the VB6 developers as not serious ones.

After some initial struggle, I got into a new company and a new project in .Net with C# using VS 2000. One of my close friends, Dhawal Mehta, at the very same time was working on another project in .Net using VS 2000 but in VB.Net. Sometimes we used to have discussions as to which language was better. No marks for guessing who was supporting which. I obviously, vehemently opposed VB.Net and favored C#, so Dhawal gave me a concrete example – in those days, if you declared a delegate and tried to call it asynchronously, the VS didn’t give you any intellisense in C# for the BeginInvoke or EndInvoke methods, but it used to show the intellisense for VB.Net so I told him, that it’s the IDE problem and not a language problem.

So he asked me once, why do I hate VB.Net so much. I told him plainly, that it is too ‘verbose‘. He reluctantly agreed to it. After some time, he had to work in .Net using VS 2000, but this time he had to use C# :) And boy, he was hooked to it and got my point of view – VB.Net is definitely verbose he said.

Circa 2008 – I’ve been happily working on the .Net platform using C# as the language. I am reading Ayende’s book on DSLs in Boo and of course Boo is a great language. It has many advanced fundas like open compiler pipeline, which I am not thorough with yet, but have a look at the pic. below -

languagecomparison

Don’t you think even C# has a lot of noise in the form of line ending “;”, curly-braces etc. There are so many other features which make even C# look verbose in comparison to Boo. e.g. you might have seen some coding guideline (for C#) that even if there is a single line statement in the if condition, you must enclose it in { }? The oft quoted reason is that tomorrow somebody else should not accidentally put a line of code, which becomes a part of the if statement. However, Boo works on indentation – just indent the statements after “if” and they form the “if” part of the if-condition. Plain and simple. No noise. And no need for coding guideline that I mentioned above.

Definitely, it takes some time to get used to it, but just work on it for some time, and I am sure you’ll get addicted.

If you like what you’ve read then please read the Ceremony vs. Essence part of this post, and this one from Neal Ford. And just think, an important concept like design patterns (some of them) is ceremony for some folks :) Similarly, this post states that Strategy pattern exists because there is no place for a function in an OO language outside of a class!!! Starting to make sense to me plus the fact that MapReduce kind of things can’t be done with plain OO.

I know the example I’ve given is too simplistic, but essentially, I’ve started feeling that I am working with a high ceremony language.  Looks like it’s definitely time for me to start exploring the dynamic or functional territories.

→ Leave a CommentCategories: Programming