The first, important, way is that a tool that offers solid theoretical foundations does not (necessarily) require those foundations. You mention algebra, for example, and it's fair to assume that most school students (and probably their teachers!) don't really appreciate the theoretical grounding of algebra—but they can still hopefully use it with proficiency. In the same way, pure functions and referential transparency need only be difficult to apprehend if you insist on investigating their theoretical foundations; they can just be the way things work, and, if this is a first programming language, then there are no habits regarding mutable state to unlearn before being able to handle immutability.
The second is that, as nine_k (https://news.ycombinator.com/item?id=9982600) points out, learning these concepts before algebra could make understanding algebra itself easier. There are deeply mathematical ideas in the foundations of most programming, even if they are (and even when they should be) hidden, and learning these ideas can help one to come to grips with abstraction in a context that encourages play and experimentation, unlike (unfortunately) the usual mathematics classroom.
I've only found mathematics really interesting within the past few years, realizing how useful it is for creative things, like making music and art, or understanding programming at a higher level. If I had learned about functions in a more interactive way, maybe being able to create art on a computer screen, or write up physics systems in games, I think I would have been fascinated, and maybe the concepts would have stuck.
I honestly wasn't sure, so I tried not to assume. Subtleties of tone are easily lost on the Internet; thank you for taking the time to clarify.
> I've only found mathematics really interesting within the past few years, realizing how useful it is for creative things, like making music and art, or understanding programming at a higher level.
While I am deeply in sympathy with this point of view, and agree with it to some extent, I think that it comes dangerously close to the monad-tutorial fallacy (https://byorgey.wordpress.com/2009/01/12/abstraction-intuiti...). As a teacher, I have four reactions to "why couldn't I have been taught this way?":
1. First and foremost, this is true. Course structure is often not set up to reward creativity and exploration, and that is a real shame. However …
2. I have heard students complain about not being taught in a way that I know is common pedagogical practice. That does not prove (they could just have been taught by bad teachers), but leads me to suspect, that sometimes students don't recognise (or don't want to see: "just show me the formulas!") alternate approaches when they are presented with them.
3. In many cases, the 'aha!' moment now couldn't have been an 'aha!' moment then; it is only because of the long struggle, and the additional learning and maturity, necessarily beginning with the confusion and uncertainty of yesterday, that everything can suddenly click today.
4. Even if I knew today the exact thing that would cause that 'aha!' moment for you, it is almost guaranteed that it wouldn't cause the same reaction for (many) others. The mission of a teacher is to serve the class as a whole; it is simply impossible, in terms of time and (let's be frank!) the teacher's knowledge, to explore for each student the application that will serve him or her best. This is not to say that some more applications and creative exploration wouldn't be welcome—they absolutely would—but more that, often, the best that can be done is to provide you with the basic tools that will allow you to explore and find the 'aha!' moment on your own, probably outside of the classroom.
I keep hearing (mostly negative) things about the Common Core program in the US, I wonder what it's really like. Creative new ways of teaching always sound good on paper, but I hear so many parents complain about the way their kids are being taught. I wonder if most of those complaints are warranted, or if the new style of questions just take getting used to.
Even cooler, these days, is Dragon Box. It teaches kids symbolic manipulation via a cute and fun game. Starts off with little creatures you move around, then simply changing the drawings from creatures to numbers and letters makes a seamless transition.