禄神是什么意思| 夏天白鸽煲什么汤最好| 双龙是什么意思| 御字五行属什么| 小儿病毒性感冒吃什么药效果好| 与虎谋皮什么意思| 什么是智商| 姓名字号是什么意思| 九月3日是什么日子| 枸杞什么时候吃最好| 工作效率等于什么| 呼吸胸口疼是什么原因| 花椒有什么功效与作用| 什么是植物人| cvt是什么意思| 护手霜什么牌子的效果好| 什么的草帽| 否认是什么意思| 脓毒症是什么引起的| 总是出汗是什么原因| ctp是什么| 换身份证需要带什么| 5月28是什么星座| 西腾手表属于什么档次| 孔子姓什么名什么| 男士内裤买什么牌子好| 36岁生日有什么讲究| 足石念什么| 什么是包皮手术| 暖对什么| 物以类聚什么意思| 属猴的守护神是什么菩萨| 3楼五行属什么| 李白长什么样| 侧睡流口水是什么原因| 万事达卡是什么卡| 男生早上为什么会晨勃| 颈椎病最怕干什么活| 深闺是什么意思| angelababy是什么意思| 感恩节为什么要吃火鸡| 色觉异常是什么意思| 肚子为什么会疼| 银离子是什么| 体温偏低是什么原因| 乙肝抗体阳性什么意思| 出差带什么| 直销是什么意思| 脑死亡是什么原因引起的| 法字五行属什么| 小腹胀痛什么原因| se是什么| 娃娃流鼻血是什么原因| 喝什么茶能减肥| 孩子注意力不集中缺什么微量元素| 烫伤用什么药最好| 观音菩萨是属什么生肖| 专一是什么意思| 苹果什么时候出新手机| 好老公的标准是什么| 肾炎是什么原因引起的| 肝病吃什么药好得快| 什么什么为什么| 腺样体面容是什么意思| galaxy是什么牌子| ooc是什么| 老专家药膏有什么功效| 维生素c高是什么原因| 吃东西恶心想吐是什么原因| 晚上夜尿多吃什么药| 活珠子是什么| 小米是什么米| 梦到老房子是什么意思| a型血为什么叫贵族血| 柳丁是什么水果| 怕冷又怕热是什么原因| 什么食物含维生素k最多| 腿凉是什么原因引起的| 组胺过敏是什么意思| 牛跟什么相冲| 天蝎女和什么星座最配| 禄存是什么意思| 仁德是什么意思| 黑色的屎是什么原因| 月什么人什么| 52年属什么| 水稻什么时候播种| 伏地魔什么意思| 什么人不能吃西洋参| 甲低有什么危害| 农历5月17日是什么星座| 晗字五行属什么| 肺活量5000什么水平| 身旺是什么意思| 7月23日是什么日子| 大白条是什么鱼| 孕妇梦见黑蛇是什么意思| 凯撒沙拉酱是什么口味| 什么车子寸步难行脑筋急转弯| 微波炉蒸鸡蛋羹几分钟用什么火| 梦见吵架是什么意思| slf是什么意思| 尿频尿急挂什么科| 小孩手上脱皮是什么原因| 胃火重口臭吃什么药好| 提成是什么意思| 什么的武松| 身上长疮是什么原因引起的| 平仓什么意思| 羊肉炖什么好吃| 慢性病都包括什么病| 蛰居是什么意思| 登革热是什么病| 蛤蟆吃什么| 什么林什么染| 奶水不足是什么原因造成的| 翌字五行属什么| 灼口综合症吃什么药| 嗓子痒痒老想咳嗽是什么原因| 23岁属什么生肖| 红顶商人是什么意思| 胃酸吃什么食物好| 眉毛里面有痣代表什么| 甲状腺结节忌口什么| 鹅梨帐中香是什么| 脱发缺什么维生素| 月经崩漏吃什么止血| 一个均一个金念什么| 反吟是什么意思| 马中赤兔人中吕布什么意思| 5月24日是什么星座| 六月一号什么星座| 尿常规白细胞偏高是什么原因| 头皮发白是什么原因| 中国最长的河流是什么河| 什么心丧气| 黄体酮吃了有什么副作用| 腰椎间盘膨出是什么意思| 放臭屁是什么原因| 小孩测骨龄挂什么科| 测怀孕的试纸叫什么| 直的是什么意思| 字读什么| 橙色加蓝色是什么颜色| 什么的东西| 鸡为什么吃沙子| 少阳病是什么意思| 新鲜橄榄菜长什么样子| hpv11阳性是什么意思| 什么是飞蚊症| 乙字五行属什么| 腰椎间盘突出和膨出有什么区别| 为什么姓张的不用说免贵| 杨梅酒有什么功效| 签发是什么意思| 什么山不能爬脑筋急转弯| 7月22日是什么星座| 梦见剪头发预示什么| 丰衣足食是什么生肖| 安德玛是什么牌子| 浮云是什么意思| 舅舅的老婆叫什么| 手臂长痘痘是什么原因| 什么药可以催月经来| 中国民间为什么要吃腊八粥| ins是什么社交软件| hpv感染用什么药| 姓杨的女孩子取什么名字| 甲亢挂什么科室| 正骨有什么好处和坏处| 什么是风象星座| 例假期间适合吃什么水果| 3月12日是什么星座| 肌酸激酶高吃什么药| 阳痿早泄用什么药| 睡眠不好用什么药调理| md是什么职位| 什么病能办低保| 乳腺结节吃什么食物好| 尿道口痛什么原因| 海底椰是什么东西| 李时珍的皮是什么意思| 咳嗽变异性哮喘吃什么药| 胎儿脉络丛囊肿是什么原因引起的| 虾和什么蔬菜搭配最好| 被香灰烫了预示着什么| 白带变绿用什么药| 鱼什么时候产卵| 什么奶不能喝| 紫薇花什么季节开花| 五月二十三日是什么星座| 敖是什么意思| 空气棉是什么面料| 竹笙是什么| 眉毛长长是什么原因| 牛杂是牛的什么部位| michaelkors是什么牌子| 鼻窦炎的症状是什么| 倒吊人是什么意思| 藏红花的功效是什么| 老鼠人是什么意思| 肚子左边是什么部位| 嗓子发炎吃什么水果| 结肠炎适合吃什么食物| 厘清是什么意思| 效价是什么意思| 户口本可以干什么坏事| 脑梗是由什么引起的| 呆若木鸡的意思是什么| 血小板聚集是什么意思| 软组织密度影什么意思| 血分析能查出什么| ckd医学上是什么意思| 左脸长痘是什么原因| 嗓子疼流鼻涕吃什么药| 嗓子疼咳嗽挂什么科| m是什么码| 核准日期是什么意思| 潜阳是什么意思| 秦始皇原名叫什么名字| 面皮是什么做的| em是什么意思| 六月飞雪是什么意思| 转氨酶高说明什么| 点痣后需要注意什么事项| 逆流而上是什么意思| 右腹疼是什么原因| 中国的国花是什么| 尿不净是什么原因| 饭中吃药是什么时候吃| 和合双全是什么生肖| 野格是什么酒| 亚历山大王什么档次| ckd3期是什么意思| 鸡口牛后是什么生肖| 结婚九年是什么婚| 月经期适合吃什么水果| 干姜和生姜有什么区别| 两规是什么意思| 报捕是什么意思| 南京是什么省| 哮喘吃什么药| 宫颈癌早期什么症状| 收孕妇尿是干什么用的| www是什么| 家奴是什么生肖| 不伤肝的他汀类药是什么| 小鸭吃什么| 山东为什么简称鲁| 九寨沟在什么地方| 诗眼是什么意思| 眼皮跳是什么原因引起的| pt指什么| 贫血吃什么补血最快| 艳羡是什么意思| 马加其念什么| 恩爱是什么意思| 吃什么有助于骨头恢复| 烂脚丫用什么药能治除根| 胯骨疼是什么原因| 白佛言是什么意思| 白色的鱼是什么鱼| 湿疹擦什么药好| 生加一笔是什么字| 百度
百度 要不忘初心,牢记使命,增强“四个意识”,坚定“四个自信”,坚决维护习近平总书记在党中央和全党的核心地位、维护党中央权威和集中统一领导。

