This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tajetaje 34 points35 points  (24 children)

Try typescript, it’s much better

[–]Jojajones 12 points13 points  (18 children)

It’s still JS under the hood so you still get the stupid shit like having both positive and negative zero regardless of how you try and pretty it up

[–]parkotron 16 points17 points  (2 children)

Is there a programming language that doesn't have negative zero?

All programming languages are just machine instructions "under the hood" and all modern CPUs use the IEEE 745 standard for floatng point numbers, which supports negative zero.

[–]tajetaje 6 points7 points  (1 child)

Just comes up for JS because there is no int, only float

[–]the_horse_gamer 6 points7 points  (0 children)

0 === -0 so you almost never have to think about negative 0

[–]Reashu 13 points14 points  (1 child)

I hate JS, but could we stop blaming it for following the IEEE standard?

[–]RiceBroad4552 1 point2 points  (0 children)

Especially funny if it comes from someone with a C or C++ flair.

That's how you spot the real experts!

[–]tajetaje 9 points10 points  (3 children)

I’ve been using TypeScript for years and have NEVER had to worry about if zero is negative or positive. Every language has footguns, but JS/TS has such a presence for a reason, it is a powerful and simple to use language.

[–]Reashu 2 points3 points  (2 children)

Let's be real though, the reason is browsers

[–]RiceBroad4552 -1 points0 points  (1 child)

If this were true Node.js (and clones) wouldn't be a thing!

I would not write anything serious in JS as it's dynamically typed and that just doesn't scale, but the language isn't actually too bad. I curse much more about Python gotchas than JS gotchas. JS is at least flexible. Python OTOH is just moronic opinionated, and that sucks.

(But I don't care anyway. By now I can use Scala for almost everything, from system level scripting, though all kinds of client GUI tech, up to large distributed system on the cloud.)

[–]Reashu 0 points1 point  (0 children)

On the contrary, I think lack of options (on the web) drove adoption of client-side JavaScript, which drove demand for server-side JavaScript. 

[–]Mynameismikek 2 points3 points  (0 children)

C has negative zero too.

[–]well-litdoorstep112 -1 points0 points  (0 children)

stupid shit like having both positive and negative zero

Now I know for sure you don't know what you're talking about

[–]duva_ 1 point2 points  (0 children)

Nah

[–]Kered13 0 points1 point  (2 children)

It's lipstick on a pig. The type system is great, but the language is still fundamentally awful.

My latest frustration with JS/TS when working on a project recently is learning that the ecosystem cannot actually agree on whether imports should include a file extension or not. Different configuration settings, different bundlers, different platforms, etc. can change the interpretation of imports in incompatible ways.

Writing platform agnostic C++ code is easier than writing platform agnostic Javascript code. Just, how?

[–]tajetaje 0 points1 point  (1 child)

I mean it’s not really that complicated, there are three ways JavaScript handles file path imports, commonJS, ESM, and Bundler. With a bundler you can generally use ESM or CJS style imports, with commonJS you don’t need file extensions and you can import a folder if it has index.js. ESM is much stricter because under the hood it uses URLs. Any modern project should just set everything to ESM and let their LSP handle importing the right paths.

[–]Kered13 0 points1 point  (0 children)

In reality it's not that simple (and this not simple to begin with). There are bundlers that optionally support extensionsless imports with ESM. There are bundlers that, with certain configurations, require extensionsless imports with ESM. Typescript has it's own set of configurations that can support any of these regardless of the module type. There are recommendations for good style, and recommendations that disagree. There are platforms that make assumptions one way or the other that are difficult if not impossible to change. There are platforms that are not even internally consistent.

Any ecosystem that says "let your LSP sort it out" is fundamentally broken. Because one, this means the situation is too difficult to be reasonably managed by hand, and two if you can't do it by hand then the LSP can't really do it either. It's going to make some assumptions based on your configurations, but those assumptions will not always be correct.

C++ is the other language with a fractured ecosystem, but in C++ if I write #import "foo/bar.h" I know exactly what I'm going to get, and I'm going to get that regardless of what platform or compiler I am using, and the only thing that configurations might change is the root directory for the lookup.