Classifying writing

So we’re getting close to another November, and that means it’s time to get to some serious writing business. Tomorrow, I’ll start, and I hope to reach the magic 50,000 mark once again. This time around, I’ll give a lot more story detail in my daily updates, along with the running word counts.

The novel I’m writing this year has the working title Nocturne, and it’s my first real attempt at book-length fantasy of the “traditional” style. It’ll have magic and mystery and all that stuff. And unlike my Linear Anthology series, it’ll be a “full-length” novel.

But what does that even mean? What’s the difference between a novel and a novella? And where do short stories fit in? Sure, there is significant overlap, and you can say it’s really a continuum; you can have short novels and long novellas. But for an objective metric, a first approximation, we can use the same measurement that every NaNoWriMo participant will be looking at come tomorrow: word count.

Taking the length of one of my works, I divide it into one of three categories: novel, novella, or short story. The numbers I use are pretty simple, and they’re loosely based on the NaNoWriMo “50,000 words” milestone.

  • A novel, for me, is a work that is at least 50,000 words. Preferably, I want it to be 60,000+, but that’s for a very specific reason: I consider my Otherworld series (I’ll start posting those to supporters in the coming months) to be made up of novellas, but some of them run as high as 59,000 words. This is where the stylistic argument comes in. Oh, and there’s no real upper limit, either. The longest work I’ve written weighs in at about 250K, and it’s still a novel. A ponderous tome indeed, but a novel all the same.

  • A novella is shorter, no more than 50-60K. It has to be a minimum of 15,000, though 20,000 is better. (The mathematically inclined reader will notice a pattern here.) By the 20K standard, I don’t actually have any novellas written yet, but I’ll remedy that soon enough.

  • Finally, I consider a short story to be anything under the minimum for a novella. Thus, it can range up to 20,000 words, though anything over 15K is pushing it. (If you prefer a category of “novelette”, then you can slot it in here as 5-15K or 6-20K, with short stories being even shorter than that.) My short stories, however, often have a lot more plot and worldbuilding than you’d expect from something with that name.

So, to sum up, it looks like this:

Type Length (5) Length (6)
Short story < 15,000 < 20,000
Novelette* 5,000-15,000 6,000-20,000
Novella 15,000-50,000 20,000-60,000
Novel > 50,000 > 60,000

Pick which progression you want to follow, and there you go. If you like the novelette category, use its minimum as the maximum for short stories. And don’t neglect the style differences between the different types of work. They’re what led me to make two different classifications in the first place. Novels have more subplots, for example, and I want a novella to be long enough that it has the depth to hook me, but not so long that I can’t read it in one sitting.

Now, it’s onward to November. Can I do this for the fifth straight year? Stay tuned!

Gamification and coding

One of the big trends this decade has been gamification. By turning everyday tasks into games, the theory goes, a person’s natural competitive streak will be triggered, causing that person to put more effort into accomplishing the task, and accomplishing it well. Companies do it with their employees, web forums have begun to implement it for their users and moderators, and so on.

It was only a matter of time before someone brought it to programming. Actually, that happened years ago. Coding competitions have been around a long time, but I saw a link to CodinGame the other day, and that got me thinking.

Games people play

The idea behind gamification isn’t hard to understand. Humans are competitive by nature. We like to win, to be better than the rest. And we really like it when there’s an objective measure of just how much better we are. The Olympics weren’t that long ago, and how many of you remember watching in anticipation, staring at the world records in the corner of the screen? How often were you on the edge of your seat, waiting for the judges’ scores to pop up?

It’s not just sports, though. Most games have some element of scoring, some record of accomplishment. In Monopoly, for example, you’ve got an obvious one: the amount of money in front of you. (Unless you’re playing one of those newer versions with the credit cards, in which case, why?) In video games, tables of high scores have existed for decades, especially in arcade games. And we wanted to set those high scores so bad, because that brought a small measure of fame. Everyone could see that MHP (or whatever) was the best at that game, at least until somebody posted a better score.

Today, when we play over the Internet instead of in public, we have online leaderboards instead, but the principle is the same. It drives us to improve, to reach for that top spot. (Story time: While my brother was working at Amazon a few years ago, I spent about three hours on his XBox, playing Forza 4 and trying to set a record in one of its weekly challenges, a quarter-mile drag race. It was some of the most fun and satisfying gameplay I’ve ever had, even though I never got higher than about 26th.)