In computer programming, one of the many ways that programming languages are colloquially classified is whether the language's type system makes it strongly typed or weakly typed (loosely typed). However, there is no precise technical definition of what the terms mean and different authors disagree about the implied meaning of the terms and the relative rankings of the "strength" of the type systems of mainstream programming languages.[1] For this reason, writers who wish to write unambiguously about type systems often eschew the terms "strong typing" and "weak typing" in favor of specific expressions such as "type safety".

Generally, a strongly typed language has stricter typing rules at compile time, which implies that errors are more likely to happen during compilation. Most of these rules affect variable assignment, function return values, procedure arguments and function calling. Dynamically typed languages (where type checking happens at run time) can also be strongly typed. In dynamically typed languages, values, rather than variables, have types.

A weakly typed language has looser typing rules and may produce unpredictable or even erroneous results or may perform implicit type conversion at runtime.[2] A different but related concept is latent typing.

History

edit

In 1974, Barbara Liskov and Stephen Zilles defined a strongly typed language as one in which "whenever an object is passed from a calling function to a called function, its type must be compatible with the type declared in the called function."[3] In 1977, K. Jackson wrote, "In a strongly typed language each data area will have a distinct type and each process will state its communication requirements in terms of these types."[4]

Definitions of "strong" or "weak"

