top | item 3847986

(no title)

Ramone | 14 years ago

I think the argument that we shouldn't rely on the parser for certain language features is a bit silly (including interpreting end-of-statements). The language is precisely what the parser says it is, and nothing more or less. JSMin is free to not do what the parser does of course, but that won't be Javascript.

discuss

order

EvilTerran|14 years ago

Surely the language is precisely what the spec says it is?

"The parser is the spec" is a nasty design smell, IMO.

jmount|14 years ago

Yup- "computer science" is definitely going retrograde. It was recognized a long time ago that the "implementation is the spec" was a disaster for program semantics. And now we have "implementation is the spec" for something as easy and inessential as parsing. 1950s computer science labored under the misapprehension that parsing was hard (FORTRAN contributing greatly to this feeling). Then parsing was solved (while we don't always user machine generated parsers the ability to specify a grammar and see what features make parsing easy versus hard is a huge step forward). In fact this early victory over the formerly hard problem of parsing is one of the reasons people started anticipating higher and higher level languages and the complete automation of programing. But (as Brooks points out in "The Mythical Man Month") parsing was solved precisely because it was an inessential difficulty. Save your mental cycles for essential difficulties (semantics, evolution of state, remote machines, concurrency and actual domain problems).

ktizo|14 years ago

Surely the environment is the spec.

If he wants his code to work with this particular minifier, he should include the semicolon, nothing more, nothing less.

Is a bit like trying to speak in official french. It might be correct according to the officials charged with protecting the french language, but you will sound extremely odd to most french people.

wpietri|14 years ago

I'm not sure if you're making that argument yourself, but it's thoroughly wrong.

First, there's no "the parser". There are a lot of parsers, some of which don't yet exist.

Second, that means there's no way to distinguish between bugs and features. If the language is defined by parser behavior, then any parser bug is now part of the language.

Third, you've eliminated the white space needed for future growth. If you look at any standard that has evolved well over a period of years, you can see in the early days there was a lot left undefined. If the implementation is the spec, then nothing can be treated as open for change.

blasdel|14 years ago

javascript the language itself has a spec that everyone has pretty much always implemented consistently even in the worst throes of the browser wars (the runtime libraries, not so much)

the problem was that jsmin didn't just violate the spec — it's not a javascript implementation at all, but rather a pile of naive textual replacements