Live data from Hacker News

For modern development Javascript indeed is a shit language

live.julik.nl

211–220 of 243 posts

Re: For modern development Javascript indeed is a shit language

#211
post #33
post #15

"JS has callable attributes, Hobjects are unusable for stable keys...object does not carry any type information, Null everywhere, since ojects are hashes" I find most of the problems listed are related with dynamic type system of JS. These all can be solved most easily by a statically typed language. Therefore the debate mostly is between static vs dynamic typing.

I would also argue that expecting an object to carry type information is an unfair expectation of a non-object-orientated language.

JavaScript is an objected oriented language.

Re: For modern development Javascript indeed is a shit language

#212

> They are not solvable by making a new ECMA spec. As it turns out, many of the issues outlined are not only very much solvable by making a new ECMA spec but either already solved in ES5 or solved in ES6. > JS has callable attributes > This is a shitty design decision I strongly recommend not following the provided link, which is basically inane, uses the term "slots" in a rather disturbing manner and makes completel…

> I strongly recommend not following the provided link, which is basically inane... This was my personal rumination on the differences between the two approaches to OOP. Or a way to verbalize it, if you will.

> to my knowledge, you most definitely can not do that in such a manner in Self. Slots manipulation in Self can only be done through primitive messages (e.g. `_AddSlots:`, which takes an object whose slots should be copied into the receiver). This is probably true, I haven't used Self in anger so I will remove that.

> I'm not saying maps-as-objects is great, but I am saying these assertions are 1. wrong and 2. nonsensical. First thing you do to diss a statement is call it flat out nonsense.

> In ES5, the exact same behavior is provided by Object.getPrototypeOf providing access to the internal [[Prototype]]. Most implementations also provide direct access via the __proto__ property, which IIRC ES6 standardizes. And of course the `instanceof` operator has been there since ES3, but that's only ~13 years ago.

Why do there have to be `typeof`, `instanceof` and `.prototype`? Whereas you actually want one way to get at the object's type?