Achievements are another popular aspect of modern games, and they work the same way. As Pokemon taught us: you gotta catch ’em all! And that’s how it is with achievements. We see that list, those empty spots, and we have goals. We have something to strive for.

That’s what gamification is. It’s the transfer of that competitive urge, that desire to complete a set or simply win, to mundane work. By adding points and trophies and collectibles, we transform drudgery into entertainment. Whether at school, on the job, or in a social setting, these artificial goals effectively make us believe we’re playing a game. Games are fun, right? So if we make the boring stuff into a game, then it magically becomes fun! Well, maybe. It doesn’t always work, and it’s not for everybody.

Games without frontiers

In theory, almost anything can be gamified, but we’re talking about programming here, so let’s stick to that. How can we make writing computer programs into a game? There are a few obvious answers. One is to make a game about coding, as with else heart.break() or TIS-100. That works, but it’s very much a niche. Another option is adding subtle programming abilities into an otherwise unrelated game. Minecraft has redstone, for example, which allows you to build logic gates, the building blocks of computing, while Final Fantasy XII gave players a bit of power to program their AI-controlled party members. In those cases, however, the programming part is not the focus. It’s an aside, sometimes an unwelcome one.

True gamification of coding, as CodinGame does, is different. It’s more of a series of programming challenges, each with objective measures of success and prowess. Code has to be correct, first and foremost. It has to do what it was designed to do. It’s also good if it’s fast; given two identically correct programs, the faster one is usually considered better. Space is another factor—smaller is generally better—and you can come up with other metrics. (“Lines of code”, by the way, is not a very good one.)

Once you have a way of measuring the “score”, you’re halfway to making a game of it. Post the scores publicly, and watch as coders eagerly train at their craft for no other reason than to move up a spot or two. It’s almost like magic!

Can it work, though? I don’t know. It works for a lot of people, but not everyone. We’re not all the same. Some of us don’t have that competitive streak, or we don’t act on it. For them, gamification is a waste of time. But for the rest of the populace, it can create a reason to learn, a reason to want to learn. That’s something the world could use a lot more of, so I say it’s worth a shot.

Social Liberty: Issues

A theory of government is useless unless it has a connection to the real world. If it does not make practical suggestions and predictions, if it does not yield practical advice, then it is nothing more than a thought experiment. To alleviate such concerns, this post will explore some of the ways a government founded on the Doctrine of Social Liberty would handle some of the most pressing issues of today. The format will be different than usual, with each issue given its own section. Also, while the government described in this piece is theoretical, it is not implausible.

Immigration

Social Liberty, with the Principles of Cooperation and Equality, sees immigration as a good thing, on the whole. A nation should not isolate itself from all the others. However, it also recognizes that some immigrants are bad actors. Under the Principle of Purpose, therefore, it must take steps to ensure that its citizens’ safety is not compromised by incoming persons.

A Social Liberty government is not allowed to perform racial profiling for the purpose of immigration control—or, indeed, for any purpose at all. And the Right of Faith, something that all states following the Doctrine would observe, also bars profiling based on religion. Instead, this government is required to perform more rigorous tests, including behavioral, background, and psychological checks on all immigrants. For most, these are, at worst, a mild inconvenience; in many cases, they can be done automatically, before the immigration process even begins. It is only when the more basic tests show an anomaly that more serious scrutiny is warranted.

Illegal immigration, on the other hand, can be taken one of two ways. First, it can be seen as an attack on sovereignty. Under the Principle of Purpose, it would be the role of government to respond swiftly at this threat to safety. A contrasting view would see it instead as a violation of the Principle of Cooperation: such immigrants are working against the system chosen by the citizens of the state. The result is the same in either case. Although Social Liberty respects the rights of all mankind, it does not give carte blanche to those seeking to enter a state by subterfuge. By creating a fair, just means of legal immigration, instead of the security theater common today, it would eliminate a major cause of illegal immigration, limiting it only to those who have ulterior motives and thus making harsher punishment socially acceptable.

Entitlements

