Talk:Strong and weak typing

Latest comment: 1 year ago by 184.160.115.111 in topic bank

Unclear introduction

edit

The introduction should explain more clearly what weak typing and dynamically typed variables mean. 2.110.93.203 (talk) 07:00, 18 May 2018 (UTC)Reply

Dead Source

edit

Now I am not good with this wikipedia thingy, I'll be the first to admit to this. But it needs to be said that the source 6 (ftp://gatekeeper.research.compaq.com/pub/DEC/SRC/research-reports/SRC-045.pdf page 3) is no longer available. I've got no clue on how to fix this but it should be replaced with this URL: http://www.lucacardelli.name/Papers/TypefulProg.pdf . Sorry to bother you GeneralDenmark (talk) 07:32, 21 February 2017 (UTC)Reply

  Done Thank you for the note. --Ancheta Wis   (talk | contribs) 12:16, 21 February 2017 (UTC)Reply

OR

edit

It looks like there's a lot of OR on this page. Since strong/weak typing doesn't have a single accepted definition, all examples should be backed by reliable sources, but most aren't. QVVERTYVS (hm?) 15:11, 17 June 2015 (UTC)Reply

Yes, "strong" and "weak" typing is just an attempt to simplify Type_system#Type_checking.
I don't think any researcher would use "weak" and "strong" type terminology nowdays. Ushkin N (talk) 00:57, 22 May 2016 (UTC)Reply


I've been researching the "etymology" of the terms strong and weak typing since a while. See my results so far at User:Ruud Koot/Computer science/Strong and weak typing. There isn't a universally accepted definition of those terms, but there are a small number of definitions that are often used. While contemporary researchers would rarely use these terms in a formal sense, they are still used in more colloquial speech. I think that a well-written article on this topic would be come too large to merge in its entirety into Type system (which should be an overview article, given the size of the topic). —Ruud 10:58, 22 May 2016 (UTC)Reply

IMO, we shouldn't use them at Type system or Programming language pages.
I'd rather mark it as Category:Buzzwords (or similar) because it confuses so many concepts in type(s) (systems) under two words "weak" "strong" (or speakers using it).
Programming_language#Weak_and_strong_typing
Type_system#.22Strong.22_and_.22weak.22_type_systems
However, we can link them in "See also" section or mention in the article from time to time. But not to crate paragraphs for these 2 words everywhere. Ushkin N (talk) 12:35, 22 May 2016 (UTC)Reply
I think people shouldn't be using the terms strong and weakly typed, but the (unfortunate) fact is that they do. And Wikipedia is descriptive, not prescriptive, so we should discuss them. I think the section Type_system#"Strong" and "weak" type systems is fine as is. It briefly states there is no universal definition and then refers to this article for the details. I think a lot can be said here about the many non-universally accepted definitions that have been given to these terms. The section Programming_language#Weak_and_strong_typing, is more problematic. It should probably read the same as Type_system#"Strong" and "weak" type systems. —Ruud 12:49, 22 May 2016 (UTC)Reply
Criticism these 2 terms was never discussed or explained with sources.
Also any claim about "weak" or "strong" typed languages are hardly sourced since we cannot trace their definitions!
Humans can use many meaningless words, but that doesn't mean we should use these words to describe topic. Ushkin N (talk) 13:24, 25 May 2016 (UTC)Reply
@Ushkin N, One approach to finding sources for usage would be to look up old programming books, say in Perl or C#, maybe 1995 or later. When the proponents of, say C#, were trying to push out the use of Perl (they have succeeded in lessening Perl usage) they used such terminology. Now that the debates are moot (JavaScript has increased usage, irregardless of its weakly typed status), it would probably help beginners in the field to learn what books to avoid. --Ancheta Wis   (talk | contribs) 14:02, 25 May 2016 (UTC)Reply
@Ancheta Wis, I wasn't following C# since the beginning and not sure how to search within C# literature (coverage of the results would be hard to achieve). 42 hits - I'm doing it wrong IMO Ushkin N (talk) 16:24, 25 May 2016 (UTC)Reply
We can trace the origins of these definitions! Again, see User:Ruud Koot/Computer science/Strong and weak typing#Literature review. The term "strongly typed" seems to have been introduced by Barbara Liskov in 1973/4 in her work on abstract data types. The term "weakly typed" by Demers et al. in "Encapsulated data types and generic procedures" (1977). Both give clear definitions of these terms. The only problem here is that later researchers and programmers gave and used several other definitions as well. —Ruud 17:14, 25 May 2016 (UTC)Reply
1974 definition uses other "terms" with loose meaning "abstract type", "abstract object". It also misses terminology that can be found at Wikipedia articles.
BTW, any definition that ignores hardware/software implementation is incomplete and lies: it is only good as "theory".
OR was formally proven. I don't any formal proofs in Barbara Liskov publications. Ushkin N (talk) 17:47, 25 May 2016 (UTC)Reply
Even if we can trace them, doesn't mean they are true. Many medal holders made imprecise statements, especially when field was rapidly developing. None of physics I know threat Newton laws as precise model of the real world, but that's off-topic here. Ushkin N (talk) 17:44, 25 May 2016 (UTC)Reply
See WP:NOTTRUTH. There is no requirement that Wikipedia article are limited to describing "mathematically precise" definitions. —Ruud 18:27, 25 May 2016 (UTC)Reply
WP:NOTTRUTH says you can include imprecise and verifiable to Wikipedia. But nothing prevents me from stating that something is incomplete or was never formally proven. WP:TRUTHMATTERS. Ushkin N (talk) 19:28, 25 May 2016 (UTC)Reply

