On Jun 19, 2012, at 8:41 PM, Rich Schiavi wrote: > > > The claim to functional being "terrible" is one I question, since I've done > some basic comparisons between a functional style versus prototype/new in > node and seen nothing to indicate it's "terrible" to use functional style. > > (The benefit of altering a prototype chain dynamically to change all > instances of a class isn't something I particularly am concerned with; so > more focused on performance and clean design of code), and I particularly > like Crockford's approach, as it induces engineers to think more > functionally, and javascripty and less java/class new Foo(),etc.
In other languages, where contexts are thin and shallow and there's no first class functions nor closures, programmers are forced to save state somewhere else such as in objects or in structs. But in this cute and lovely JavaScript language of Brendan, most of the times you simply don't need to save any state explicitly, because it persists -automatically- as long as it's closed over by a/some/any function. Remember, an object is nothing but a bunch of functions that operate on a set of data. JavaScript's closures and functions give us that too, in an exciting, lighter and very comfortable way. Call it a vice if you want, but once a programmer discovers that, he enjoys it so much that begins to create only a hundredth the objects as before. A Rubyist will call you names for not creating a "well documented class" for each and everything. A Java programmer too. But what the hell, we simply don't need to, as they do (*). Objects are not a good thing per se: create one only when it makes sense or when your (lesser) language is forcing you to do it, but don't do it when you don't need to, and/or if your (better) language lets you avoid it... :-P When a program is dealing with thousands of concurrent individual tasks, each driven by hundreds of events that may arrive at any time and interleaved in almost any order -as is the case in most node programs- *not* having to design a ton of classes nor instantiate thousands of objects for each kind of event and or kind of task or whatever, is often a *great* pleasure. Call me lazy if you want. (*)Ruby has closures too, but rubyists rarely exploit them, never so much as we do. Ruby also can haz event loops, but rubyists rarely program evented code (perhaps that explains why they don't use closures so much). Oh, and ruby haz threads too, but don't even get me started on that... -- Jorge. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
