Zwetan Kjukov

My main interests are:

What I plan to do here on the wiki:

ECMAScript is misunderstood and most of the time underestimated, so I'll try to add content to this wiki to help people get a better understanding of this great language. :)

EDIT: I don't have the time to do everything so I will try to concentrate on editing my blog - http://www.zwetan.com/ and hopefully try to inject some of the content here at the appropriate places.


Some small contribution in:


Pages I would like to contribute to:


I'm an ECMAscript fan because:

ECMAScript is most misunderstood because: ECMAScript is capable of: (hopefully I hope I'll have time to give elaborate examples of all that)


Great documents/articles/etc... about prototype-based languages:

Great documents/articles/etc... about ECMAScript:


Public question:

Is it normal to feel overwhelmed by total stranger who completely changes my small contribution to something which I think is unreadable and unusable? No - that would be unusual, and probably unintentional.

How do you place (or force) a CR or a LF inside the wiki? (I searched TextFormattingRules, etc., but I didn't find the answer.)
In general, you can't. However, single newlines are rendered for lines starting with whitespace, such as monospaced text lines. Other workarounds are deprecated. The use of characters (such as newline) in situations where they won't be rendered is also discouraged.

is it considered rude to clean up the comments and discussions in WikiMail or keeping only the EcmaScript related subjects ?


Leave WikiMail here:

Important note: if you want to comment or leave a message ok do it, if you want to do it anonymously also ok, but at least provide a personal mark (anything) so I can differentiate your comments from another personn comment. Think it that way I'm stupid, if numerous comment come in a raw I will simply consider they are from the same personn :).

another note: I don't think discussion as in newsgroups discussion should occur here on a "personal page", why not bring the subject to a plain wiki page if the subject worth it ?

You're a javascript fan, so am I, what do you like about it so much? I like higher order functions such as the common... -- anonymous

(could you tell me who you are?)

It is part of wiki practice for people to remain completely anonymous if they please. (I'm not the person you were asking, by the way, I'm just commenting on your question) [humm so that's why I feel disoriented, if people who commenting directly to a "personal" page don't announce clearly if there are the same people or not that the other it can become HARD to follow the conversation -- zwetan]

  forEach(document.getElementsByName("*"),function(each){
    alert(each.outerHTML);});
or
  var tallItems = select(document.getElementsByName("*"),function(each){
    return each.style.height>50;});
or closures to hook behavior to the UI
  when(window,"onunload",function(){
    window.opener.close();});
or
  when(document.body,"onclick",function(anEvent){
    alert(anEvent.srcElement.outerHTML);});

hello :) humm I got a different interest, here you're talking about programming the DOM with JavaScript, I'm more into build program using the ECMAscript prototype-based "way" of thinking and furthermore I don't think forEach and when are keywords defined in the ECMAscript specification (or perharps you had wrote fast in a pseudo-language way?). I'll try to explain all that in a better way in the future, things like: programming closer to the objects, delegation, closure, use of prototype for visualproxy (instead of MVC), etc... -- zwetan

No, I don't care about the dom, it was just sample code.. and foreach and when are higher order functions to make the code look cleaner and remove duplication, I only have my for loop's in my higher order functions, I don't write loops in regular code... here they are -- anonymous

  function forEach(aList, aFunction){
    for(var i=0;i<aList.length;i++)
      aFunction(aList[i]);}

when(anObject, anEvent, aFunction){ anObject.addEventListener(anEvent, aFunction, true);}
I like prototypes too, but functions and closures are just as useful, whether you're using DOM or Scripting Host.

OK no problem, I had answered quickly and did not spot the functional programming ;), I'm quite sure you know this web page: http://w3future.com/html/stories/hop.xml which have an insteresting article about this subject.

Functional programming is really powerful but IMO it tends to obscure the code clarity, so I prefer to write the for... loop each time I use it; in some cases, you cannot add a higher order function which can deal with every case you need, for example double condition in a loop: -- zwetan

 sample_method = function()
    {
    var i, j;
    for( i=0,j=10; i<11; i++, j-- );
    ...
    }

That's funny, since the whole point of functional programming is to make the code more readable. For loops are low level and unnessary, why not just make that idiom into a function called forEachDoubleCondition and then call it when you need that pattern. Functional programming says patterns are a smell, you should be able to abstract the pattern into a single function with a name. You can always create higher order functions that are more clear than the equivalent code. Thanks for the link though, nice little site, I didn't know about it. Oh, and JavaScript rocks!