Coercion's definition by Aahz contradicts the definition in Type conversion

edit

Type conversion#Implicit type conversion says (specifically WRT C-like languages) "Implicit type conversion, also known as coercion, is an automatic type conversion by the compiler", which contradicts Aahz's definition. In case the former definition is the one usually used (i am not an expert), i think that the reference to Aahz's example should be removed. Orenmn (talk) 15:44, 26 October 2017 (UTC)Reply

Is Python strongly typed?

edit

At the beginning of the text, it is said: "A weakly typed language has looser typing rules and may produce unpredictable results or may perform implicit type conversion at runtime."

And later: "Smalltalk, Perl, Ruby, Python, and Self are all "strongly typed" in the sense that typing errors are prevented at runtime and they do little implicit type conversion."

But it seems to me that Python (I don't know for the others) has "loose typing rules that may produce unpredictable results or may perform implicit type conversion at runtime". For example, the function

   def add_integers(a,b):
      return a+b

will return:

   In [2]: add_integers(1,2)                                     
   Out[2]: 3

but also:

   In [3]: add_integers("1","2")                                 
   Out[3]: '12'

This behavior might produce undesirable results at runtime, because the programmer can't rely on types to guarantee the validity of preconditions. To guarantee that this function adds integers, the programmer needs to explicitly check the types of a and b inside the function and raise an exception if the type is not int.

Also,

   In [4]: add_integers(1,2.0)                                 
   Out[4]: 3.0

performs an implicit type conversion from 1 to 1.0 before doing the addition.

Finally: eval(a) where a is a string returns an unpredictable type: eval("5") returns an int, eval("5.0") returns a float, eval("x") returns x which can be of any type (if x exists), known only at run time.

So Python has all the characteristics of a weakly typed language according to the definition given at the beginning. Scemama (talk) 00:33, 5 December 2020 (UTC)Reply


Multiple incompatible definitions

edit

Doing some research on the subject, I found a very pertinent answer on StackOverflow (answered Dec 9 '16 at 16:57 by ikegami): https://stackoverflow.com/questions/41063809/is-perl-weakly-or-strongly-typed

There are eight incompatible definitions for what it means to be strongly-typed, so what should we write on the Wikipedia page? - A list of all possible incompatible definitions mentioning that this notion is not well defined ? - The choice of one definition among all the possible, hoping to converge to the unique definition in the future ?

Of course, this makes my question above "Is Python strongly typed?" irrelevant... Scemama (talk) 00:47, 5 December 2020 (UTC)Reply

Remove 'strong' and 'weak' from info-boxes

edit

The info-boxes for many programming languages on Wikipedia (at least Python, C, Java, JavaScript, PHP, Swift, Rust, C# and Go, but not C++ or TypeScript) declare their typing systems to be 'strong' or 'weak'. This page, (or https://www.destroyallsoftware.com/compendium/strong-and-weak-typing?share_key=6b0dd1ec18ab6102) make it pretty clear that these terms are vague to the point of near meaninglessness, so it might be best to replace these with more precise descriptions. TomFryers (talk) 14:51, 16 May 2022 (UTC)Reply

bank

edit

let foo = 42; // foo is now a number foo = "bar"; // foo is now a string foo = true; // foo is now a boolean 184.160.115.111 (talk) 16:02, 31 January 2023 (UTC)Reply