Friday, March 19, 2010

Using console in development

Today I had a discussion with my friend on usage of console during the development process. He excels in Java, and just can't get the idea behind the Erlang/Python/Haskell-style console, in which you can evaluate language terms. He uses Python as calculator, and that's all. Main argument is, "why you should need that? If you want to run your program, write a shell script that will execute it in any way you wish. For testing there are unit tests and special frameworks. Console is just too awkward."

I find it pretty useful to hit "Run" button in IDE and to be able to test my (small) code pieces by simply calling them with any arguments I like. IMO unit tests aren't so convenient at very early stages of development, especially when you're writing small program without detailed project documentation and all that enterprise-level stuff. Or if your function is non-deterministic, i.e. uses something like random number generation? In this case console is just simpler, as it allows you to examine the output by yourself and quickly decide whether it is correct or not.

Then, you can use console to perform one-time tasks without including their code in your project. For example, imagine you wrote Erlang function that fills Mnesia table with data, executed it and found that it has a bug and the data is wrong. What should you do? Of course, write "mnesia:clear_table(something)." in console, hit return, fix your function and execute it again. Without console you'll write some ugly one-time function or script just to delete it after a couple of minutes.

I don't try to convince somebody that console is completely essential and I can't live without it, but it's definitely very useful thing that simplifies a lot of tasks.

No comments:

Post a Comment