DEV Community

Discussion on: Why is our source code so boring?

Collapse
 
cjbrooks12 profile image
Casey Brooks

Why has there not been a single revolution in the way source code is written in nearly a hundred years?

I would argue that there has. To me, "source code" itself really isn't a thing. At least, the typography of ASCII-text code is not the important thing in the way that typography on a website or a book or a magazine article is. For that other media, the text is the end-result of the work, and the way it is presented is, in itself, part of the art of the whole piece.

But with code, the final presentation, the end-goal, is the execution of the source code and not the text of the source code itself. Text, as presented in a source file, is simply a medium for writing executable programs. Thus, typography does not improve the experience of coding in the same way that it does for reading a book or an article. In fact, usage of ligatures, fancy fonts, emojis, etc. in code can often detract from the experience of coding because it obscures what is actually underneath. A program, when compiled and executed, does not understand the ligature for . It understands =>. So while ligatures can help improve comprehension of prose materials, they can actually hinder the comprehension of code for someone who is not intimately familiar with the ASCII characters that are actually being interpreted.

But source code is not stuck in the past. We just have different mechanisms other than typography to improve comprehension of our code. Things like editor autocomplete, static code analysis, and yes, syntax highlighting, all help to improve our comprehension of the code as a parallel to the way typography improves comprehension for prose. Keep in mind that typography isn't important for its own sake: it is important because it helps our human minds interpret text faster and more accurately.

Code is interpreted and understood differently in our brains; namely, we do not read code strictly top-to-bottom and left-to-right. We understand it through its relationships with other parts of code. Thus, we can't simply expect the same things that worked in prose to help in the same way for code. This goes even as far as why most programmers prefer monospace fonts, because the relationships of individual characters in their columns are important, while it is not in prose.

So while typography has not changed much for source code, I would argue that is it because typography fundamentally isn't as helpful. There are other ways to help programmers that are better than just improving the visual display of the text in an editor.

Collapse
 
awwsmm profile image
Andrew (he/him)

Code is interpreted and understood differently in our brains; namely, we do not read code strictly top-to-bottom and left-to-right. We understand it through its relationships with other parts of code.

And yet we still, generally, arrange code into libraries, packages, and files. If the "atom" of programming is the method / function / routine (maybe variables are the subatomic particles?), why don't we have a better way of visualising and modifying the interrelationships between those atoms?

Surely, blocks of code arranged sequentially in a file is not the best representation of those relationships.

Collapse
 
cjbrooks12 profile image
Casey Brooks • Edited

I can see the adoption of component-based programming as an iteration on this very concept (emergence of React and Vue; the change from Angular 1 to 2+; SwiftUI on iOS and Jetpack Compose on Android; even GraphQL; etc). Take what was previously a big jumble of code, and break them down into components that carry significantly more semantic and contextual meaning than just normal functions.

At their core, they're not so different from moving code from one file to another, or from one function to another, but conceptually it really is a big leap forward. Encapsulating/passing data through a tree of components, rather than a system of functions, makes it easier to understand the relationships among them all. These relationships are still expressed through text, but it is objectively better-organized and helps to make the relationships explicit. It feels like the "atom" has taken a big step up from just functions and classes.

Collapse
 
cjbrooks12 profile image
Casey Brooks

As for why we don't see more things like graphical programming languages, I could draw a parallel to why you see many more people writing blog posts and books than you see people making videos or photo-essays. It's simply easier and faster for humans to compose our thoughts through text than through other mediums. Consider how many thousands of years humanity has been writing, compared to just decades of alternative media even existing, and it's easy to understand why our brains are adapted to prefer text-based media.

Collapse
 
awwsmm profile image
Andrew (he/him)

Fair enough, the idea of "information density" was discussed above and it makes sense that a flow chart carries less information per unit area of screen space than some equivalent Python code, for instance.