Thursday, April 19, 2007

JAVAScript is difficult..

Yesterday I had an opportunity to have a chat with Dr. Sanjiva Weerawarne. Once I told I feel 'working with javascript is more difficult' than 'working with C/C++/java' he seems not much convinced.
Well my reasons were..

1. Javascript is still difficult to debug. Even though there are great plug-ins like firebug which support Javascript developer very much, javascripting is still difficult to debug. I feel its better put 'alert's in most of the cases.
2. You have to take decision which part should be kept in server or client.
3. Javascripts more than 1000 lines of codes doesn't mean any thing, as it eat 30/40kbs bandwidth. so client should be kept thin.

In addition to them, there are some reasons to prove why javascript is really tough.

1. Browser dependency..
C programmers may tell it is normal;). They work with machine dependent or OS dependent stuff. Actually javascript not much different from browser to browser if you only use only the basic functionality. But the browser independence come into the action sometimes in very minor cases.
for an example: if you type
div1 = document.getElementById('div1');
instead of
var div1 = document.getElementById('div1');
//note the starting 'var' keyword

It works on Mozilla, but in IE it don't work. But if you use javascript variables not declared with 'var' in other situations, it works nicely.

So when you write a big javascirpt work nicely in mozilla and you realize it dont work in IE which dont have a good debugger, It takes a while to realize that the error is due to such a small mistake or a misunderstanding:).

2. To be a javascript expert you need to be expert on HTML, CSS and most probably in PHP or some other server side language as well.

3. Javascript should have functions to do drawing at the canvas like drawLine(x,y) drawRectangle(x,y,width,height). That is the main difference you feel in javascript if you just come from Java/ C++ GUI developing. Javascript have some handy ways to draw lines using some DOM manipulations but not many people are stupid to use that to do a simple drawing.

Although I complain a lot about Javascript, It is a great language. I'm still a beginner, I hope I will feel comfortable with it as time goes on. This hope itself is some months old. But I'm still suffering.:(

No comments: