4 ms·
>For example, 2 raisedToInteger: 3 is perfectly readable, but chatty at best. For the life of me I will never understand this opinion. If you're trying
by cco 8y ago
>For example,
2 raisedToInteger: 3
is perfectly readable, but chatty at best.
For the life of me I will never understand this opinion. If you're trying to eek out the last bits of memory, fine, verbosity is a valid concern, but at least today code should be written to be read by a human, the more easily it can be read and understood the better.
- kragen 8y agoYou can calculate the (population) standard deviation of a set of data as the square root of the difference between the mean of the squares of the data and the square of the mean of the data. Is that easier to understand than √(Σ(xᵢ²/N) - (Σxᵢ/N)²)? If you're one of the two and thirteen one-hundredths percent of the population that said "yes" to that, can you explain how to derive that formula (which gives a one-pass algorithm) from the fundamental definition √(Σ((xᵢ-x̄)²)/N)? Or, rather, that the standard deviation is the square root of the mean of the differences between the data and their mean? Without using any formulas, remember, because the position you're defending is that sequences of words are more easily read and understood by humans than mathematical formulas are. But convincingly. The benefit of notation as a tool of thought is not that it saves memory in the computer; it's that it enables you to think thoughts that you could not have thought with an inferior notation.
- cco 8y agoThat is a good point, I would refine my argument a based on your response. √(Σ(xᵢ²/N) - (Σxᵢ/N)²) is unhelpful on its own, and as you point out a more "human readable" version of this equation would be rather convoluted. The middle ground here would be to use more specific syntax like yours, while also ensuring that each variable is clearly defined and this logic is robustly documented to explain both the why of this function and how this specific function carries out that logic.
- kragen 8y agoThe justification for why that formula is correct (equivalent to the fundamental definition) is even more incomprehensible than the formula itself if written in English, but fairly clear, almost trivial, using algebraic notation. That is, if you want to "explain both the why of this function and how this specific function carries out that logic," using algebraic notation is far, far better than just using a natural language.