Sorry, can you explain more? The code snippet doesn't make any sense to me.
The _ function seems to be some sort of wrapper? I'm guessing to return a
collection type with special methods like filter() and reduce()? If so, why
is there a need to wrap the results of filter()?
On Wed, Oct 24, 2012 at 8:46 AM, Alexey Petrushin <
Yes, You are right, that was a poor example, both `filter` and `reduce` are standard JS methods and available directly on Array.
But, there are lots of other methods that aren't available, thats exactly the reason libraries like http://underscorejs.org exists.
For example You frequently need to
- extend object with another object - more flexible way to sort an arrays than Array.sort can provide (take a look at `underscore.sortBy`) - have handy Array.first() and last() - would be nice to have sort of `Array.has` method (instead of indexOf(v) > 0) - Array.reject (opposite of Array.filter)
and so on ...
Even worse - it's not easy to create Your own implementations of collections (Backbone has to use `collection.get(id)` because it's impossible to do `collection[id]` for custom collection in JS) an so on, standart loops won't work for custom collections either.
That's what I meant by poor support for collection.
I may be roughly one of this kind of people... I tried to learn Python, JS, Haskell before and failed to get familiar with a language. Then I come across CoffeeScript and begin to write programmes in Chrome and Node with it. Now most of my code on Github is in CoffeeScript. Though I'm not an experienced coder - -!.
And I think CoffeeScript already contains all basic features one should know about programming. A problem is.. it's quite hard for one who only learnt CoffeeScript in China. But I think the more readable code fits me better than JS which contains too many flaws..
> I may be roughly one of this kind of people...
> I tried to learn Python, JS, Haskell before and failed to get familiar > with a language.
> Then I come across CoffeeScript and begin to write programmes in Chrome > and Node with it.
> Now most of my code on Github is in CoffeeScript. Though I'm not an > experienced coder - -!.
> And I think CoffeeScript already contains all basic features one should > know about programming.
> A problem is.. it's quite hard for one who only learnt CoffeeScript in > China.
> But I think the more readable code fits me better than JS which contains > too many flaws..
> On Friday, October 19, 2012 6:10:18 AM UTC+8, quartzmo wrote:
>> Do you know of anyone who learned programming by starting with >> CoffeeScript?
>> I'm just really interested to hear about actual cases of starting out >> with CoffeeScript as the first programming language.
Unless I'm missing something, you simply cannot program CS without knowing JS. Indeed, many of us are learning the JS core capabilities by staring at the JS produced by CS. Here's a great quote from Trevor Burnham's CoffeeScript book:
Maybe… in the short term… perhaps if you are thinking 6 months into the future and need to get a project out the door, but you cannot possibly be an efficient frontend developer without knowing JS as well as you know CS. Mainly because you will undoubtedly have to use other people's libraries, and they will be written in vanilla JS. If you can't understand that code, you're left in a poorer position any 3rd party code has bugs in it or doesn't do what you want it to do. Plus, if you're doing open source stuff, you should do it in vanilla JS to maximise the number of possible contributors.