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

2

u/showellshowell Dec 23 '11

I totally agree with your sentiment that there is no "odd language out." I have never found two languages that agree on variable scoping; there are too many tradeoffs, and it's natural that different language designers made different design decisions.

Surely there are languages that get variable scoping dead wrong, but I think the majority of mainstream languages, including CoffeeScript, make sane decisions once you understand their philosophy.

There's obviously a spectrum of convenience vs. safety. Convenience and safety aren't always mutually exclusive, but I do think some languages choose sides. Ruby, for example, is a little more fast and loose than Python. I'm not sure exactly where CoffeeScript fits on the spectrum, but there is definitely a philosophy that drives the decisions.

2

u/clgonsal Dec 24 '11

Yeah, I agree that there are there are tradeoffs, though I think people often overestimate (or at least overstate) the amount of mutual-exclusion between convenience and safety.

Even if we were to assume that these three languages have maximized the level of safety achievable for the particular level of convenience they have chosen, I feel that Python (arguably the safest of the three) is "convenient enough". Any less safe than Python, and errors start to pile up pretty fast for all but tiny "toy" programs. Even if one's goal is only to write toy programs, when you're talking about something that small the added convenience of never having to write "global" becomes negligible, and so it doesn't seem worth it to give up the ability to write larger programs that are actually maintainable.

1

u/[deleted] Dec 25 '11

|when you're talking about something that small the added convenience of never having to write "global" becomes negligible, and so it doesn't seem worth it to give up the ability to write larger programs that are actually maintainable

I've brought this up numerous times but get downvoted whenever I do. I don't see coffeescript as a net positive for this and other reasons similar to it. The things you have to do differently in coffeescript don't actually mean you have to do any less entering of text to write a program, when you consider the workarounds needed to do things 'the coffeescript way'. If anything it is a break-even at best in terms of writing code. At worst it is a clusterfuck waiting to happen if you don't know all of coffeescripts 'gotchas'.