The best kittens, technology, and video games blog in the world.

Sunday, October 29, 2006

Prototype-based Ruby

Guardians of the horizon by good day from flickr (CC-NC) Object-oriented programming is all about objects. About objects and messages they pass to each other. Programs contain many objects. Way too many to make each of them by hand. Objects need to be mass-produced. There are basically two ways of mass producing objects.

  • The industrial way - building factory objects that build other objects.
  • The biological way - building prototype objects that can be cloned.
A language with classes that are not objects is not object-oriented. Period. Most object-oriented languages like Smalltalk and Ruby use the industrial way. The object factories are also known as "class objects" (or even "classes", but that's a bit confusing). To create a new object factory you do:
a_factory = Class.new()
a_factory.define_instance_method(:hello) {|arg|
    puts "Hello, #{arg}!"
}
And then:
an_object = a_factory.new()
an_object.hello("world")
Some languages like Self and The Most Underappreciated Programming Language Ever (TMUPLE, also known as JavaScript), use biological method instead. In biological method you create a prototype, then clone it:
a_prototype = Object.new()
a_prototype.define_method(:hello) {|arg|
    puts "Hello, #{arg}!"
}
Then:
an_object = a_prototype.clone()
an_object.hello("world")
Biological way is less organized, but simpler and more lightweight. There are only objects and messages, nothing more. Array is a prototype for all arrays and so on. Industrial way is more organized, but much more complex and heavy. There are objects, classes, class objects, superclasses, inheritance, mixins, metaclasses, singleton classes. It's just too complex. This complexity exists for a reason, but sometimes we'd really rather get away with it and use something simpler.

Prototype-based programming in Ruby

And in Ruby we can ! First, we need to be able to define methods just for individual objects:
def x.hello(arg)
    puts "Hello, #{arg}!"
end

x.hello("world") # => "Hello, world!"
Now we just need to copy existing objects:
y = x.clone()
y.hello("world") # => "Hello, world!"
The objects are independent, so each of them can redefine methods without worrying about everyone else:
z = x.clone()

def x.hello(arg)
    puts "Guten Tag, #{arg}!"
end

def z.hello(arg)
    puts "Goodbye, #{arg}!"
end

x.hello("world") # => "Guten Tag, world!"
y.hello("world") # => "Hello, world!"
z.hello("world") # => "Goodbye, world!"
Converting class objects into prototype objects would probably introduce compatibility issues, so let's go halfway there:
class Class
    def prototype
        @prototype = new unless @prototype
        return @prototype
    end
    def clone
        prototype.clone
    end
end

def (String.prototype).hello
    puts "Hello, #{self}!"
end

a_string = String.clone
a_string[0..-1] = "world"

a_string.hello #=> "Hello, world!"

Horizontal gene transfer

Of course transfer of genes from parents to offspring is only half of the story. The other half is gene transfer between unrelated organisms. We can easily use delegation and method_missing, but let's do something more fun instead - directly copying genes (methods) between objects.
a_person = Object.new
class <<a_person
    attr_accessor :first_name
    attr_accessor :name

    def to_s
        "#{first_name} #{name}"
    end
end

nancy_cartwright = a_person.clone
nancy_cartwright.first_name = "Nancy"
nancy_cartwright.name = "Cartwright"

hayashibara_megumi = a_person.clone
hayashibara_megumi.first_name = "Megumi"
hayashibara_megumi.name = "Hayashibara"
But Megumi is Japanese, so she needs reversed to_s method:

def hayashibara_megumi.to_s
    "#{name} #{first_name}"
end
Later we find out that another person needs reversed to_s:
inoue_kikuko = a_person.clone
inoue_kikuko.first_name = "Kikuko"
inoue_kikuko.name = "Inoue"
We want to do something like:
japanese_to_s = hayashibara_megumi.copy_gene(:to_s)
inoue_kikuko.use_gene japanese_to_s
OK, first let's fix a few deficiencies of Ruby 1.8. define_method is private (should be public), and there is no simple singleton_class. Both will hopefully be fixed in Ruby 2.
class Object
    def singleton_class
        (class <<self; self; end)
    end
end

class Class
    public :define_method
end
And now:
class Object
    def copy_gene(method_name)
        [method(method_name).unbind, method_name]
    end

    def use_gene(gene, new_method_name = nil)
        singleton_class.define_method(new_method_name||gene[1], gene[0])
    end
end
We can try how the gene splicing worked:
puts nancy_cartwright #=> Nancy Cartwright 
puts hayashibara_megumi #=> Hayashibara Megumi
puts inoue_kikuko #=> in `to_s':TypeError: singleton method called for a different object
If we try it in Ruby 1.9 we get a different error message:
puts inoue_kikuko #=> in `define_method': can't bind singleton method to a different class (TypeError)
What Ruby does makes some sense - if method was implemented in C (like a lot of standard Ruby methods), calling it on object of completely different "kind" can get us a segmentation fault. With C you can never be sure, but it's reasonably safe to assume that we can move methods between objects with the same "internal representation". We need to use Evil Ruby. Evil Ruby lets us access Ruby internals. UnboundMethod class represents methods not bound to any objects. It contains internal field rklass, and it can only bind to objects of such class (or subclasses). First, let's define a method to change this rklass:
class UnboundMethod
    def rklass=(c)
        RubyInternal.critical {
            i = RubyInternal::DMethod.new(internal.data)
            i.rklass = c.object_id * 2
        }
    end
end
Now we could completely remove protection, but we just want to loosen it. Instead of classes, we want to compare internal types:
class Object
    def copy_gene(method_name)
        [method(method_name).unbind, method_name, internal_type]
    end

    def use_gene(gene, new_method_name = nil)
        raise TypeError, "can't bind method to an object of different internal type" if internal_type != gene[2]
        gene[0].rklass = self.class
        singleton_class.define_method(new_method_name||gene[1], gene[0])
    end
end
And voilà!
puts nancy_cartwright #=> Nancy Cartwright 
puts hayashibara_megumi #=> Hayashibara Megumi
puts inoue_kikuko #=> Inoue Kikuko
This is merely a toy example. But sometimes prototypes lead to design more elegant than factories. Think about the possibility in your next project.

Full listing

require 'evil'

class Object
    def singleton_class
        (class <<self; self; end)
    end
end

class UnboundMethod
    def rklass=(c)
        RubyInternal.critical {
            i = RubyInternal::DMethod.new(internal.data)
            i.rklass = c.object_id * 2
        }
    end
end

class Class
    public :define_method
end

class Object
    def copy_gene(method_name)
        [method(method_name).unbind, method_name, internal_type]
    end

    def use_gene(gene, new_method_name = nil)
        raise TypeError, "can't bind method to an object of different internal type" if internal_type != gene[2]
        gene[0].rklass = self.class
        singleton_class.define_method(new_method_name||gene[1], gene[0])
    end
end

a_person = Object.new
class <<a_person
    attr_accessor :first_name
    attr_accessor :name

    def to_s
        "#{first_name} #{name}"
    end
end

nancy_cartwright = a_person.clone
nancy_cartwright.first_name = "Nancy"
nancy_cartwright.name = "Cartwright"

hayashibara_megumi = a_person.clone
hayashibara_megumi.first_name = "Megumi"
hayashibara_megumi.name = "Hayashibara"

def hayashibara_megumi.to_s
    "#{name} #{first_name}"
end

inoue_kikuko = a_person.clone
inoue_kikuko.first_name = "Kikuko"
inoue_kikuko.name = "Inoue"

japanese_to_s = hayashibara_megumi.copy_gene(:to_s)
inoue_kikuko.use_gene japanese_to_s

puts nancy_cartwright
puts hayashibara_megumi
puts inoue_kikuko

Wednesday, October 04, 2006

Why Perl Is a Great Language for Concurrent Programming

Cable Beach sunset by marj k from flickr (CC-BY-NC)If you asked people what things Perl is good for, they would talk about stuff like web programming, data processing, system scripting and duct taping things. But concurrency ? Can Perl seriously beat languages designed with concurrency in mind like Java (well, kinda) and Erlang ? Surprisingly it can, and here's the story.

Wikipedia contains a lot of links to other websites. About one per article. It does not have any control whatsoever over servers where they are hosted, and every day many of the links die. Some websites move somewhere else, others are removed completely, and there are even those that were incorrect in the first place due to typos etc. Nobody can seriously expect people to check millions of links by hand every day - this is something that a bot should do. And that's what tawbot does.

The first thing we need is to extract list of external links from Wikipedia database. There are basically two ways. First way is to get XML dump of Wikipedia and parse wiki markup to extract links. It's easy to get about half of the links this way, but it's pretty much impossible get close to all. There are at least three formats of external links, and even worse - links can also be assembled from pieces by templates hackery - like links to imdb in film infobox which are not specified explicitly, but only imdb code of a movie is in the article, and template turns the code into an URL.

The alternative is to use MediaWiki engine. Reparsing every single page would be really slow. That's not a new problem - every Wikipedia mirror needs to do the same thing. Fortunately they already fixed it, and Wikipedia dumps include SQL dumps of the tables that are technically derivable from the XML database, but are a bit too expensive. One of the tables is "externallinks" table (yay). Another is "page" table with pages metainformation (id, title, access restrictions etc.).

The first problem is to extract data from MySQL dumps somehow. I could run a MySQL server, but I hate using database servers for standalone applications. I would need to install MySQL server, setup user accounts, and create a special database on every computer I wanted to run the script on. And then deal with usernames, passwords and the rest of the ugly stuff. So I thought I'd use Sqlite 3 instead. It was to be expected that table creation syntaix is different - they aren't the same in any two RDBMS (SQL is as much of "a standard" as Democratic People's Republic od Korea is of "a democracy"). That part was easy. But Sqlite didn't even accept MySQL INSERTs !

Interting multiple values with a single INSERT statement is MySQL extension of SQL (a pretty useful one): INSERT INTO `externallinks` VALUES (a, b,c), (d, e, f), (g, h, i); and Sqlite doesn't support it. Now come on, MySQL is extremely popular, so being compatible with some of its extensions would really increase Sqlite's value as duct tape. Anyway, I had to write a pre-parser to split multirecord inserts into series of single inserts. It took some regexp hackery to get it right, and Sqlite started to accept the input. But it was so unbelievably slow that Perl 6 would have been released by the time Sqlite finishes importing the dump. I guess it was doing something as braindead as fsync'ing database after every insert. I couldn't find anything about it on man pages or Sqlite FAQ. But then I thought - the code that splits multi-value INSERTs into single-valued inserts is already almost parsing the data, so what the heck do I need Sqlite for ? A few more regexps, a lot of time (regexping hundreds of MBs is pretty slow, but it was way faster than Sqlite), and I have the list of links to check extracted. So far I didn't use any Perl or concurrency, it was unthreaded Ruby.

Now let's get back to Perl. There were 386705 links to check, and some time ago I wrote a Perl program verifying links. It is so simple that I'm pasting it almost whole here (headers + code to preload cache omitted):

sub link_status {
my ($ua,$link) = @_;
if(defined $CACHE{$link}) {
    return $CACHE{$link};
}
my $request = new HTTP::Request('HEAD', $link);
my $response = $ua->request($request);
my $status = $response->code;
$CACHE{$link} = $status;
return $status;
}

my $ua = LWP::UserAgent->new();
while(<>)
{
/^(.*)\t(.*)$/ or die "Bad input format of line $.: `$_'";
my($title,$link)=($1,$2);
my $result = link_status($ua, $link);
print "$result\t$title\t$link\n";
}
Basically it reads info from stdin, runs HTTP HEAD request on all URLs, and prints URL status on stdout. As the same URLs are often in multiple articles, and we want to be able to stop the program and restart it later without remembering where it finished, a simple cache system is used.

The program was getting the work done, but it was insanely slow. Most HTTP requests are very fast, so it doesn't hurt much to run them serially. But every now and then there are dead servers that do not return any answer, but simply timeout. When I came the next day to check how the script was doing, I found it was spending most of its time waiting for dead servers, and in effect it was really slow. Now there is no reason to wait, it should be possible to have multiple HTTP connections in parallel. Basically it was in need for some sort of concurrency.

Concurrent programming in most languages is ugly, and people tend to avoid it unless they really have no other choice. Well, I had no other choice. First thing that came to my mind was Erlang (really). The concurrency part shtould be simple enough, and it would be highly educational. But does it have something like LWP ? It would really suck to implement cool concurrency and then have to work with some lame half-complete HTTP library. So I didn't even try. Ruby has only interpretter threads, so concurrent I/O is not going to work. And it would be an understatement to call its HTTP library incomplete. But wait a moment - Perl has real threads. They are pretty weird, sure, but I don't need anything fancy. And I can keep using LWP.

Perl (since 5.6.0) uses theading model that is quite different from most other languages. Each thread runs as a separate virtual machine, and only data that is explicitly marked as shared can be shared. It also has syntax-based locks and a few other unusual ideas. The real reason it was done this way was retrofitting threading on fundamentally unthreadable interpretter. That's the real rationale behind Perl OO too. Of course it sucks for some things, but for some problems it happens to work very nicely.

The design I used was very simple - one master thread, and a group of worker threads. Master would keep pushing tasks on @work_todo, and threads would pop items from it and push result to @work_done. When master doesn't have anything else to do, it sets $finished to true and waits for workers to finish.

Before we spawn threads, we need to declare shared variables:
my @work_todo : shared = ();
my @work_done : shared = ();
my $finished : shared = 0;
Now let's spawn 20 workers (I originally had 5, but it wasn't enough):
my @t;
push @t, threads->new(\&worker) for 1..20;
Workers basically keep taking tasks from todo list until master says it's over:
sub worker {
my $ua = LWP::UserAgent->new(); # Initialize LWP object
while (1) {
    my $cmd;
    {
        lock @work_todo;
        $cmd = pop @work_todo; # get a command
    }
    if($cmd) { # did we get any command ?
        my ($link, $title) = @$cmd;
        # do the computations
        my $status = link_status($ua,$link);
        {
            # @done_item needs to be shared because threads are otherwise independent
            my @done_item : shared = ($status, $title, $link);
            lock @work_done;
            push @work_done, \@done_item;
        }
    } elsif($finished) { # No command, is it over already ?
        last; # Get out of the loop
    } else { # It's not over, wait for new commands from the master
        sleep 1;
    }
}
}
Link checker got even simpler, as cache logic was moved to master.
sub link_status {
my ($ua,$link) = @_;
my $request = new HTTP::Request('HEAD', $link);
my $response = $ua->request($request);
my $status = $response->code;
return $status;
}
After spawning threads master preloads cache from disk (boring code). Then it loops. The first action is clearing @work_done. The done items should be saved to disk and updated in the cache. It is important that only one thread writes to the same file. Under Unices writes are not atomic. So if one process does print("abc") and another does print("def"), it is possible that we get adbefc. Unix is again guilty of being totally broken, inconsistent and hard to use, for the sake of marginally simpler implementation.
while(1)
{
{
    lock @work_done;
    for(@work_done) {
        my ($result, $title, $link) = @$_;
        $CACHE{$link} = $result;
        print "$result\t$title\t$link\n";
    }
    @work_done = ();
}
if (@work_todo > 100) {
    sleep 1;
    next;
}
...
# More code
}
And finally the code to put new items on the todo list:
  my $cmd = <>;
last unless defined $cmd;
$cmd =~ /^(.*)\t(.*)$/ or die "Bad input format of line $.: `$_'";
my($link, $title)=($1, $2);
next if defined $CACHE{$link};
{
    # Explicit sharing of @todo_item again
    my @todo_item : shared = ($link, $title);
    lock @work_todo;
    push @work_todo, \@todo_item;
}
And the code to wait for the threads after we have nothing more to do:
$finished = 1;
$_->join for @t;
Now what's so great about Perl concurrency ?
  • It works
  • Access to all Perl libraries
  • By getting rid of really stupid "shared everything by default" paradigm, it avoids a lot of errors that plague concurrent programs
The most important are the first two points. Third is just a small bonus. Perl concurrency works a lot better than Ruby or Python (at least last time I checked). We get access to all libraries that Erlang will never ever get its hands on. And while "shared-nothing pure message passing" may be more convenient, at least explicit sharing and locking-by-scope are better than "shared everything" model. And we get the basic stuff like Thread::Queue (which I should have used instead of managing lists by hand, whatever).

Could such link checker be written in Erlang as quickly ? I don't think so. In most programs that need concurrency or would benefit from concurrency, the "concurrency" part is a very small part of the program. It's usually far better to have lame concurrency support and good rest of the language than absolutely awesome concurrency part and lame rest of the language. Every now and then you simply have to write a massively concurrent program (like a phone switch), and a special language can be really great. For everything else, there are "business as usual, with concurrency bolted-on" languages like Perl and Java.

Sunday, October 01, 2006

Habeas corpus in the Soviet constitution

Coat of arms of the Soviet Union by Madden from Wikimedia Commons (public domain)Many people have been lamenting "loss of freedom" in USA. American Congress passed laws that among other things allows torture, warantless searches, and imprisoning people without a trial. Legal and illegal election fraud is rampant, and wars can be started without aproval of the Congress. Constitution is pretty much irrelevant at this point. Is it death of democracy and freedom in America ? No.

Constitutions mean nothing. They are just pieces of paper. The 1936 Soviet constitution (passed during Stalin's time) for example stated that:

Article 112
Judges are independent and subject only to the law.

Article 120
Citizens of the U.S.S.R. have the right to maintenance in old age and also in case of sickness or loss of capacity to work. This right is ensured by the extensive development of social insurance of workers and employees at state expense, free medical service for the working people and the provision of a wide network of health resorts for the use of the working people.

Article 121
Citizens of the U.S.S.R. have the right to education. This right is ensured by universal, compulsory elementary education; by education, including higher education, being free of charge; by the system of state stipends for the overwhelming majority of students in the universities and colleges; by instruction in schools being conducted in the native Ianguage, and by the organization in the factories, state farms, machine and tractor stations and collective farms of free vocational, technical and agronomic training for the working people.

Article 122
Women in the U.S.S.R. are accorded equal rights with men in all spheres of economic, state, cultural, social and political life. The possibility of exercising these rights is ensured to women by granting them an equal right with men to work, payment for work, rest and leisure, social insurance and education, and by state protection of the interests of mother and child, prematernity and maternity leave with full pay, and the provision of a wide network of maternity homes, nurseries and kindergartens.

Article 123
Equality of rights of citizens of the U.S.S.R., irrespective of their nationality or race, in all spheres of economic, state, cultural, social and political life, is an indefeasible law. Any direct or indirect restriction of the rights of, or, conversely, any establishment of direct or indirect privileges for, citizens on account of their race or nationality, as well as any advocacy of racial or national exclusiveness or hatred and contempt, is punishable by law.

Article 124
In order to ensure to citizens freedom of conscience, the church in the U.S.S.R. is separated from the state, and the school from the church. Freedom of religious worship and freedom of antireligious propaganda is recognized for all citizens.

Article 125
In conformity with the interests of the working people, and in order to strengthen the socialist system, the citizens of the U.S.S.R. are guaranteed by law:

1. freedom of speech;
2. freedom of the press;
3. freedom of assembly, including the holding of mass meetings;
4. freedom of street processions and demonstrations.

These civil rights are ensured by placing at the disposal of the working people and their organizations printing presses, stocks of paper, public buildings, the streets, communications facilities and other material requisites for the exercise of these rights.

Article 127
Citizens of the U.S.S.R. are guaranteed inviolability of the person. No person may be placed under arrest except by decision of a court or with the sanction of a procurator.

Article 128
The inviolability of the homes of citizens and privacy of correspondence are protected by law.

Article 134
Members of all Soviets of Working People's Deputies--of the Supreme Soviet of the U.S.S.R., the Supreme Soviets of the Union Republics, the Soviets of Working People's Deputies of the Territories and Regions, the Supreme Soviets of the Autonomous Republics, and Soviets of Working People's Deputies of Autonomous Regions, area, district, city and rural (station, village, hamlet, kishlak, aul) Soviets of Working People's Deputies--are chosen by the electors on the basis of universal, direct and equal suffrage by secret ballot.

Article 135
Elections of deputies are universal: all citizens of the U.S.S.R. who have reached the age of eighteen, irrespective of race or nationality, religion, educational and residential qualifications, social origin, property status or past activities, have the right to vote in the election of deputies and to be elected, with the exception of insane persons and persons who have been convicted by a court of law and whose sentences include deprivation of electoral rights.

Article 136
Elections of deputies are equal: each citizen has one vote; all citizens participate in elections on an equal footing.

Article 137
Women have the right to elect and be elected on equal terms with men.

So what do we have here ? Guarantees of freedom of speech, of the press, of assembly, of conscience, and of religious worship. It contains equivalent of habeas corpus provisions. It protects against unreasonable searches. Unlike the American constitution, it actually guarantees right to vote. Surprisingly this basic right is not guaranteed by American constitution. It contains very strong equality provisions, including a very important provision of education in native language (Soviet Union had many minorities). It also contains guarantees of free access to education and health care, and of social security. This is 1936, time of Stalin.

Of course everyone knows that in spite of these provisions, Soviet Union was breaking every conceivable human right, including murder of about 60 million people. It's about three times as much as Nazis.

So the most genocidal state in history of mankind had stronger human rights provision in its constitution than most of the countries have now.

Was Soviet Union somehow exceptional ? Not at all. Most of the countries in 20th century, including ones with worst human rights record, have human rights guarantees in their constitutions. In particular constitution of USA wasn't worth that much. All branches of government at all levels disregarded it when they felt like doing so. The Supreme Court was often effective in limiting the abuse, but in many cases it rubberstamped human rights abuses and other violations of the constitution. Some examples of abuses of human rights and separation of powers allowed by the Supreme Court (some of them overturned later):

  • 1798 - Criticism of government can be prohibited (not a Supreme Court case, as the Supreme Court didn't deal with such cases before 1802, but other courts were ok with it)
  • 1849 - Some parts of constitution can be freely ignored by the government
  • 1857 - Slavery is legal in every state, and black people are forbidden from becoming American citizen. According to the constitution, both issues were decided by individual states.
  • 1896 - Racial segregation is still legal
  • 1919 - Freedom of political speech can be freely restricted
  • 1927 - Freedom of speech and political activism can be freely restricted
  • 1938 - Federal government can regulate local economy, ignoring constitution explicitly stating otherwise
  • 1939 - "The right of the People to keep and bear arms" can be infridged now.
  • 1942 - Federal government can even regulate thing that have little to do with economy as "interstate commerce"
  • 1944 - Concentration camps are legal. The executive branch can arbitrarily imprison people (it did not even require an act of Congress)
  • 1951 - Political activism can be freely restricted
  • 1957 - Freedom of speech can be restricted (on religious grounds)
  • 1987 - Federal government can force state governments to do anything by economic pressure
  • 2000 - There is no effective protection against elections forging
  • 2004 - Government can arbitrarily imprison non-citizens
  • 2005 - Confiscation of property are not limited to "public use" any more
  • 2005 - Federal government can forbid medical marijuana as "interstate commerce" in spite of state laws that allow it
  • Ignoring constitution was also used sometimes to do something good. Some cases are limits on gerrymandering (1964), actual enforcement of prohibition of illegal searches (1961), right to abortions (1972), right to homosexual sex (2003)

    The situation is far better than it was in Soviet Union. American Supreme Court is better than most when it comes to limiting human rights abuse by government, but it keeps letting the Constitution be severely broken. And there are no other legal ways of enforcing the Constitution.

    Constitutional guarantees of human rights and limits on government power are worth less than the paper they're written on if ways of enforcing them are insufficient.

    Seriously, what USA needs right now is a new constitution, or a major update. The reality is different than it was in 18th century, and answers to many questions should be explicitly written, instead of judges deciding whichever way they felt like. Constitution does not claim that federal government has control over everything, it does assert gun rights, it doesn't say anything about abortion and homosexuality rights. Such de-facto changes should be given de-jure status. Sure, judical activism is all right sometimes, but it's a short-term fix, not a long-term solution. Basic rights should be recognized - right to vote, including right to have one's vote effectively counted, and reasonable protection against gerrymandering (in most countries district boundaries are set by independent elections commission).

    Protection against abuse must become much stronger. USA is about the only country where Supreme Court packing is even being seriously considered, and where supreme court judges are so involved in politics. In very few countries (mostly not very democratic ones) president gets a total control over every aspect of executive powers (including powers that were supposed to be handled by individual states), without any external control or oversight, and additionally has huge influence on the legislature and can even declare de-facto wars. There is no need for one person to have that much power. There is no need to use insane election systems. There is no reason for making challenging constitutionality of laws that difficult - it should be possible to go to Supreme Court directly (in many countries ombudsman can do that, or a group of any 15 members of parliament etc.). The legal system is known to biased for big corporations and against the poor and minorities, and this can be limited, even if not eliminated.

    Back in 18th century the Constitution was an experiment. Some things worked well, others less so. But now we have many years of experience with different solutions, in so many countries. What is everybody still waiting for ? It is a plausible scenario for elections to get stolen by massive use of gerrymandering, denying right to vote to minorities, Diebold machines and other creative methods, then the Supreme Court to get packed by pro-government judges, and to extend its interpretations of Constitution just a little bit further to validate even more serious violations of human rights. Maybe it's not happening yet, but it doesn't seem that far off.

    Without efficient means of defending the Constitution, it means very little. If you let your freedoms be takes, it will be possible to get them back someday, but it's going to be much more difficult. (By the way in spite of what gun nuts say, historically violence was very rarely successful at restoring freedom and democracy.)

    Act now. Or else ...