Stories
Slash Boxes
Comments

SoylentNews is people

posted by janrinok on Wednesday July 05 2023, @07:10AM   Printer-friendly

ECMAScript 2023 spec for JavaScript finalized:

ECMAScript 2023, an update to the official specification for the JavaScript programming language, has been approved by ECMA International. The new spec adds new methods for searching and changing arrays, extends the WeakMap API to allow unique symbols, and introduces some standardization for the use of hashbangs.

Approved on June 27, the ECMAScript 2023 specification cites the following synopsis of improvements:

ECMAScript 2023, the 14th edition, introduced the toSorted, toReversed, with, findLast, and findLastIndex methods on Array.prototype and TypedArray.prototype, as well as the toSpliced method on Array.prototype; added support for #! comments at the beginning of files to better facilitate executable ECMAScript files; and allowed the use of most Symbols as keys in weak collections.

The finished proposals, published by the ECMA TC39 (Technical Committee 39) on GitHub, elaborate on the four features to be published this year:

  • Array find from last, a proposal for .findlast() and .findLastIndex() methods on array and typed array. Finding an element in an array is a very common programming pattern, the proposal states. Scenarios under which this feature would be used include when a developer knows that finding an element from last to first may have better performance, or developers care about the order of the elements.
  • Permitting symbols as keys in WeakMap keys, a proposal that extends the WeakMap API to allow the use of unique symbols as keys. Currently, WeakMaps are limited to allow only objects as keys.
  • Change array by copy, a proposal that provides additional methods on Array.prototype and TypedArray.prototype to enable changes on the array by returning a new copy of it with the change.
  • Hashbang grammar, a proposal to match the de facto usage in some CLI JS hosts that allow for Shebangs/Hashbang. These hosts strip the hashbang to generate valid JS source texts before passing to JS engines. This plan would move the stripping to engines and unify and standardize how that is done.

Updated versions of ECMAScript traditionally are finalized by ECMA in June. Last year's ECMAScript 2022 featured class elements and top-level await capabilities.


Original Submission