edit

A number of different language design decisions have been referred to as evidence of "strong" or "weak" typing. Many of these are more accurately understood as the presence or absence of type safety, memory safety, static type-checking, or dynamic type-checking.

"Strong typing" generally refers to use of programming language types in order to both capture invariants of the code, and ensure its correctness, and definitely exclude certain classes of programming errors. Thus there are many "strong typing" disciplines used to achieve these goals.

Implicit type conversions and "type punning"

edit

Some programming languages make it easy to use a value of one type as if it were a value of another type. This is sometimes described as "weak typing".

For example, Aahz Maruch observes that "Coercion occurs when you have a statically typed language and you use the syntactic features of the language to force the usage of one type as if it were a different type (consider the common use of void* in C). Coercion is usually a symptom of weak typing. Conversion, on the other hand, creates a brand-new object of the appropriate type."[5]

As another example, GCC describes this as type-punning and warns that it will break strict aliasing. Thiago Macieira discusses several problems that can arise when type-punning causes the compiler to make inappropriate optimizations.[6]

There are many examples of languages that allow implicit type conversions, but in a type-safe manner. For example, both C++ and C# allow programs to define operators to convert a value from one type to another with well-defined semantics. When a C++ compiler encounters such a conversion, it treats the operation just like a function call. In contrast, converting a value to the C type void* is an unsafe operation that is invisible to the compiler.

Pointers

edit

Some programming languages expose pointers as if they were numeric values, and allow users to perform arithmetic on them. These languages are sometimes referred to as "weakly typed", since pointer arithmetic can be used to bypass the language's type system.

Untagged unions

edit

Some programming languages support untagged unions, which allow a value of one type to be viewed as if it were a value of another type.

Static type-checking

edit

In Luca Cardelli's article Typeful Programming,[7] a "strong type system" is described as one in which there is no possibility of an unchecked runtime type error. In other writing, the absence of unchecked run-time errors is referred to as safety or type safety; Tony Hoare's early papers call this property security.[8]

Variation across programming languages

edit

Some of these definitions are contradictory, others are merely conceptually independent, and still others are special cases (with additional constraints) of other, more "liberal" (less strong) definitions. Because of the wide divergence among these definitions, it is possible to defend claims about most programming languages that they are either strongly or weakly typed. For instance:

  • Java, Pascal, Ada, and C require variables to have a declared type, and support the use of explicit casts of arithmetic values to other arithmetic types. Java, C#, Ada, and Pascal are sometimes said to be more strongly typed than C, because C supports more kinds of implicit conversions, and allows pointer values to be explicitly cast while Java and Pascal do not. Java may be considered more strongly typed than Pascal as methods of evading the static type system in Java are controlled by the Java virtual machine's type system. C# and VB.NET are similar to Java in that respect, though they allow disabling of dynamic type checking by explicitly putting code segments in an "unsafe context". Pascal's type system has been described as "too strong", because the size of an array or string is part of its type, making some programming tasks very difficult. However, Delphi fixes this issue.[9][10]
  • Smalltalk, 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 these languages make no use of static type checking: the compiler does not check or enforce type constraint rules. The term duck typing is now used to describe the dynamic typing paradigm used by the languages in this group.
  • The Lisp family of languages are all "strongly typed" in the sense that typing errors are prevented at runtime. Some Lisp dialects like Common Lisp or Clojure do support various forms of type declarations[11] and some compilers (CMU Common Lisp (CMUCL)[12] and related) use these declarations together with type inference to enable various optimizations and limited forms of compile time type checks.
  • Standard ML, F#, OCaml, Haskell, Go and Rust are statically type-checked, but the compiler automatically infers a precise type for most values.
  • Assembly language and Forth can be characterized as untyped. There is no type checking; it is up to the programmer to ensure that data given to functions is of the appropriate type.

