5 ms·
> JavaScript is a great programming language, but ... Why are we so afraid to call trash "trash"? It's not attacking the creator, but just how can we make prog
by nodejs_rulez_1 5y ago
> JavaScript is a great programming language, but ...
Why are we so afraid to call trash "trash"? It's not attacking the creator, but just how can we make progress if things are not perceived as they are?
https://wtfjs.com https://wtfjs.com
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- globular-toast 5y agoI thought the same thing. I think the author is afraid of offending people. Downvote culture has conditioned a lot of people to walk on eggshells and write this way.
- n4bz0r 5y agoFunny how this comment got downvoted into Valhalla in a matter of minutes.
- cout 5y agoTrash is something you are discarding. If you are keeping it because it still has some utility to you, then it is by definition not trash.
- cies 5y agoLoved this video (4mins) of a talk by Gary Bernhardt (CodeMash 2012) on the topic of JS' quirks: https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- azangru 5y agoIs javascript any more "trash" than python or ruby? I don't think so.
- blowski 5y agoFrom what I read on forums, every single piece of technology that's ever been invented is trash according to some self-appointed expert. I doubt I could name a programming language used by more than 100 people about which at least one person hasn't written a crtical comment.
- kingludite 5y agoElixir? I've never used it but reading about it I kept going ohh, ahhh and wow! In stead of my standard: ** ** *k * ** *sh?!?
- blowski 5y agohttps://news.ycombinator.com/item?id=25787548 https://news.ycombinator.com/item?id=25787548 I've never used Elixir so can't say whether the criticisms are justified.
- hootbootscoot 5y agoPresuming server-side JS, as you won't run Ruby or Python in the browser, typically, you can say that all 3 dynamic languages, as such (garbage collected, heap-based, untyped) will waste computer resources and perform worse than typed compiled languages (even garbage-collected ones) due to memory usage patterns. Python has an interesting C FFI interface, among other approaches, that can at least allow CPU and memory-bound tasks to be accomplished inside of a native code module. You see a lot of domain specific work in Python due to these approaches, cython, etc.. Crystal lang is what I would urge all Ruby devs to look at. (an LLVM-based compiled language that has HTTP in it's standard library, for one thing...I'd pit it against Go, for example.) As I see large front-end teams frequently pushing JS from a typescript base lately, I'm not sure that even the JS community supports "everything JS" anymore. At the point one does backend Node.js work with typescript or other more rigidly typed systems, I have to wonder if targeting V8 is really the desired option any more, and if the programmer would not be better off switching to a high-performance and feature-complete typed backend language system. (the single-threaded JS execution model being a needless constraint at this point, for example. It's great as an event loop)
- nicoburns 5y agoThe vast majority of these are implicit type coercion issues. Which is fairly easily banned with a linter. Once you've done that, I think JavaScript is probably the nicest of the big dynamic scripting languages (Perl, PHP, Python, Ruby) to work with. There could definitely be improvements, but trash seems to be taking things too far.
- pansa2 5y ago> I think JavaScript is probably the nicest of the big dynamic scripting languages (Perl, PHP, Python, Ruby) to work with. As an experienced Python programmer learning JavaScript, this isn’t true for me yet but I hope it becomes true. I think JS will be much more useful to me than Python. > Which is fairly easily banned with a linter. Any particular recommendations?
- furstenheim 5y agoEslint is the default linter. Standard is a curated list of rules with good quality. https://github.com/standard/eslint-config-standard https://github.com/standard/eslint-config-standard I would start with that and tweak what you don't like
- dfabulich 5y ago> Any particular recommendations? TypeScript.
- ehnto 5y agoThe article only really touches on weird language caveats, but where JS really gets weird is it's ecosystem. If you are working with JS in a commercial capacity you will eventually find dependency hell, arbitrary toolchain complexity, asynchronous and callback mind bending, transpiling and compilation, and all just to render some HTML. Quick, get your compsci degree bobby, we need to make this button go to another page!
- ljm 5y agoWhy is it trash? Or is this just like PHP where people are so accustomed to shitting on something that they're completely oblivious to the progress that's actually been made? I don't understand what this actually contributes to the discussion beyond it being a tired, beaten-down programming meme.
- hootbootscoot 5y agoIt is 'trash' for the general purpose 'one-size-fits-all' programming language that it's fans want to impose upon the world. (I shake my head at microcontrollers running dynamic languages. "micro-python" = spare me. line breaks over a TTY? there's the primary question of on-chip resources and a giant shim between the physical realities of a microcontroller and some high-level fantasies about what programming "should be", absent any information on the low level specifics = the issue here.) It's ES3 API is missing a few things, like Object.keys, etc. I still happily code for browsers in ES5 with a few polyfill functions. JS works fine for it's core competency: manipulating DOM elements and local data representations. It's not JS's fault that the browser is the way it is and that HTTP is the way it is and that using a remote directory "browsing" protocol via a specialized file browser that renders hypertext isn't a 2-way bound GUI framework...
- jiofih 5y agoThat’s a load of gibberish. JS as a language has nothing to do with browser APIs, why would you judge it based on that? Also, ES6 was ratified six years ago. Seems like you had a bad experience with espruino / jerryscript or something and are projecting based on that? Dynamic languages are easier to program in. That’s a fact, and why they are so popular.
- golergka 5y agoAlthough I like Javascript (Typescript) a lot, I have to bite: > Dynamic languages are easier to program in. Only if you don't care about writing correct and maintainable programs. The only thing that dynamic languages make easier is writing code. Or, more specifically, the first couple of versions of it. That's not what typical programming as a process mostly consists of.
- jraph 5y agoWe are not saying this because we are afraid to say it, but because it is not true. JS is a great programming language with a lot of quirks and footguns, most of them easily avoidable by enforcing good coding styles, using easily available and widespread tooling. And most language have linters or compilers that issue coding-style related warnings, including C, so this is not specific to Javascript.
- tasuki 5y agoWhy is JS a great programming language?
- jraph 5y agoThere are a lot of things to hate about JS: its questionable choices around type coercion, its Date object, for..in on arrays (indices are string) (a consequence of every object key is a string), for..in on objects which also iterate on inherited properties, the fact everything is dynamic, its weak standard library, null vs undefined, many original things…. There are also great things about it: the ease at which one can write in a functional style code, anonymous functions (vs Python), closures (vs Java), immutable strings, the fact that there is not a shitload of classes to instantiate to achieve anything (vs Java), block-scoped variable definitions, sane default function parameter handling (vs Python). Javascript engines are also very fast nowadays because of the ton of engineering going into them. I'd say, above all arguments, you can rapidly build very fast, lightweight and program programs with it. Sure, you can pull a shitload of pointless dependencies and write bloatware that re-render the world on each keypress, and that's what many people do. And to make things worse, they wrap their shit with an entire browser that uses a lot of ram and processing power. But you are not forced to do that. You can also write efficient server code that does not show up in top, has few dependencies if at all, consume a negligible amount of memory and run without failure for months. That's possible too. Frontend-wise, you have amazing frameworks like Svelte that do wonders and would allow you to build very lightweight apps rapidly. That said I would often pick TypeScript so your program is statically type-checked and your code is documented through types, especially for more-than-one-person / non-trivial projects. I also use and like other languages like Python and D (and a bit of Rust) that have good stuff which JS doesn't have (list comprehension, borrowing, traits, named parameter, sane coercion to False…), or bad stuff which JS has. Javascript is not always the best answer, or even a good answers, but it can be one.
- dfabulich 5y agoCalling it "trash" is a very inflammatory way to describe one the most popular programming languages in the world. Language like that is against the HN guidelines, because it distracts from your argument to debate about whether JS is "trash" or not. JavaScript has a bunch of quirks, but it's still great. In the StackOverflow survey, JS reliably ranks highly in the list of "most loved" languages. https://insights.stackoverflow.com/survey/2020#technology-most-loved-dreaded-and-wanted-languages-loved https://insights.stackoverflow.com/survey/2020#technology-mo... Node.js is a thing because people liked JS so much that they wanted to use it on the server side. You may think they're all fools, but it's actually pretty nice. I like the latest version of Node better than working in Python (mostly because node_modules are better than virtualenvs, IMO.) You can use TypeScript to address many of the quirks described in TFA, but you can also reliably avoid them just by never using == and always preferring ===, using String() before using + to concatenate, and using Number() before subtracting. I basically never encounter situations like the ones depicted in TFA in real code, because I never try to add two arrays or subtract two strings or what have you.
- wruza 5y agoTrash “Admitting like this has a bunch of quirks, but it’s still great.” (not arguing for it though) Criticism is a driving force behind change to the better. Calling something “great” without pointing out great sides I find… pointless and harmful. To name a few great points, distinct from other languages: JS has a pretty shameless object model, where you (usually) have ordered keys, and every key is a property with an {enumerable, writable, configurable, get, set} descriptor. It is much more usable and practical than in almost all other languages. (They do that for “efficiency”, but that’s non-sequitur) JS has very useful destructuring syntax, which many languages lack of and that leads to assignment bloating and boredom. Also, jit optimizes out temporary objects, so foo({x, y}) / function foo({x, y}) works almost at the same speed as foo(x, y). JS has a nice Function type, which allows easier metaprogramming and substitution of ‘this’ object. Functions are objects, so you can function foo() {}; foo.x = 1; console.log(foo.name, foo.x). JS bare objects may have methods and properties: t={_x:1, get_x(){return this._x}, …} JS doesn’t treat syntactic lists in a last-value-only way, so you can expect foo(…a, …b, c) to work, and to work as intended. E.g. Lua cannot do that, and python (afair) requires you to collect items into a single array (not sure, correct me if I’m wrong). But what people usually mean by “great” is “it generally works”. I know it is an american thing, but some aspects of js, including those you meet everyday, are really just trashy. It would be nice to not have them at all.
- MaxBarraclough 5y agoI wouldn't say it's trash. JavaScript has many ugly quirks, but it has many good facets too, and it can be be used to write effective and fairly elegant code. Considering how quickly it was thrown together, and that's it's been evolving since then, I'd say it's a surprisingly good language. > how can we make progress if things are not perceived as they are? People aren't blind to JavaScript's failings. The evolution of JavaScript has been a mix of adding new features and fixing what they got wrong before, e.g. the way it has two different isNaN functions. [0] [0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- lampe3 5y agothe only trash is that comment LooL
- LandR 5y agoBecause some developers will take offense. They will think that if you call the language they use trash then you are calling them a trash developer. It's odd, there are developers who make the language they work part of their identity and see attacks on that language as attacks on their identity. I don't get it, but it is what it is. If you call javascript trash, you will offend people.
- sesm 5y agoIf we want to perceive JS as it is we need to follow its history, understand the basic ideas behind different features of the language, understand the trade-offs behind various design decisions, etc. Basically, it was meant to be a dialect of Scheme, but with map and array data structures at the bottom, as opposed to lists (hello, Clojure!). Suddenly, the last-minute decision was made to add Java-like syntax and OOP to this language and rebrand it as 'JavaScript'. Brendan Eich did the best he could in the limited timeframe to implement this. Then in 2015 'design-by-committee' approach was accepted and horrible feature creep started. We can then investigate every feature and how it pushed individual company's agendas while compromising the integrity and vision of the language, but that's a typical design-by-committee story.
- lkj23ioj233i 5y agobecause people here wasted years to learn all the quirks in JS and now they should realize all that was a mistake? Much better to downvote negative comments.