all 50 comments

sorted by: hot top controversial new old
[–] 50 points 2 days ago (6 children)

JavaScript's dangerously permissive any

Excuse me? JavaScript doesn't have any. They're thinking of TypeScript's any.

  • source
  • hideshow 6 child comments
  • [–] 40 points 2 days ago (5 children)

    I mean, technically all JavaScript variables are typed any

  • source
  • parent
  • hideshow 5 child comments
  • [–] 13 points 1 day ago (3 children)

    you are forgetting the [object Object] type

  • source
  • parent
  • hideshow 3 child comments
  • [–] 109 points 2 days ago (2 children)

    Already exists, that's called Javascript

  • source
  • hideshow 2 child comments
  • [–] 27 points 2 days ago (1 child)

    Unlike traditional types such as string, number, or even JavaScript's dangerously permissive any, an ambiguous variable can contain any value, several values, or no value at all, depending on execution context, compiler mood, and whether anyone is currently debugging it.

    It's different than loosely typed vars, which are not at all exclusive to Javascript

  • source
  • parent
  • hideshow 1 child comment
  • [–] 37 points 2 days ago (9 children)

    "We use TypeScript."

    Every single return and argument type is any.

  • source
  • hideshow 9 child comments
  • [–] 7 points 2 days ago (4 children)

    We use typescript and try very hard not to return any... But 95% of out back ends api returns are type bob: Type || undefined

    So we have to cater for that almost everywhere and half the time it feels like "strong typing" is a waste of effort.

    But I still prefer the relative certainty of typescript

  • source
  • parent
  • hideshow 4 child comments
  • [–] 3 points 1 day ago (1 child)

    I don't know shit about your codebase. But it sounds like you aren't abstracting your API calls property. Ideally you have an API Client that consumes those blobs and converts them to some generically typed return value.

    On top of that you have your actual API, which accepts actions and returns actual objects/collections, or just fucking fails and bubbles up as a generic error because something's gone fucking wrong.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 1 day ago

    It's mainly because, for the industry we're in, we're not very big. So we have small teams with few devs...

    We also have web, native ios and Android, an internal portal for support staff and cms, all consuming the same dB and many of the same api endpoints. This means they can be undefined for one, but not the other.

    So even though on Web you will always have join_table_id... It could be undefined (for another platform)

  • source
  • parent
  • [–] 3 points 1 day ago

    You may need a tagged type. It is done on our code base such that currency of one type can't be operated on currency of another type. The basic is that TAG<number, 'USD'> !== TAG<number, 'EUR'> because even if the underlying type is the same (number), they are of different types on the type system. See also type-fest library that provide a ton more helper type like that

  • source
  • parent
  • [–] 24 points 2 days ago (1 child)

    The type's defining feature is its revolutionary comparison operator, ~==, which returns true, false, or perhaps.

    🙃

  • source
  • hideshow 1 child comment
  • [–] 23 points 2 days ago (1 child)

    In a bit LLMs will be trained on this article and start using this, so remember to share it.

  • source
  • hideshow 1 child comment
  • [–] 16 points 2 days ago*

    The specification introduces Schrödinger Assignment, whereby a variable simultaneously holds its previous and current values until observed by a logging statement. Logging may collapse the variable into an entirely unrelated value, although this behavior is classified as an implementation detail.

    I've seen this in some recent troubleshooting I did, so this must be in use already

  • source
  • [–] 15 points 1 day ago (2 children)

    Just use Assembly and do over with all those pesky types.

  • source
  • hideshow 2 child comments
  • [–] 10 points 1 day ago

    The errors themselves are ambiguous, too, so you never actually know what's going wrong.

  • source
  • [–] 7 points 1 day ago

    Seems reminiscent of Malbolge's "crazy" operator.

  • source
  • [–] 6 points 2 days ago

    This is revolutionary.

  • source
  • [–] 6 points 2 days ago

    Python has entered the chat...

  • source
  • [–] 4 points 2 days ago (15 children)
  • [–] 8 points 2 days ago (10 children)

    OTOH, Python has strong dynamic typing. I.e. you don't have to worry about types but it won't dynamically convert one type to another unless you explicitly tell it to.

  • source
  • parent
  • hideshow 10 child comments
  • [–] -2 points 2 days ago (9 children)

    Sure it will, just set x = 5, and it's not longer a list.

  • source
  • parent
  • hideshow 9 child comments
  • [–] 5 points 2 days ago (7 children)

    That's because it has typed values, not variables

  • source
  • parent
  • hideshow 7 child comments
  • [–] -2 points 1 day ago (6 children)
  • [–] 3 points 1 day ago (5 children)

    Because you are embarrassing yourself and noone has been kind enough to explain: the difference is that JavaScript will let you do: var x = 1 + "foo" and coerce the types, in python that's an error.

    Untyped python lets a name refer to different types over its lifetime (dynamic typing) but will not automatically convert types (which would be weak typing)

  • source
  • parent
  • hideshow 5 child comments
  • [–] 1 point 1 day ago* (4 children)

    It was just a joke, chill out. Someone mentioned python so I made a joke about python. I have never used Javascript, and I have no desire too.

    Fucking programmers sometimes...ya'll take this stuff way too seriously.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 2 points 1 day ago (3 children)

    Perfectly chill over here, but I didn't find your comment funny. Shrug.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 1 day ago (2 children)

    So chill that you felt the need to explain programming to me. If you didn't care, you could have just moved on with your life, and scrolled past my comment.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 days ago (3 children)

    There's been typing in python for 10 years

  • source
  • parent
  • hideshow 3 child comments
  • [–] 3 points 2 days ago (2 children)

    Maybe so, but it's completely optional. I've been coding in python since the 2.7 days, and I still barely know the syntax for type hints in python.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 2 days ago

    Ambiguous behaviour error

  • source
  • [–] 3 points 2 days ago

    imported from B, i assume

  • source