With the Principles of Purpose and Cooperation, it is easy to envision Social Liberty as a recipe for socialism. This is by design. A representative government is free to implement whatever economic measures its people are willing to approve, but there will always be a sizable segment of the populace without access or ability to work for a living. Whether through injury, handicap, situation, or lifestyle, a portion of the state will be unemployed. It is then up to the government to provide for that segment’s health needs.

Social Liberty, then, is fully compatible with a large welfare state, including universal health care, a universal basic income, and many other measures. However, it can also be reconciled with a more capitalistic approach. The Principle of Purpose only states that a government protects the health and well-being of its constituents. It need not provide for them, if private interests can do so more cheaply and efficiently. Rather, its purpose would then be to ensure that these private means remain in place, and that they do not infringe upon the Rights of the populace. This last part is necessary because, although Social Liberty largely refrains from interference in interpersonal relations, the object here is a function of government. Thus, government must not, by its own inaction, allow for its Principles to be violated within its own sphere.

Military

A Social Liberty government must have a means of defense. It does not, however, require an outsized military-industrial complex, massive expenditures for research and development, or an arsenal capable of destroying the entire world many times over. In short, such a state needs only as much military might as to fulfill its obligations under the Principle of Purpose and those it creates under international agreements.

In addition, as a government following the Doctrine is expected to refrain from offensive, imperialistic warfare, its military actions will be more limited in their scope. Once the primary objectives are achieved, there is no need to continue fighting. Thus, further engagement becomes more and more likely to fall outside the dictates of the Principle of Purpose. When a state is fighting not for its own defense—or that of its allies—then it is no longer serving the needs of its citizenry.

Social justice

Although the phrases are similar, Social Liberty is not intended to advance the cause of social justice. True justice is a matter for government—one of the instances where it is allowed to interfere with interpersonal relations. If rights are being violated, that is a matter for the state to judge. The people are allowed and encouraged to speak their minds, to not associate with those they deem unacceptable; this is simply a restatement of the Right of Free Expression that any Social Liberty government is expected to uphold.

People are not, however, allowed to restrict the same right for another. A concerted effort to deny free expression to an individual or group is a case where government intervention is both required and welcome. The Doctrine of Social Liberty is blind to “privilege”; it treats all such cases equally, because to do otherwise would run afoul of the Principle of Equality.

Conclusion

This concludes the brief look at the Doctrine of Social Liberty, a new vision for a government of, by, and for the people. Founded on the principles of logic and reason, it is intended to be a guiding focus for change, whether evolutionary or revolutionary. It is also an ideal, one that may never truly be achieved. If it is, then I believe that the resulting system of government would be one better suited for today’s world than any that has been tried before. We must all work together, though, always keeping our ultimate goal in mind. To stray from the path is to invite tyranny, inequality, and infighting that will destroy us. But by cooperating, we can reach greater heights, perhaps even the greatest.

Social Liberty: Relations

A person does not exist in a vacuum, and neither can a government. We are all connected, whether in our relationships to each other or by the ways we interact with society at large—our society, as well as others. Thus, a proper system of government must recognize these relationships if it is to fulfill its purpose.

There are three main types of relation that are of interest to a governing body: those between two people, those between two governments, and those between a person and the government. We will look at each of these in turn.

Interpersonal relations, those between two members of the same society, are the simplest to handle under the Doctrine of Social Liberty. As the Doctrine’s principles of good government define only those aspects necessary for a stable state, Social Liberty effectively takes no sides. It is not entirely silent on the issue; rather, interpersonal relations are considered private matters, only becoming of importance to the government if and when natural or granted rights become an issue.

One case where this can happen is in contracts. Under most circumstances, Social Liberty considers a contract willingly entered and in good faith negotiated to be entirely outside the scope of government interference. A citizen may waive some of his rights to another, and it is of no consequence to the state. However, a contract may not be designed to break laws, so the government can be asked to intervene to determine if an agreement is unlawful. Similarly, contracts of adhesion—where one party is essentially forced into unfair terms, with no opportunity for negotiation—do become matters for a Social Liberty government, as they are an attack on the founding principles of the state, namely, the Principle of Purpose: onerous contracts affect the liberties and well-being of those parties bound by them.

