News for hackers. Stuff that matters.
Re:How an Anti-TypeScript “JavaScript developer” like me bec... by recursive on Tuesday March 02, 2021 @12:33PM (#26317852)
JQuery dealt with DOM and browser stuff. Coffeescript dealt with syntactic language stuff. I can't think of a case where Coffeescript helps with the same thing JQuery does, although it may exist.
Re:How an Anti-TypeScript “JavaScript developer” like me bec... by tenaciousDaniel on Tuesday March 02, 2021 @12:51PM (#26318075)
Yeah as best I can tell, Coffeescript was a thing because Ruby was very popular at the time, and some Ruby devs had to write JS but they wanted to write Ruby.
Re:How an Anti-TypeScript “JavaScript developer” like me bec... by wmil on Tuesday March 02, 2021 @10:06PM (#26324236)
I was never a fan of the Rubyisms in Coffeescript. But it's sad nothing else ever implemented the YAMLisms.

Typing up constants in Babel JS is so much uglier than it needs to be.

But Coffeescript also introduced things like arrow functions that bind `this` to JS. Transpiling to ES5 allowed JS to evolve.

Re:How an Anti-TypeScript “JavaScript developer” like me bec... by ForHackernews on Tuesday March 02, 2021 @02:30PM (#26319359)
I think everyone except JS devs wishes they could write something other than JS for the browser.

Maybe eventually with WebAssembly...

Re:How an Anti-TypeScript “JavaScript developer” like me bec... by WorldMaker on Tuesday March 02, 2021 @03:17PM (#26320021)
That was definitely the case before ES2015. I think many of the non-JS devs that still hugely wish they could write something other than JS for the browser haven't kept up with ES2015+ nor Typescript. ES2015 is a much improved language and vanilla JS isn't painful anymore, especially with type="module" support now green enough in caniuse statistics that we can finally kill AMD and CommonJS for good in greenfield vanilla JS projects. The sky is quite sunny and ES2015+ is a better language than a lot of non-JS devs think JS is.

It will still be a while before all the brownfields in the larger ecosystem get cleaned up (if some of them ever do), but that's no longer a language problem, that's a a long tail ecosystem problem.

Re:How an Anti-TypeScript “JavaScript developer” like me bec... by tenaciousDaniel on Tuesday March 02, 2021 @04:31PM (#26321111)
Yup. I don't find myself using classes much, but some of the other new features remove the vast number of issues you tend to face.

Is scoping an issue for you? Just use arrow functions!

Is callback nesting an issue for you? Just use `async/await`!

I love it so much.

Re:How an Anti-TypeScript “JavaScript developer” like me bec... by recursive on Tuesday March 02, 2021 @05:13PM (#26321742)
I use classes a fair amount, but there's still some weird stuff in the language I'd take out if I could.

Sparse arrays, all object keys are strings (or symbols), crazy coercion rules, the existence of `null`, weird float vs int rules.

Re:How an Anti-TypeScript “JavaScript developer” like me bec... by runarberg on Tuesday March 02, 2021 @05:50PM (#26322234)
You can use `Map` instead of object which allows keys of any type, or typecheck your objects with `Record<K, V>` and let typescript warn you about any weirdness. Typescript can also warn you if you do some weird implicit coercion. You can typeguard against `null` (although I admit it is annoying, I just want to use an optional†). And if you really want to use integer types there is always `BigInt`.

---

†: I haven’t checked, but I bet there are some libraries out there that provide proper optionals using Proxy.

Re:How an Anti-TypeScript “JavaScript developer” like me bec... by recursive on Tuesday March 02, 2021 @07:24PM (#26323155)
I use BigInt often, but you can't (for example) do most substring operations with it, even though floating point indexes make no sense.

Map goes part of the way to what I want. But I really want to control which objects are considered equivalent keys, rather than being limited to reference equality.

Re:How an Anti-TypeScript “JavaScript developer” like me bec... by WorldMaker on Wednesday March 03, 2021 @01:34PM (#26332528)
There's a Stage 2 proposal before TC-39 to add immutable Record and Tuple types [1] which would be structurally compared and perfect for complex Map keys.

It's also easy enough to find or write quick simple Map wrappers that use a hash function on an object as keys when provided (either piggy-backing on the existing Object.prototype.valueOf, which always exists on every object and easily falls back to the reference-based current behavior, and expecting classes to have custom overrides for that, or using a Symbol named function of their own to avoid polluting own-property-keys/name clashes with other libraries).

[1] https://github.com/tc39/proposal-record-tuple

Re:How an Anti-TypeScript “JavaScript developer” like me bec... by lmm on Tuesday March 02, 2021 @08:38PM (#26323648)
Scala.js actually works really well. Frontend people aren't very aware of it, but if you're a backend dev who just needs to write a bit of code that has to run in the browser then I highly recommend it.
Re:How an Anti-TypeScript “JavaScript developer” like me bec... by adav on Friday March 05, 2021 @11:26AM (#26358637)
Even as an engineer happiest in Scala almost forced to write Typescript, I'll be the first to admit that the Scala.js library is still a bit lacking in comparison for real world productivity.
Re:How an Anti-TypeScript “JavaScript developer” like me bec... by lmm on Sunday March 07, 2021 @08:50PM (#26381591)
I had exactly the opposite experience. I kept trying to make Typescript work and it just wouldn't, eventually resorted to Scala.js and found (to my shock) that everything just worked and there were far less random rough edges.
Re:How an Anti-TypeScript “JavaScript developer” like me bec... by adav on Monday March 08, 2021 @06:19PM (#26393011)
That’s great :) Scala.js has such potential. I hope that my next opportunity to try it out (versus TypeScript) will be a similar experience to yours!