r/programming • • Dec 22 '11

The Problem with Implicit Scoping in CoffeeScript

http://lucumr.pocoo.org/2011/12/22/implicit-scoping-in-coffeescript/
83 Upvotes

116 comments sorted by

View all comments

Show parent comment

3

u/[deleted] Dec 23 '11

so your workaround is to do a search any time you want to use a variable? And how exactly does this make coffeescript easier to use than javascript? I can't see having to do a search every time I want to use a variable as somehow easier than javascript. That logic baffles me. You know, the only real way to be certain you don't have this particular coffeescript gotcha is to write only one function per file. If a serious coding shop were to adopt coffeescript, this would no doubt have to be one of the design patterns, because you just can't guaruntee that with a few people working on the same project files, you won't get someone that uses a variable name twice unless you limit your source to one function per .coffee file.

0

u/showellshowell Dec 23 '11

I already listed four best practices for avoiding accidentally naming collisions in files with multiple functions, and only one of them involved searching. We probably agree that smaller files would help as well, but I wouldn't go to the extremes that you suggest are necessary.

3

u/[deleted] Dec 23 '11 edited Dec 23 '11

None of your 'best practices' make coffeescript easier to use than javascript. At best they are workarounds, not best practices. If you were to use coffeescript in a team of say 12 programmers, it would not be excessive to make a rule of having only one function per source file to avoid variable name conflicts. Coffescript does not seem like it would scale well at all.