Other obvious instances where government interference in interpersonal relations is acceptable to the Doctrine include cases of abusive behavior—whether to children or adults—injury through negligence, and most abuses of authority. In general, you may sign away your rights, but you may not take those of another.

International relations are at the other extreme. Here, as a government represents its populace, it has near total control over negotiations and agreements. Within the confines of the Principles, a state may agree on behalf of its people to any number of treaties, trade deals, international conventions, and offers or requests for aid. The populace decides whether these measures are appropriate through the mechanisms of representation, and it should be understood (via the Principle of Evolution) that these international agreements are always subject to renegotiation, should they no longer serve their stated purpose.

It is far easier to enumerate those international actions a Social Liberty government cannot take. It cannot, for example, declare a war for the sole purpose of obtaining land or resources. Nor can it impose sanctions on other nations or regions based on their race, religion, or even their own system of government. And it cannot work to overthrow regimes, as there is no possible explanation for such an act that does not conflict with the Principle of Necessity.

Finally, we must look at the interactions between a person and the government. These are subject to the Principles as well as the Rights, Laws, and Responsibilities of the nation-state. In fact, such interactions are entirely governed by them. Thus, there is little to be said about them here. A government must treat its citizens in accordance with its defining Principles and its code of Laws, while citizens must follow those Laws and uphold their own Responsibilities. Anything else is a violation of the social contract between governed and governing.

However, there are always corner cases, so-called gray areas. It is up to a specific state to clearly delineate these outliers. The Doctrine itself must remain silent on them, as they are often highly situational. For example, what are the intrinsic factors of the Principle of Equality? One can imagine a world in which science has provided the ability to alter skin color at will. Here, “race”, in the sense of color, is no longer an intrinsic factor. Therefore, it does not qualify for the Principle of Equality. Potentially, the same could be true of many other factors we would consider intrinsic, such as sex or other genetic indicators.

It is by relating to others that we experience more of the world. Thus, a government must respect those relations. It must understand them. Sometimes, it must make its own. The Doctrine of Social Liberty recognizes these necessities. Its Principles confine and constrain the government’s role in these relationships, defining that role as the minimum needed to function while upholding the rights of all.

Social Liberty: Rights and Responsibilities

The following are some of the founding rights of Social Liberty, as set out by the Principle of Initial Conditions. Each is then given its own commentary regarding how it fits within the system and why it was chosen.

Right of Free Expression — All persons have the right to express in spoken, written, and published forms any truthful or opinionated statement not intended to cause direct harm to another, whether alone or with others.

This is a restatement of part of the First Amendment, covering freedom of speech and the press together with the right to assemble. “Direct” harm is intentional: words have no power to physically hurt, but they can incite others to do so.

Right of Faith — All persons have the right to practice their own faith without interference from a citizen or government.

This one covers the Establishment Clause part of the First, as well as most other “freedom of religion” aspects. Note that something like a cult where members are poisoned, or the rape and slavery practiced by ISIS, are not protected under the Right of Faith; allowing those violates the higher Principle of Purpose, as a government must endeavor to keep its citizenry safe.

Right of Arms — All persons are permitted to own and bear personal arms intended for their own defense.

Your basic Second Amendment, but written more clearly. Also, there’s no room for a comma splice to change the meaning.

Right to Privacy — No agent of government may observe or search a person without a warrant obtained under reasonable suspicion that a crime has been committed, nor may an agent of government seize any of a person’s property unless that person has been charged with a crime.

Definition of Agent of Government — An agent of government, in regards to the Right to Privacy, is any person working directly subordinate to the state for purposes of defense, security, or law enforcement, or granted such status by another agent.

Here’s your Fourth, with the usual search-and-seizure stuff. “Observe” includes wiretaps, too, and you can see how it also covers the Third Amendment.

Right to Criminal Trial — A person charged with committing a crime must be allowed a fair trial, by a jury if that person so chooses, without undue delay, and the person must be given sufficient opportunity to present a defense of the charges.

Standard Sixth with this one, plus a requirement that the court allow a proper defense. No “freeze their assets so they can’t pay a lawyer” trickery here.

Right to Civil Trial — When two people are in dispute regarding a debt or infringement of rights, either party may request a judicial hearing or jury trial to settle that dispute.

This one’s the Seventh Amendment, often forgotten in our time of binding arbitration. Arbitration, as a private matter, is not part of Social Liberty. Only the use of it in place of a court is within the government’s purview.

Right to Petition — Any person may petition the government, through a trial by an impartial arbiter or jury of citizens, to redress a perceived violation of that person’s rights.

This one’s actually part of the First Amendment (“petition the government for a redress of grievances”), but it’s put here so it falls with the other “trial” Rights. Effectively, it is the right to sue the government if it is breaching your rights. As with the others, the wronged party has the right to choose a hearing or jury trial.

Right to Freedom of Person — No person may be forced by another to work without proper compensation.

Definition of Proper Compensation — Proper compensation, in regards to the Right to Freedom of Person, consists of monetary pay, tangible benefits, and status or rank as befits the work performed.

Slavery, technically, is forbidden by the Principle of Purpose, but this restates it as a Right, roughly equivalent to the Thirteenth Amendment. The definition also subtly invokes minimum wage, “wage gaps” (via the Principle of Equality), and things like insurance benefits.

Right to Vote — All able citizens are permitted to vote on matters of government representation and public petitions, and no action may be taken by another to deprive a person of this right.

Responsibility Of Voting — An able citizen must vote in representative elections or on balloted matters of local or state import, unless this would cause undue hardship or duress.

Definition of Able Citizen — Regarding the Right to Vote and the Responsibility of Voting, an able citizen is a person above the age of majority who is of sound mind.

Voting rights are mentioned in quite a few amendments to the US Constitution: the 15th, 19th, 24th, and 26th are all concerned with opening up the vote to more people. Social Liberty dispenses with all that; every adult who is capable of doing so not only can vote, but must vote. In other words, it’s more like Australia, where everyone is both automatically registered and required to vote in elections. Also, ballot measures are enshrined here as an important part of the political process.

These are not the only rights granted by the Doctrine of Social Liberty, but they are some of the most notable. For the most part, they flow logically from the Principle of Initial Conditions, sometimes affected by the other Principles. And they are rights that, when stated in this form, should be universally agreed upon. Nothing in them prefers or promotes a specific political agenda, except the general notion of greater liberty for all.

Social Liberty: Definitions

First, let us call the fundametnal properties of good government the Principles. These are so central to the idea of Social Liberty that they literally cannot be violated within its framework. A Principle is inviolate by definition, for changing it would change the nature of the space. Principles are thus axiomatic; the six I have chosen define the very concept of Social Liberty.

Second, a Right is a property taken to be inherent to the system. It cannot be abridged, violated, or removed except by another Right or as punishment. Rights in Social Liberty include many of those taken to be inalienable and self-evident, such as freedom of expression, freedom of religion, the right to bear arms, and the right to a trial. A new right can be created, as described by the Principle of Evolution, in a manner dependent upon the system of government.

Third, a Law may be defined as a requirement that must be followed by the citizens of a state. Laws may not be written to directly infringe Rights, but they may define the boundaries of those Rights, and violation of a Law may cause Rights to be lost temporarily. In addition, Laws may be used to clarify cases where two different Rights are in conflict. For example, a Law cannot revoke a Right of Free Speech, but it is allowed to spell out those instances where that Right is overruled by a Right of Privacy.

Fourth, a Responsibility is a duty impressed upon citizens as part of the social contract they form with their government. Laws may bring about Responsibilities, but these may not permanently deprive a citizen of a Right. Responsibilities may also arise logically from Principles; these Responsibilities may violate Laws and limit Rights.

Fifth, a Privilege is subordinate to a Law. It is a lesser right created by the interaction of Laws and Rights, and it may be removed by either. New Rights are rare, but new Privileges may be invented more rapidly, under the Principle of Evolution.

Finally, let us define a Definition as a clarification of the meaning of a word as it is used in the text of a Right, Responsibility, Law, or Privilege.

The Doctrine of Social Liberty is made up of these Principles, Rights, Responsibilities, Laws, and Definitions. They are written in plain language, because understanding the principles of one’s state is necessary for a citizen. Each is given a name for easier reference, as in this example:

Right of Arms — All persons are permitted to own and bear personal arms intended for their own defense.

In later Laws or other text, this can be referred to simply as “the Right of Arms”. For example:

