Why is C# statically typed?

As others have said, C# is static/strongly-typed. But I take your question more to be “Why would you want C# to be static/strongly-typed like this? What advantages does this have over dynamic languages?” With that in mind, there are lots of good reasons: Stability Certain kinds of errors are now caught automatically by the compiler, … Read more

Static typing in python3: list vs List [duplicate]

Not all lists are the same from a typing perspective. The program def f(some_list: list): return [i+2 for i in some_list] f([‘a’, ‘b’, ‘c’]) won’t fail a static type checker, even though it won’t run. By contrast, you can specify the contents of the list using the abstract types from typing def f(some_list: List[int]) -> … Read more

What are the proper typescript types for addEventListener mousemove and its event argument?

What are the proper typescript types for addEventListener mousemove and it’s event argument? Being explicit will set you free: onMouseMove: { (event: MouseEvent): void } = (event: MouseEvent) => { } Or, let TypeScript infer it from assignment 🌹: onMouseMove = (event: MouseEvent) => { }

Can someone tell me what Strong typing and weak typing means and which one is better?

That’ll be the theory answers taken care of, but the practice side seems to have been neglected… Strong-typing means that you can’t use one type of variable where another is expected (or have restrictions to doing so). Weak-typing means you can mix different types. In PHP for example, you can mix numbers and strings and … Read more

Should you put quotes around type annotations in python

Putting quotes around type hints is something that makes sense when making a Forward Reference according to PEP 484. In this case putting quotes around a name is used to subdue a NameError that would occur. In other cases, don’t use quotes, it doesn’t result in the hint you want: >>> def bad_foo(a: ‘int’): … … Read more

Which languages are dynamically typed and compiled (and which are statically typed and interpreted)?

Here’s a list of a few interesting systems. It is not exhaustive! Dynamically typed and compiled The Gambit Scheme compiler, Chez Scheme, Will Clinger’s Larceny Scheme compiler, the Bigloo Scheme compiler, and probably many others. Why? Lots of people really like Scheme. Programs as data, good macro system, 35 years of development, big community. But … Read more

Why Is Dynamic Typing So Often Associated with Interpreted Languages?

Interesting question. BTW, I’m the author/maintainer of phc (compiler for PHP), and am doing my PhD on compilers for dynamic languages, so I hope I can offer some insights. I think there is a mistaken assumption here. The authors of PHP, Perl, Python, Ruby, Lua, etc didn’t design “interpreted languages”, they designed dynamic languages, and … Read more

Python typing what does TypeVar(A, B, covariant=True) mean?

Covariance and contra-variance are terms that relate to the intersection between object orientation and generics. Here’s the question this concept is trying to answer: We have a couple of “regular”, “object-oriented” classes, Base and Derived. We also have some generic type – let’s say List[T]. We know that Derived can be used anywhere Base can … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)