The amazing adventures of Doug Hughes

Archive for the ‘Uncategorized’ Category

Defining Constants on a Subclass from a Superclass in Ruby

TIL about TracePoint!

Let’s say I have a Ruby class that is extended by many subclasses. I want each of these subclasses to have a constant named FRIENDLY_NAME. Obviously, I can edit each of these classes and add the constant. But, if it’s not specified in the subclass, is there a way to define the constant in the subclass from the superclass?

For example, maybe I could set each subclass’ FRIENDLY_NAME to be the subclass’ class name demodularized and underscored, when FRIENDLY_NAME is not already defined.

It turns out that the answer is yes!

To expand on this, I had a superclass I wanted to extend many times:

class BaseClass

I wanted all extended versions of the class to have a FRIENDLY_NAME constant. When specified explicitly in the subclass, that would be the value for the constant. EG:

class Subclass1  Subclass1::FRIENDLY_NAME
=> "Bob seems like a friendly name!"

However, maybe I have another subclass where I don’t define the constant. EG:

class Subclass2  Subclass2::FRIENDLY_NAME
NameError: uninitialized constant Subclass2::FRIENDLY_NAME
from /bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `block in load_missing_constant'
Caused by NameError: uninitialized constant Subclass2::FRIENDLY_NAME
from /bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/active_support.rb:60:in `block in load_missing_constant'

How to add that constant? You can add self.inherited to the superclass. This method is called each time the superclass is extended. There’s also a method on Module named const_set, so I could automatically set the constant on the child like this:

class BaseClass
  def self.inherited(child)

This works just fine for Subclass2:

pry(main)> Subclass2::FRIENDLY_NAME
=> "Subclass2"

However, it produces ugly warnings for Subclass1

(pry):10: warning: already initialized constant Subclass1::FRIENDLY_NAME
(pry):3: warning: previous definition of FRIENDLY_NAME was here

Initially I tried using the const_defined? method to check to see if the FRIENDLY_NAME constant was already defined. The problem is, the self.inherited method is invoked before the constant is defined in the subclass. Basically, as soon as Ruby see < BaseClass it runs self.inherited.

Eventually I found this SO question about how to execute code after a class has been defined. The answer there was to use TracePoint.

TracePoint is a class that allows us to handle events in our code. These could be when a line of code is executed, when we call a method, when an error is raised, etc. What we care about is :end event, which happens when a class or module definition is finished.

Knowing that, we can update our self.inherited method like this:

class BaseClass
  def self.inherited(child)
    TracePoint.trace(:end) do |t|
      if child == t.self
        unless child.const_defined?(:FRIENDLY_NAME)
          child.const_set(:FRIENDLY_NAME, child.code)

Now, both Subclass1 and Subclass2 have a FRIENDLY_NAME constant, but neither produce warnings!

Having written all of the above, I’m probably not going to use it. I initially wrote this writeup to answer my own StackOverflow question, but as a commenter points out, this is basically reinventing inheritance for constants in a way that will be difficult for people who haven’t read this post to understand.

An easier way to do this is simply to create a class method like friendly_name. Override it in classes where I want to, and don’t in those where I do.

Ruby Void Value Expression Errors Explained

Today I was doing a quick code review on a pull request and noticed that all of our test suite had failed CI. This was surprising since the change made was so small and looked so reasonable.

This is (more or less) what the method had been:

def query
  @query ||= begin
    query = SomeModel.where(...)
    query = query.addressed if addressed

The details of addressed are irrelevant to this article, so don’t worry about them. I’m leaving it here to illustrate that the query variable may have been updated under some circumstances.

The method had been updated like this in the PR:

def query
  @query ||= begin
    query = SomeModel.where(...)
    query = query.addressed if addressed
    return query.to_a

So, all that happened was that the last line of the begin block had been changed from query to return query.to_a. It’s not important to get into the reasons why the query was being turned into an array, it just was.

However, this caused all of our tests to fail with a “void value expression (SyntaxError)”.

At first I didn’t see what was going on, but, after some research, I figured it out. Long story short, this would work just fine without the return keyword.

It seems natural to think of a begin block as an inline method that has its own return value, but, in reality, it’s an expression that evaluates to a value. There’s a subtle difference. Consider this expression:

5 + 5

This expression evaluates to 10. It’s not a method that returns a value. If you run that in a Ruby console you’ll see as much.

This is not a valid expression in Ruby, outside the context of a method:

