1. 31

When you cast some bits to a new type:

  • Are they being “cast” in a new role, like in theater?
  • Are they being “cast” into a new shape, like molten metal in a mold?
  • Are they being “cast” like a spell into a new form?
  • Are they being “cast” like being thrown into a new type space?
  • Something else?

It would be interesting to see how different people think about this many-faced word, and how it might affect how they think about type casts in general.

  1.  

  2. 29

    I don’t think I’ve ever interpreted the “cast” in “typecast” as an English word, so to me… the bits are being “cast” into a different type, like in programming ;)

    1. 4

      I only recently started wondering where do all this programming vocabulary comes from (kind of an “etymological” point of view), and oh boy does it help understand the underlying ideas and very important concepts behind what could just stay random words forever. I encourage anyone to question why was a word chosen, it’s such a fun exercise :)

      1. 3

        Any good findings?

        1. 2

          A recent one was “thread”, which for a non-native english speaker had no meaning for me. Could it be “thread” as in “filament”? And Suddenly I wonder if “fibers” is linked to this.

          Unfortunately, it could also be seen as many other things so I’m still not sure :)

          1. 2

            Ah, actually, this reminded me of this article I found once (probably on Lobsters): https://kb.iu.edu/d/abnd The article talks about what “rc” in “bashrc” means, along with other terms.

      2. 2

        This was it for me. I never mapped the word to anything in the “real” world.

        1. 5

          I had this realization with “threads”. I find yarn a strange analogy.

      3. 19

        “molten metal in a mold”, no question. Also, awesome alliteration :)

        1. 4

          Absolutly, I thought it was very obvious. It’s interesting to see so many different interpretations.

          1. 3

            awesome alliteration

            frysquinting.jpg

            1. 1

              Except it’s wrong.

              The bits don’t change… just the way the compiler now interprets them.

              It’s more like solid metal in a different bucket.

              See, I have in this bucket, a beautiful art deco statue.

              See, I pour this art deco statue out of it’s bucket into my bucket of hammers….

              CLUNK!

              See. I now have a hammer in this bucket!

              Let me just grab this hammer by it’s legs, ahh, handle, and use it to whack a nail.

            2. 18

              here’s another one: “cast” as in “casting a shadow”, you’re not seeing the original thing but a projection of it

              1. 4

                This is essentially the image that I’ve always had in my head with typecasts. Shadows or rays of light…either way, a projection of some kind. It may have even been explicitly taught to me this way by some early programming teacher.

                One thing I like about the projection analogy is that the surface you’re casting onto (the target type) could be larger than the image you’re trying to project (the bits) in which case you end up with some blank space; or the surface could be smaller than the image, in which case something’s getting chopped off.

                1. 3

                  It’s molten metal in a mold for me, but I love this imagery

                  1. 1

                    I think this is the most etymologically correct modern use of it.

                    In languages derived from Norse (I’m Norwegian), we literally say kaste skygge (throw shadow), kaste lys (throw light), kaste blikk (throw sight), and there is the new verb å kringkaste (to broadcast).

                    Funny that the abstract sense of the verb survived in English (while throw replaced it in the physical sense).

                  2. 11

                    I’m a huge theater nerd so I always imagined the bits being actors that are cast in different roles, but apparently the Algol-68 committee used “cast” in the sense of “casting into a new shape” like metal in a mold.

                    1. 9

                      Funny story, since I enjoy etymology: all those meanings stem from the same root! So you could argue that all the “interpretations” are really just examples of a single word.

                      https://www.etymonline.com/word/cast

                      Reading between the lines there, I speculate that the meaning of giving new shape was added via an intermediate stage in pottery, where you give new shape literally by throwing the clay in different directions.

                      1. 7

                        cast like a spell into a new form, probably because I like the SICP wizard

                        1. 4

                          Not being an English native speaker, the first time I reflected about that was when reading SICP, which mentions wizards casting spells.

                          Then I though about typecast being a special spell.

                          1. 4

                            I remember reading Harry Potter in French (being a native English speaker) and reading jeter des sorts and thinking “jeter means throw and cast is just another way of saying throw in English and you cast spells and whoa…” My mind was blown. I had never thought about spells being “thrown” in English, like “cast” had a distinct meaning there.

                            1. 2

                              Haha incredible to see that even JKR can help us visualize concepts in our daily work!

                              Each time I think about throwing an error, I think about throwing something in the trash, like there’s something bad being thrown out.

                              1. 2

                                I’ve learnt so much English from learning other languages (Danish and Spanish in my case). You suddenly start seeing etymological connections everywhere.

                                I read Kidnapped by Robert Louis Stephenson a few years back and came across loads of old Scottish words I had never seen in an English book before, but recognised them all from Danish.

                                Also, I’m a big fan of Harry Potter as a language learning resource! Haven’t tackled Latin or ancient Greek yet though…

                            2. 4

                              Cast as in broken, then wrapped in plaster to heal in a new shape.

                              1. 4

                                I think of “cast” as sent or thrown, like casting a line when fishing. You’re taking the thing and throwing it into something else. Now that I write that out, it doesn’t exactly make much sense, but hey-ho.

                                In addition to “casting” in the sense of casting an actor in a role, there is also “typecasting” (in the sense of stereotype) where the actor gets repeatedly cast in the same role :-)

                                1. 4

                                  I always thought of the “cast” as in casting bread into a lake a la Tashlikh.

                                  1. 3

                                    Cast as in casting types in lead (traditional typesetting).

                                    1. 3

                                      Like theater, casting a known actor in a new role (EDIT: which, funny, seems opposite the hollywood term). Metal casting seems more permanent, and it’s not a throwing motion, either.

                                      Funny, my brain seems to pronounce “typecast” as a single word (noun), but “type casting” is definitely .. casting, with types. Type aliasing, etc. Typecasting is the hollywood term.

                                      1. 2

                                        I look at it like putting a window in a wall. It doesn’t change the “outside”, but it’s a different way of looking at things.

                                        1. 2

                                          A recent Computerphile video about Algol mentioned the “cast into a metal mold” interpretation, which was the first time I’d heard, and made me utterly convinced that it’s correct: https://youtu.be/TdzsB-iYj4Y&t=4m55s around 4:55

                                          1. 2

                                            All of these related words: typecast, stereotype etc come from hot metal printing so that’s what I think of.

                                            1. 2

                                              Option 2 (new shape) I think is closest to how I’ve been thinking of it in my native language. The literal translation to English would be type-shifting, like shape-shifting.

                                              1. 2

                                                Like metal or clay: you’re taking raw material and giving it a new shape.

                                                1. 2

                                                  Huh, I’ve always thought of it in the acting sense, especially since “typecasting” is a theater/acting term - https://en.wikipedia.org/wiki/Typecasting

                                                  I… guess it doesn’t actually make much sense in that context, since typecasting in acting is applying an actor to a role they very commonly play, and I don’t think that has much of a parallel in the programming sense?

                                                  Hm.

                                                  1. 2

                                                    For me, I’ve mostly thought of it as it’s own thing, like in programming.

                                                    However, the one that makes the most sense to me is being cast like metal into a mold. If you think about it from a data-flow perspective, the bits are being re-arranged from one well-defined shape to another well defined shape. This is in stark contrast to parsing, where input and output are both usually pretty flexible, and not always well defined.

                                                    I think the cast like a spell makes more sense in a messaging context, though usually that’s a send and/or a broadcast.

                                                    1. 1

                                                      I think cast in a new role like theater, because it’s a matter of how the data is viewed and interpreted.

                                                      1. 1

                                                        Are they being “cast” in a new role, like in theater?

                                                        Are they being “cast” into a new shape, like molten metal in a mold?

                                                        I read it as one of these two. The latter implies some reorganization of the bits took place, e.g. int to float.

                                                        1. 1

                                                          I’ve interpreted it as “projecting”. A bit like /u/formerly_a_trickster but without any lights involved ;-)

                                                          1. 1

                                                            How about several, AKA all?

                                                            We have several casts:

                                                            • casting to add/remove type modifiers, usually constness
                                                            • reinterpreting a bit pattern
                                                            • performing language-defined changes, e.g. casting from bool to int
                                                            • calling user-supplied code

                                                            IMO these aren’t the same, and don’t map to one older sense of cast. Rather, they extend the number of senses of cast with n, n>1.

                                                            1. 2

                                                              I think most items on that list shouldn’t qualify as casting in the first place, e. g. the second and third would just be some operation done by a method call by me.

                                                              It’s just because C/C++ put all those different things into the same syntax that they are all associated with the term “casting”.

                                                              1. 0

                                                                Well, C and C++ have had some influence on the language programmers use for operations. They aren’t fringe languages, ignored by all.

                                                                Without knowing who you are, I venture to suggest that C/C++ have immeasurably greater impact on programming term usage than what you think a term should mean. Even if you’re Niklaus Wirth. C and C++ matter a great deal.

                                                            2. 1

                                                              cast into a new shape yes

                                                              1. 1

                                                                I have never thought of “cast” in “typecast” to mean anything. When I first saw “typecase” I just saw that it meant to convert one datatype to another.

                                                                1. 1

                                                                  Definitely like being cast into a new mold. Like steel.

                                                                  1. 1

                                                                    There is probably some good Hollywood joke here about a type cast actor { now the bits “fill the role” they are supposed to, etc. } but I think like most here that the “mold” origin is the correct one (for metal, plastic, gelatins, etc.).

                                                                    1. 1

                                                                      I always thought it to mean “cast as”, i.e. “to view a thing in a particular limited or different way”.

                                                                      1. 1

                                                                        Why not all of them? There is a clear theme of some sort of transmutation without actually changing the thing fundamentally in all of those definitions. I don’t see those various definitions as really separate.