The Science of Functional Programming [pdf]
github.com
github.com
https://github.com/winitzki/sofp/raw/master/sofp-src/sofp.pd...
The list isn't ordered or complete yet. I just started the doc today. I'll be adding stuff as I move along.
I retried on Windows an it (the download button) worked just fine however.
I guess what I'm asking is there an alternative to traditional mathematical notation that's commonly used?
sine -> sin()
cosine -> cos()
tangent -> tan()
cotangent -> cot()
secant -> sec()
hyperbolic sine -> sinh()
hyperbolic cotangent -> coth()
etc.
Mathematicians would like to use one symbol for one entity. Is pi the same as π or just p multiplied by i?
As for summation vs Sigma? It'd take much longer to write, and probably a bigger pain to read. Having double summations is extremely common, and triple summations are fairly common as well. If you're doing mathematical manipulations/derivations with these, you'll have them on each line.
The terse syntax exists for a reason - it's efficient. If you read fairly old math books (e.g. from the Arabs, or even more resent), you'll see that they were very expressive. The use of symbols for algebra was a significant advancement in math.
Iirc sussman (and maybe Steele), weren't happy about the syntax. Thus re-expressing Lagrangian mechanics in a scheme.
Why do you think that would be an improvement?
See: https://undsci.berkeley.edu/article/mathematics
> Mathematics is such a useful tool that science could make few advances without it. However, math and standard sciences, like biology, physics, and chemistry, are distinct in at least one way: how ideas are tested and accepted based on evidence. Math doesn't rely on testing ideas against evidence from the natural world in the same way that other sciences do. Mathematical ideas are often accepted based on deductive proofs, while ideas in other sciences are generally accepted based on the accumulation of many different observations supporting the idea.
>The answer depends on one's philosophical views on the nature of mathematics — and in this area, philosophers and mathematicians have not reached a consensus
>...
>Now it's up to you. How is math similar to and different from science?
> Science (from the Latin word scientia, meaning "knowledge") is a systematic enterprise that builds and organizes knowledge in the form of testable explanations and predictions about the universe.
> Mathematics (from Greek μάθημα máthēma, "knowledge, study, learning") includes the study of such topics as quantity (number theory), structure (algebra), space (geometry), and change (mathematical analysis). It has no generally accepted definition.
One of those words is a bit more defined than the other. I’m not sure how the above qualifies as science.
The word carries too much baggage and for many discussions there are better, more precisely defined terminology to use.
My opinion only and may not at all work for you.
Such as?
This seems to me more like a simple issue of the meaning of a term being dependent on the context. "Science" is not a term with a single, rigorous definition.
> When I see the word "science" being bandied about, I take it that the person is NOT understanding what they are trying to discuss or do NOT have any ability to discuss the subject in a clear and precise manner.
This is a weakness on your part. Unless your idea of science is at least somewhat compatible with, say, what Feyerabend described in Against Method, you may have a romantic and unsubstantiated view of science, which could be dismissed just as easily as your dismissal of those that bandy about the word "science."
You then go on to say [This is a weakness on your part. Unless your idea of science is at least somewhat compatible with, say, what Feyerabend described in Against Method, you may have a romantic and unsubstantiated view of science, which could be dismissed just as easily as your dismissal of those that bandy about the word "science."]
My problem with this statement is that amongst various groups who are classified as professional scientists, there is much debate over what "science" is or isn't. An example of this debate is the long running differences that have occurred over whether or not "String Theory" in all of its myriad variations can be classified as science or physics.
Please do note that I did say that what I wrote was my opinion and that you may well have a different opinion and perspective. If you don't agree, I don't have a problem with that. You may be having far better success than I when it comes to discussing all sorts of subjects.
At any rate, I'll stop making further comments now as I have to get a fire going to get the house warmed up. We have had the first month of spring pass and it's still far too cold for my wife to endure not having a fire running.
Why do materials on functional programming always have to be at least somewhat condescending towards the reader?
Or maybe: why such sentences seems to appear only in them?
To me it comes off as somewhat douchy.
If I write a book about calculus and people say it's too hard, because they don't know what a function is, is it then not more then fair to say to them they should first know some basic math before attempting to understand my book?
That's basically just helping the reader to me and not condescending in any way.
Because I find it hard to imagine somebody "unfamiliar with school-level math" picking it up in the first place.
To understand how and why an FP language compiler works you need to grok the lambda calculus (as a bare minimum). I'd call that algebra. To even understand what problems are being solved by closures, I really had to “learn difficult concepts through prolonged mental concentration and effort”. Giving newbies a heads-up that competent use of such a tool requires nontrivial knowledge is only fair.
I don't see why understanding closures requires so much mental effort. Just using them a few times should give you a practical understanding of how they work. Closures are not a complicated concept - a bunch data your function has access to outside of its own scope.
How do you propose to master the language if you don't understand the principal tool that embodies that language? Of course it's always an option to use a language without really understanding it, if that's your thing.
> Closures are not a complicated concept
The first lectures introducing closures after their discovery had CS professors in the audience who didn't understand what they were good for. Functions could access a bunch of data outside their local scope before that.
Lambda calculus won't hurt. Implementing scheme (which imho is pretty darn close to the lambda calculus) really just requires understanding some operational semantics and you're good to go.
It's often approached much more formally, using the terms and methods of category theory -- and that is very much the approach of this book.
I'd argue, if somebody has written their own interpreter and compiler, leveraging the interpreter at compile time first for constant expression evaluation and then something more sophisticated for partial function evaluation is a lot more intuitive. You can kinda climb a hill of difficulty rather than be teleported to the top and wish them luck.
(To be totally fair i keep trying to open the pdf, but the browser tab locks up. So maybe my observations are meaningless)
_edit_
There is no royal road. but some roads are perhaps longer, but a little easer to travel.
A closure is essentially a function pointer with some additional data about what some of the symbols refer to. It happens that you're able to write the function nested inside another function.
Edit: (in light of another reply that mentioned the lambda calculus). The addition to Real World OCaml that I suggested was to call out the implementation of the Y combinator in the section on Memoization. The explanation used the Y combinator to work up to an implementation of memoization, and it was so intuitive that I felt it should be noted, but that won't easily fit into an already dense chapter.
Seems like an odd group to target in such a warning.
When I took advanced physics classes in 3rd year of undergrad, I was surprised to note that many of my very smart friends who were computer science majors had lost touch with high-school and introductory college math (particularly calculus) because of an immersion in different kinds of stuff for 2-3 years. Similarly, I've sat in on machine learning classes where CS grad students have little knowledge of probabilistic reasoning or linear algebra (both of which I would consider high-school math, or early college level).
It's not surprising that someone who's not written code for a decade will have a tough time jumping in to start programming right away. So, what's so special about math? It just so happens that some texts on functional programming use a different starting point to approach programming, with different pre-requisites. I wouldn't be surprised if people lose touch with these things after a decade of not using/needing them.
How many programmers can solve a quadratic equation without knowing the quadratic formula (i.e. how many can do the algebraic manipulations needed to solve it)?
That is school level math.
I'm a high school drop out. I'm teaching myself functional programming and I'm slowly relearning HS algebra so I can move on to subjects I've never taken like precalculus, calculus, and undergrad math.
And I think that's what the OP is questioning. Most technical writing will spell out what's expected from the reader, but articles about FP also tend to have a "... if you're smart enough" sentiment added in.
Because who else will get to put in such a sentence? A PHP tutorial, or some Javascript one? On what intellectual grounds would they even be able to justify it?
Besides, the accusation is not even true. You can find many C tutorials that are equally "somewhat condescending towards the reader" -- eg. for not understanding pointers, not knowing how the metal works, etc...
I tell people who do analysis and planning for work they are doing calculus all day without realizing it as calculus is the math of continuous change. As a result an analyst who has never programmed before may find the concept of lambda calculus far easier to understand in practice without being a math scholar.
glad to find this comment though. it's the other thing that's a little bothersome with the FP community -- at least for me. to be honest, i don't think they realize they are doing any of this. they just seem like the PHD level mathematicians, so to speak, of the programming community!