return 5 + 5

Running this in a console gives you an “unexpected return” error.

Next, let’s consider this method:

def foo
	5 + 5

This method, when evaluated, returns the result of evaluating the expression 5 + 5. The reason it returns this is because Ruby assumes that the last expression evaluated in any method is its return value, unless something else is returned first.

The above is exactly the same as this next example, we’re just being explicit now:

def foo
	return 5 + 5

It’s important to know that the return keyword immediately terminates execution of the method and returns the specified value (or nil). Here’s an example with an early return:

def foo
	return 75
	5 + 5

As you might expect, this returns 75 due to the early return terminating execution and returning the specified value.

Now let’s consider variable assignments:

def foo
	a = 5 + 5
	return a

Running this method returns 10. Keep in mind that the return statement is immediately terminating the method and returning the value of a.

Here’s another variable assignment example:

def foo(bool)
	if bool
		a = 5 + 5
		a = 75
	return a

In this example we’re setting a to 10 or 75 depending on a conditional statement and then returning a. This is one way to write this logic. We could also have written it this way:

def foo(bool)
	a = if bool
		5 + 5
	return a

This works because if statements in Ruby (like case statements, blocks, etc) evaluate to a value. It’s tempting to think of them as returning a value, but that’s not what’s going on. If they returned, the foo method would immediately terminate and return the value of the statement. To put it another way, a is set to the result of evaluating the entire conditional statement.

But what about this example?

def foo(bool)
	a = if bool
		5 + 5
		return 75
	return a

If you try to paste this into a Ruby console you’ll get a “void value expression” error. But why? Isn’t it effectively the same as the example above? Nope! Ruby sees the a = and knows it’s expected to assign something to a. The “something” being assigned is the result of evaluating the expression to the right of the = operator.

It’s pretty clear what this should be if bool is true, but what if it’s false? Our instinct might be to assume that the if statement returns a value, but, as we determined above, that’s not how return works.

Effectively, Ruby sees that it could be in the middle of setting a and be interrupted to return 75 from foo, effectively leaving a abandoned. That is, the expression to the right of the = operator either evaluates to a value or not at all (IE: a void value). Ruby doesn’t like this and raises a “void value expression” error.

So, looking back at the query method above, it’s trying to set @query to the result of evaluating the begin ... end expression. But, before it can do so, it encounters a return statement that wants to immediately exit the query method, which Ruby dislikes.

The solution to this problem is simple: Just remove the return keyword. Since Ruby assumes that a statement’s value is the last line of code evaluated, Ruby will set @query to the result of evaluating query.to_a.

Testing for Perfect Numbers in Java with Streams

I was challenged recently to write a Java method that could validate whether a provided number was “perfect” or not. A perfect number is one where the sum of its divisors (excluding itself) add up to the number. For example, 28 is a perfect number because it’s divisors are: 1, 2, 4, 7, and 14. If you add these up you get 28, the original number.

However, consider 16. It’s divisors are: 1, 2, 4, 4, and 8. If you add these up you get 19. Therefore, 16 is not perfect.

This calculation was to be done via a static method that accepted an argument num. The method was to return a boolean indicating whether the number provided was perfect or not.

My first attempt was naive. I stared by using a for loop to loop backwards from one less than the number being tested to 1. I tested each step to determine if the number was divisible by the step. If so, I collected both numbers into a tuple which I collected into a HashSet to remove duplicates. I then iterated over the set and summed the values in the tuple and added 1. It worked, but was considerably inefficient.

It was pointed out to me that, because I was looping backwards, I was doing two times the amount of work needed. If I looped forward to half the number being tested I could simply create a sum of the valid divisors. Understanding this, I decided to try a few other approaches…

First, I wanted to see if I could make a one-line solution to this puzzle. In particular, I wanted to experiment with streams of numbers in Java. My first attempt used a stream of integers. I reduced this to those which were valid divisors of the number being tested and summed the resulting set. If this was equal to the number, the validation passed. If not, it didn’t. This is the code:

