▲ | davetron5000 4 days ago | ||||||||||||||||
There’s also a typography element to formatting source code. The notion that all code formatting is mere personal preference isn’t true. Formatting code a certain way can help to communicate meaning and structure. This is lost when the minimal tokens are serialized and re-constituted using an automated tool. https://naildrivin5.com/blog/2013/05/17/source-code-typograp... | |||||||||||||||||
▲ | Mikhail_Edoshin 4 days ago | parent | next [-] | ||||||||||||||||
And I'd add that typographers go out of their skin to typeset tables and formulae so that everything is aligned and has proper spacing. For centuries this was done manually because it it important, even though an outsider cannot notice it. (That said, it must be possible to make a more sophisticated formatter for the source code too.) | |||||||||||||||||
▲ | anticodon 4 days ago | parent | prev | next [-] | ||||||||||||||||
Yes. In Python, black formatter consistently breaks SQLAlchemy queries in an unreadable way (e.g. splitting conditions over multiple lines when it's not really necessary and makes reading harder). | |||||||||||||||||
| |||||||||||||||||
▲ | frizlab 4 days ago | parent | prev | next [-] | ||||||||||||||||
Yes! I’m always appalled that people cannot see that. | |||||||||||||||||
▲ | jauntywundrkind 4 days ago | parent | prev | next [-] | ||||||||||||||||
I'm pretty unconvinced by the examples. > Some of us even align other parts of our code, such repeated inline comments > Now, the arguments block forms a table of three columns. The modifiers make up the first column, the data types are aligned in the second column, and the names are in the third column These feel like pretty trivial routines that can be encompassed by code formatting. We can contrive more extreme examples, like the for loop, but super custom formatting ("typesetting") like that has always made me feel awkward, feels like it givesicemse for people to use all manners of arbitrary formatting. The author has some intent, but when you run into an inconsistent code based with lots of things going on, the variance doesn't feel informative or helpful: it sucks and it's a drain. What's stored is perhaps more minimal, some kind of reference encoding, maybe prettier-ifies for js. The meat of this article to me is that it shouldn't matter: the IDE should let you view and edit as you like: > Everyone had their own pretty-printing settings for viewing it however they wanted. | |||||||||||||||||
▲ | pwdisswordfishz 4 days ago | parent | prev | next [-] | ||||||||||||||||
> A C argument declaration is made up of modifiers (register, const), a data type (char *), and a name (from). Now explain a declaration like "char *argv[]"... > We’ve also re-set the data type such that there is no space between char and * - the data type of both of these variables is “pointer to char”, so it makes more sense to put the space before the argument name, not in the middle the data type’s name (update: it should be pointed out that this only makes sense for a single declaration. A construct like char* a, b will create a pointer to char, a, and a regular char, b). Ah, yes, the delusional C++ formatting style. At least it's nice that the update provides the explanation why it should be avoided. | |||||||||||||||||
| |||||||||||||||||
▲ | psychoslave 4 days ago | parent | prev | next [-] | ||||||||||||||||
Caring for typography but blindly bending to dubious programming-language convention feels really like putting efforts on the wrong starting point though. What’s the point of such an heavy obfuscation of the intend, really? Let’s take the first example.
If we are fine with the "lengthy" register, why not use character in full word? Or if we want something shorter sign would be actually semantically more on point in general.What with the star to design a pointer? Why not sign-pointer? Or pin for short if we dare to use a pretty straightforward metaphor, so sign-pin. Ah yes by the way, using "dot" (.) or "dash, greater than" (->) is such a typographical non-sense. And as a side note *char brings nothing in readability compared to sign-pin-pin. Remember that most people read words or even word sequences as a whole. And let’s compare **char to something like sign-pin-back-5. What with strcpy? Do we want to play code-obfuscation to look smart being able to decode this pile of letter sequence? What’s wrong with string·copy* or even stringcopy (compare photocopy)? Or even simply copy? If we want to avoid some redundant identifier without relying on overriding through argument types, English is rich in synonyms. For example duplicate, replicate, reproduce. Various parentheses could be just as well optional to ease code browsing if proper typography is already on place, and English already provide many adverb/preposition that could replace/complement them into a linguistically more usual counterparts. Speaking about prepositions, using from and to as identifiers for things which would be far more aptly described with nouns is really such a confusing choice. What’s wrong with origin/source and destination/target? It’s also a bit counterproductive to put the identifier, which is the main point of interest, at the very end of it’s declaration statement. Equal for assignment is just really an artifact of more relevant symbol like ← or ≔ because most keyboard layouts stem from disastrous design. But using an more adequate symbol is really pushing for unnecessary obscured notation. Mandatory semicolon to end a statement is obviously also a typographical nonsense. If a parameter is to be left blank in for, we would obviously be better served with a separate control-flow construction rather than any way to highlight it’s not filled in that employ. So packing it all:
Given that in that case the parentheses and comas are purely ornamental, the compiler could just ignore them and would have enough information with something like
Or even
| |||||||||||||||||
▲ | IshKebab 4 days ago | parent | prev [-] | ||||||||||||||||
Yeah in theory people can do a better job than auto-formatters. In practice they absolutely do not, so that argument is moot. | |||||||||||||||||
|