45

Wait a minute! :0

Comments
  • 8
    Shouldn't he be too far away because of indentions?
  • 9
    Oof. Don't even start about strong vs weak typing.

    All languages are special boys.

    It's a myth that languages can be classified so easily -- C used to be known (90s) as a weakly typed language, compared to languages like Haskell and Prolog.

    Because what does strongly typed mean?

    Types annotations are attached to variables instead of values? Constraints are checked at compile time? Or at run-time? The type of a value is immutable? Types must be explicitly defined? Values can not be cast? The language has a compound typing system which allows GADTs? All objects have a fixed type?

    The industry has never been able to come up with a satisfactory, unified definition in my opinion.

    Type systems must be compared on way more traits than just strong vs weak and static vs dynamic.

    In Perl for example, an array is strongly typed, while a string is weakly typed. Is the language... hybrid? And is PHP 7.4 suddenly strongly typed if you use type annotations on properties?
  • 1
    @bittersweet interesting. I never thought about that.

    For me, dynamically typed means there is no compiler that tells me that I am assigning a value to a variable of incompatible type which will fail at runtime.
  • 4
    @Lensflare

    Java: "Integer num;"

    num is now a reference without a value, not an Integer. Compiler will not complain about it being null. I can pass it to a method which requires an Integer as a parameter, which will throw a NullPointerException.

    In Haskell the type would be "Maybe Integer", a compound monadic type which is either Nothing or Integer, and functions must either bear the same type signature or the Nothing case must be handled before -- runtime NullPointerExceptions are impossible because the compiler type-checks both "Integer" and "Maybe Integer" as distinct types.

    Is Java a weakly/dynamically typed language?

    I realize I'm being pedantic here by focusing on null as an edge case specifically, but I hope you get my point that the "weak/strong" and "dynamic/static" terms are useless.

    Type systems are a very complex topic matter, you can't easily categorize programming languages using 4 words.
  • 2
    @bittersweet yeah, I agree. But I guess we can categorize languages by "tries to keep you from making errors" and "completely ignores types". Most languages fall into one of both.
  • 1
    @bittersweet by no means was that pedantic my dude. It was actually stated beautifully.
Add Comment