public static boolean reduceIsPerfect(long num) {
  return LongStream.rangeClosed(2, num / 2)
    .reduce(1, (sum, test) -> num % test == 0 ? sum + test : sum) == num;

Mission accomplished! It’s one (wrapped) line of code. However, this led me to wonder if I could parallelize this. So, my next test was to make a parallel stream of numbers that I then filtered to those that cleanly divided the number being tested. I then summed these, checked for equality to the original number, and returned that.

public static boolean parallelFilteredIsPerfect(long num) {
  return LongStream.rangeClosed(1, num / 2)
    // make this a parallel stream so we can find the whole divisors more quickly (ideally)
    // filter out any non-whole divisors
    .filter(test -> num % test == 0)
    .sum() == num;

This too worked, though arguably it’s more than one line of code.

This success made me wonder how much (if at all) more efficient this method was than my first attempt. I wrote tests for the first six perfect numbers and found that the sixth one, 8,589,869,056, took quite a while to process. My first attempt with reduceIsPerfect() took about 45 secs to validate. My second attempt, parallelFilteredIsPerfect() took 23 seconds, so it was about two times faster. But, this left a bad taste in my mouth. 23 seconds is a really long time.

I tried a few other approaches, but found that, in general, most of my attempts tested in the 45 to 50 second range, which was disappointing.

So, next, I did what any good programmer would do, I turned to Google. I reasoned that the part of the process that takes the most time is determining if a number is a divisor or not. Google led me to a more efficient algorithm.

The way I was testing for perfection was by looping from 1 to half the number being tested. At each step I tested to see if the number could be divided cleanly. For example, with 28 I was doing this:

Start with a sum of 0. Loop from 1 to 14 (inclusive).

  1. 28 % 1. Yes! Add 1 to sum. sum is now 1.
  2. 28 % 2. Yes! Add 2 to sum. sum is now 3.
  3. 28 % 3. No!
  4. 28 % 4. Yes! Add 4 to sum. sum is now 7.
  5. 28 % 5. No!
  6. 28 % 6. No!
  7. 28 % 7. Yes! Add 7 to sum. sum is now 14.
  8. 28 % 8. No!
  9. 28 % 9. No!
  10. 28 % 10. No!
  11. 28 % 11. No!
  12. 28 % 12. No!
  13. 28 % 13. No!
  14. 28 % 14. Yes! Add 14 to sum. sum is now 28.

So, 28 is perfect.

But, Google pointed out to me that half of this information is already known by the time I calculate it. The divisors are 1, 2, 4, 7, 14, 28. As soon as I discover 1 I can quickly determine that it’s paired with 28. 2 is paired with 14, and 4 with 7. I don’t need to continue working at all once I’ve gone to 4! This is less than the square root of 28, 5.291502622129181.

So, if I loop from 1 to the square root of the number being tested, I can just take the number being tested as well as it’s paired divisor at the same time. Add these to the sum and I’m in business:

Start with a sum of 1. Loop from 2 to the square root of 28 (rounded down to 5) (inclusive).

  1. 28 % 2. Yes! Add 2 and 14 to sum. sum is now 17.
  2. 28 % 3. No!
  3. 28 % 4. Yes! Add 4 and 7 to sum. sum is now 28.
  4. 28 % 5. No!

And, again, I’ve confirmed that 28 is perfect.

With this in mind, I rewrote my original one line solution like this:

public static boolean reduceSqrtIsPerfect(long num) {
  return LongStream.rangeClosed(2, (long) Math.sqrt(num))
    .reduce(1, (sum, test) -> num % test == 0 ? sum + test + (num / test) : sum) == num;

And viola, my test of 8,589,869,056 went from taking 23 seconds to 3 milliseconds!! After all, rather than looping from 1 to 4294934528 and testing each step along the way, I am now looping from 2 to 92681! This is significantly less work.

And so, I’m fairly happy with the result. That, and, after all that, it’s just one line of code.

The full code and tests for this project have been posted to Github here.

Will the Real Doug Hughes Please Stand Up?

I heard that someone going by the name of Doug Hughes landed a gyrocopter on the lawn of the capitol building in DC. Sorry, but I am not that Doug Hughes.

It’s been fun and amusing to receive calls of support for the other Doug Hughes. I’ve received half a dozen calls for him. Most have been people gushingly praising him. Some have offered legal and financial support. Others have asked for interviews. Perhaps I should have accepted the cash and given the interviews?

Anyhow, I do support the other Doug’s ideas. We need to get the influence of cash out of our government. Corporations are not people, cash is not free speech, etc, etc.

I recently got ahold of the other Doug’s email address. I’m going to see if he minds me forwarding on these messages, but for now it’s safe to assume that I’m not able to forward these messages.

I’ve Always Wanted a Gyrocopter

Ye Olde GyrocopterI’ve Always Wanted a Gyrocopter!

I hear there may be one up for auction in DC soon.


Please find a way to explain anti-vaxxer politicians to me!

Recently Chris Christie and Rand Paul made some comments supportive of the anti-vaxxer “movement”. This is really gives me pause.

These two are also both in the climate change denial camp. I always assumed that climate change denying politicians only did so because they receive money from climate change denying businesses, and/or pandering to the climate change denial demographic.

You see, I honestly picture politicians as being quite smart and savvy. (I’m not sure whether this is cynical or optimistic of me.) They have to be smart to weasel their way into power. It takes a degree of brilliance to convince the masses that something which is economically bad for them is actually somehow good for them. You’ve got to be sharp to pander effectively to a constituency without actually doing anything for them. You’ve got to be intelligent to find every way to increase your, your friends’, and your corporate overlord’s power and wealth without inciting the population to rise up with pitchforks and torches.

In other words, I have a hard time believing that politicians are actually dumb. I figured they actually believe in climate change, they just have a strong incentive to deny it and legislate against it. I figured they knew it was dumb to disallow scientists from advising the EPA.

But this anti-vaxxer situation makes me wonder if these politicians legitimately don’t understand science. Where’s the political advantage? The anti-vaxxer community can’t be nearly large enough to risk pandering to. And where’s the financial advantage? It’s not like Big Pharma is going to advocate for making less money.

Perhaps that’s it. If more people get sick with preventable illnesses they’ll be able to sell more medications, thereby making more profit? (Perhaps I need to make a tinfoil hat?) This doesn’t pass the smell test.

They only option I am left with is that these two politicians at least actually are scientifically illiterate. They must legitimately not understand the scientific method, how it is used test theories, find evidence, and draw conclusions. You can’t scientifically say that there is no climate change because it gets cold in winter. The evidence doesn’t match the theory.

If these two jackasses are representative of any significant portion of politicians, then we are all well and truly fucked. I for one, will require a lot of pandering to convince me it’s somehow good for me.

Should The Tech Sector do Blind Interviews?

I was on my way home today and switched on Marketplace on NPR. They were reporting on how Google and other tech companies are making efforts to diversify their work forces. From there, they branched off into a story of how the New York Symphony diversified their musicians.

It used to be that the symphonies were dominated by white males. To counteract this, the New York Symphony instituted (mostly) blind auditions. They went to great lengths to prevent the judges from seeing the auditioning musician, or being able to determine any other facts about them such as gender, height, weight, etc. This resulted in a 50% increase in the hiring of women!

So, if Google and others wish to (and should!) remove bias from their hiring practices, maybe they should find a way to prevent interviewers from seeing or even hearing candidates?

Consider this, large companies almost always have online forms that candidates fill out to apply for a job. These necessarily collect potentially telling information. For example, a name or email address can suggest a gender and ethnicity. The duration of past employment and schooling can suggest age. When you show up for an interview, whether on the phone or in person, more judgements can be, and are, made.

What if a hiring manager only received the bare bones information about a potential hire? Maybe they see an unsigned cover letter, a list of previous employers, previous responsibilities, areas of expertise, etc, but not length of employment. The hiring manager could exclusively communicate with the user via an anonymized email address generated for the user, or directly through the HR software being used. The phone would not be used. This would help avoid any hints from the user’s email address or voice.

Instead of a traditional interview, an online meeting could be established where there is either a third party relaying messages back and forth (like translation services for phone calls) or they communicate exclusively though instant messaging. Questions are asked, answers given, etc. Additionally, screen sharing and other collaboration tools could be used for things like coding tests, white boards, etc. Now the hiring manager can only judge the candidates based on their responses. With this more restricted type of communication, I think there’s a better chance that implicit bias could be removed from the process.

As I think about, all of the various tools exist, but perhaps not in one place. Perhaps this approach could even be facilitated by the major job boards and/or HR software? They could provide the tools I described in one integrated package, allowing hiring managers to be blind.

Would this be a perfect system? No. But, could this be a better system? Maybe. It might help lead to increased diversity, which has been shown to improve financial performance.

What do you think?


Alagad Inc is Hereby Closed. Long Live Doug Hughes, LLC

To paraphrase Monty Python:

It’s not pinin’! It’s passed on! This business is no more! It has ceased to be! It’s expired and gone to meet it’s maker! It’s a stiff! Bereft of life, it rests in peace! If Doug hadn’t dragged it out so long, it’d be pushing up the daisies! It’s metabolic processes are now ‘istory! It’s off the twig! It’s kicked the bucket, it’s shuffled off this mortal coil, run down the curtain and joined the bleedin’ choir invisible!! THIS IS AN EX-COMPANY!!

As of the first of October, 2014 I have officially ceased operating as Alagad Inc. This has  been a long time in coming, but the time has arrived. At the ripe age of 18 Alagad has ended. Enter Doug Hughes LLC, stage right.

Running Alagad was a wild, amazing, horrifying, unforgettable, stressful, heartbreaking, astonishingly awesome experience. I founded Alagad in 1996, while still in high school. Initially it was supposed to be a graphic design company, but that didn’t take off. Around 1997 it started to gain traction as a web development company. Throughout college it fed me, kept me housed, and stocked me with plenty of beer.

In the years since I have had the pleasure of working with a diverse range of more than 80 companies and organizations around the world. (I think… part of me wonders if that number gets bigger every time I say it…) I have worked with dozens of employees and contractors. I have worked tirelessly with some very awesome teams.

But now I’m moving into a new phase of my life. I’ve stopped imagining that Alagad will someday be my ticket to retirement. I am now working with a single steady client, less than 40 hours a week. I’m not working on any side projects or a Next Big Thing. I’m idling and recuperating and I couldn’t be happier about it.

As I idle I’m working with new hobbies such as engineering a homemade CNC machine, 3D printing (eventually), wood working, reading, spending time with my kids, any anything else that strikes my fancy. I’ve even returned to college via Arizona State University Online to finish up a bachelor’s in Software Engineering.

I’m also on what I call a Unicorn Hunt. What is this Unicorn Hunt, you may ask? Well, I’m keeping my ears to the ground for an amazing opportunity as a traditional employee. This opportunity would allow me to learn and use new programming languages, techniques, frameworks, approaches, etc. I would be a junior to mid-level team member working under some amazingly brilliant people from whom I can learn new things. I would be working on a single project that I believe in and which is interesting and challenging. And I want to be paid like an executive (or at least what I am currently making) and be able to either work remotely or within 15 minutes of home. Oh, and I want my own pet unicorn too!

If you have an opportunity, checkout my resume!

Doug Hughes LLC is the new Alagad Inc. Eventually I’ll move good blog entries from to If you have my email address in your contacts you may wish to update it to My phone number is still 651-252-4234.

So, for now I idle. Life goes on.

Change, Fear, Life After Death

Back in 2009 my company, Alagad, had what I think of as The Big Layoff.  We went from about 13 employees and contractors down to three people in a matter of a fifteen minute phone call.  This wasn’t the first round of layoffs I’ve had to do, but it was the hardest.  I loved the people who worked with me.  I cared about them and their families and I felt as though I had personally failed them. Frankly, I did.  I’m sure that I could have done more to protect them, their jobs, and their families.  That said, they’ve all gone on to bigger and better things and I’m extremely happy for them.

In the year or so leading up to these layoffs I was constantly assaulted with panic attacks. My chest would seise, I’d get tunnel vision, my mind would shut down everything except worry.  White hot worry. I worried about the people who worked for me and the overwhelming responsibility I had to them.  I worried about paying my bills.  I worried about my family.  Through the support of my family, the remaining employees, and the miracle of modern pharmacology I somehow made it through that period.

Sometimes I wonder if I didn’t completely fry my nerves. I wonder this because I am again tearing Alagad down.  Three weeks ago we were faced with the very real fact that we would likely go out of business.  Both my personal and business accounts were overdrawn and we couldn’t make payroll.  Again.  We had to leave the PEO that provided our health benefits and payroll service.  The walls were coming down.

So I held a call with all four of us, three family members and one employee who may as well be family at this point.  We talked about shutting down and what that would mean.  Throughout this experience I felt calm.  Not happy, but calm, collected.  Worried too, but not like in 2009.  I sincerely felt as though I had done everything I could and that, if we failed, no one could blame me for not trying.

What’s interesting to me is that I don’t feel the same panic I did in 2009.  I don’t feel like a hole is being burrowed in my chest.  I can breath and sleep. I’m not entirely sure why.

I imagine that when death is imminent – when you are terminally ill – that a certain peace and calmness comes from that knowledge.  I imagine that you release your desperate grip on everything that holds you to the physical world. Nothing can harm you now.  There are no more consequences. You transcend fear.

That’s where I am. Nothing can hurt me now. And strangely, because of this, I am free.  I can do anything I want.  I can take tremendous risks without fear.  I am like the terminally ill patient who decides to live each day as if it were their last, because it might be.

Much to my surprise, out of that phone meeting was born an entirely new strategy we’re calling Alagad 2.0.  I’ve detailed it on an all-new website and will spare you the details here.  Suffice it to say it’s not the traditional way of running a software company.

I feel like the terminally ill patent who is given experimental treatment.  It might save their life, but might just kill them even faster.  There’s only one way to find out and I’m comfortable with this.

I can’t lie and say that I’m entirely at peace.  I still worry.  We don’t currently have health insurance and we depend on our prescriptions for our mental well being.  Many have criticized our new approach saying that we don’t understand the business.  But others have suggested it’s might actually be a good idea.

Maybe I’m just delaying the inevitable, but I’m ok with that. The picture that has emerged to me is that there is in fact life after death.  It’s a rebirth of some sort – a renaissance.  A new start. I look forward to it with an open and calm mind.

Representative Democracy is Failing Us? What Can We Do?

I’ve had a thought niggling at the back of my mind for a while now.  I feel like our current form of government in the US is badly broken.  I have an idea that, for lack of a better term, could be described as an alternative system of governance.  Perhaps this sounds crazy, and maybe it is, but I figured it couldn’t hurt to throw it out to the world and see what people thought about it.

This idea comes from my own personal perspective on the US government, how it functions, it’s shortcomings, and where it seems to get things right.  There’s a good chance that my opinion and perspective lays well outside of the mainstream.  I should also state for the record that I truly admire and respect how my country has led the world towards greater freedom and I think there’s room for improvement.

My thesis for this article is that representative democracy is failing US citizens.

How do I see representative government failing us?  Here are some of the ways I personally see the government failing us:

  • There is too much money in politics.  A few rich people can, with relative ease, swing an election in their favor and buy favors from politicians.
  • Representatives are not consistently well informed about the issues on which they are voting.
  • Lobbyists have undue and unproportional influence over politicians.
  • Representatives cannot fairly represent all of their constituants.  In particular, those who voted for the “other person” are under represented.
  • The political parties gain unfair advantages by gerrymandering and otherwise manipulating the system.
  • Two parties – or any number of political parties – can not effectively represent the full range of political opinions held by citizens.
  • We are stuck with a two-party political system with few realistic alternate parties to choose from.
  • The government does not trust its citizens and spies on them.
  • The government is not completely transparent and keeps secrets that it does not need to.
  • We have a complex and unfair tax system.

Many citizens do not trust government to make decisions or implement programs effectively or efficiently.  I can’t speak for citizens of other countries, but I suspect that many of them also feel similarly about their government.

So, what can be done about this?

The classic answer to this question is that we could get involved and try harder to elect people (or ourselves) who will beter represent us in government with the hope that it brings about positive change.  I believe that almost all (if not all) politicians enter politics for this reason.  I don’t think many people enter public service just for the power and privilege.  However, it’s impossible for an individual to represent any more than their own opinions.  Elections are simply a tool by which the citizenry, as much as possible, try to select the least offensive candidate from a very small pool of options.  And, the longer a person holds a position of power and influence, the harder it is for them to not to be corrupted.

Additionally, citizens of non-democratically elected governments have even fewer options to change their system of government.  This is one of the primary reasons the US government has worked so tirelessly over the decades to try to bring democracy to the whole world.  Unfortunately, this effort has had mixed results.  Many countries resent the arrogance of the US and its citizens, others are outright hostile to us.

So, again, what can be done about this?

When life in the colonies became unbearable, our US forefathers declared independence from England.  The Declaration of Independence states that a government’s power comes from its people and that it’s primary role is to protect its people’s inalienable rights.  Furthermore, it says that if a government should fail its responsibilities that the people have a right to abolish that government and establish a new one.

To be clear, I am not at all proposing that the US or any other country or people should abolish their government.  However, perhaps it’s time to consider experimenting with new forms of government and new forms of countries?

Historically, countries have been united by the land they are founded on.  Countries have clearly defined borders  in the physical world.  All people within these borders must obey the laws of that country.  But, the modern age has, through invention of the internet, world wide communication networks, telephones, overnight mail delivery, easy and inexpensive travel, and many other modern conveniences, opened us up to an alternative which may not have been feasible in the past.

What if a country’s jurisdiction were not based upon its physical location on this planet, but merely on a social contract among its citizens?  What if all citizens of this new form of country were beholden to following its laws, no matter where they were physically located?  Furthermore, what if every citizen of this country had an equal say in the laws that are formed?

I would like to paint for you a hypothetical form of government:

Imagine, if you would, that a population of people decided to come together and use modern tools such as the internet to establish a new, virtual, country.  This new country would not have any physical borders and would not have a claim to any physical territory.

This new virtual country would establish its own government.  The structure of the government and its laws would be defined in a set of legal documents.  The very first draft of these documents would define the basic underlying structure and function of the new government.  For example, it would define the following:

  • How is the government structured?
  • What is the definition of citizenship and how do people become citizens?
  • What rights do citizens have?
  • What rights does the government have?
  • and much more…

These documents would be entered into a distributed version tracking system, thereby constituting the government.  The most recent “trunk” version of these documents would be law.  This new government would coexist with, but always be secondary to, the whatever the local government is in the physical world.

Any citizen of this new virtual country would be permitted to make their own personal copies of these legal documents and to revise them as they see fit.  If the citizen so wished, they could submit revisions of these documents back to the government for consideration.

Durring the consideration period, all citizens of the country would be encouraged to review and debate the proposed changes and to cast a vote on whether the changes should be approved or rejected.  If approved, the changes would be applied and the laws of the country would be changed.

Anyone in the world who wished to do so would be permitted to become a citizen of this new virtual country and would be able to gain the benefits of citizenship.  Citizens of this new country would essentially have dual citizenship in their physical country as well as in this new virtual country.  All citizen of this new country would be obliged to follow the laws enacted by this new country, so long as they don’t conflict with the laws of the physical country where the person is located, or risk losing their citizenship.

So, what we’ve established is a country that is directly under the rule of its people.  Changes to government and law can be proposed by and voted on by any citizen.  This country’s laws are always secondary to the laws of the country where the person physically is located.  Citizens of this new country must always obey the laws for their physical country as well as the laws of their virtual country.  When in conflict, local laws will always supersede.

I imagine that eventually, this new virtual government might levy taxes, establish a judicial system, establish its own currency, and provide services to its citizens including health care, social safety nets, roads, and anything else that its citizens wish to have their government do.  Of course, this all depends on what laws the citizens of the country enact and how well they collectively manage it.

I even envision a future where corporations and businesses could be formed within the framework of this government.  These businesses would likely exist in parallel with businesses in the physical world.  But, these businesses would be beholden to the laws of the new country.  This might be useful, for example, if this new government does offer health care for its citizens.  Perhaps only medical providers who are citizens and who have also registered their business entity with the new government would be eligible to provide services paid for by this government.  And, when this happens, they are now beholden to the laws of these people.

Furthermore, if the people do form their own currency, and banks are formed to hold this currency, or perhaps banks in the physical world decide to accept deposits in this currency, then they may need to follow the laws of this country.

Instead of having a prison system to punish criminals, perhaps we have an excommunication system where the convicted criminal loses their citizenship and associated benefits for a period of time?  For less serious crimes perhaps the government would collect fines?

I also imagine that the citizens of this country may work to define subsets of the over-arching virtual country.  This could be considered states or provinces or counties or cities or whatever.  Each of these subsets would define their own rules and may in fact actually be tied to physical boundaries in the real world.  Citizens of the over-arching virtual country would be beholden to local variations of laws, though the none of these laws could override the base laws of the country.

This would be similar to how the united states is divided into states, counties, cities, etc, each with their own laws, none of which supersede it’s parent government.

Perhaps some day in the far, far, distant future some physical countries may elect to dissolve their governments and to live exclusively under this new form of government?  It could happen!

I personally feel like the overall structure of our world-wide society is beginning to change.  While technology creates new efficiencies and new jobs, it also seeks to save labor and eliminate jobs.  Labor and the ability to earn money is the foundation of our world economy.  In the very long run, as technology evolves, I believe almost automation will replace almost all workers and dramatically transform the nature of our economy.

How will society cope with these drastic, foundational, changes to the world and economy?  If history is any guide, it will be through violence, war, and suffering.  Perhaps this hypothetical form of government I am proposing could somehow be used to mitigate the impact of this?  Perhaps the people of this virtual country can come together to find new ways of structuring our society and our social contracts to protect its citizens?

What do you think?

Tag Cloud