6 ms·
Also closer to how most of us learn and are taught. Consider, I often tell my kids that they need a cup if they want water. I just as often have to change tha
by taeric 10y ago
Also closer to how most of us learn and are taught.
Consider, I often tell my kids that they need a cup if they want water. I just as often have to change that to "go get a cup, and I'll get you water."
Declarative seems to be natural at a desire level, but at an action level, imperative seems to be more common.
I believe this is flipped for topics and actions that are well internalized. When my kids are older, I can just say "cup". If cups aren't in the right drawer, I have to provide imperative to where to check, though.
And yes, all of this is anecdotal. YMMV. I'm highly interested if folks know of studies or counter examples.
- hood_syntax 10y agoYou're right that it's closer to how people are taught, but there's no reason we can't teach from the FP perspective. Consider the imperative cup_of_water get_water (cup_loc, water_loc) { cup = get_cup(cup_loc); return fill_cup(cup, water_loc); } or something like that, versus getWater :: CupLoc -> WaterLoc -> Cup Water getWater cupLoc waterLoc = fillCup (getCup cupLoc) waterLoc It's just a slightly different way of thinking about things.
- hyperpape 10y agoThere's nothing in either example that is intrinsically functional or imperative, they're just different syntax.
- taeric 10y agoThis is dodging things by all being symbolic. Which is well after the point my kids are at in these examples. I'm taking about my one year old. It is amazing how they can understand well before they can say words. Or read and write them. Sign language can be taught really early. Not sure what data that adds here. But, I believe that imperative makes sense because so much in life is imperative. Especially directions we give each other. For things that can be done symbolically, declarative can be a big boon. But it does seem to be the minority.
- pjc50 10y agoNow audit each cup-filling in a database. (Easy in an imperative system, painful in a functional one where you have to start passing monads around and caring how many times the cup is constructed rather than how many cups you end up with.)
- digi_owl 10y agoOr it could simply be that your kids have wrapped the imperatives in a object called cup. All this gets me thinking back to the micros and how they booted straight into a BASIC interpreter. In a sense while booting to a mouse (or touch) driven GUI helps with getting now common tasks done out of the box. That no mainstream OS ship with something that allows someone to sit down and instruct a computer similarly to how it was done back then seems to have turned modern personal computers into near appliances.
- taeric 10y agoI believe this is a common line of thinking. More so with phones, which are surprisingly difficult to get self written programs on. Compared to early computers where I literally bought printouts of programs. (Toys, but still...) Not that it is impossible, but it is surprisingly difficult and not shocking that fewer do it. (Of course, I question myself on that claim. Fewer, but by what measure? And do I have proof?)
- digi_owl 10y agoThing is, back around the early days of Android Google offered a online dev environment that could sideload APKs to phones. I think it was based on Scratch. But they have since handed the whole project over to MIT. Frankly Android could have been a computer in our pockets, and i get the feel Rubin wanted to take it in that direction. But around the time of 3.x-4.0 there was pressure from elsewhere in Google to take in a more iOS direction. We see this with the introduction of music and video into the then named Android Marketplace (later renamed Google Play). And then there was the whole push towards ChromeOS as the choice of businesses, complete with Citrix being a launch day demo. Only in the last few years have Google done an about face regading Android. Both with Android apps coming to ChromeOS, and with various functionality being added to Android to make it more business friendly.
- godmodus 10y agoI have my hopes up for Nokia and Microsoft - win10 devices are more or less a pocket PC. When Linux Support gets properly implemented into Windows, a brilliant new era will dawn. Not to mention c# is a beautiful language.
- lacampbell 10y agoI am not sure what can be gained by comparing human languages or speech to computer language paradigms. I mean I could easily encode "go get a cup, and I'll get you water." as (ocamlish/F#ish) get_a_cup |> Option.map(fill_with_water)
- taeric 10y agoMy assertion is that people are more comfortable with imperative programming, because we are learning imperative thinking from a very early age. That is, there is no intrinsic advantage to imperative, by my assertion. Just that it is something we are much more comfortable with from experience.
- lacampbell 10y agoWhat I am trying to get in as I am not sure that this kind of thinking/speech is inherently imperative or declarative in (in the computing sense). The idea of modifying and controlling bits of state which other processes depend is fairly novel to the novice programmer, isn't it? I'm sure it tripped me up a lot.
- taeric 10y agoI'm not sure I follow. Imperative/Declarative in the programming sense is no different from the speech sense, is it? Quickly skimming the wikipedia page [1] for imperative mood makes it look similar enough to me. The page for imperative programming [2] references the grammar page, even. As for the state, I think in life everything has state. Kids are quickly learning which ones have states that they care about. It is not uncommon to see them learn that cups filled with water need to be held a certain way, otherwise they spill. Now, like more formalisms, computing and programming is much more strict. But that is a matter of rigor, moreso than of form. That is, it is the same form, just not forgiving in syntax/content. Though, seriously, if I am abusing terms here please let me know. Is not my intent. [1] https://en.wikipedia.org/wiki/Imperative_mood https://en.wikipedia.org/wiki/Imperative_mood [2] https://en.wikipedia.org/wiki/Imperative_programming https://en.wikipedia.org/wiki/Imperative_programming