> All runtimes but MSIE (unless they've added it in IE11) already implement `const`, and it's standardized in ES6.

Maybe I should note that I was talking about JS as it is deployable today, to narrow the scope.

> You mean, something like ES6's yield? This one? http://stackoverflow.com/questions/2282140/whats-the-yield-k... > Terrible exception handling No objection there, javascript may well have a worse exception handling than Go, a language whose users try very hard to make others believe doesn't have exceptions in the first place. At least runtimes are finally trying to generate callbacks worth reading. Not that this help when mixing with async, as your final traceback will lack 90% of the necessary context.

If your stack records the necessary metadata it could easily give you something like `closured on line X in Items.fetchItems` insted of the 'anonymous function' 5 levels deep.

Re: For modern development Javascript indeed is a shit language

#213
post #203

Earlier quoted context omitted.

> We're talking about programming errors. Are you suggesting the solution to human error is to just not make errors?? Not at all, I'm simply suggesting that people take care to acknowledge and operate within the rules of the language. If you're making changes to a function signature in JS without assessing the impact for code elsewhere, then you're doing a bad job - and that's all there is to it. JS allows you to do…

> If you're making changes to a function signature in JS without assessing the impact for code elsewhere, then you're doing a bad job - and that's all there is to it. Given that other people are working on the same code base and may have added calls to this function, this is not even possible . Also, dynamic languages all require you to fix calls to changed functions. But at least, when you test that code, it won't a…

> Given that other people are working on the same code base and may have added calls to this function, this is not even possible.

Except it clearly is possible since I and millions of other developers seem to manage it daily.

> Also, dynamic languages all require you to fix calls to changed functions. But at least, when you test that code, it won't accidentally seem to work when it is broken.

This is a problem of your code-base, not the language. If your code is so brittle that it can't stand a few function changes without collapsing into a miasma of shit, then whose fault is that? Of course you need to fix calls to changed functions - but if doing so is causing you and your team pain, then perhaps you have other problems.

> This doesn't sound potential at all. It sounds like you either lose a huge amount of reliability, or add a huge burden to development.

Of course it's potential. Nobody's forcing you to write tightly coupled, shitty code which breaks after every merge. Seriously? Figure it out.

> What do you gain here? You save an asterisk in the syntax when you want to overload?

Like I said before, squishiness.

> In a collaborative environment, we merge work with each other every single day.

As do I, and clearly millions of other developers who don't seem to run into your problems.

> Do you have documentation and release notes for every commit you publish?

We have proper commit messages and tracking codes for every task / bug, yes. There's no such thing as perfect information - and sometimes merges get messy - but this is not unique to JS. Sure, not every single commit is perfectly documented, but small commits and concise messages go a long way to ensuring that the history is traceable and the code is clean. The more often you commit and merge with your collaborators, the more in lock-step you are and the less likely you are to run into these kinds of issues. Messy merges will happen from time to time regardless of your preferred language.

> Do you go and check the commit's release notes every time you pull?

Not always, but often. Maintaining visibility of the trajectory of the code and the project as a whole will help massively in heading off risks and development issues.

Re: For modern development Javascript indeed is a shit language

#214

Earlier quoted context omitted.

But you do see why people are complaining, right? You are having to manually write thousands of tests to check something that is trivial for a compiler to check.

This is just an absurd complaint, it's a dynamic language, if you want compiler forced type checking, use a static language. Dynamic languages are not broken because they don't behave like static languages.

You're missing the point.

A static language catches the error at compile-time.

A dynamic language catches the error at run-time.

Javascript hides the error and gives a cryptic bug, instead.

Re: For modern development Javascript indeed is a shit language

#215
post #203

Earlier quoted context omitted.

> If you're making changes to a function signature in JS without assessing the impact for code elsewhere, then you're doing a bad job - and that's all there is to it. Given that other people are working on the same code base and may have added calls to this function, this is not even possible . Also, dynamic languages all require you to fix calls to changed functions. But at least, when you test that code, it won't a…

> Given that other people are working on the same code base and may have added calls to this function, this is not even possible. Except it clearly is possible since I and millions of other developers seem to manage it daily. > Also, dynamic languages all require you to fix calls to changed functions. But at least, when you test that code, it won't accidentally seem to work when it is broken. This is a problem of you…

> Except it clearly is possible since I and millions of other developers seem to manage it daily.

Clearly possible to fix code that's in branches/working trees that you don't even have access to??

> This is a problem of your code-base, not the language. If your code is so brittle that it can't stand a few function changes without collapsing into a miasma of shit

When you change function signatures, code that calls those functions is broken. In static languages the breakage is a compile-time error. In dynamic languages the breakage is a run-time error. In JS the breakage is a cryptic bug.

> Of course it's potential. Nobody's forcing you to write tightly coupled, shitty code which breaks after every merge. Seriously? Figure it out.

The code is tightly-coupled and shitty because it has functions that get called?

> Like I said before, squishiness.

By squishiness, do you mean "trade errors for cryptic bugs"? You seem to be exactly who Dijkstra referred to when he said [1]:

> It was a significant improvement that now many a silly mistake did result in an error message instead of in an erroneous answer. (And even this improvement wasn't universally appreciated: some people found error messages they couldn't ignore more annoying than wrong results, and, when judging the relative merits of programming languages, some still seem to equate "the ease of programming" with the ease of making undetected mistakes.)

> As do I, and clearly millions of other developers who don't seem to run into your problems.

I'm wise enough to avoid JS, so I don't encounter such silly problems. I don't trust you to even know you are having these troubles, because the whole point is that these problems translate to cryptic bugs, rather than visible errors.

> We have proper commit messages and tracking codes for every task / bug, yes. There's no such thing as perfect information - and sometimes merges get messy - but this is not unique to JS

Note that the word "merges" may be misleading here. As every little pull you do (even a FF pull in git which updates files that don't overlap with your modified files) is a merge for this purpose.

Your approach here means that I must review all the function signature changes in every commit I pull, synchronously, before I carry on work. This doesn't help lock-step development as it incurs a serious overhead on such development.

> Not always, but often

That means when you pull, all the function calls to functions that may have had their signatures changed in your pulls may now become cryptic bugs. Awesome!

[1] https://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/E...

Re: For modern development Javascript indeed is a shit language

#216
post #214

Earlier quoted context omitted.

This is just an absurd complaint, it's a dynamic language, if you want compiler forced type checking, use a static language. Dynamic languages are not broken because they don't behave like static languages.

You're missing the point. A static language catches the error at compile-time. A dynamic language catches the error at run-time. Javascript hides the error and gives a cryptic bug, instead.

I'm not missing the point, and I don't agree that it hides an error and gives a cryptic bug. Messing with a function signature and not updating callers of that function is not a bug in the language, it's a bug in the programmer and will result in runtime bugs in any dynamic language. If you require X number of args, then assert that they aren't undefined. If you presume callers pass in X number of args in a variable args language, and then change the required args, you're the bug, not the language.

Re: For modern development Javascript indeed is a shit language

#217
post #58

I have always wondered why so many people like dynamically types languages... I mean, if I have a variable I ALWAYS know what kind of data I expect in it. If I try to use different kinds of data in the same variable then something is clearly wrong - either with me (for wanting that) or with the way I use the variable (and I would appreciate some warning about it). The problem is that you hardly have a choice nowadays…

It's good to have dynamic typing as an optional feature in a language (e.g. how it is implemented in C#). It could be useful for some very specific scenarios - typically around integration of different systems. But I agree that it doesn't make much sense to use them all the time. I think people mean that they like decent type inference when they say they like dynamic languages. C# makes a distinction between 'var' an…

^THIS TIMES A MILLION! Static typing, with good type inference, is awesome. Old-school C static typing, is not.

Re: For modern development Javascript indeed is a shit language

#218
post #33

Earlier quoted context omitted.

I would also argue that expecting an object to carry type information is an unfair expectation of a non-object-orientated language.

JavaScript is an objected oriented language.

Not really, from what I gather it's closer to a functional language that lets you implement objects with private data by using closures.

Re: For modern development Javascript indeed is a shit language

#219
post #214

Earlier quoted context omitted.

You're missing the point. A static language catches the error at compile-time. A dynamic language catches the error at run-time. Javascript hides the error and gives a cryptic bug, instead.

I'm not missing the point, and I don't agree that it hides an error and gives a cryptic bug. Messing with a function signature and not updating callers of that function is not a bug in the language, it's a bug in the programmer and will result in runtime bugs in any dynamic language. If you require X number of args, then assert that they aren't undefined. If you presume callers pass in X number of args in a variable…

> I'm not missing the point, and I don't agree that it hides an error and gives a cryptic bug.

It hides the error by carrying on, despite having the wrong number of arguments, and executing code with thus necessarily wrong inputs.

> Messing with a function signature and not updating callers of that function is not a bug in the language, it's a bug in the programmer

When editing code, you routinely change the function signatures of hundreds of functions. Of course you're going to miss some, some of the time. Human errors happen, and good languages help us deal with them.

Also, every time you pull code from another repository, function signatures all over the place change. Some of those may be functions your currently edited code is calling. This means every little divergence requires reviewing every single signature change or cryptic bugs will result.

> and will result in runtime bugs in any dynamic language.

It will result in runtime errors in dynamic languages. Errors that are visible, and difficult to ignore. That means the code gets fixed. UT triggers it trivially.

Whereas with Javascript, even code under UT can easily pass accidentally when wrong numbers of arguments are used.

This Dijkstra quote is relevant:

> It was a significant improvement that now many a silly mistake did result in an error message instead of in an erroneous answer. (And even this improvement wasn't universally appreciated: some people found error messages they couldn't ignore more annoying than wrong results, and, when judging the relative merits of programming languages, some still seem to equate "the ease of programming" with the ease of making undetected mistakes.)

> If you require X number of args, then assert that they aren't undefined

That captures half of the bugs (too few arguments), for a large overhead (an extra line for almost every argument in every function).

> If you presume callers pass in X number of args in a variable args language, and then change the required args, you're the bug, not the language

Every time you change code, there is potential to insert bugs. Of course all bugs originate from programmer errors. The tools can work with us to find these errors and mitigate them, or they can give us hell.

Re: For modern development Javascript indeed is a shit language

#220
post #215

Earlier quoted context omitted.

> Given that other people are working on the same code base and may have added calls to this function, this is not even possible. Except it clearly is possible since I and millions of other developers seem to manage it daily. > Also, dynamic languages all require you to fix calls to changed functions. But at least, when you test that code, it won't accidentally seem to work when it is broken. This is a problem of you…

> Except it clearly is possible since I and millions of other developers seem to manage it daily. Clearly possible to fix code that's in branches/working trees that you don't even have access to?? > This is a problem of your code-base, not the language. If your code is so brittle that it can't stand a few function changes without collapsing into a miasma of shit When you change function signatures, code that calls th…

> Clearly possible to fix code that's in branches/working trees that you don't even have access to??

This is a non-issue - if you're using unstable libraries then that's your own problem and breakages are to be expected. This is not the fault of JS.

> When you change function signatures, code that calls those functions is broken. In static languages the breakage is a compile-time error. In dynamic languages the breakage is a run-time error. In JS the breakage is a cryptic bug.

When you change function signatures, you document the change and you increment the version. If you're randomly updating dependencies without first checking that the new version is compatible with your existing code, then that's your problem. Again, this is not JS.

> The code is tightly-coupled and shitty because it has functions that get called?

If a change in a dependency causes you to have a ripple effect of completely broken code - then yes, your code is tightly coupled.

> By squishiness, do you mean "trade errors for cryptic bugs"? You seem to be exactly who Dijkstra referred to when he said [1]:

Squishiness is difficult to explain without describing the general ins and outs of dynamic languages, which I'm sure you're not completely alien to. Essentially, what I'm saying is that the problems you're experiencing with JS are largely your own fault - and no amount of complaining is going to solve the problem of the user lacking due diligence when they rely on unstable code or aren't maintaining their own dependent code properly. Again, these problems are not specific to JS.

> I'm wise enough to avoid JS, so I don't encounter such silly problems.

So you're weighing in on the problems of a language you don't even use. Doesn't that strike you as somewhat...silly?

> I don't trust you to even know you are having these troubles, because the whole point is that these problems translate to cryptic bugs, rather than visible errors.

They translate to cryptic bugs if you develop shitty software, sure. However, if you do your homework, correctly check your dependencies and retain some semblance of stability in your code-base, then no, these problems aren't nearly as dramatic as you're suggesting.

> Note that the word "merges" may be misleading here. As every little pull you do (even a FF pull in git which updates files that don't overlap with your modified files) is a merge for this purpose.

A merge is a merge is a merge. If you're merging unstable code, then you have to expect that you're going to need to do some maintenance. In what world is it sensible to develop software where you're not even attempting to ensure that potentially breaking changes aren't flagged up, discussed, and dealt with? Have you never heard of the phrase 'don't break the build'? In my job, if somebody commits and pushes something which is going to completely fuck the rest of the development team, then they're told to piss off and fix it. If you absolutely must change a function signature which is part of an API that others may be depending on, then you fucking document it and alert your users. Again, not JS. Sort your process out.

> Your approach here means that I must review all the function signature changes in every commit I pull, synchronously, before I carry on work. This doesn't help lock-step development as it incurs a serious overhead on such development.

No, my approach is that if I'm developing a library which others depend on, I don't fuck about with the API without a very, very good reason - and if I do, then I document it. Don't randomly update your dependencies if this is such a problem for you. If your code is so tightly coupled to whatever dependencies you have that updating that dependency means you need to change a thousand different lines of code scattered throughout your software, then you're already doing it wrong.

> That means when you pull, all the function calls to functions that may have had their signatures changed in your pulls may now become cryptic bugs. Awesome!

Except it doesn't, because who updates a dependency without checking that they can actually depend on it? The clue's in the name.

Post reply on HN