IMO code must be readable, algorithm and/or patterns must be identifiable inside a code, so I does not agree at all with what you're saying. I don't know your background and if you are into programming seriously or not, but I can assure you that for even a small project with a ECMAscript-based language (let's say 2KLOC) replacing all the low level loops with function will simply make the whole program unreadable, hard to refactor and really really difficult to maintain. -- zwetan

First off, I've done large over 2kloc projects in Javascript, and am in fact doing one now, and let me tell you someting, replacing all the low level loops with higher order functions has drastically reduced the amount of code I had to write, and has also made the program much easier to read, and far far easier to maintain. Functional programming is superior to imperitave programming, and patterns in you code... show a lack of abstraction, patterns are not a good thing imho. I've studies many languages, and all the good one's, use higher order functions to do the bulk of their work, things like.. map, filter, select, reject, detect, do, foreach, reduce, inject, remove, all of which are easily done in javascript. So if you aren't using HigherOrderFunctions to do much of your work for you, I think you need more exposure to better languages. Writing loops by hand is low level simple stuff for simple code. If my being anonymous gives you reason to not take my comments seriously, then I think you need to learn a little more about wiki, aninimity is preffered, allows rational discussion without ego's getting in the way. I've been here a long time, and have been programming a long time, don't insult me just because you don't know my name.

[Yeah, Zwetan, be careful about comments like that. There are many highly knowledgeable and experienced people here, and yet they frequently disagree]

Well now after 3 15KLOC projects under my belt I feel I can make a more educated answer (well I hope). What I find unreadable about a higher order function is when you use it like a language keyword defining it as a global function

  map( someAction, toAnObject )

Sure if you are the one who have wrote it you will have no problem to use it without even thinking about it, but in the case of people reusing your code they will have to go read its implementation to really understand what you mean and in which context its appropriate to use it, the simili keyword is just too abstract.

But if you define something as

    Array.prototype.map = function( /*Function*/ callback, thisObject )
        {
        var arr, i;
        arr = [];

if( thisObject == null ) { thisObject = _global; }

for( i=0; i<this.length; i++ ) { arr.push( callback.call( thisObject, this[i], i, this ) ); }

return arr; }

There you associate a context to the map keyword and its usage are more obvious imho. Someone seeing "[0,1,2,3].map( toRomanNumber )" in your code will not really need to go see the method implementation to understand its use. -- zwetan

[I believe this particular issue is, however, widely considered to be a settled issue. If a language supports higher order functions, then for most common purposes, using them leads to more expressive, more readable code than low level loops. If the language doesn't have them, then iterators are the next best thing. Low level loops are a last resort 90% of the time -- although not 100% of the time.]

[Lisp programmers, for instance, do in fact use loops rather than higher order functions or iterators sometimes, if they think they're a particularly good match for the problem at hand. Lisp code with explicit loops has appeared in some of the ProgrammingChrestomathy solutions here, for instance.]

Exactly, there are times when you need to drop to a low level loop for some reason or another, but 90% of the time, the HigherOrderFunction is the better, cleaner, more readable solution.

[It's also true that higher order functions can simply get too abstract to be easily understandable, e.g. if one is using a 5th-order higher level function. This doesn't seem to actually come up very often in practice, though. -- dm]

I agree with that, I remember some JavaScript program where the overuse of higher level function where almost redefining the language itself, like a whole new API to learn just to understand what was doing the code. -- zwetan

<Would you mind if I correct your English (a) on this page or (b) in your contributions elsewhere? It would make what you say easier to read, but will sometimes mean that the previous edit is less easily discerned. If you prepare your text using a syntax-checker and spell-checker first, the need for such edits will be minimized.>

That was from someone else, not me.

[I'm writing in [] brackets because I'm yet another person: it is standard procedure to correct spelling and syntax here, but few people use spell checkers, and almost no one uses a syntax checker, yet we all manage to communicate. Zwetan's English is perfectly comprehensible; it does him an injustice to imply otherwise.]

<I didn't say it was incomprehensible. Correct spelling and punctuation would make it easier to read. More importantly, correct spellings enable full-text searches to work better, help Google, and set a good example for others. Inattention to spelling causes a very gradual decline in standards until, eventually, sentences do become really difficult to understand properly.>

<Relatively few points of etiquette are relevant here, so it's possible to cover them in this wiki. Similarly, the entire English language is not of concern here. Most spelling errors are detected automatically, so it's quite easy to correct them, much as one would promptly correct erors detected by a test compilation of a program.> [On the other hand, it certainly is polite of you to want to respect his wishes, whatever they may be, on his homepage. Homepages are not inviolate, but by and large, by convention they receive more latitude than other pages.]

humm tons of my comments just disapeared, I don't have time to rewrite them all, so in a quick large answer:

-- zwetan


CategoryHomePage


EditText of this page (last edited December 29, 2011) or FindPage with title or text search