4 ms·
Interesting that it started out as typeless but as C came from B, they introduced types only for Python to come along and make typeless popular again. Types def
by moftz 5y ago
Interesting that it started out as typeless but as C came from B, they introduced types only for Python to come along and make typeless popular again. Types definitely do have their usefulness but you can certainly get by without them.
- RcouF1uZ4gsC 5y agoIf you look at the current trends, it seems that people are realizing the problems of typeless. Look at the effort to retrofit types onto Python. I think strong typing with type inference hits the sweet spot of providing the safety of types, while also cutting down on boilerplate.
- syockit 5y agoPython is not typeless as in the sense of B. In B, everything is int, while in Python you still have floats and other stuff. Sure, Python does need declarations but that's called duck typing.
- deleted 5y ago[deleted]
- xtracto 5y agoPython is a Strongly Typed, dynamically typed language.
- spijdar 5y agoLike someone else mentioned below, B isn't really typeless, so much as it's all just one type, which was the standard for BCPL -- everything is just a word! If memory serves, part of what made C itself was adding "char", which refers to a single byte, using the (newly released!) PDP-11's byte addressing mode (which didn't exist on the machines B was started on). Nowadays we do byte addressing for everything, but in PDP-11 machine code a byte address and word address are different AFAIK, so char and int pointers would be incompatible.
- simias 5y agoWhile C is a direct descendant of B, Python is a very different beast. It's a bit odd to frame Python as "C but without types". Maybe I misunderstand what you're saying. Also I don't know much about B but given its age I seriously doubt that it's dynamically typed like Python. I suspect that it's more like assembly: you don't have types because most of everything is effectively an integer if you squint hard enough, and the way you decide to use the data lets the compiler/CPU know how to treat it. For instance in this snippet from TFA: v[10] 'hi!', 1, 2, 3, 0777; You may think that `v` is clearly dynamically typed, since it contains both ints and a character string, but I actually think it's a lot simpler than that: a pointer to a string is effectively an int, so you can store a pointer in an int array no problem. You can still do it (mostly non-portably) in modern C, you'll just need a cast or two at most. Of course it means that the type info is not actually carried by the variable like in Python. If you write `'hi!' + 'oy'` in Python you get 'hi!oy'. If you write 'hi!' + 'oy' in B I suspect that you get a garbage pointer, if not straight up undefined behaviour.
- not2b 5y agoB only had one type, "machine word", and a word could be interpreted as a pointer or an integer. The notion in C that an array is effectively a pointer to its first element is also in B.