I'm sure in some form this has been asked previously, but I just want to ask here to get a clear answer. The with statement has been touted as deprecated due to, I believe, obfuscation with variable declarations. The impression, from what I gather, is that it can be both difficult to read as a human being and for an interpreter, and can occasionally be the culprit for a slight dip in performance. That's all well and good - but I've also heard that this is a misconception and that with is not deprecated, but simply frowned upon like eval.
It certainly has it's advantages, but it isn't difficult to program around in the slightest so that's of no concern to me. My real question is based upon deprecation status or not? My specific situation is that I'm picking up projects from an old coworker at our company(RIP) and a few dependencies that he utilized to create basic work flow/template engines, are peppered with the with statement.
I'm wondering if it would be best for me to retire and create an analogous build process so that I don't get hit with any latent unexpected errors?
I did try following up and attempted to put in my due diligence looking into the spec itself and around online. For instance 2ality states it's deprecated, mdn states it's ambiguous to the situation, and stackoverflow, quora, and the rest of the q&a worlds seem to be all over the place.
Basically, there seems to be some confusion on what the actual status is and in the spec there is no mention of it having been deprecated outside of a syntactical outline and performance warnings.
I was hoping someone could simply enlighten me? Thanks!
My understanding is that with is forbidden in strict mode, which also includes class bodies and Modules. It鈥檚 effectively deprecated as a result, by being unavailable in all likely instances where new code is written.
It will continue to work in sloppy mode Scripts for the foreseeable future, to prevent breaking the web, so while you may want to update those dependencies, i don鈥檛 believe it will break (since typically transpilers like babel aren鈥檛 run on third party code, so any assumptions about the parse goal being Module wouldn鈥檛 apply).
I think the usage of the term "deprecation" is just underspecified in this context. People use it for both "discouraged" and "will be removed", without specifying which they mean. with is definitely discouraged, but it isn't going to be removed (:heart: realms shim)
There's also a _ton_ of legacy usage. I would assume it's going with (馃) us forever.
I think the usage of the term "deprecation" is just underspecified in this context. People use it for both "discouraged" and "will be removed", without specifying which they mean.
I can see that. It's a good point, but when I see the word deprecation I have Microsoft IE PTSD and I become nervous :)
but it isn't going to be removed (鉂わ笍 realms shim)
I agree that with is not going to be removed for the foreseeable future, to avoid breaking the web. I also 鉂わ笍that you 鉂わ笍the realms shim!! Thanks for the kind iconography!
But to be pedantic, I'll point out that the use of with in the realms shim is intended as a temporary measure. We hope to retire the entire shim once realms are standard and directly supported on all platforms; and all previous versions of these platforms are old enough that we no longer care to support them. This will of course be years. But fewer years than such transitions used to take ;).
I agree that
withis not going to be removed for the foreseeable future, to avoid breaking the web.
with can't ever go away for non-strict code because that would break all with using web pages on stable unmaintained websites. In particular, such pages cannot be purged from archive.org or similar archival sites. Nor should we want that to happen.
@erights I haven't looked too deep into it, but I thought realms was a really interesting idea. If I'm thinking correctly it allows for script separation( edit: Object separation might be more appropriate of a term? Idk) much in the way that iframes natively do now correct? It raised some questions when I was skimming because I was concerned about prototypes - but I noticed Global Symbol has the ability to cross "realms" currently I believe? If that is it, I have zero idea how you shimmed it into existence. It sounds really impressive.
I have zero idea how you shimmed it into existence. It sounds really impressive.
Thanks!
Probably our best explanation is https://youtu.be/9Snbss_tawI
Further discussion on this topic should occur at
https://ocapjs.org
https://github.com/tc39/proposal-realms
https://github.com/Agoric/SES
Sure thing! I'll take a look.
Thanks for the helpful answers guys, I appreciate it!
Most helpful comment
There's also a _ton_ of legacy usage. I would assume it's going with (馃) us forever.