See also

edit

References

edit
  1. ^ "What to know before debating type systems | Ovid [blogs.perl.org]". blogs.perl.org. Retrieved 2025-08-07.
  2. ^ "CS1130. Transition to OO programming. – Spring 2012 --self-paced version". Cornell University, Department of Computer Science. 2005. Archived from the original on 2025-08-07. Retrieved 2025-08-07.{{cite web}}: CS1 maint: bot: original URL status unknown (link)
  3. ^ Liskov, B; Zilles, S (1974). "Programming with abstract data types". ACM SIGPLAN Notices. 9 (4): 50–59. CiteSeerX 10.1.1.136.3043. doi:10.1145/942572.807045.
  4. ^ Jackson, K. (1977). "Parallel processing and modular software construction". Design and Implementation of Programming Languages. Lecture Notes in Computer Science. Vol. 54. pp. 436–443. doi:10.1007/BFb0021435. ISBN 3-540-08360-X.
  5. ^ Aahz. "Typing: Strong vs. Weak, Static vs. Dynamic". Retrieved 16 August 2015.
  6. ^ "Type-punning and strict-aliasing - Qt Blog". Qt Blog. Retrieved 18 February 2020.
  7. ^ Luca Cardelli, "Typeful programming"
  8. ^ Hoare, C. A. R. 1974. Hints on Programming Language Design. In Computer Systems Reliability, ed. C. Bunyan. Vol. 20 pp. 505–534.
  9. ^ InfoWorld. 2025-08-07. Retrieved 16 August 2015.
  10. ^ Kernighan, Brian (1981). "Why Pascal is not my favorite programming language". Archived from the original on 2025-08-07. Retrieved 2025-08-07.
  11. ^ "CLHS: Chapter 4". Retrieved 16 August 2015.
  12. ^ "CMUCL User's Manual: The Compiler". Archived from the original on 8 March 2016. Retrieved 16 August 2015.
枸杞泡水有什么功效 物上代位性是什么意思 陈旧性骨折是什么意思 高晓松为什么进监狱 吃什么不容易怀孕
孔子名什么 手上有痣代表什么 晨尿泡沫多是什么原因 破釜沉舟是什么意思 包租婆是什么意思
邮件号码是什么 毒龙是什么意思啊 二十不惑什么意思 膝关节疼痛挂什么科 5点到7点是什么时辰
魅可口红属于什么档次 女人乳房疼是什么原因 小儿流鼻涕吃什么药好 部委是什么意思 5月28日是什么星座
尚书是什么官hcv8jop2ns0r.cn 祠堂是什么意思hcv9jop3ns0r.cn 吸毒是什么感觉hcv8jop7ns6r.cn 虾不能和什么水果一起吃hcv9jop7ns9r.cn 月经血黑是什么原因hcv9jop3ns3r.cn
晚上总是做梦是什么原因引起的wuhaiwuya.com 脚底痛什么原因hcv7jop4ns8r.cn 脸部肌肉跳动是什么原因hcv8jop3ns5r.cn 智商135是什么水平hcv9jop1ns3r.cn 本科专科有什么区别helloaicloud.com
二尖瓣反流吃什么药bjhyzcsm.com 家里为什么不能放假花hcv9jop3ns2r.cn 坦诚相待是什么意思hcv7jop9ns3r.cn 端午节干什么hcv9jop8ns3r.cn 驾照c2能开什么车hcv9jop3ns9r.cn
什么是空腹血糖hcv9jop4ns1r.cn 硅对人体有什么危害hcv9jop1ns6r.cn 6月30日是什么日子hcv8jop7ns2r.cn 什么惚惚96micro.com 女人人中深代表什么hcv9jop5ns8r.cn
百度