4 ms·
I have limited knowledge in web development and its history, but why is javascript a first class language in web dev when all I heard is "javascript bad"? Web a
by usagitoneko97 5y ago
I have limited knowledge in web development and its history, but why is javascript a first class language in web dev when all I heard is "javascript bad"? Web assembly seems like a much better choice in hindsight where you can choose different language to compile down to wasm.
- lol768 5y agoWASM support hasn't been around for long, comparatively - and I'm not sure if there's been any recent headway with DOM manipulation or GC from WebAssembly.
- Santosh83 5y agoWebassembly is too recent. It needs to catch on. The momentum behind Javascript/Node is huge beyond comprehension. The engineering that has been poured into the JIT is also quite something. Just scrapping all of this and starting again with Wasm is not going to get traction from anyone.
- BenFrantzDale 5y agoCan you explain “Javascript/Node”? I thought Node.js was a JS interpreter but not the interpreter used in the major web browsers. Rather, that Node is an interpreter that’s used to run Js in (typically) headless (server) environments, allowing both sides to be written in JS. Is that accurate?
- madeofpalk 5y ago> Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.
- jraph 5y agoWASM is not a good solution in a lot of situations. In short: - you have to package your complete runtime in the Wasm binary, this leads to a large binary and memory footprint - DOM manipulation requires calling Javascript code, and calling JS from WASM is costly
- hazz99 5y agoYou only need to package your runtime if you’re using a language that requires a runtime :) Languages that perform their own memory management (C, C++, Rust etc) will be extremely small. Just one big array of bytes/instructions.
- jraph 5y agoyou still need to provide their standard library, at least the subset used by your program
- hazz99 5y agoThat’s the same for everything, no? I assume most JavaScript websites come packaged with their (transpiled, minified) versions of the “standard library” of whatever framework they’re using. And that has to be transmitted as gzipped bundles of plaintext javascript. Further, tree shaking is much harder with a dynamic language. My understanding is that a WebAssembly implementation would usually be smaller than a JavaScript one, assuming you’re using a language without a runtime.
- Zealotux 5y ago"There are only two kinds of languages: the ones people complain about and the ones nobody uses." – Bjarne Stroustrup JS may be weird, but the kind of weird that works well enough and is rather easy to pickup and maintain with reasonable rules in place. When it comes to JS my empirical experience has often been: most of the time, the issue is situated somewhere between the keyboard and the chair.
- pansa2 5y agoUsing WebAssembly currently means programming in C, C++, Rust, or maybe Go. Despite its flaws, many people prefer programming in JavaScript over any of those lower-level languages.
- fulafel 5y agoThose are fortunately not the only options, there are many nice HLLs around that compile to JS.
- golergka 5y agoModern Javascript, and especially compiled-to-javascript languages, like Typescript, Reason, Elm and others, are quite great. Those quirks are funny and weird, but it's not something you actually run into when you write code that isn't actively trying to show the weirdness of javascript.
- fulafel 5y agoMost real world non-JS frontend code compiles to JS, not Wasm. Lots of apps written in ClojureScript, TypeScript, Elm etc. These are mature and Wasm has mostly only disadvantages to offer.
- wruza 5y agoIn general, a scripting language for a software product (a “browser” being one of them) may be easily substituted in most cases. Because this integration always has a clear API border than can be retargeted to another scripting language in a straightforward way. E.g. vim text editor has vimscript as its main scripting environment, but may be compiled (in addition) with perl, python, lua, tcl, ruby interfaces. But guys who control web standards resisted for decades to suggestions for other languages, though it was fine to have flash/activex for the same period of time, until Apple killed it for good. Even JS “2.0” (a theoretical better but incompatible version of itself) had no chance, because reasons. Javascript is okayish generally, but its unusual parts come from the times when it was used as a glue between textual inputs and some~ data structures. Stroustrups’ phrase is just a stockholm syndrome (in his case self-induced). Edit: webassembly support is not really required to transpile anything to a browser, see asm.js
- jokoon 5y agoGMail managed to be popular thanks to the XMLhttprequest() function being implemented in internet explorer. Microsoft had a monopoly on software, but it was still possible to do things through a web browser, enabling competitors and websites running on linux. Javascript got popular because it was here first, so developers used it and became able to work with it. When this happens, javascript had inertia which is impossible to stop. Javascript allows one to deploy anything on any platform with a web browser, without copying files. Webassembly is great, but it's not easy to build WASM files, the toolchain software used (compilers linkers etc) are not mature (only rust can build to WASM natively), and it requires that all language compile to wasm, so compiler developer need to implement a WASM compile "target", which takes time and is not always possible depending on language (python comes to mind, because of its large library, global interpreter lock, etc). Also, WASM doesn't have access to the DOM or webGL, meaning that you still need to make JS calls to interact with a webpage.
- arkh 5y ago> Javascript got popular because it was here first, so developers used it and became able to work with it. And you could easily copy and learn from scripts before minification became the norm. And you just have to refresh some page after updating your sources to see the result.
- jokoon 5y agoSure, but it's difficult to make newcomers understand why the language still has those nasty behaviors. In essence, it's very expensive to risk losing backward compatibility or to make large portions of js software obsolete just to remove some bit of language ambiguity. It's very frustrating but it's true for all languages out there. Same concept when linus torvalds yells "YOU DON'T BREAK USERSPACE". Backward compatibility almost has its own philosophical chapter on software design. Also remember how painful it was from switching from python 2 to 3. I guess a solution would be heavy usage of linters, typescript or other compile-to-js solution, but in the end, a lot of developers are just wishing very hard for better solutions. Personally I am really not willing to become a professional JS dev. I'm too perfectionist and nitpicky to have the courage to suffer so much for such thing. Deep down I know it's a bad choice, but I'm too lazy.
- fmakunbound 5y agoIf you have limited exposure to JavaScript, that’s great. Try to keep it that way. Personally, the article/quiz reminds me what an utter shit field web development really is and that shaving my face with a lawn mower and hot sauce might be the preferable alternative. Also, reading the sibling comments here describing JavaScript as having characteristics like “great defaults” and “reasonable rules in place” make me wonder what fucked up alternate reality they’re all living in where those are true.