This discussion was created by janrinok (52) for logged-in users only, but now has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
(1)
  • (Score: 0) by Anonymous Coward on Wednesday July 05 2023, @08:38AM (4 children)

    by Anonymous Coward on Wednesday July 05 2023, @08:38AM (#1314498)

    I don't think I have ever used find() or findIndex().

    • (Score: 2) by janrinok on Wednesday July 05 2023, @08:41AM

      by janrinok (52) Subscriber Badge on Wednesday July 05 2023, @08:41AM (#1314499) Journal

      Perhaps not, but others might have done so.

    • (Score: 3, Touché) by GloomMower on Wednesday July 05 2023, @03:35PM (2 children)

      by GloomMower (17961) on Wednesday July 05 2023, @03:35PM (#1314562)

      You just do your own loop then?

      • (Score: 2) by bussdriver on Wednesday July 05 2023, @03:42PM (1 child)

        by bussdriver (6876) Subscriber Badge on Wednesday July 05 2023, @03:42PM (#1314564)

        people who can't handle doing the loop ... well, it's supposed to be accessible to as many people as possible so i guess this is ok. but classes and other complex bloat shouldn't be allowed. I think they should require 5 years between changes! We are not supposed to be building large complex projects in this scripting language. it should be the glue it was intended to be.

        • (Score: 2) by GloomMower on Wednesday July 05 2023, @09:51PM

          by GloomMower (17961) on Wednesday July 05 2023, @09:51PM (#1314629)

          > We are not supposed to be building large complex projects in this scripting language.

          It really grinded my gears in the early 2000s, but I don't mind it so much anymore.

          Kind of have to face reality. Though if you really don't like it, you can do a lot now with web assembly.

  • (Score: 3, Interesting) by DannyB on Wednesday July 05 2023, @02:29PM (10 children)

    by DannyB (5839) Subscriber Badge on Wednesday July 05 2023, @02:29PM (#1314547) Journal

    In what future year can you safely use these features and feel comfortable that all of your users have browsers equipped with these language improvements? 2030? 2040? Oh, wait, 2040 is well after 2038, so nevermind.

    Obviously SN is very concerned about the browser compatibility of ECMAScript among its users.

    Now for a note about nomenclature. JavaScript sounds better than ECMAScript. However JavaScript is inevitably confused with Java. But ECMAScript sounds like some sort of medical condition in need of a cream, lotion or salve.

    --
    What doesn't kill me makes me weaker for next time.
    • (Score: 3, Informative) by GloomMower on Wednesday July 05 2023, @02:55PM

      by GloomMower (17961) on Wednesday July 05 2023, @02:55PM (#1314554)

      You can use transpilers where you set which feature set you support (Browsers within the last 8 years, or > 5% market share), it can then take these new features and automatically replace them with code that works on older browsers. Compilers like https://babeljs.io/. [babeljs.io] Eventually after enough time the transpiler won't do the replacement for you because it is supported by most people.

      Also javascript is used on the server side, in which case you have more control over what version of nodejs you use.

    • (Score: 0) by Anonymous Coward on Wednesday July 05 2023, @05:17PM (1 child)

      by Anonymous Coward on Wednesday July 05 2023, @05:17PM (#1314582)

      Since Chromium dominates the landscape and browsers are aggressive about updating themselves now, probably sooner than you expect.

      But ECZEMAScript is used in more places than just the browser, scary as that is.

      • (Score: 3, Funny) by DannyB on Thursday July 06 2023, @06:52PM

        by DannyB (5839) Subscriber Badge on Thursday July 06 2023, @06:52PM (#1314783) Journal

        ECMAScript is used in the user interface of the SpaceX Crew Dragon.

        Yes, really. [os-system.com]

        --
        What doesn't kill me makes me weaker for next time.
    • (Score: 4, Informative) by Zinho on Wednesday July 05 2023, @05:30PM

      by Zinho (759) on Wednesday July 05 2023, @05:30PM (#1314586)

      In what future year can you safely use these features and feel comfortable that all of your users have browsers equipped with these language improvements?

      Ummm, this year, for the most part?

      A quick search of my favorite JS reference shows that, with the exception of Firefox and the Array copying methods, these changes already have widespread adoption:

      Array.prototype.findLast() [mozilla.org]
      Array.prototype.findLastIndex() [mozilla.org]
      WeakMap Non-registered symbols as keys [mozilla.org]
      Array.prototype.toReversed() [mozilla.org]
      Array.prototype.toSorted() [mozilla.org]
      Array.prototype.with() [mozilla.org]
      Hashbang (#!) comment syntax [mozilla.org]

      Compared to the bad old days of the Browser Wars, JS programming today is quite a pleasant experience as far as compatibility goes.

      --
      "Space Exploration is not endless circles in low earth orbit." -Buzz Aldrin
    • (Score: 4, Insightful) by theluggage on Wednesday July 05 2023, @05:43PM

      by theluggage (1797) on Wednesday July 05 2023, @05:43PM (#1314587)

      In what future year can you safely use these features and feel comfortable that all of your users have browsers equipped with these language improvements?

      If you wanted something like the .findlast() Array method, you could always extend the Array class with your own function. Now, you can write your own .findlast() function to the official spec, and - a few years down the line when browsers have been updated - easily switch to the (probably more efficient) built-in version. "Polyfills" which test browsers for recently-added features and insert compatibility code if they're not there have been used in HTML/Javascript for years.

      Additions to the underlying language will probably turn up in Typescript which can transpile to earlier versions of Javascript - and maybe other transpilers.

    • (Score: 2) by quietus on Wednesday July 05 2023, @07:13PM (2 children)

      by quietus (6328) on Wednesday July 05 2023, @07:13PM (#1314603) Journal

      But ECMAScript sounds like some sort of medical condition in need of a cream, lotion or salve.

      That's an interesting association you make there, DannyB.

      Now, on behalf of a company located in Red...ehm...Wood, what are your associations with the term micro-soft?

      • (Score: 2) by DannyB on Thursday July 06 2023, @01:49PM

        by DannyB (5839) Subscriber Badge on Thursday July 06 2023, @01:49PM (#1314741) Journal

        I presume you are referring to MS since we are talking about medical conditions confused with computer terms.

        Please don't get them confused. There are two kinds of MS.

        1. An affliction suffered by millions which makes it difficult to do even the simplest tasks.
        2. A medical condition of the brain.

        --
        What doesn't kill me makes me weaker for next time.
      • (Score: 2) by Rich on Friday July 07 2023, @01:33AM

        by Rich (945) on Friday July 07 2023, @01:33AM (#1314838) Journal

        what are your associations with the term micro-soft?

        Obviously fabric conditioner:

        http://desmotivaciones.es/carteles/detergentes [desmotivaciones.es]

        (They didn't register their trademarks for that market segment in Switzerland, iirc.)

    • (Score: 2) by digitalaudiorock on Thursday July 06 2023, @03:42PM (1 child)

      by digitalaudiorock (688) on Thursday July 06 2023, @03:42PM (#1314757) Journal

      In what future year can you safely use these features and feel comfortable that all of your users have browsers equipped with these language improvements? 2030? 2040? Oh, wait, 2040 is well after 2038, so nevermind.

      Clearly you're missing how this shit works these days. It'll go something like this:

      1. The Chrome and Mozilla shitheads will jump on these features pretty fast because..."shiny"...

      2. Their asshole fanboy web developers will jump on it as fast as possible.

      3. Many sites will stop working for all but a few major browser.

      As an avid palemoon user I can tell you this IS how it works. This is almost as annoying as when the browser police at cloudflare fuck over non-mainstream browsers in their Godless security checks used by web site admin sheep.

(1)