News for hackers. Stuff that matters.
Re:In Java 3 = 12 by pasquinelli on Wednesday November 15, 2017 @02:09AM (#15701976)
dynamic vs. static typing is independent of strong vs. weak typing. strong typing is basically allowing fewer implicit converstations, weak more. static means type checking happens before runtime, dynamic means the opposite.
Re:In Java 3 = 12 by guelo on Wednesday November 15, 2017 @03:07AM (#15702205)
Thanks for that explanation. So Java is weakly typed? Or would you say less strongly typed? Is the strength determined by the amount of implicit type coercions that are available?

Does static vs dynamic also imply that the strong-ness is checked at compile vs runtime? In other words, in python this bug can lurk undetected in your code

    list = (1, 2, 3)
    ‎x = list + 1
while in Java it will throw the error at compile time

    int[] list = {1, 2, 3}
    ‎Object x = list + 1
Re:In Java 3 = 12 by sametmax on Wednesday November 15, 2017 @03:13AM (#15702230)
> In other words, in python this bug can lurk undetected in your code

Well, if you use Python 3 and a modern editor, you will get a big red warning. mypy has been able to check types for a while and a lot of editors embed it.

Re:In Java 3 = 12 by guelo on Wednesday November 15, 2017 @03:41AM (#15702360)
But mypy is basically a static type checker for python. So my point still stands that static implies that strong-ness is checked at compile time, or IDE time in this case.

Thinking about this more, if all that strong vs weak is referring to is implicit type coercions then it is a useless confusing term. Static vs dynamic refers to when the type checking occurs, implicit type coercions are just one of the things the type checker looks for.

Re:In Java 3 = 12 by BerislavLopac on Wednesday November 15, 2017 @05:24AM (#15702768)
I've always seen the difference as this:

- In statically-typed languages, variables are containers, which allow only objects of a certain type to be contained within.

- In dynamically-typed languages, variables are more like labels which can be attached to different objects, which can be of different types.

Each of these approaches have its merits, which is obvious when you look at all the lengths languages of one type go to to emulate the features of the other: interfaces and generics in statically-typed languages, or type hints and statical checkers in dynamic ones. But I have yet to see a language that would offer both types of variables...

As a Python developer, I can easily imagine a PEP that would introduce some kind of "container variables" that would accept only properly typed objects and throw a syntax error if a violation occurs at compile time. But I'm not holding my breath, with a language which ironically doesn't even have an implementation for constants.

Re:In Java 3 = 12 by dozzie on Wednesday November 15, 2017 @04:01AM (#15702434)
> Does static vs dynamic also imply that the strong-ness is checked at compile vs runtime?

It's less like "implies" and more like "it's the definition of".

Re:In Java 3 = 12 by zurn on Wednesday November 15, 2017 @04:07AM (#15702455)
Strong vs weak typing also means whether you can circumvent the type system. So C/C++ are weakly typed systems because the laws of types are more like guidelines there and you can cast around them to reinterpret memory contents.