Article View: comp.lang.c
Article #1988Re: C and its peasant 'ancestors'
From: Dan Cross
Date: Mon, 30 Nov 2026 00:23
Date: Mon, 30 Nov 2026 00:23
103 lines
5832 bytes
5832 bytes
In article <11eieib$3v2hj$1@kst.eternal-september.org>, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >cross@spitfire.i.gajendra.net (Dan Cross) writes: >> In article <20261130010153.00003664@yahoo.com>, >> Michael S <already5chosen@yahoo.com> wrote: >[...] >>>There is a whole continuum of possibilities between strongly typed and >>>untyped. >> >> Then you should explain yourself. >> >> "Python is strongly typed. It is of little practical >> importance." What, precisely, did you mean? And why do you >> consider it of, "little importance?" > >I think this is devolving into an debate that's mostly about the >meanings of English phrases like "strongly typed" rather than about the >semantics of various programming languages. > >I do agree that if someone is going to say a language is "strongly >typed", they should probably explain just what they mean by that. > >I'm not aware that there's any widely accepted definition of >"strongly typed". And I would argue that "strong typing" cannot >be measured along a single continuum, with "weakly typed" languages >at one end and "strongly typed" languages at the other. One language >might have strong typing enforced at run time; another might have >weak typing enforced at compile time. No, these terms of art that are, as I understand it, fairly well understood in the PL community. Generally, "strong typed" means "no implicit conversions", and "statically typed" means "types are known at compile time." I do agree that there are languages that are more strongly or weakly typed than others; on the one hand, assembly languages tend not to have any notion of type at all: they work in terms of different sized pieces of memory and registers of various kinds. But if you want to load bytes from a string into a floating-point register most hardware won't stop you (though you may get an exception if you try to _use_ those bytes). Towards the weaker end you've got languages like C and COBOL; at the stricter side you've got languages based on affine and linear types; Rust, Idris, and so on. On the strictest end you've got, I dunno, the typed lambda calculus or something. Many (most?) interpreted languages (Python, Ruby, Tcl, Perl, Lua, and so on) as well as most Lisps are dynamically typed; the type of an object is a runtime property, and the type of the object associated with an identifier might chaghe over time. >> To tie this back to C, C is a weakly-typed language; add a >> number to a string literal and the result is a pointer. This >> has been a source of a _huge_ number of bugs over the years. > >I can imagine a definition of "weakly-typed" that applies to C, >probably based on its rather promiscuous implicit conversions. On >the other hand, every C expression has an unambiguous type, determined >entirely by the expression itself and the rules of the language. Just so. C is a curious beast that is statically but weakly typed. >(The conversion/adjustment of expressions of function an array >type is arguably an exception to this, but one that's completely >specified by the language rules). > >Adding an integer to a string literal yields a pointer because >(a) an array expression, such as a string literal, is "converted" >to a pointer expression in most contexts, and (b) there exists an >addition operator that takes a pointer and an integer and yields >a pointer. (And I'm skeptical that this has been a source of a >huge number of bugs.) Python allows a string to be multiplied by >an integer; "foo" * 3 yields "foofoofoo". Sure; we know _why_ C does this. But it is an example of weak typing. As for bugs....Consider how many "off-by-one" bugs have resulted from C's loose treatment of pointer arithmetic. Most languages that provide non-nullable references don't allow you to perform arithmetic on them at all. >In a typical assembly language, you can load two floating-point values >into registers and apply a bitwise xor to them as easily as you can >multiply them. You can't do that in most higher-level languages, >including C, without extra steps that make the weirdness explicit. In >Python, you can assign an expression of any type to a variable named >"x"; the type is associated with the value, not with the variable. >C doesn't do that. I would argue that most assembly languages are >very weakly typed, but I wouldn't necessary say that C is more >strongly typed than Python is or vice versa. Yes. I agree that assembly languages are weakly typed; however, your Python example is along the dimension of being dynamically typed: you can't perform arithmetic addition on a list in Python while you can in C: assuming a _linked list_ in C, this is almost certainly an error (as opposed to following a `next` pointer or whatever), whereas in Python it's just not expressible. - Dan C.
Technical Details
Message-ID:
<11eifmr$4dk$1@reader2.panix.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mailReferences:
<11dup6q$v4j9$1@dont-email.me> <20261130010153.00003664@yahoo.com> <11eibdf$snv$1@reader2.panix.com> <11eieib$3v2hj$1@kst.eternal-september.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail From: cross@spitfire.i.gajendra.net (Dan Cross) Newsgroups: comp.lang.c Subject: Re: C and its peasant 'ancestors' Date: Mon, 30 Nov 2026 00:23:55 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <11eifmr$4dk$1@reader2.panix.com> References: <11dup6q$v4j9$1@dont-email.me> <20261130010153.00003664@yahoo.com> <11eibdf$snv$1@reader2.panix.com> <11eieib$3v2hj$1@kst.eternal-september.org> Injection-Date: Mon, 30 Nov 2026 00:23:55 -0000 (UTC) Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="4532"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross)