Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-20 Thread Dominic Tarr
scopes and prototypes are indeed different. By 'similar' I meant that they share an important quality in common, like two triangles are similar if they have the same angles, irrespective of size or rotation. I agree, in other respects they are completely different, which is why it's useful to hav

Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-20 Thread Rick Waldron
On Wednesday, June 20, 2012 at 10:15 PM, Dominic Tarr wrote: > prototype chains and closure scopes actually work in a precisely similar way. > > This is egregiously incorrect. Before you give out advice, I beg you to read the spec and actually understand the material. > > this gist gives

Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-20 Thread Dominic Tarr
prototype chains and closure scopes actually work in a precisely similar way. this gist gives some examples of identical structures created with scopes and prototypes. https://gist.github.com/2904285 On Thu, Jun 21, 2012 at 7:34 AM, P. Douglas Reeder wrote: > Use the style that your team find

Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-20 Thread P. Douglas Reeder
Use the style that your team find most natural for the problem you're solving. That will make it easier to fix bugs and add enhancements. If profiling shows one part of your app is the bottleneck, consider rewriting it. Other problems may make other styles more appropriate. -- Job Board: htt

Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-20 Thread Matt Freeman
I found recently Im doing something like this (untested) after looking at bits of other people's code, SubStacks etc.. however this aint without its problems, as this context inside the prototype methods could be pointing elsewhere depending on how the fn is passed around in the called code, hence

Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-19 Thread mixu
I agree, the point is more that if you're going to write OOP JS **with inheritance**, then prototypes are nice because they are the standard way. My point is NOT that "functional is terrible", it is that if what you want is OO with inheritance, then please use the capabilities the language prov

Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-19 Thread Jorge
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

Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-19 Thread José F . Romaniello
I agree with Nuno on this (but I'm a beginner). I mostly do functional but often I find a places where i prefer an object abstraction. And I find that this is mostly the case of the node api, you will find like a bunch of functions in "fs"... but then things like Stream or the EventEmitter loo

Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-19 Thread Nuno Job
>> What is your experience (and suggestions)? Awesome. I'm an haskell geek and I love nodejs :) It's great to code functional style, if you like it go for it. SubStack mostly code functional style (hence I find his code very easy to read), and so do I. Check some code: - http://github.com/s

Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-19 Thread Nuno Job
Do functional style if you feel like it, OO if you feel like it. It's your choice, nodejs lends itself to both. A lot of good nodejs developers do OO. A lot of good nodejs developers do functional style. Ignore FUD, and all the benchmarks that consistently look at non bottlenecks. (If you are cr

[nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-19 Thread Rich Schiavi
Cool, yeah, that is what we are doing. Our tests against prototype showed prototype was 5x faster, but in cases where classes/object were more "real world" in style about a 1ms difference at most in creation time On Thursday, September 29, 2011 8:30:07 AM UTC-7, Giovanni Giorgi wrote: > > Hi all

Re: [nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-19 Thread Jake Verbaten
There is nothing wrong with not using the prototype and preferring a functional style. There is something wrong with using closure scope when you can use `this` For example function fooFactory(bar) { return { baz: function () { return bar } } } function fooFactory(bar) { ret

[nodejs] Re: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-19 Thread Rich Schiavi
Anyone out there have any deep benchmarks to back up using prototype/new over a functional style in Node/V8? And that it is a clear performance/memory win?? Mixu's node book says: http://book.mixu.net/ch6.html "Don't construct by returning objects - use prototype and new" The claim to fu