10 ms·
I think the term "algebra" is nice and neutral, common ground from grade school through college mathematics and higher, and I think it's a good clue for someone
by dkarl 1y ago
I think the term "algebra" is nice and neutral, common ground from grade school through college mathematics and higher, and I think it's a good clue for someone who doesn't have much math background. "You know how you learned to do math operations on numbers, and then in algebra class you learned to do them on other things like variables and equations? You can do operations on types as well."
It's inevitable that someone starting from zero like this needs some time to get used to the ideas. Nobody learns this stuff instantly. Even if they can read an explanation in ten minutes and understand every word of it, it still takes time for the ideas to sink in and become natural. That's why an undergraduate math course might only cover a couple hundred pages in a semester. For someone not used to the process of absorbing ideas like these, the time it takes can be confusing and disappointing, but it's normal.
I think one point of confusion that could be avoided is that areas of math that are initially taught as separate topics often get freely mixed in introductory explanations of type theory. For example, someone who is exposed to a little bit of set theory in one class, and a little bit of logic in another, probably thinks of these things as separate from each other and both separate from algebra. But then an explanation like this confuses them by freely interchanging "union" and "sum" and the operator "|" which programmers learn as logical "or." Ideally, I think an introduction should stick to a single set of terminology from one area (I would pick set theory) at first, and after the student is comfortable with the concepts and operations, only then show how the other terminology maps to the ideas the student has learned.
- taeric 1y agoOddly, that is precisely my problem with it as a name. I can't do any "basic algebra" operations on these things. I say this as someone that is having to help my grade schoolers learn algebra this week, actually. :D I can squint to see where things are going and how they intersect. But it takes a lot of squinting.
- adastra22 1y agoWhere are grade schoolers learning algebra?
- taeric 1y agoJust google "algebra 1." Largely, it is where they learn to do symbolic math. Lots of time spent on quadratics.
- adastra22 1y agoYes, where I live (Silicon Valley) the earliest you can take algebra 1 is in middle school, and that is the accelerated pathway for the smart kids.
- taeric 1y agoAh, I see that "grade school" is sometimes defined as just to 6th grade or so. I have always used it to include all schooling up to college. So, apologies on that. I am referring to the same stuff you are mentioning. I don't think that changes my point, at all?
- adastra22 1y agoNo it doesn’t, I was just curious. And yeah in the US grade school is just through 5th grade, and 6th grade in most of the rest of the world. Synonymous with elementary school AFAIK. I think the US is far too slow in introducing algebra, with it standardly being taught in 9th grade. So that made me curious.
- taeric 1y agoI don't remember my school days, oddly. For my kids, they don't have an "algebra" class until later. But they do basic symbolic math far sooner. I know they have done what we would call linear systems of equations as early as 6th grade. Different number systems even earlier. My 9th grader is in an algebra class. I don't remember if it is 1 or 2. I'm still not entirely clear I see the obvious path from the things they are doing to algebraic types.
- jghn 1y ago> in the US grade school is just through 5th grade, and 6th grade in most of the rest of the world Be careful with this. Where I grew up in the US, "Grade school" was usually through 6th grade with a grade 7-8 middle school or just 1-8.
- dkarl 1y agoYou can add and multiply. You have to learn what add and multiply mean with types. There was a time when you only knew how to add and multiply with numbers, and you had to learn how to deal with things like "x". It's confusing for most kids at first, and they spend weeks getting used to it. I'd say that virtually anybody who has learned grade school algebra will learn to add and multiply types faster than they learned to add and multiply polynomials. "Squaring" and "cubing" is an easy way to build intuition with type multiplication, because the name helps you visualize the result. If you have a type C with three values {red, green, blue} then C^2 = C x C is a "square" of values: (red, red) (red, green) (red, blue) (green, red) (green, green) (green, blue) (blue, red) (blue, green) (blue, blue) and C^3 = C x C x C can be visualized as a "cube" of values. You can imagine arranging other products of finite types in the same way: class Foo(color: C, enabled: Boolean) // the values of Foo can be arranged in a 3x2 array Foo(red, true) Foo(red, false) Foo(green, true) Foo(green, false) Foo(blue, true) Foo(blue, false) This is analogous to how kids are taught to multiply 3 x 2.
- taeric 1y agoLike I said, I can squint to see what you mean. But people tend to treat types more as what grade schools call units. And those act more as constraints on what you can do with the values. With you doing add/multiply on the values. Note that I'm not necessarily arguing that things should change. At this point, I'd consider the name fairly well established. But, it should be noted much more heavily that you are doing algebra on the types and that this does not imply anything that you can do with the values they may represent at any time.
- dkarl 1y ago> But people tend to treat types more as what grade schools call units. And those act more as constraints on what you can do with the values. With you doing add/multiply on the values. Ah, I see. Yes, it doesn't make sense unless you see types as sets of values. I haven't been super deep into type theory, so I don't know how far that definition takes you, but it's the intuitive/naive starting place for understanding the idea of algebraic data types. The addition and multiplication operations are on sets of values and don't have anything to do with adding or multiplying the values themselves.