11 ms·
Semantics and configurability is what what makes a language great. JS doesn’t have function environments, i.e. every unlexical lookup goes to global/window and
by wruza 9y ago
Semantics and configurability is what what makes a language great. JS doesn’t have function environments, i.e. every unlexical lookup goes to global/window and that cannot be redirected. It doesn’t have green threads (at least). There are generators, but one cannot just yield without marking all the functions generators too (async/await in modern terms). Stack traces are lost when generators throw(). JS has no good introspection — you can do some Reflect, but cannot e.g. write a module that has a function, that when called enumerates all functions in a caller module and exports them by specific criteria. JS can’t properly substitute objects with proxies. It can catch simple existing key accesses, but can’t enumerate keys or arrays. There was handler.enumerate, but it was deprecated. Vue, which was written by no fools I think, cannot “app.array[3] = v” or “app.newkey = v”. It cannot dynamically watch an entire app too, all structure has to be defined before Vue().
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.
- rusk 9y agoI think that much of these criticism relate to the implementation, and the runtime (i.e. browser) rather than the language itself. As a scripting language for a browser environment it's pretty good. Modern variants have lots of lovely language features and tools like babel mean you can use a lot of these new features without sacrificing backward compatibility. 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.
- egeozcan 9y agoThere are a lot of valid criticisms against JavaScript. This is a fact. It's not a great language (clearly demonstrated by the discussion about it being good or not) but it's not terrible. I doubt anyone calls JS terrible on its own merits. There is a lot of hate against the runtime (edit: I mean the browser, not JS VMs or interpreters). The runtime enforces JS and the runtime itself is enforced everywhere. There is also this new flow of very inexperienced developers who seem to think JS (and perhaps Ruby) is the only language. This is very similar to the hate PHP got. Pragmatic choices vs experienced having their "I told you so" moment when they see "sql_srsly_escape_string_this_time(...". 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.
- anton-107 9y ago> It's not a great language (clearly demonstrated by the discussion about it being good or not) but it's not terrible 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
- tromp 9y agoI like to think of Haskell as a great language. It still has its warts (e.g. last [0,1/3..2] > 2), but if you wan't wart free, there's probably nothing beyond lambda calculus. Being the closest thing to lambda calculus with enough syntactic sugar on top to make it practical is a large part of what makes Haskell great.
- CiPHPerCoder 9y agoThe one thing that makes Haskell not great is that its understanding is not widely intuitive. People with mathy backgrounds that don't blink at the phrase "lambda calculus" won't consider this, but a lot of people struggle with math. If you can't put it in the hands of a 6th grader (in the public school system with no special tutoring) and have a reasonable chance of it being understood (n.b. I self-taught myself early JavaScript when I was in the 5th grade, and picked up PHP the following year), it won't ever be "great".
- gcommer 9y agoAll but maybe a few small % of the TIOBE index would fail all or some of those requirements... So while the enthusiast side of me heartily agrees with you, the professional programmer side of me has seen plenty of good code despite a lack of those features. Just because I know that better language features exist doesn't condemn every language lacking them as unusable.
- JepZ 9y agoWhat are great languages in your opinion?
- wruza 9y agoIf we’re talking about “dynamic CRUD over socket abstracted to death”-style tasks, and not considering minor preferences like syntax, then python, lua, most of lisp/schemes, perl. All of these allow enough meta-anything to do: ./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.
- 1897234234235 9y agoI think python is a terrible language. It has so little syntax you can't tell the difference between various things. A variable declaration, a reassignment, a keyword, a whatever else, they don't have any visual distinction from each other. 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.
- amelius 9y agoMy main problem with Python: passing a temporary closure to a function is very messy. You can't do functional programming well in Python. Also, I think scoping rules in Python are terrible. I always end up with a namespace that is a mess. And you can't do something like this in a clean way: counter = 0 def add(n): counter += n add(1) add(2) add(3)
- aldanor 9y ago
- ralusek 9y agoAre you aware of ES6 Proxy? I may be mistaken, but almost every example of an issue that you have with the language seems to be resolvable using Proxy objects. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- wruza 9y agoYes, and “handler.enumerate” deprecation is stated in this mdn link. I thoroughly checked every described [un]feature in my recent research. There is some space for error ofc, but I’m aware of most obvious things. Again, simple get/set of existing or known keys is easy, but try to proxy an arbitrary object, array or class instance and see how it falls apart. This is almost a rule in JS: every feature is somewhat mentioned in docs, in the web, in excited conversations, but in fact it is shallow workaround that cracks under moderate pressure. So, please Vue.set(app.array, 3, v) and forget about abstracting vue away from your logic. I suspect that this is a consequence of commumity-driven design. >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.
- maga 9y agoWe use proxies to watch models in our in-house MVC framework[1] and all those use cases are covered. You can watch setting array items with indexes, nested objects etc. It did take some jumping through hoops because the model also has to extend EventTarget which didn't like proxies. And we had to keep track of nested objects without creating new proxies on every call, but it's still not a rocket science. Here the code of the model implementation: https://github.com/zandaqo/compago/blob/master/src/model.js https://github.com/zandaqo/compago/blob/master/src/model.js [1]https://github.com/zandaqo/compago https://github.com/zandaqo/compago
- dsego 9y agoImo, all people saying that some language or tech is good enough seriously lack imagination. Things could be so much better.
- slikts 9y agoThe generators or async/await in JS are 'shallow' coroutines because you can only `yield` or `await` in the direct scope of a generator or async function, but the benefit of shallowness is that the control flow is explicit; you don't have to consider whether a function call will suspend the calling context's execution or not. I find the explicit clarity to outweigh the reduced power of shallow coroutines. 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.
- lambdadmitry 9y ago> 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. 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 https://github.com/tc39/proposal-dynamic-import/issues/35
- slikts 9y agoDynamic imports don't replace static imports.
- Izkata 9y ago> As an aside, there exist green threads in JS, namely node-fibers, although it's only a Node.js extension. 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_API/Using_web_workers https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers...
- mkirklions 9y agoI have done javascript programming, but after reading this I dont feel like I know anything.
- alangpierce 9y ago> Stack traces are lost when generators throw(). 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();
- Ajedi32 9y agoYeah, V8 in particular has possibly the best debugger tool available in any language ever; an easy to use UI, but still absolutely chock full of just about every useful feature you could imagine.