Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I would like a strict mode in js and rendering engine, which shows syntax error like a compiler instead of eating them and failing later at random places. Ffat fingers and typos take disproportionate time while development.


Beyond ES5 Strict Mode ("use strict";), Firefox has a "javascript.options.strict" about:config pref that will log extra warnings (such as accessing undefined object properties) to the JS console. These warnings are not enabled by default because they are non-standard and can report false positives.


When developing Firefox Addons they have logging that is kind of like what you describe – doesn't break running but problematic code, but does complain. I found the result unusable. Normal development involves using libraries like jQuery, Google Analytics, or whatever other framework that sometimes acts weird, or makes seemingly odd choices for compatibility reasons, or has code that is effectively dead for everyone but IE6 but does get loaded. And since I didn't write jQuery or whatever other library, I don't care about those warnings.

It could be useful if there was a way of indicating what scripts are actually under development, and therefore only complaining about things the developer can fix.


That sounds like a good idea for a dev version. Do you want to file a bug?


You might be interested in looking at TypeScript: http://www.typescriptlang.org/

It does something very similar to what you're suggesting, adding in static type information for JavaScript and giving you compiler errors if you mess things up.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: