Tuesday, March 31, 2009

Titles optional

For all the bad media, the American military is damn good at warfighting. It's true that their upper echelons have made (i.e. still making) terrible decisions and the whole American military complex is a huge clusterfuck, but even if you put a squad of US soldiers into an ambush situation--outgunned, outnumbered and without close air--they will come out on top.

While the initial gunslinging bravado of the US Army has given way to a new counter-insurgency docterine, the rest of NATO is still struggling to adapt as their peacemakers come under heavier attack.

Iraq is well on its way to recovery whether because of the surge or the Anbar Awakening (I'd vouch for the latter), but on the homefront people have been losing their stomach for war.

Meanwhile, Afghanistan and Northern Pakistan are slipping back into Taliban grips. Pakistan is especially inept at this fighting business so the US Army really needs to be there. [1]

So, can America keep up the momentum and capitalize on their bloody gains or will everything come falling down like a house of cards?

1. Quiz time: what should your main battle tanks do when they encounter insurgents? Hint: full reverse is not the correct answer.

Thursday, March 26, 2009

Battlestar Galactica

So, I've had 4 different blogs in 3 different folders on my RSS aggregator bring up the Battlestar Galactica finale.

Including a personal finance blog and a paramedic blog.

I don't know what this says about me as a person.

Thursday, March 19, 2009

Fighting piracy with Aegis cruisers

Absolutely ridiculous.

The Russians are even worse, blowing up pirate skiffs with a Cold War era 28 000 ton nuclear battlecruiser.

Well, maybe not

Doesn't America have any better idea than to fight fishing trawlers with ships excess of 3000 tons?

1. They actually are, since Boxer is replacing San Antonio on station, it makes sense looking at it as a logistics ship with air capability rather than a 40 000 ton aircraft carrier, whereas the Kirovs are arsenal ships pure and simple. I'm just being a troll. Alternatively: Boxer can launch an invasion on Somalia by itself.

Saturday, March 14, 2009

So...

You can see what type of developers Ruby attracts:

http://poignantguide.net/ruby/
http://shoooes.net/

It's scary and awesome all at once.

Scarily awesome.

edit: For the record, I found the guide to be too ADD even for me and I was upset that shoes isn't actually a GUI library, it's just its own development environment that uses Ruby.

Tuesday, March 10, 2009

GTFO my Ruby, C users

Alternatively: Lies revisited.

It's often stated that Ruby has no primitives, everything is an object. That's not true, rather almost everything is actually a pointer to an object. There is also one primitive: int. They've just been made to behave as objects through other means. Ints are primitive as an interpreter optimization, since you're going to be storing int values in pointers, there isn't much to be gained in constantly creating int objects and then pointing to it, at least in Ruby's case.

What's really interesting is the objects:

a = 'hello world'
b = a
a = 'goodbye world'

puts a #outputs goodbye world
puts b #outputs hello world


Wait, what happened there? Well, since Ruby is meant to be intuitive (this isn't C after all), we don't want to be dealing with all this pointer nonsense. Everything is made to behave as though they were passing by value, so treating everything as an object works. Mostly. What actually happens behind the scenes is that b still points to the old value, but when a is changed, a new value is created and a is redirected to that. If we change b as well, then our garbage collector sees that 'hello world' is unref'd and reclaims the memory (this isn't C goddammit).

Ruby gives us some options for changing values directly:

a = 'hello world'
b = a
a.replace('goodbye world')

puts a #outputs goodbye world
puts b #outputs goodbye world


In addition to that, there are a number of bang (!) functions, which behave like their counterparts except that they modify values directly. The ! signifies that they're dangerous.

So what happens? Well, knowing this information, a user decides to suggest in a thread that Ruby ought to have pointers to pointers so he can do things like he could in C.

Because .replace is too messy.

Nevermind that Java gets along just fine without any.

Fucking C.

Yeah, that was a long setup to a bad punchline. I know. I also know that the interpreter was coded in C.

Monday, March 09, 2009

Rediscovering ternary operators

Check out this factorial function, now not even error handling can increase my line numbers!

factorial = lambda{|x| x<0 ? 'error':(x==0 ? 1:(1..x).inject{|x,y| x*y })}

This is just what came to mind, it could handle strings as well if you add in another ternary. What's really interesting now is that when you combine ternaries with iterators you have the two major control structures: if statements and for loops. That means you can conceivably create some massively complex functions in just one line. One long incomprehensible line, but one line nonetheless.

Of course, even the most fanatical Ruby developer wouldn't actually do this because the code would look ridiculous.

I think.

Saturday, March 07, 2009

Bits and Funnels

Apparently Block III Apaches are supposed to have the capability to control Fire Scouts from their cockpits. Imagine that, an attack helicopter tailed by a swarm of smaller attack helicopters. I'm pretty sure that Fire Scouts can pack Hellfires too.

This is one of those things that sound ridiculous yet awesome at the same time. You know, like it shouldn't work in real life but apparently does anyways.

On a different note, why are Perry class ships still designated FFGs? The Mk-13s have been removed years ago!

Wednesday, March 04, 2009

Itt: Lies

People often talk about how readable Ruby is, how a person who's never seen a computer program could just about understand what's happening. After all, the clean syntax is what initially attracted me to Ruby. As it turns out though, that's only true if you're writing in the imperative.

For instance, this is how you'd be expected to write a summation function in something like Java:

def summation1 (n)
  if n == 0
    return 0
  else
    return n + summation1(n-1)
  end
end

puts summation1(3) #Outputs 6


That's readable even to the layperson right? Except spoilers: nobody actually uses Ruby that way. Let's try something else then:

def summation2 (n)
  a = Array.new
  n.times {|x| a << x)
  return a.inject {|x,y| x+y }
end

puts summation2(3) #Outputs 6


Okay, I admit that was a bit contrived. But you can see where this is leading:

summation3 = lambda {|x| (1..x).inject {|x,y| x+y }}
p summation3[3] #Outputs 6


What. Did I get hit by the Haskell train or something?

Basically what I'm trying to say is, Ruby is a very concise and elegant language. But with so many shortcuts built in, its general readability does suffer. At least for people not familiar with this kind of functionality. That said, condensing 8 lines of code into 2 only makes me enjoy Ruby more, not less.

Note: That is not a typo in example 3, there is indeed a shortcut for puts. People don't tend to use it so much though, or at least I don't.

Sunday, March 01, 2009

Such precision targeting

I subscribed to a new feed called Concept Art World.

...and realized I wanted to buy every advertised item that came up in the sidebar.

Intuos + Painter 11 bundle?
Art of Watchmen the Movie?
Compilation book of Massive Black?

Too bad my monies are going towards education or I'd be throwing bucket fulls of cash at their advertisers.

Alternatively: Good thing my monies are going towards education or I'd be throwing bucket fulls of cash at their advertisers.