Law of Disallowed Weapons — Any weapon capable of killing multiple people with a single shot, or requiring the operation of more than one person, shall not be considered a personal arm under the Right of Arms.

With these definitions, we are able to construct the structure necessary to create a nation-state that fulfills the goals of Social Liberty.

On procedural generation

One of my favorite uses of code is to create things. It always has been. When I was young, I was fascinated by fractals and terrain generators and the like. The whole idea of making the code to make something else always appealed to me. Now, as it turns out, the rest of the world has come to the same conclusion.

Procedural generation is all the rage in games these days. Minecraft, of course, has made a killing off of creating worlds from nothing. No Man’s Sky may have flopped, but you can’t fault its ambition: not only was it supposed to have procedurally-generated worlds, but a whole galaxy full of aliens, quests, and, well, content. That last part didn’t happen, but not because of impossibility. The list goes on—and back, as Elite, with its eight galaxies full of procedural star systems, is about as old as I am.

Terrain

Procedural terrain is probably the most widely known form of generation. Even if you’ve never played with TerraGen or something like that, you’ve probably played or seen a game that used procedural heightmaps. (Or voxels, like Minecraft.) Making terrain from code is embarrassingly easy, and I intend to do a post in the near future about it.

From the initial generation, you can add in lots of little extras. Multiple passes, possibly using different algorithms or parameters, give a more lifelike world. Tweaking, say, the sea level changes your jagged mountain range into an archipelago. You can go even further, adding in simulated plate tectonics or volcanic deposition or coastline erosion. There really are no boundaries, but realism takes some work.

Textures and models

Most 3D modeling software will give you an option to make “procedural” textures. These can be cool and trippy, especially those based on noise functions, but it’s very difficult to use them to make something realistic. That doesn’t stop them from being useful for other things; a noise bump map might be more interesting than a noise texture, but the principle is the same.

Going one step up—to actual procedural models—is…not trivial. The “creature generators” as in No Man’s Sky or Spore are severely limited in what they can do. That’s because making models is hard work already. Leaving the job in the hands of an algorithm is asking for disaster. You’re usually better off doing as they do, taking a “base” and altering it algorithmically, but in known ways.

Sound

Procedural sound effects and music interest me a lot. I like music, I like code. It seems only natural to want to combine the two. And there are procedural audio packages out there. Making them sound melodic is like getting a procedural model to work, but for your ears instead of your eyes. It’s far from easy. And most procedural music tends to sound either very loopy and repetitive, or utterly listless. The generating algorithms we use aren’t really suited for musical structure.

Story

Now here’s an intriguing notion: what if algorithms could write a story for us? Creating something coherent is at the high end of the difficulty curve, but that hasn’t stopped some from trying. There’s even a NaNoWriMo-like contest for it.

On a smaller scale, games have been making side quests and algorithmic NPCs for years. That part isn’t solved, but it isn’t hard. (For some reason, Fallout 4 got a lot of press for its “radiant quests” in 2015, like it was something new. Though those are, I think, more random than procedural…) Like modeling, the easiest method is to fill in parts of a pre-arranged skeleton, a bit like Mad Libs.

Anything else

Really, there’s no limit to what can be made through procedural generation. That’s probably why I like it so much. From a small starting seed and a collection of algorithms, amazing things can be brought forth. In an age of multi-gigabyte games full of motion-captured animation, professional voice talent, and real-world scenery, it’s a refreshing change to make something beautiful out of a few letters and numbers.

The alternative

No form of government is perfect. If one were, every nation-state would eventually gravitate towards it. Nor will I say that I have developed the perfect form of rule. In fact, I’m not sure such a thing is possible. However, I can present an alternative to the deeply flawed systems of the present day.

Guided by the principles of good government we have previously seen, and aided by logic, reason, and the wisdom of ages, we can derive a new method, a better method. It is not a fully-formed system. Rather, it is a framework with which we can tinker and adjust. It is a doctrine, what I call the Doctrine of Social Liberty.

I cannot accept the strictures of current political movements. In my eyes, they all fail at some point. That is the reason for stating my principles. Those are the core beliefs I hold, generalized into something that can apply to any nation, any state. A government that does not follow those principles is one that fails to represent me. I am a realist; as I said above, nothing is perfect. Yet we should strive for perfection, despite it being ever unattainable. The Doctrine of Social Liberty is my step in that direction.

More than ever, we need a sensible, rational government based on sound fundamentals. The answer does not lie in slavishly following the dogmatic manifestos of radical movements. It does not lie in constant partisan bickering. It can only be found by taking a step back, by asking ourselves what it is that we want from that which governs us.

Over the coming weeks, I hope to detail what I want from a government. I don’t normally post on Tuesdays, but the coming election presents a suitable reason to do so. In four posts, I will describe my doctrine in its broadest strokes, and I will show how our current ruling class violates the principles I have laid out. Afterward, following the start of next year, I want to go into greater detail, because I think these things will become even more relevant.

On visual programming

With the recent release of Godot 2.1, the engine’s developers broke the news of a project coming to a future version: a visual scripting system. That’s nothing new, even in the world of game development. Unreal came out with Blueprints a while back, and even Godot already used something similar for its shaders. Elsewhere, “visual programming” has its proponents and detractors, and I’m going to throw in my two cents.

Seeing is believing

In theory, visual programming is the greatest revolution in coding since functions. It’s supposed to deliver all the benefits of writing programs to those who don’t want to, well, write. The practice has its origins in flowcharts, which are graphical representations of algorithms. Computer scientists got to thinking, “Okay, so we can make algorithms like this, so why not whole applications?” It’s only been fairly recently that computers have been able to fulfill this desire, but visual programming languages are now springing up everywhere.

The idea is deceptive in its simplicity. Instead of laboriously typing out function declarations and loop bodies, you drag and drop boxes (or other shapes), connecting them to show the flow of logic through your program. The output of one function can be “wired” to another’s input, for example. The benefits are obvious. Forget about syntax errors. Never worry about type mismatches again. Code can truly become art. With the name of this site, you’d think I could get behind that.

It does work, I’ll give you that. MIT’s Scratch is used by tens of thousands of programmers, young and old alike. Through its ingenious “building block” system, where the “boxes” are shaped like pieces in a jigsaw puzzle, you never have to worry about putting the wrong peg into the wrong hole. For children who barely understand how a computer works—or, in extreme cases, may not know how to read yet—it’s a great help. There’s a reason why it’s been copied and cloned to no end. It even makes coding fun.

What can’t be unseen

The downsides to visual programming, however, are not fun at all. Ask anyone who’s ever suffered through LabVIEW (I’ve read enough horror stories to keep me away from it forever). Yes, the boxes and blocks are cute, but complex logic is bad enough when it’s in linear, written form. Converted to a more visual format, you see a literal interpretation of the term “spaghetti code”. Imagine how hard it was to write. Now imagine how hard it would be to maintain.

Second, visual programming interfaces have often suffered from a lack of operations. If you wanted to do something that there isn’t a block for, you were most likely out of luck. Today, it’s not so bad. Unreal’s Blueprints, for example, gives you about 95% of the functionality of C++, and Godot’s variation purports to do the same.

But some things just don’t fit. Composition, an important part of programming, is really, really hard to get right visually. Functional styles look like tangled messes. Numerics and statistics are better served in a linear form, where they’re close to the mathematics they’re implementing.

The verdict

I’m not saying visual programming is useless. It’s not. There are cases where it’s a wonderful thing. It’s great for education, and it’s suited to illustrating the way an algorithm works, something that often gets lost in the noise of code. But it needs to be used sparingly. I wouldn’t write an operating system or device driver in Scratch, even if I could. (You can’t, by the way.)

In truth, the visual “style” doesn’t appeal to me. That’s a personal opinion. Your mileage may vary. When I’m learning something new, it’s certainly a big help, but we have to take the training wheels off eventually. Right now, that’s how I see a visual scripting system. For a new programmer, sure, give it a try. You might love it.

But you probably won’t. After a while, you’ll start bumping into the limitations. You’ll have webs of logic that make spiders jealous, or customized blocks that look like something by Escher. Stay simple, and you might keep your sanity—as much as any programmer has, anyway. But we’re not artists. Not in that way, at least. Code can be beautiful without being graphical.

Let’s end threads

