Live data from Hacker News

Conversations with a six-year-old on functional programming

byorgey.wordpress.com

101–110 of 319 posts

Re: Conversations with a six-year-old on functional programming

#101
post #19

Side question: maintenece of functional programs is easier, because you don't need to think about state. Could it be used to create a functional programming language, easily understood by non-programmers or beginners , so they too could take a program and adapt it to their needs ? Does such language exist ?

Yes: Joy.

https://en.wikipedia.org/wiki/Joy_(programming_language)

(Shameless plug for my own implementation: http://joypy.osdn.io/)

Re: Conversations with a six-year-old on functional programming

#103
post #66

Earlier quoted context omitted.

Affected? f(x) = 6 has a pretty obvious effect on all input other than 6. Your comment is more of an indictment of identity functions than dimension-losing functions.

A phrasing more to the point is that one expects the input to have some effect on the output . One usually obtains this by, colloquially speaking, performing actions on the input, since if you don't act upon the input in some way, you're going to get a constant result. Of course, you are correct in that some actions don't really do anything, but they're observationally indistinguishable from not acting on the input i…

Your comment seems confused in exactly the same way as coldtea's. How are you imagining turning input 20 into output 6 without acting on the input?

If you don't act on the input, you have an identity function, not a constant function. Constant functions must alter their input whenever it doesn't match the constant output. Nobody ever complained that the problem with Procrustes was that he didn't do anything to the guests in his bed.

And in the other direction, I don't understand why you want to characterize "multiply the input by zero" as an action that "doesn't do anything"? In what sense would that be true?

Re: Conversations with a six-year-old on functional programming

#104

This is fantastic. Reminds me of Hofstadter's conversations between Achilles and a Tortoise. The trouble with most math I've encountered isn't the concepts, it's the quality of the abstractions we use to represent and interpret them. The best(worst) example I can think of is the Alice/Bob description of cryptographic protocols, where somebody's idea of teaching is, "let's take these symbolic representations and inste…

I for one really like reading about Alice and Bob. Amongst other benefits, it helps me consider how, even if currently just a theoretical algorithm, that particular protocol could end up being used in real world communications.

Yeah, it adds time to the equation :)

Re: Conversations with a six-year-old on functional programming

#105
And it works with procedural programming also! I've been teaching programming in schools since I was in school myself - teaching the kids who know more than their teachers, as well as the kids that teachers don't think are ready to code.

Procedural thinking is something that anybody who knows socks come before shoes can do. Conditionals can be understood by anybody who wears different clothes on a weekend than on a schoolday. Loops can be understood by anybody who can eat a bowl of soup by drinking a single spoonful and then doing that again and again until the soup is gone.

Kids can definitely engage in computational thinking from a young age. We just need to offer them the opportunities to do so.

Re: Conversations with a six-year-old on functional programming

#106
I enjoyed reading this story :) Nice buildup to the gate of complex problems.

I remember that at elementary school we turned on a bunch of C16-s at the same time and we tested random number generators and some showed the same value, cool demo of determinism

instead of xλ6 I would have chosen xλ3.14159265359 it might lead to different questions, but who knows, just deeper rabbit holes :)

Re: Conversations with a six-year-old on functional programming

#107

This is fantastic. Reminds me of Hofstadter's conversations between Achilles and a Tortoise. The trouble with most math I've encountered isn't the concepts, it's the quality of the abstractions we use to represent and interpret them. The best(worst) example I can think of is the Alice/Bob description of cryptographic protocols, where somebody's idea of teaching is, "let's take these symbolic representations and inste…

I disagree with your example being a bad and reason is right there in your comment: the word "protocol". From wikipedia we find that a "communication protocol is a system of rules that allow _two or more entities_ of a communications system to transmit information...", where I have underscored the essential phrase and cryptographic protocols are just a subset of communication protocols.

The reason that Alice and Bob are introduced is because they are different entities and each has different powers, restrictions and goals. If you want to do a correctness or security analysis of a protocol, introducing and defining these parties is hugely important and useful. Otherwise, its very easy to make mistakes about where information is in the system and how it is being manipulated. More generally, there is a philosophical approach called operationalism [1] that demands that all science theories be couched in terms of protocols so we don't make mistakes about what they say.

[1] https://plato.stanford.edu/entries/operationalism/

Re: Conversations with a six-year-old on functional programming

#108

This game can be played in a group, too: https://en.wikipedia.org/wiki/Zendo_(game) > once the guesser thinks they know what the function does, the players switch roles and the person who came up with function specifies some inputs in order to test whether the guesser is able to produce the correct outputs. In Zendo when the guesser offers the wrong rule, the 'master' must tell them an (input,output) pair where the g…

Come to think of it, I find Zendo much harder than the game described in the article. I think it’s because the inputs (arrangements of shapes) are more complex than numbers, and the outputs (Booleans) give you less information than numbers.

Re: Conversations with a six-year-old on functional programming

#110
> It’s called the function machine game. I will think of a function machine. You tell me things to put into the function machine, and I will tell you what comes out. Then you have to guess what the function machine does.

Cool, this sounds like a general form of the picnic game[0].

An input to the "picnic" function is a food (or other object), and the output is whether or not it can be brought to the picnic. The picnic game's hidden function that needs to be uncovered is a predicate function. E.g. if the hidden function is "Things that start with the letter A", then "apples", "anchovies", and "albatrosses" could be brought to the picnic, but not "bananas", "cameras", nor "dessert". In that example, the function would look like:

  lambda x: x.firstLetter() == 'a'
[0] https://www.thegamegal.com/2011/06/11/going-on-a-picnic/
Post reply on HN