3 ms·
Why? I'm genuinely curious why you think that it's worse in functional languages than, eg Python or C. It's not like you don't specify all of those variables
by SomeStupidPoint 9y ago
Why?
I'm genuinely curious why you think that it's worse in functional languages than, eg Python or C.
It's not like you don't specify all of those variables when using a loop in C -- you just have a special syntax to. I was outlining the actual recursion mechanism, not showing what you'd have to code....
You can make it look basically the same, with a signature like...
loop (idx test update) fn acc
...which in practice will look like...
loop (0 (\ x -> x < 5) (+1)) fn 0
The only annoyance is the slightly verbose lambda syntax for the test, but if you're using a function as a test, it becomes a smaller issue.
- eropple 9y agoPython (well, sort of) and C (despite its numerous other flaws) have a special syntax that doesn't read poorly, yes. The code you just described reads awfully. It's line noise. One of the most important aspects of a programming language is encouraging code that can be trivially read by someone who is familiar-but-not-reflexive with the language and does not necessarily understand the domain well enough to be managing both application state and syntactic state. If I have to think about what the code's syntax means, I'm not thinking about the problem. And, frankly, the idea that you have to soft-pedal it as "you could do this" should be a red flag for you. I could meditate about a `loop` function or I could write the code I actually care about.
- chowells 9y agoAre you sure you've got it the right way around? For-loops in C are syntactic garbage. "This is what I'm used to" is not the same as "this is good."
- skybrian 9y agoWhy not? "What I'm used to" will tend to win in most usability studies. Weird and unfamiliar are harder to use. Looking at how human languages work, it's hard to see how it could be otherwise. Your own language is always going to be easier to use than an unfamiliar one. And this is why language debates can't be settled via logic alone.