HN user

lagom

5 karma
Posts0
Comments4
View on HN
No posts found.

Aside from API, there's a convincing performance argument to have len() return the byte count rather than number of utf8 characters.

The implementation of strings in Go is a 2-word struct containing a pointer to the start of the string and the length (in bytes). Under this implementation, len(s) is O(1) and RuneCountInString(s) is O(n). It makes sense to have the default case also be the fast one, particularly since people appreciate Go for its performance.

Alternatively, you could store the rune-count in the 2-word struct to reverse the above runtimes. However, this is detrimental for the common operation of converting between []byte/string as well as writing a string to a buffer. Both of those operations are a simple memcpy with the actual Go implementation, but would be O(n) using this alternate implementation.

Perhaps you could make it a 3-word struct that contains both byte-length and rune-length; Then all strings take up additional memory as well as requiring more overhead when used as function arguments.

If only Scala compilation weren't so slow. This is a bit off topic, but I find the difference between Scala and Go to exemplify some of the fundamental tradeoffs in the languages.

Scala is certainly the more researchy language with an advanced type system, better type inference, and multi-paradigm. However, its compilation is horribly slow, programming styles vary wildly, and I find its tools e.g., SBT, to be underdeveloped.

On the other hand, Go has constrained features and complexity, while providing higher-level features like GC, first-class functions, and simple type-inference, along with excellent tools e.g., gofmt and the build system.

I don't want to imply that one is simply better than the other, but I have enjoyed working in Go much more than Scala.

I think the contrast between mindfulness and mindlessness is more apt than that of thinking and non-thinking. I consider his call to non-thinking to be more hyperbolic than anything else. I believe the primary goal is really that of focus without distracting thoughts, and non-thinking is a way to practice observing the present without being consumed by the stream of thoughts.

In this sense, mindlessness refers to states where one's mind is wandering or unfocused from the present task. Obviously non-thinking is not practical for all activities, but mindfulness includes both non-thinking observation and focused thinking when necessary. Many people associate non-thinking with aimless mind-wandering, which is certainly not the original message of this article. On the contrary, the article is referring to non-thinking as simple observation without judgment or distractions from the mind. Non-thinking, along with meditation, is more of a practice for the application of mindfulness in day-to-day life.