News for hackers. Stuff that matters.
Re:TypeScript 5.2's New Keyword: 'using' by gentleman11 on Monday June 19, 2023 @12:40PM (#36393132)
JavaScript used to be a little elegant in its simplicity. JavaScript now is getting complicated. Syntactic sugar, I think, is only there to build a moat around a tech to justify a salary premium and reduce the number of newcomers. You end up with a dozen arcane ways to do the same thing, and you have to be fluent with all of them in order to read your teammates code. It makes the language harder to use, while adding no new functionality
Re:TypeScript 5.2's New Keyword: 'using' by hungryforcodes on Monday June 19, 2023 @12:45PM (#36393195)
This is really true. I feel somehow the problem came when the functional programming gang hijacked it and forced ES6 on us. Promises were so counter intuitive they had to create shortly after async / wait...

Don't get me wrong there are alot of great things in ES6, but it was not quite the same language after...

Re:TypeScript 5.2's New Keyword: 'using' by merrywhether on Monday June 19, 2023 @01:01PM (#36393483)
> functional programming gang

This is a bit of weird assignment, given that the Class syntactic sugar over Prototype was one of the marquee features of that release.

Re:TypeScript 5.2's New Keyword: 'using' by salwadordali on Monday June 19, 2023 @12:55PM (#36393386)
How would you solve the async/await issue then? I think JS handles asynchronicity very elegantly. You just need to create a proper mental model around it. I don't want to go back to the old times of callback hell, that's for sure.
Re:TypeScript 5.2's New Keyword: 'using' by efdee on Monday June 19, 2023 @12:48PM (#36393253)
What would you prefer instead of promises? Callbacks?
Re:TypeScript 5.2's New Keyword: 'using' by manigandham on Monday June 19, 2023 @12:57PM (#36393415)
async/await and promises are both just syntax on top of yield/generators.

Most programming languages are just different syntax on top of the same core primitives.

Re:TypeScript 5.2's New Keyword: 'using' by verdagon on Monday June 19, 2023 @12:49PM (#36393281)
> Syntactic sugar, I think, is only there to build a moat around a tech to justify a salary premium and reduce the number of newcomers.

Ascribing that kind of motive to something as innocuous as syntactic sugar is silly at best. Most syntactic sugar I've seen is pretty clearly an attempt to make users' lives easier (whether successful or not is irrelevant).

Source: am an actual language designer.

Re:TypeScript 5.2's New Keyword: 'using' by roetlich on Monday June 19, 2023 @01:03PM (#36393507)
I love how this all went full circle. You know, just a few years ago, there still was the narrative of how bad JS is. Especially on HN. "Designed in only ten days", people made fun of it for being such a half-assed language. Stuff like the "Wat" talk, making fun of left-pad, etc.

Now it's "JavaScript used to be a little elegant". Fantastic.

More seriously:

1. This is typescript. Feel free to use js without it. (EDIT: This is wrong :)

2. This is a relatively easy feature, and there are equivalent features in some other mainstream languages.

You don't have to like it, I'm not sure I do, but this feels so dramatic.

Re:TypeScript 5.2's New Keyword: 'using' by johnny22 on Monday June 19, 2023 @01:11PM (#36393651)
no, it's not typescript. it's a language feature coming to js.
Re:TypeScript 5.2's New Keyword: 'using' by roetlich on Monday June 19, 2023 @01:14PM (#36393698)
Oh, thanks for the correction!
Re:TypeScript 5.2's New Keyword: 'using' by johnfn on Monday June 19, 2023 @01:04PM (#36393529)
What? I'm the biggest TypeScript apologist today, and even I think that JavaScript used to be terrible! Remember `function`? Remember `var that = this`? Heck, remember `var`? Remember `.bind()` and having to bind all class methods? Remember `parseInt(08)`?
Re:TypeScript 5.2's New Keyword: 'using' by baq on Monday June 19, 2023 @03:31PM (#36395552)
> JavaScript used to be a little elegant in its simplicity.

Sir.

Wat. [0]

I could not possibly imagine a sentence I would be so vehemently disagreeing with.

[0] https://www.destroyallsoftware.com/talks/wat