SlashData: Rust sees fastest growth, JavaScript still dominates - eviltoast
  • Feathercrown@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    4 months ago

    You can’t, because there’s no such thing as an integer value. It’s all floats, always.

    But you can. Any number that precisely represents a 32-bit integer can be used with binary operations as if it was one, and there will be no loss of information or unexpected results. Is it weird that JS has no integer type, or that its max safe integer representation caps out at 2^53? Yes, but that’s not the complaint you made. Binary operations work literally perfectly as expected for any inputs that have the appropriate type. Actual float values are truncated, which fits the language design.

    Ah yes I forgot sets. But I don’t think there’s anything else? Last time I checked there were no binary trees, no proper queues, no ordered sets, but I may be wrong on that. It’s not enough imo for a proper standard library.

    I’m sure you’re aware of push, pop, shift, and unshift, which together can make a FIFO or FILO structure, or a more complicated one, from an array. If you’re using TS you could create a semantic type that only allows a subset of these operations. I will concede that we have no tree type, although I’m not sure if that’s standard in other languages? I haven’t needed to use one myself.

    Anyways, I won’t fight you on JS being overused. I will say that it’s flexible enough that it can be used in any way, even if it’s not the greatest idea. Something like embedded programming or safety-related things shouldn’t use JS. And as you keep mentioning, it wasn’t made for low-level stuff, although it can do it. I don’t think that’s a requirement for a stdlib though.