3 ms·
Maths is what you get when you limit all your variable names to single letters.
by foobar_ 7y ago
Maths is what you get when you limit all your variable names to single letters.
- kybernetikos 7y agoAnd make symbols mean different things in different situations, and sometimes reuse symbols for the same thing, and sometimes make sin(x+3) mean the variables s * i * n * (x+3) and sometimes mean taking the sine of x+3. Mathematical language is worse specified than markdown and has a huge amount of ambiguity and requirement that you understand the context that you're working in. It works fairly well for mathematicians, in terms of being concise to express complex ideas on a blackboard, but overall it's a mess.
- foobar_ 7y agoAnd the naming convention is absolutely horrid. It seems the main criteria is .. it should sound clever.
- louthy 7y agoI used to think the way you do (or the way I'm inferring you think), especially coming from the OO world to functional. But, functional programming is really about programming with types, not named things, and so a lot of the time we work with much smaller functions that are expressions. It should be trivial to follow the intention without explicit names. Having terse and concise names can make it much easier to read if you're following the types. Occasionally, if a piece of code is more challenging to read, I may use single word variable names, but mostly it's trying to get the names out of the way of the types and operators. For example, if I have a type (where `a` is generic): a -> bool Then this can only be a predicate function. If it's provided as an argument to a function, I'll call it `f`, not `predicate`, because the type itself is the documentation. It's definitely a mindset change for a different approach, functional programming is much more about function composition, whereas imperative is about a list of steps to perform, and so that composition is much more about whether the types fuse or not, the names become slightly less relevant, especially for general purpose library functions. Personally, I feel it helps. But this is probably one of those subjective things like tabs vs spaces. (spaces are correct)