4 ms·
Beauty is inherently linked to readability, at least in my opinion. If you look at typesetting, a lot of care is taken to tweak letter spacings and getting the
by randomdata 14y ago
Beauty is inherently linked to readability, at least in my opinion.
If you look at typesetting, a lot of care is taken to tweak letter spacings and getting the font just right. This makes the work easier to read than a giant wall of text, and visual beauty comes as a natural side effect of that optimization.
Code really isn't any different. While there is certainly some variance by the beholder, code that is generally easy to read is going to naturally look beautiful. Additionally, and perhaps more importantly, if the code is beautiful, it will attract you to maintain it.
I am still a Go newbie, but my initial impression is that certain constructs make it more difficult to write beautifully than it should, which only serves to detract from the readability (not talking clever one-liners here – which shouldn't even come up in beauty discussions). However, given that I am new to the language, I may just not be yet able to express things as well as I could.
- jbooth 14y agoCoding is completely different from typesetting, otherwise we wouldn't all be using monospace fonts. Beauty's more subjective than readability, but most of the time a beautiful, elegant, recursive structure takes more time to figure out than your ho-hum for loop, in my experience at least.
- 4ad 14y agoNot everyone. I certainly don't :-). A significant minority of Go users come from or like Plan 9, and they use acme or sam, Rob Pike's editors, which by default display text in a variable width typeface.
- blablabla123 14y ago>I am still a Go newbie, but my initial impression is that certain constructs make it more difficult to write beautifully than it should, which only serves to detract from the readability (not talking clever one-liners here – which shouldn't even come up in beauty discussions). However, given that I am new to the language, I may just not be yet able to express things as well as I could. It depends very much on what you want to write. If you want to write something related with File I/O or Network I/O in a reliable fashion, chances are that you cannot see it more beautifully implemented than in Go. No big surprise, the language designers are known for being involved in a lot of Unix stuff. On the other hand, if you want to implement a linear algebra package that has support for a lot of structures, you will see less beautiful code. The same is somehow true for a number of algorithms that act on collections. There are no templates, so you either Copy&Paste or you work with interface{} worst case, meaning such code is cluttered with type assertions. But besides that, I think most Go code can be made beautiful. It definitely has its sweet spot in Server Programming.