• ShortFuse@lemmy.world
    link
    fedilink
    English
    arrow-up
    9
    ·
    edit-2
    1 year ago

    I used to not like JavaScript when I started, having done C# and Java for about a decade before moving.

    But I feel differently now, having spent about a decade with it and having better tools (VSCode, Typescript, eslint). I code in JS, and use JSDocs whenever Typescript’s automatic type detection needs help (no-implicit-any).

    The 2015 changes brought a paradigm shift to write more expressive/declarative code and it’s continued from there. async/await is much easier than the Future<T> in Java. Tree-shaking of imports is great at reducing code bundling size. Classes are also optional, not mandatory which helps simplify code (functions vs methods).

    But for the nerdy stuff, I like I can still pass around functions as objects, something that harder to do in C# (delegates). It makes building functions more versatile dealing with arguments, so I can pass a string|number|function|Promise to one function and write more expressively httpPost(variableContent).

    Not perfect though. The prototype system is powerful if you learn it, but definitely confusing. Multithreading is basically non-existent in usage since you have to essentially convert a function to string (serialize) or script threads into their own file.

    I heard python is better for beginners, but I grew up on C style and needs my braces over indents.

    • fidodo@lemm.ee
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      I’ve always said JavaScript was an elegant language with a horrible implementation. Now that we have typescript and modern ecmascript standards I feel vindicated.

      The prototype system is a bit confusing despite being simple, but it’s very powerful despite being simple, which I think balances it out. Also using modern classes abstracts the more confusing bits and you very very rarely need to actually understand the underlying mechanics if ever anymore. Plus you rarely even need classes either with the first class functions.

      Parallelism could really improve. Don’t think I’d want to mess with shared memory, but I’d like to be able to pass actual in memory objects instead of having to serialize everything first. Maybe a child process sandbox that can be filled and relinquished once or something like that?

      • ShortFuse@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        1 year ago

        You can use SharedArrayBuffer but honestly it feels like something engineered for one specific purpose (OpenGL).

        It would be nice to have shared objects and strings with whatever syntax helps sync locks. You can technically use UTF8 with helpers like TextDecoder, and I could probably sit and write all that logic using Promises, but I’d imagine the amount of data conversion to make it happen would negate the performance gains from multithreading in the first place.