345 points · by skellertor · 8y ago · 358 comments
Other problems exist, which are just stupid (null/undefined, in/of, ===, ;, this, etc) or minor design choices like coersion and lexical rules. But these above are stoppers for turning JS into something great. It is now a BASIC-level language with scoping and sugar. Yeah, you can write like that snippet presented in an article, but you are forever stuck with doing all things by hand, from asyncing to orm, from exporting to update scheduling. I don’t find that great in any way, especially when that is the only semantics you have in a browser.
As an aside, there exist green threads in JS, namely node-fibers, although it's only a Node.js extension.
You actually can reflect on module exports and dynamically change them with node modules; you can't do it with ES modules, but that has the significant advantage of enabling static analysis.
Proxies absolutely can trap the property assignments you mentioned, but Vue can't take advantage of this because Proxy can't be polyfilled in older browsers.
As for the enumerate handler, it would only have worked with for-in loops, which are a legacy feature. The iteration protocols used by for-of are a much more flexible solution. It might seem silly to have both for-in and for-of loops, but the context of the language is that it can't just go and break older websites. Same goes for == and ===, etc. Linters come in very handy for dealing with this.
Your criticism is better than most, which usually just point out some "wat" moments with mis-features like implicit coercion, but you didn't really make a case for having to do "all things by hand" in JS.
Aren't Web Workers real threads, and supported natively in browsers? (Haven't used them myself, maybe there's some limitation that excludes them from the criteria above...)
https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers...
I also bet that I couldn't make 'in' work for proxy with empty abstract target, but maybe it's just me. Btw, 'in' and 'of' are two separate iterators, one iterates array elems and the other iterates object's keys -- something essential to metaprogramming. My whole point on in/enumerate is that it considered legacy by someone special.
And on Vue: I didn't know that, but if Vue can't take advantage of Proxy, can I?
for-in is a legacy feature; due to dynamic inheritance, it's generally not safe to use without also calling Object#hasOwnProperty() every iteration. for-of is not for "array elems", it uses the iteration protocols that are implemented for all built-in collection types, not just Array, and some DOM types, and can be implemented for any user types. Protocols are a much more flexible and clean approach to metaprogramming than overloading the for-in looping construct would be.
You can't use Proxy if you need to target legacy browsers like IE9, and Vue needs to, since it's about 15% of all browsers.
And yet even that advantage got thrown out from the language with the introduction of "import()". Apparently static analysis is a non-goal (see discussion in [1]).
[1]: https://github.com/tc39/proposal-dynamic-import/issues/35
The threadless/nonblocking model is "interesting" but in my opinion its wholly suitable for user-oriented scripting as it forces a style of development that doesn't block.
The null/undefined thing actually makes sense to me. The concept of "Null" is a swirling vortex of uncertainty in most languages and it's nice to see it get some more nuanced treatment.
There's something about the bloody-minded pragmatism of javascript that appeals too ... it's very much a language that has evolved from the bottom up based on need, and much of it is very much community driven. You see problems solved in interesting and unusual ways that you mightn't see in a more stringently stewarded language.
I wouldn't use it for everything. I wouldn't prescribe it for beginners to programming either. But it's great for what it does. I like lots of other languages too, but I respect their applicable limitations. It's a nice language.
All this makes a lot of people react emotionally and makes talking about JS itself (like many other mass-adopted technology) very hard.
Is JS nice? Yeah, as my personal opinion - but we can all say that it is good enough, evidenced by the ecosystem and the things people create with it.
I'm wondering what would be an example of a great language? Because we know that there are only two kinds of languages: the ones people complain about and the ones nobody uses
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
>almost every example of an issue that you have with the language seems to be resolvable using Proxy objects. I don’t think that light threading, introspection, scoping, etc is resolvable with proxy objects. If it is, it would be nice to know how.
Here the code of the model implementation: https://github.com/zandaqo/compago/blob/master/src/model.js
V8 (and probably others) now has some special cases for async functions (and generators, I think, but those are much more rare) to show useful stack traces with the lineage of async calls. For example, this code shows the stack trace you'd expect when run in latest Chrome or Node.js.
async function c() { throw new Error('Some error'); }
async function b() { await c(); }
async function a() { await b(); }
a(); ./file.src:
func api_foo()
for x in objs
x.a = fetch(x.b)
ui.btnok.enabled = yes
commit()
And have foo exported as api, and when called, all clients/servers, databases synced, validations passed, schemas updated, triggers and reactions done, errors handled, developer errors reported.I also find that python has reserved a whole bunch of keywords that I can't use as function names, making APIs hard to create with appropriate names. You also have to pollute your code with self everywhere.
It is also really slow, has no where near the number of libraries on github as javascript, is not a client-side language, doesn't have anything like babel, which can allow you to do a lot more than reflection/introspection (but not the same things exactly), etc.
I'd hate to see Python become as popular as JavaScript and to have it be used as the defacto standard in browsers because honestly, it's nowhere near as enjoyable to use as JS.
As a concrete example, here's a library I made that relies on symbols and dynamic inheritance to extend the built-in data types: https://github.com/slikts/symbol-land
Saying that the community is more advanced in the JavaScript ecosystem than it is in the iOS world is a nonsense to me. Don't we have more JS developers than iOS developers ?
Moreover, saying that JS syntax is really good with tools like TypeScript is another nonsense. You can also write Swift code and use another transpiler to get JavaScript code from it and you would say that JS is great.
Last but not least, giving a state of the art of JS without event talking about tools like npm, babel or webpack is like scratching only the surface of the subject. I mean come on, JS is not only about == and === in 2018
and I just thought, hmm, here's this guy with ~5 years of ~professional dev(mainly with iOS) and he self qualifies himself as world class.
Looking at his bio, I see he's worked for 3 companies doing quite ordinary things.
I would love to know what gave him the confidence/ignorance to describe himself as such.
Do you frequently launch into personal attacks on authors whose articles you disagree with?
This guy's not writing an opinion piece about which brand ketchup tastes best. He has published an opinion piece in which he speaks authoritatively about matters related to the domain he claims he's a world expert in.
As for the harmless exaggeration, it's not harmless. It's poison to my chosen profession.
It's ok to sell oneself but I'd be careful with exaggerations in a field with probably >1 million professionals.
If the author is joking about being world class, that would be kind of odd. So is saying you're world class at something in general (unless you're the tiger woods of that something and can demonstrate/back it up).
I have found it is commonly a trend with frontend/javascript/rails devs to be senior/lead/etc after a few years of experience. I think there's a variety of reasons for this, but going back to the author he probably is very adept at his given field. But to brand yourself as world class seems a bit much.
Personal attack? Nope. But if I saw that line before interviewing a candidate - I'd definitely probe them about it
I personally blame Jeff Atwood who pretty much green lit a lot of developers to consider themselves "elite" just because they were reading a blog about programming.
That attitude is something I'd love to see stamped out.
Ash is a pretty well known developer in the iOS world. He contributes to a lot of well used open source projects and what Artsy is doing (open source by default) isn't something I would describe as "quite ordinary" even if what they're working on is.
I don't know if those credentials are enough to be described as world class, but I would bet it's a bit tongue in cheek anyway.
Probably not what they meant though :)
s/good/busy/Without spending more time or having some domain knowledge of his problem, I can't really comment on the architecture setup/choices.
I haven't read the article yet, but what you're saying is something completely different, in my opinion. If you write Swift you're writing a completely different language, with all the hassles usually introduced when transpiling. TypeScript, however, is just Javascript with some of the assumptions made explicit and a transpiler that actually checks whether you're violating those assumptions. In that sense, it's not much different from a linter - another tool that makes Javascript more pleasant to write.
Reducing all that to "but it has to be transpiled to Javascript" is a simplification that doesn't help in highlighting potential concerns associated with transpilation, in my opinion.
I care less about the performance benefits of web assembly than the fact that it will open browser/cross platform scripting to other languages and I’d be curious to find out if we are still talking about JavaScript in 10 years.
I personally find all programming languages limiting in one or another way and I use almost daily C#, Python and JS (sometimes I use other programming languages as well).
bash is good, for chaining small utilities together.
python is good, for single-threaded problems which don't hurt performance
go is good, if you don't want to manage memory and need easy concurrency, strong typing/etc
rust is good if you want to prevent having a footgun and low level access.
C++ is good for giving you complete control over hardware.
R is good for data science (although is being supplanted, many say, by python).
Javascript doesn't have to be the "best" if it's not competing at all things, unfortunately, as Jobs famously said: "The future is web applications" and now javascript (which, if we remember is from a spec written by 5 guys in 2 weeks) has to fit all use-cases... it's a tall order for any language.
Funny you should mention it. Excel will now support JS scripting.
VBA, on the other hand, hasn't really changed at all over the past decades. It's still as annoying as it can be with no help from the IDE. That's helpful as scripts from Office XP usually run with only minor edits but it also means that flaws annoying a decade ago are now much more severe. Luckily, we'll get JS on Office, although it'll probably take another decade until a reasonable share of companies have upgraded to a version that supports it.
I don't really judge a language based on the number of design flaws. That is like judging a computer based only on its specs.
>and most of its users never really got a chance to solve the same problems with a better language.
I don't really think there is such a thing as "better languages". Also your statement is probably true, and was said about php as well. It is only true though because it has the most number of people using it, so will have the highest percentage of casual programmers. As with php though, you also have very good programmers using it.
I am not really sure what the point of characterising the users is other than to subtitute for a lack of any arguments related to the language. But of course, the arguments on these topics are just a bunch of copy and paste from "list of reasons javascript sucks" articles. These just list design flaws like === and so on.
"My PC is better because it has 2GB more ram than the mac". etc....
>web assembly
Web Assembly is not supposed to remove javascript, it is supposed to be used in addition to it when you need high performance. If people try to promote it as a way to not have to use javascript, it will just result in a more fragmented client-side programming situation, where libraries are not available for particular languages, etc.
I guess you have been missing the news what is being done in Go, Java, .NET, Rust, Unity and everyone else regarding WebAssembly.
We will have the revenge of plugins, like it or not.
The only way out is if the browser vendors backtrack and remove WebAssembly support.
There are lots of developers that stayed as backend engineers as they couldnt stand javascript (as a language and its integration with DOM), they stepped over the beginner phase with their development skills while javascript forced them to write BASIC (LOGO) level code. On the top of it, there were always some junior engineers that barely started to develop and were playing smart and bragging how cool the javascript is. There is a lot of rage stored in those circles and there are lots of excelent developers (I can tell you that 90% of top developers (not 25 years old kids, people that are able to write runtime compilers and OSes if given enought time) I know never wanted to work in javascript). Different reasons but I can tell you that most of them would say "I dont like java, but javascript is humiliating".
Now the webasm is comming, I am preparing to bet that the frameworks will start to pop out in year or something after DOM is supported and they will overrun javascript in shortest possible time, just to prove the point - it sucks big time. QT is beeing prepared, all the "real" languages are starting to prepare to support compiling into webasm... the traditionally backend languages (that... you wouldnt believe... backend engineers know very well) are now having a chance to shine in browser that was restricted for them due to javascript monopoly.
I wouldnt take the javascript future as really bright, in best case it will be used in same way as today shell scripts are (this is what they meant that webassembly is not replacement for javascript). To glue some parts of "system" (read as: browser) together.
And quite frankly, this is step that should be done 10 years back. It would save world a lot of trouble.
And have fun: https://s3.amazonaws.com/mozilla-games/ZenGarden/EpicZenGard...
Even once support exists, there's a payload issue. Nobody wants to spend loads of bandwidth downloading runtimes.
The biggest reason for JavaScripts greatness to me is JSON. I couldn't understand how Java developers put up with such bulky ways to deal with data. After some time in Java land I've come back to appreciating its strengths again though. Code completion is nice. I'm kind of hoping for more typescript in the future.
You can have a one-liner class like
class Person(val name: String, val email: String, val yearOfBirth: Int? = null)
Or you can make it a `data class` and get automatic `equals` and other things.When I suggest switching to Kotlin everyone's always smiling dismissively like "ah, you with your crazy ideas again".
Might do it though. Maybe.
To me, it's much better to let every company send error messages in the format that makes sense to them rather than having the One True Error that doesn't quite work for anyone.
My biggest complaints about JSON are syntactic. Optional comments, multi-line strings, and trailing commas would do wonders for day-to-day readability without significantly bloating the specs.
With respect to your "lack is strength" argument, I can't help but find this unconvincing. We all know JSON is derived from JavaScript object/array literal syntax; your argument is akin to retro-fitting the requirements for service payload serialization to the suboptimal de-facto situation with JSON.
I miss the "and a project which doesn't use modern standards"-part in your post. It's not as if JSON or other modern things are not used in many Java projects. Your project seems to be stuck in the past, as are many JS projects. Legacy code is no fun most of the time.
Whereas javascript you can just go `require(myjsonfile)`
I love java, but Javascript is indeed great for some of these kinds of things :-)
I'm not current on Node features, but that looks dangerous to do. Is that equivalent to reading the file and `eval()`ing it?
JSON5 is something that should've been.
If you take a language like Java and an IDE like Eclipse or Intellij IDEA, it is trivial to find from where a particular piece of code is called from. Whereas in JavaScript, particularly in huge codebases, you can't easily tell how a piece of code ends up getting called. You will need to run the code, make some educated guesses and put breakpoints or console.log statements to verify that yes, this particular line does end up getting called on this particular action.
Refactoring is also a joy in a language like Java. You can easily modify a method signature and the IDE will take care of updating all the places this method is called from. Now imagine you add a new argument to your JavaScript function and want to update all the places where the function is called from.
So judging JavaScript on these factors, it isn't such a good language.
That being said, TypeScript is not sound and obviously in a real TypeScript program you'll eventually touch things that are untyped. But still, getting a different set of trade-offs than "statically typed" and "dynamically typed" is useful. It makes me wish there was something like this for Python (no, MyPy and Pyre are not this. They only provide nominal typing, which is definitely not good enough for everyday Python like Django.)
Then play musical chairs and have each team develop a new feature in one of the other teams' project/language. Measure how long that takes.
For disadvantages, how serious are they, how easy are they to be abused, to creep into the codebase, to be prevented from happening again, etc.
It also depends on the team. If it is a small team of 5 people and they are all excellent engineers, I think whatever languages are fine. The 5 engineers will discuss and decide what features to NOT use, etc. and abide to them. If it is a team of 500 engineers, it will take much more efforts and eductions and much longer to achieve that.
Lambdas, First class functions, and closures are a great feature missing in basically every other popular language (things like Javas lambdas or function pointers aren't even close in real world use).
Proper tail calls is another feature missing from that list and despite some browsers refusing to honor the spec they ratified, it's still implemented in Safari/javascriptCore, XS6, duktape, node 6-7, etc.
The interplay between js dynamic objects and closures is difficult to describe, but a thing of beauty when fully understood. Object literals are also basically unique to js on that list as well.
There's a lot to love about most languages and JS is no exception.
None of the languages are new.
As a matter of fact, you can even use IntelliJ for checking function usages and refactoring in JavaScript.
Yes, modern IDE do wonderful thing to help you with JS but they will never be able to match the help they can give with a language that is statically typed.
Obviously it's far from pure FP, but I think it's much more at the heart of JS than it is say Python. The Scheme parts of JS are the good parts.
I think some of the resurgence of FP is down to JS. The wealth of libraries available is pretty impressive [0]
One day I got curious about monads and spent over a month trying to wrap my head around it, which obviously set me on the path to Haskell which is now my favorite thing in the world.
Javascript is a great language because it allows you to develop incredibly fast (scripting language) for a platform that runs everywhere (the web).
It used to be far simpler, but IMHO, insecurity because of all of the FUD that this sort of article prescribes, has meant that the language has bloated to incorporate all sorts of syntax improvements and new patterns.
It's not a systems programming language, so all the comparisons against typed, compiled languages are moot. Introducing transpiling as a mandatory pattern for JS development was a mistake.
The reason JS has won is because the web has won. Arguing about its merits misses the point.
No they are not 'moot'. At least not if you're building applications with 100k+ LOC. For dinky websites and small projects I'm with you.
>Introducing transpiling as a mandatory pattern for JS development was a mistake.
Again, what are you building? A dinky website, or a large application that you'll have to maintain for the next 10 years?
If you want to build a web application, at some point, until we have true web assembly, you will have to use javascript, which does make a lot of the arguments here moot, regardless of the size of the project.
You answered your own objection. The language is deficient so alternatives are sought (lack of standard modules is one problem). Nobody likes transpilation and nobody would do it if JavaScript was conducive to building and maintaining large applications.
>If you want to build a web application, at some point, until we have true web assembly, you will have to use javascript
No. You can build it in TypeScript or Dart or any number of more sane language and transpile to JavaScript. Which is what people are doing.
You will have to refactor everything and entirely change your toolchain every two years. If you had the misfortune of using some framework, it will no longer be supported by then.
No JS application has that kind of longevity, because the entire ecosystem is extremely volatile.
Also, people making legitimate criticisms about a technology (in this case to try and cut through the hype train a bit) are not 'trolls'.
I can say a lot of good thing about elm, but the most important one, and something that outweight a lot of thing is maintainability. Each time I had to change something in a shipped app it was painless, stressless (I know I won't add regression) and fast.
I won't say JS is bad, but the absence of a compiler makes it much more fragile, especially when working on old code.
JavaScript does has two good typecheckers, TypeScript and Flow.
I'm really surprised that whilst the language on the one hand gives nice tools like the object spread syntax, the last time I checked it didn't make it easy to make the interpreter enforce immutability.
It seems strange to me that the language evolves in this way to recognise foot-guns but doesn't give you the tools to turn them off. Object.freeze looked like it would do the trick, but it's shallow. Freezing doesn't survive the spread syntax, which makes perfect sense because it freezes the original object, and of course the whole point of immutable objects is to create a new object.
It feels like you're able to program in this style, but the language designers didn't really consider it very much and were just introducing the syntax to be consistent with the other spread syntax.
I recommend that you read : https://www.lesswrong.com/posts/dLJv2CoRCgeC2mPgj/the-fallac...
I think a fundamental problem with the language is that it's not particularly memory-efficient, and it's hard to make it memory-efficient. The V8 team has done a lot to make it better but they are still limited by the design of the language.
That's particularly painful in mobile where memory is constrained, and on the desktop it's making the typical 4 - 8GB of RAM less and less sufficient. That's important when discussing why Javascript is still an issue when using stuff like Electron and React Native.
Any meaningful definition of good has to draw a line between things that are and things that aren't. The definition here is broad enough to include basically any language that is popular. C++ is also good because it has a good syntax for the things people use C++ for, a big community that builds tools for it, and it has quirks but come on every language has quirks.
"Just because you disagree with the decisions doesn't make the language bad" is a funny way of describing absolute bald-faced mistakes like typeof null == 'object', the baggage of 20 years of browser quirks (JS tristate logic: true, false, and document.all), and "no that was totally intentional minimalism" oversights like the lack of coherent collections and iteration primitives.
When I think about good, I think about Rust's memory model, Erlang/OTP's supervisor trees, Java's standard library, Clojure's immutable data structures, Python's syntax, .NET's LINQ, Haskell's type system, Idris's type system, Go's mascot, or Elm's delightful mix of programming language and solo performance art piece.
Despite the author's attempt to head this criticism off, the reason we use Javascript really is just because it's in the web browsers. Web developers had to use it, so we made the best of it. We wrote libraries and tools to make it bearable, we built new languages on top of it so we didn't have to deal with its bullshit, and once Ballmer quit ruining the internet we built those improvements back into the language itself.
But is that good? Layers upon layers of accreted improvements, each with more legacy carve-outs than the last? "We can never throw away a bad idea" is a one-way complexity ratchet that precludes unqualified goodness unless there were no bad ideas to begin with. With Javascript, that is not the case. The best it will ever achieve is that it has good parts.
If INTERCAL was the de facto language of the web, we'd be writing Medium posts about the benefits of Automatic PLEASE Insertion and how excited we are for ASYNC COME FROM to land in INTERCAL2018. And, hey, it's not perfect, but it gets the job done, there's a good community, and at least it's not Objective Malbolge. Who are we to criticise?
That made my day and next few mornings, thank you.
Brilliant.
For the first and third use case, really not much has changed since ES3/ES5: if you want portable JavaScript and appreciate simple "press reload button" workflows without babel or other complex transpilation steps, then ES6+ features don't add any essential capability, and I tend to avoid them.
If OTOH you really need to develop SPAs with massive code bases and third-party libs, then ES6 and in particular ES7 with async/await is a big win.
But I can't help wondering if the tension between these language profiles is going to work well for JavaScript in the long run. IMHO for full-blown apps there are much better alternative back-end languages available, and in any massive ES6 code base I've come across the desire to introduce types and type metadata is very much noticable (Angular and Typescript come to mind).
He claims on one hand that Javascript is great and then cites the awesome tooling like Typescript. Well, a great language would not need Typescript, now would it?
I think the most obviously damning thing about Javascript is how the rest of the world bends over backwards and speaks JSON now because it's less trouble if we adapt to JS than if we adapt JS.
Well, yeah, if you change the problem to fit your programming language better, then your programming language will feel convenient and like it always fits well. Duh.
That said, I agree with the rest of the points. I do love JSON though.
[0] The Pipeline Operator Stage 1 proposal is currently the closest proposal to making something like that happen: https://github.com/tc39/proposal-pipeline-operator
[1] Stage 1 Proposal: https://github.com/gsathya/proposal-slice-notation/
{Garbage code example} "Syntax is just syntax". "Tool writers are neutral, then get to work fixing this terrible language".
Really?
Javascript the language is getting much better, and is quite nice in many dimensions. Javascript the ecosystem has a lot of strengths, while also having embarrassingly poor base libraries that require stupid levels of duplicated effort and a platform that is still painfully inconsistent. The fragmentation around Coffescript/Typescript and linters hints at a much stronger need for a language that does more than JS does at its core... As traditional languages encroach into the browser space I see a lot of the "SPA" and cutting edge fat-client-in-html moving away from JS because of those warts.
The point the author is making is that the haters love to point at these quirks and claim that they cause "untold pain"; yet in actual practice I've only been bitten by == maybe twice in 15 years.
This argument applies equally well to using PHP for most anything. Not impressive.
> You may have noticed that the code above isn’t even JavaScript, it’s TypeScript, which brings me to my next point.
Which kind of invalidates the entire premise of the article.
Removing the cast means removing static typing. It might be a small change for this snippet, but at the project level, you'd need considerably more changes, and you'd lose type safety.
It has almost no new "features" (apart from enums and namespaces, I think) and only contains a typing + visibility system and related syntax on top.
The only part that is not ES2015 in the given code example is the ' as ConsignmentSetup' cast.
I agree with the other posters - there are probably good defences of JavaScript that can be written, but writing an article about how great JavaScript is and then showing a code sample from a different language just reinforces the idea that JavaScript developers probably don't have much experience with other kinds of programming.
You could say that about C++ and C, but that's an entire different can of worms.
So why not give the example in JavaScript then? Arguing that JavaScript is "Good, Actually" and then showing examples of tools people have build to avoid using vanilla js because it lacks X or Y is actually an argument for js being "Not Good Enough".
Also I never seen anyone complain about Electron apps because of the language they're written in. The main complaint is that it's a tremendous waste of computer resources. If your chat app needs more than 1gb of RAM, I don't care what language it's written it, it sucks period.
Also JS + Typescript is a force to be reckoned with (the added safety is great), and once a multi-threaded runtime like Chakra[0] takes shape, it'll be even better. JS's early introduction of concurrency primitives (callbacks, futures/deferreds, promises) will make javsacript developers much productive much faster than the equivalent ruby/python 2 developer with not as much early exposure to managing concurrency.
- easy accessibility of higher order functions (AKA functions as a first class object from the get go)
- graceful inclusion/addition of concurrency-handling functionality despite the language being single threaded (this might be much more to do with the context javascript was to be used in)
I agree with your sentiments on the value of type systems and compile-time type checking, but so many languages are in the same boat as JS in this regard -- it even applies to a bunch of lisp dialects (CL does have the `declare` form), and not many could consider lisp a "bad" language.
2. Concurrent execution has also been introduced in the 1960s (Dijkstra 1965), Ada and Erlang supported that behaviour since the 80s.
3. LISP has a type system and basically any LISP runtime will yell at you for comparing strings with numbers just like that. SBCL can do this check at compile time even.
Additionally LISP lets you add a type system on top using macros and other tricks (some going as far as implementing a Haskell-like typesystem in LISP).
C and Assembly are probably the only languages left where this isn't the case.
And even C has the blocks extension on Apple platforms, although I would take the "easy" part out of it given the lifetime semantics.
The developers do, yes; with Javascript, they don't have to worry about compiling for multiple platforms like, say, a C developer would, they could even just ssh into a server and edit a single text file while everybody across Windows/Linux/MacOS/iOS/Android/etc can run the new version as soon as you save the file (mod browser compatibility issues, of course). I think their point was that Javascript is the only language that can do end-to-end simplicity like that.
I don't hesitate to say I like JS. These days I try creating any small experimental programs I need in JS and run them in FF instead of starting the whole build process with C++ code. If there is file i/o needed, I use an extention that I have created for this purpose. When necessary, converting this prototype into C++ code is not a big deal.
As for its flaws, well, which language doesn't have flaws. Part of being an experienced dev is to learn, respect and avoid the shortcomings of the technology you use, aka paying attention. Its arguable that some flaws in some systems are worse than some flaws in other systems since the design factor comes into play, but with something as pervasive and monopolistic as JS, there is a clear choice to be made - create something better for the community or shut up and live with it. I am sort of doing both. (To pull off the first one, I need some serious credeitials, which I hopefully earn in the near future.)
Totally agreed. Same coming from Java. It is crazy how much I prefer it over Java. Maybe this is a consequence of coming from verbose languages? The lack of boilerplate is very refreshing!
Tell that to Brainfuck.
Sure, JavaScript is a great language if you ignore all the shitty parts.
Re the Javascript advantages of JSON and quick writing: Python! It too has its flaws, but so many fewer and writing in it is a breeze. Python 3 is only getting better to, so if you do start, take the time to start in 3, not 2.
Javascript is indeed pushing more function programming type stuff, but if you really want that, go with a Lisp/Scheme or Haskell IMO. It's simply what I've been exposed to, but Racket is a great language for quick little programs. You can also go functional in Python easily enough as well.
The problem is, the children did do it, skipped going to school to learn the basics, and now we see clearly reflected in the evolution of the ecosystem their efforts to slowly re-discover and re-invent everything.
Browsers should have just created a Lua dialect, which is like a more sane version of JS, and throw JS back into the nineties-fads hellscape that spawned it. Perhaps in an alternate dimension Eich will have done a non experimental port of Scheme or would just have done WASM from the start. I’m pretty sure at least there every PC would just boot into Netscape by now.
It’s true that the infrastructure around JS has gotten a lot better, but that’s despite the language. If anything I should thank it for popularizing FP which will hopefully eventually slay the chimera that is OOP.
[1] Or, more specifically, “POOP” to emphasise its prototypical nature.
That flux capacitor diagram is super interesting but I think it is missing a point. The bizarre equality happens due to truthy and falsy evaluation, which is a very practical concept that saves you a lot of time when you actually want to get shit done.
The fact it was named "standard" is quite infuriating, as it's just a bunch of random people churning out an arbitrary set of formatting rules. This is not how standards are acquired. Now, many devs unfamiliar with JS use it because they google "javascript standard formatting" and obviously find this.
That's like saying that Java is good, actually, if you use Kotlin. But not really, because the UX of using Kotlin is 100x nicer than using transpilers.
The JavaScript ecosystem is large and this question can be broken down into:
- Is JavaScript good on the browser for the front-end work?
- Is JavaScript good on the server?
Also for those interested, I create a Poll HN: favorite web server language and front-end submission over here:
JavaScript is popular because the learning curve is low and it was good enough for the web. Otherwise it is pretty mediocre even when just compared to scripting languages.
Then, the "about" page of that blog is very concerning: "I am a world-class software developer". A world-class software developer would be people like John Carmack, Linus Torvalds or Dennis Ritchie.
That's a weird criticism. Object-oriented programmers are premised on mutation. As for JavaScript itself, mutations can be avoided. 'const' to prevent reassignment, using Object.freeze, or just applying functional programming principles and keeping functions pure.
I'm a Java OOP developer, and I make everything I can immutable. It's a design decision adopted by most of my colleagues.
2) Mutate the prototype of a "frozen" object and you would indirectly affect it through its prototype chain... or mutate an nested property inside a "frozen" object.
Most of JS standard library and most popular frameworks and libraries have fully mutable definitions. That sucks and is BAD design decision.
This counterargument is not a good one. Just because other languages do things a certain way doesn't mean it's the right way in every situation. C++ has multiple inheritances and template metaprogramming, but that's C++.
> Most of JS standard library and most popular frameworks and libraries have fully mutable definitions. That sucks and is BAD design decision.
It's subjective whether this is a bad design decision. For the standard library, this enables polyfills. As for the popular libraries / frameworks, they have the option of freezing the prototype. They don't do this because they make the fair assumption that the client is not mutating the library state. It's the programmer's fault for breaking the interface contract and mutating the implementation. At any rate, this would be a criticism of the ecosystem, rather than language. If the criticism is about untrusted third party code, it's not an apples-to-apples comparison between JavaScript and other languages that are operating in different environments.
And aren't frontend dev essentially forced to use javascript since we can't compile to anything else at the current time? yes webasm is coming and yes there are languages that compile to js
He seems to be saying, “Hey, this ting that everyone calls a shit sandwich isn’t really a shit sandwich. Let me tell you why.
I go to this nice restaurant and eat things that are not shit sandwiches. And they are fantastic. But they all end up as shit eventually, so it does t matter. Therefore JavaScript is not a shit sandwich.”
It's not better that the example isn't even JS itself but rather the only JS dialect I don't refuse to work with since it has a type system that is more solid than wet tissue paper.
As the author themself admit, syntax is not important, so why bring it up? That genuinely seems like a way to A) bring up the argument and B) in case anyone refutes the argument being able to simply say "well it didn't matter anyway".
---
Toolchains are another bad point. VSCode doesn't only exist for JS, it has support for other languages as well and I very rarely make use of it as JS IDE.
If I need a third-party toolchain to fix up the most basic mistakes of the language's design I don't think the language under that mess will be terribly good.
Other languages don't require an entire toolchain to provide a minimum of coding safety.
People agree that writing in C is something hard and dangerous, it also needs an entire toolchain to achieve a minimum of "not segfaulting on startup".
I should be able to simply take the first party language tools and use those to get to a point where my application starts and the correctness of my code not being coerced to false.
---
While it is indeed commendable that JS has such a big community, I think the community still has lessons to learn. The churn in the ecosystem is beyond fantastical levels, not in a good way.
When I pull in sqlite3 for my project I can be reasonably sure that this project will be maintained for the next 20 decades and I will be able to use sqlite3 in 20 decades without much problem.
With JS dependencies I will always ask myself subconsciously if they're going to be maintained next week.
I don't write software that runs for next week, software I write is intended to function for the next 20 decades. Of course it'll get patched and maintained but I don't want to switch out my underlying framework because Google decided that their JS code has become too boring after 4 months of work.
The GraphQL examples is just an example of this. The tech is barely 5 years old, the tooling in all languages other than JS was extremely immature last I checked. Why should I bet on something like that to work and be maintained in 20 years?
---
I'm getting a bit rant-y but I'll take this last paragraph to disagree with the conclusion too. Most languages have some bad design. Usually that is fixed in the language or by first party tooling. That's not my problem with JS.
My problem with JS is that the moment I write JS I have to involve myself with the community of JS, a community that has laughed (!) and scoffed (!) at me for suggesting that I want to maintain software for a long time beyond $CURRENT_YEAR.
The ecosystem and community of JS are rotten and flawed, that's why I don't use JS where I possibly can and if I do it's vanilla browser JS pushed through the minimum installation of typescript I can get away with.
We are moving to Go for our backend because dynamic languages don't scale with complexity or team size, but that's another matter.
I'd say that holds for pretty much any language. The blog starts with an example to show how clear and concise etc the syntax is. I, personally, find the syntax unclear, verbose and I have no clue what that code does at a glance.
But I guess that is actually the crux of it: if you enjoy Js and are productive with it, great! Just don't ask me to work on your code, I'd make a mess :)
It was there.