The lure of Sprint was too strong to pass up, but ultimately ended in letdown and abandon.
Sprint's pitch was simple. Where else can you get an all you can eat data plan and ample minutes for $75.00 including the government’s taxation scheme that Karl Marx would be proud of? Done. Sign me up.
Choosing a phone for Sprint's network was not as easy. They offer three compelling choices.
First, you can speak random thoughts of consciousness in a Sprint store, and if a customer has pressed the Siri button on the display model iPhone 4s, you'll likely get verbal confirmation to choose it.
For those flirting with escape from Jobs’ utopia, the gorilla glass encased false god of Android is eager to entice, with a Samsung Galaxy S II. Like a hollywood celeb it's light weight and beautiful.
But for some, age brings truth, hence the third option, a year old Samsung Nexus S anointed with the purity of plain Gingerbread. I chose this option.
Despite the sweetness of Gingerbread, there is nothing tasty about Samsung’s Nexus S. Extremely poor antennas for wifi, 3g and 4g? Check. A battery that can’t last ½ day with light to moderate use? Check. Screen jitter while scrolling through your twitter feed? Check.
Needless to say the phone went back to the Sprint store. This left two choices left. The iPhone 4s and the Galaxy S II. I opted with the Galaxy S II.
The Galaxy S II represents everything that is right and wrong about Android, the device manufacturers, and the carriers.
On the Galaxy S II, gone is the jerky scrolling of the Nexus S. The screen is vibrant and huge. Samsung retained its use of a plastic enclosure, yet improved its sturdiness, a move that makes the device feel better quality. The antennas are dramatically better, resulting in greater wifi availability and improved call quality.
Unfortunately, the battery still sucks. And Samsung managed to load the device up with crap ware that you cannot delete from the application menu.
To mitigate the battery life, I bought a few chargers to plant at strategic locations at home, in the car and at the office. And most of the crap ware can be stashed in a folder on the desktop. This uncluttered things enough to pass inspection.
Just as I was getting used to the device, and on the last day of my free trial, Sprint dropped the mother of all bombs. They announced the ending of the unlimited data plan. Furthermore, current users would not be grandfathered in, and thus would be subject to huge data overage charges.
This triggered my immediate cancellation of the Sprint plan.
The data plan was the only reason why I went to Sprint in the first place. With Sprint customers faced a trade-off. You received unlimited data for a unreliable network that has poor coverage in rural areas.
With their latest decision, there is no tradeoff, and therefore no logical reason why anyone whould choose Sprint over another network.
I leveraged the "winback" program AT&T offers customers who made the transgression of choosing another carrier. They put you back on the program exactly as you left it at no charge.
So here I am, back with AT&T using a feature phone with nothing but time to ponder my next move.
Do I wait three weeks for Samsung’s Galaxy Nexus that boasts Ice Cream Sandwich, Google’s new OS? Do l let lust get the best of me, and choose a Windows Phone 7, with the Mango update, knowing I'll likely be ultiamtely dissapointed with its feature incompleteness? Or do I return to utopia with an iPhone 4s?
The reality is that in this temporal existence, utopia doesn’t exist and there is no perfect phone. Therefore, I’m sticking with my wife’s old feature phone.
Your Go program can easily grab command line arguments.
Let's say your program prints a person's name that gets passed into the program as a command line argument.
To make this happen, you need to import the "flag" package. Next you need to declare a variable that you will store the flag's value in.
I chose to declare a string variable called "value" for this purpose.
With a variable set, use the flag.StringVar(...) function to set the value (assuming the value you wish to parse is a string). Your other option is to use the flag.IntVar(...) function to bind an integer variable with an integer command line argument.
Note that the flag.StringVar function accepts a reference to a string variable, not a pointer. This reference is used internally by the flag package. Also, not that if you don't specify a command line flag, this function sets one up for you with the default name "The Dude".
Finally, execute flag's Parse() function, and either the flag passed in from the command line, or a default flag will be ready for use.
This took a while to figure out how to do, so I thought I'd post how to identify which security groups a given user belongs to within a Microsoft Active Directory system.
Assuming you still haven't bought a mac, here are the steps:
Start --> Run -- CMD
First, find out your user info by issuing this command.
C:\Documents and Settings\cthomps> dsquery user -name Charles*
A recurring meme of the Scala community is that Scala is a better Java than Java. Or Scala is the next Java. Some even say it will replace Java.
I must admit, I salivate over things like list comprehensions, closures, and a REPL. And for that, Scala had me at hello.
Toss in a little immutability and Erlang’esq message passing to simplify concurrency oriented programming, and I’m taking Scala home to meet mom.
When I discovered Akka, a Scala library that gives you things like supervision, and other goodies pulled from the Erlang/OTP pot of gold, I was in like a bear claw in a honey pot.
But then it happend. I set up a Lift site on my box, and started hacking. Scala’s documentation is good, but not as superlative as what I’ve seen with other platforms and languages. This led me to start reading a lot of Scala source code. That’s when I found a mole with a hair growing out of it.
Scala embraces creativity. For example, you can write your own domain specific language. You can overload operators like Bill Clinton re-defines the word “is”. Add these capabilities together and devs start writing code that reads like Mrs. Cleaver’s lines from Airplane!
Sheeeet. Transation: Scala is a beautiful language and an engineering marvel. The virtues of its flexibility far outweigh source code I do not understand.
But my last smokey smokey off the Scala hooka went down like the first time I swallowed my saliva with a chew in. If you’ve done this, you know what I’m talking about.
Point a browser window at Typesafe. Scala. Akka. Simple. That’s the tag line. Typesafe was created by the inventors of Scala and Akka. This firm is backed by some serious pedigree. The firm was created in part to deliver a simple one stop shop for all your IDE, Scala language, and build tool needs.
I liked what I saw, so I checked out the getting started guide. Typesafe’s tutorial walks a user through writing a program that calculates pi concurrently. The equation is:
The Scala tutorial performs the calculation by sending messages to a bunch of worker processes whose job it is to calculate an iteration of k. It then collects the results from the workers and prints it out. It’s kind of map reduce’ish.
Wikipedia says you need to sum 300 iterations to get a precision of 3.14. The tutorial burns through 1000 iterations.
Normally, I’d think this solution is pretty slick. It features Java’s familiar inheritance, a new twist on the singleton, some mixed in traits, some message passing, and a cool Akka doohicky called a load balancer (it load balances tasks across the pool of worker processes).
// define the work def calculatePiFor(start:Int, nrOfElements:Int):Double={ var acc =0.0 for(i <- start until (start + nrOfElements)) acc +=4.0*(1-(i %2)*2)/(2* i +1) acc }
def receive ={ caseWork(start, nrOfElements)=> self reply Result(calculatePiFor(start, nrOfElements))// perform the work } }
overridedef postStop(){ // tell the world that the calculation is complete println( "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis" .format(pi,(System.currentTimeMillis - start))) latch.countDown() } }
// ================== // ===== Run it ===== // ================== def calculate(nrOfWorkers:Int, nrOfElements:Int, nrOfMessages:Int){
// this latch is only plumbing to know when the calculation is completed val latch =newCountDownLatch(1)
// create the master val master = actorOf(newMaster(nrOfWorkers, nrOfMessages, nrOfElements, latch)).start()
// start the calculation master !Calculate
// wait for master to shut down latch.await() } }
There is one problem. I’ve been toying around with a language called Go. I can’t put it down. That’s because after Go, programming in anything else seems as difficult as balancing the State of California’s budget.
You can summarize the Go programming language in one word. Simple.
Here’s a version of Go that solves this problem using Go idioms.
Instead of load balancing tasks across a pool of worker processes, this program spawns a goroutine (think lightweight process) to solve each iteration of the equation. Processes run in parallel. After each process does the math, it adds the sends the result to a channel. Finally the function that spawned the goroutines in the first place collects the results from the channel and sums them.
Here’s the code:
package main
import ( "fmt" "math" )
func main() { //spawn 300K goroutines to calculate pi fmt.Println(CalculatePi(300000)) }
//map for i := 0; i <= term; i++ { go formula(ch, float64(i)) } result := 0.0 //reduce for i := 0; i <= term; i++ { result += <- ch } return result }
func formula(ch chanfloat64, term float64) { result := 4 * (math.Pow(-1, term)/(2.0 * term + 1.0)) ch <- result }
Hmmm. 33 lines. Not bad. Let’s do a deep dive.
If you don’t have Go already, follow the installation instructions at golang.org. Next, dump the above code into your favorite text editor then save it as pi.go.
From the command line, you can compile, link, then execute your code by running this command:
$ 6g pi.go && 6l pi.6 && ./6.out
3.14159598691202
Let’s revisit what we just did.
Each file must be assigned to a package. The main function in the main package is what gets executed first in a Go program.
Main tells the function CalculatePI to compute 300,000 iterations of the Pi equation.
CalculatePI is dirty simple. It begins by defining a channel. In this case, I’m using a channel as a threadsafe queue to add the result of each iteration to.
Next, CalculatePi loops 300,000 times, each time spawning a new goroutine to calculate the next iteration of pi using the formula function.
Finally, CalculatePi pulls each result off of the queue, summing the result in the process.
This code runs on a dual core Mac mini in about 2 seconds. Think about this. The code spawned 300,000 processes and retrieved the results in 2 seconds. That’s totally awesome!
Goroutines and channels are my favorite aspect of the Go programming language. Goroutines provide you with a simple mechanism to spawn off pieces of work to happen at the same time. And channels enable you to easily synchronize access to a mutable data structure.
Scala is an immensely powerful and beautiful langauge. But Go’s simplicity and power is attractive. And the source code is easy to read and understand. For these reasons, I think Go has a shot at being the next Java.