Today’s computers almost all have multiple cores. I don’t even think you can buy a single-core processor anymore, at least not one meant for a desktop. More cores means more things can run at once, as we know, and there are two ways we can take advantage of that. One is easy: run more programs. In a multi-core system, you can have one core running the program you’re using right now, another running a background task, and two more ready in case you need them. And that’s great, although you do have the problem of only one set of memory, one hard drive, etc. You can’t really parallelize those.

The second option uses the additional cores to run different parts of a single application. Threads are the usual way of doing this, though they’ve been around far longer than multi-core processors. They’re more of a general concurrency framework. Put a long-running section of code in its own thread, and the OS will make sure it runs. It won’t block the rest of the program. And that’s great, too. Anything that lets us fully utilize this amazing hardware we have is a good thing, right?

Well, no. Threads are undoubtedly useful. We really couldn’t make modern software without them. But I would argue that we, as higher-level programmers, don’t need them. For an application developer, the very existence of threads should be an implementation detail in the same vein as small string optimizations or reference counting. Here’s why I think this.

Threads are low-level

The thread is a low-level construct. That cannot be denied. It’s closer to the operating system layer than the application layer. If you’re working at those lower levels, then that’s what you want, but most developers aren’t doing that. In a general desktop program or mobile app, threads aren’t abstract enough.

To put it another way: C++ bears the brunt of coders’ ire at its “manual” memory management. Unlike C# or Java, a C++ programmer does need to understand the lifecycle of data, when it is constructed and destructed, what happens when it changes hands. But few complain about keeping track of a thread’s lifecycle, which is essentially the same problem.

Manual threading is error-prone

This comes from threads being low-level because, as any programmer will tell you, the lower you are in the “stack”, the more likely you’ll unwittingly create bugs. And there might not be any bigger source of bugs in multithreaded applications than in the threading itself.

Especially in C++, but by no means unheard of in higher-level languages, threading leads to all sorts of undefined or ill-defined behavior, race conditions, and seemingly random bugginess. Because threads are scheduled by the OS, they’re out of your control. You don’t know what’s executing when. End a thread too early, for example, and your main program could try reading data that’s no longer there. And that can be awfully hard to detect with a debugger, since the very act of running something in debug mode will change the timing, the scheduling.

Sharing state sucks

In an ideal situation, one that the FP types tell us we should all strive for, one section of code won’t depend on any state from any other. If that’s the case, then you’ll never have a problem with memory accesses between threads, because there won’t be any.

We code in the real world, however, and the pure-functional approach simply does not work everywhere. But the alternative—accessing data living in one thread from another—is a minefield full of semaphores and mutexes and the like. It’s so bad that processors have implemented “atomic” memory access instructions just for this purpose, but they’re no magic bullet.

Once again, this is a function of threads being “primitive”. They’re manually operated, with all the baggage that entails. In fact, just about every problem with threads boils down to that same thing. So then the question becomes: can we fix it?

A better way

Absolutely. Some programming languages are already doing this, offering a full set of async utilities. Generally, these are higher-level functions, objects, and libraries that hide the workhorse threads behind abstractions. That is, of course, a very good thing for those of us using that higher level, those who don’t want to be bogged down in the minutiae of threading.

The details differ between languages, but the usual idea is that a program will want to run some sort of a “task” in the background, possibly providing data to it at initialization, or perhaps later, and receiving other data as a result. In other words, an async task is little more than a function that just happens to run on a different thread, but we don’t have to care about that last part. And that is the key. We don’t want to worry about how a thread is run, when it returns, and so on. All we care about is that it does what we ask it to, or else it lets us know that it can’t.

This async style can cover most of the other thread-based problems, too. Async tasks only run what they’re asked, they end when they’re done, and they give us ways (e.g., futures) to wait for their results before we try to use them. They take care of the entire lifecycle of threading, which we can then treat as a black box. Sharing memory is a bit harder, as we still need to guard against race conditions, but it can mostly be automated with atomic access controls.

A message-passing system like Scala and Erlang use can even go beyond this, effectively isolating the different tasks to an extent resembling that of the pure-FP style. But even in, say, C++, we can get rid of most direct uses of threads, just like C++11 removed most of the need for raw pointers.

On the application level, in 2016, there’s no reason a programmer should have to worry about manual memory allocation, so why should we worry about manual thread allocation? There are better ways for both. Let’s use them.