The Daily Parker

Politics, Weather, Photography, and the Dog

I hate Scala

"It is no one's right to despise another. It is a hard-won privilege over long experience."—Isaac Asimov, "C-Chute"

For the past three months, I've worked with a programming language called Scala. When I started with it, I thought it would present a challenge to learn, but ultimately it would be worth it. Scala is derived from Java, which in turn is a C-based language. C#, my primary language of the last 18 years, is also a C-based language. 

So I analogized thus: C# : Java :: Spanish : Italian; therefore C# : Scala :: Spanish : Neapolitan Italian. So as with my decent Spanish skills making it relatively easy to navigate Italy, and my decent C# skills making it relatively easy to navigate Java, I expected Scala to be just a dialect I could pick up.

Wow, was I wrong. After three months, I have a better analogy: C# : Scala :: English : Cockney Rhyming Slang. Or perhaps Jive. Or maybe even, C# : Scala :: German : Yiddish. That's right: I submit that Scala is a creole, probably of Java and Haskell.

Let me explain.

Most C-based languages use similar words to express similar concepts. In Java, C#, and other C-based languages, an instance of a class is an object. Classes can have instance and static members. If you have a list of cases to switch between, you switch...case over them. And on and on.

Scala has a thing called a class, a thing called an object, a thing called a case class, and a thing called a match. I'll leave discovering their meanings as an exercise for the reader. Hint: only one of the four works the same way as in the other related languages. In other words, Scala bases itself on one language, but changes so many things that the language is incomprehensible to most people without a lot of study.

Further, though Scala comes from object-oriented Java, and while it can work in an object-oriented fashion with a lot of coercion, 

As in Yiddish or Gullah, while you can see the relationship from the creole back to the dominant language, no deductive process will get you from the dominant to the creole. "Answer the dog," a perfectly valid way to say "pick up the phone" in Cockney (dog <- dog bone <- rhymes with phone), makes no sense to anyone outside the East End. Nor does the phrase "ich hab' in bodereim," which translates directly from Yiddish as "I have (it) in the bathtub," but really means "fuck it." The fact that Yiddish uses the Hebrew alphabet to express a Germanic creole only adds to its incomprehensibility to outsiders.

These are features, not bugs, of Jive, Gullah, Yiddish, and other creoles and slangs. They take words from the dominant language, mix them with a bunch of other languages, and survive in part as a way to distinguish the in-group from the out-group, where the out-group are the larger culture's dominant class.

I submit that Scala fits this profile.

Scala comes from academic computing, and its creator, German computer scientist Martin Odersky, maintains tight control over the language definition. Fast adoption was never his goal; nor, I think, was producing commercial software. He wanted to solve certain programming problems that current computer science thinking worries about. That it elevates a densely mathematical model of software design into commercial development is incidental, but it does increase the barriers to entry into the profession, so...maybe that's also a feature rather than a bug?

Scala isn't a bad language. It has some benefits over other languages. First, Scala encourages you to create immutable objects, meaning once an object has a value, that value can never change. This prevents threading issues, where one part of the program creates an object and another part changes the object such that the first part gets totally confused. Other languages, like C#, require developers to put guardrails around parts of the code to prevent that from happening. If all of your objects are immutable, however, you don't need those guardrails.

A consequence of this, however, is that some really simple operations in C# become excruciating in Scala. Want to create a list of things that change state when they encounter other things? Oh, no, no, no! Changing state is bad! Your two-line snippet that flips a bit on some objects in a list should instead be 12 lines of code (16 if it's readable) that create two copies of every object in your list through a function that operates on the list. I mean, sure, that's one way to do it, I suppose...but it seems more like an interview question with an arbitrary design constraint than a way to solve a real problem.

Second, this same characteristic makes the language very, very scaleable, right out of the box. That is actually the point: "Scala" is a portmanteau of "Scaleable" and "Language," after all. That said, C# is scaleable enough to run XBox, NBC.com, Office Online, and dozens of other sites with millions of concurrent users, so Scala doesn't exactly have a monopoly on this.

Not to mention, Scala gives frustrated Haskell programmers a way to show off their functional-programming and code-golf skills in a commercial environment. Note that this makes life a lot harder for people who didn't come from an academic background, as the code these people write in Scala is just as incomprehensible to newbies as Haskell is to everyone else.

All of this is fine, but I have developed commercial software for 25 years, and rarely have I encountered a mainstream language as ill-suited to the task of producing a working product in a reasonable time frame than this one. Because the problem that I want to solve, as a grizzled veteran of this industry, is how I can do my job effectively. Scala is making that much more difficult than any language I have ever dealt with. (There are a number of other factors in my current role making it difficult to do my job, but that is not the point of this post.)

Maybe I'm just old. Maybe I have thought about software in terms of objects with behavior and data for so long that thinking about it in terms of functions that operate over data just doesn't penetrate. Maybe I've been doing this job long enough to see functional programming as the pendulum swinging back to the 1980s and early 1990s, when the implementationists ruled the day, and not wanting to go back to those dark ages. (That's another post, soon.)

This cri de coeur aside, I'll continue learning Scala, and continue doing my job. I just really, really wish it had fewer barriers to success.

Three nights, three hotels

I'm traveling this weekend, starting with a night about a block from my office. Tonight is WhiskyFest Chicago, starting in about 90 minutes (though they let us start gorging on cheese and crackers at 5pm). For easily-understood reasons, I'm staying at the same hotel tonight, then heading to my college radio station's 60th anniversary party tomorrow morning. Not my first choice of timing, but I had no control over either event.

Sunday I head into Manhattan, and coincidentally the Yankees are in town...

The view from my room today fails to suck:

Starting the April entries

It may appear that blogging will slow down a little bit going into the last week of March. That's because Blogging A-to-Z entries take a little more time to write. This year might be a little ambitious, also, because I plan to provide musical snippets to go along with the text (otherwise what's the point?).

My goal today: get through a chunk of the first week of April. And figure out when I can write the rest for that week.

I've also written an entry for an historical anniversary mid-April.

Stay tuned.

Historic Chicago election

I told you the Chicago mayoral election would be difficult. I had no idea that my preferred candidate would come out in first place, setting up an April 2nd election that will elect Chicago's first African-American woman mayor:

It’s only the second time Chicago has had a runoff campaign for mayor, which occurs when no candidate collects more than 50 percent of the vote in the first round.

Unofficial results showed Lightfoot with 17.5 percent of the vote, Preckwinkle with 16 percent and Bill Daley with 14.7 percent, with 96 percent of precincts counted. They were trailed by businessman Willie Wilson with 10 percent, state Comptroller Susana Mendoza with 9 percent, activist and policy consultant Amara Enyia with 8 percent, Southwest Side attorney Jerry Joyce with 7 percent and former CPS board President Gery Chico with 6 percent.

The remaining six candidates, former CPS CEO Paul Vallas, former police Superintendent Garry McCarthy, state Rep. La Shawn Ford, former Ald. Bob Fioretti, tech entrepreneur Neal Sales-Griffin and attorney John Kozlar, each collected less than 6 percent.

The results set up a showdown between two self-styled progressives — Preckwinkle, chair of the Cook County Democratic Party and a former longtime alderman who rose from Hyde Park’s bastion of liberal politics, versus Lightfoot, a first-time candidate who has railed against Chicago’s history of machine politics and vowed to usher in a new era of reform at City Hall.

One of them will become Chicago’s second female mayor, following Jane Byrne, who served one term from 1979 to 1983. And if Lightfoot is elected, she would become the city’s first openly gay mayor. Both would become the second African-American elected Chicago mayor after Harold Washington, who served from 1983 until he died in 1987.

On the other hand, out of 1.5 million registered voters in Chicago, only about a third showed up at the polls. My ward has about 55,000 residents, and the top-two candidates for Alderman only got 8,000 votes between them. (My candidate came in third, sadly.)

Still, I'm pleased with the results. I think Preckwinkle will win the runoff, given her name recognition and County-level machine behind her, but I'm OK with her as mayor. Regardless, the next four years should see some shifts away from policies that benefit people like me towards people who need the benefits more, which ultimately will help the city in the long run. Having an African-American mayor might also stem the flow of African-Americans leaving the city, which, again, will make Chicago stronger.

Difficult vote ahead

Chicago's mayoral primary takes place Tuesday with 256 12 people on the ballot. That means the election will likely determine only the two people who will stand in the runoff election in April.

Many local news organizations have round-ups of the candidates' policy provisions, and interactive tools to help voters figure out who mirrors their own policies most closely. I've gone through Chicago Public Media's guide twice, the second time choosing "No answer" for items that matter less to me than other matters.

My results? Even though the thought of a third Mayor Daley makes me want to move to Saskatchewan, it turns out I don't have to hold my nose and vote for Bill Daley: he's almost at the bottom of my list, with 37% matching policies, ahead of only attorney Jerry Joyce who has no chance anyway.

My top three, to my surprise, are Amara Enyia, Lori Lightfoot, with 69% and 67% matching policies respectively, and a tie between Bob Fioretti and Garry McCarthy at 63%. Enyia and Fioretti will be lucky to clear 10% of the vote, let alone the 50% required to avoid a runoff, so I'm not really considering them. Lightfoot and McCarthy both have fighting chances.

Of the questions that really matter to me, Enyia and Fioretti get one (in favor of city income tax), everyone but Daley, Paul Vallas, and Joyce support an elected school board, and everyone except Daley, Joyce, LaShawn Ford, Toni Preckwinkle, and Willie Wilson support ending "aldermanic perogative."

Lower priorities of mine include raising ride-share fees to benefit the Chicago Transit Authority (Lightfoot and McCarthy say yes, Enyia says no); hiring social workers to assist police in mental-health calls (everyone says yes except Daley and Joyce); and opposing a city-run casino (Enyia agrees with me; Lightfoot doesn't).

So the front-runner for my vote right now is Lori Lightfoot, in part because I believe either Daley or Preckwinkle will also be in the runoff, and Lightfoot has a chance. That said, I would bet a dollar that the April 3rd runoff will be between Daley and Preckwinkle, because they both have huge machines backing them. And this is Chicago.

And all this is just a smaller version of what will happen a year from now when my party starts voting for its nominee to run against the president 619 days from now.

Actually, it is rocket science: personal edition

One of my friends from high school, Beth Moses, today became the 571st person to travel into space:

Virgin Galactic sent three human beings on Unity for the first time in Friday's supersonic test flight, which reached three times the speed of sound on its way up. Just before the flight, Richard Branson's space tourism company told CNBC that astronaut trainer Beth Moses is on the company's spacecraft Unity, along with the two pilots.

"Beth Moses is on board as a crew member," a Virgin Galactic spokeswoman told CNBC. "She will be doing validation of some of the cabin design elements."

The mission launched horizontally, rather than the traditional vertical method of launching rockets. The jet-powered mothership Eve lifted the spacecraft Unity, taking off from the Mojave Air and Space Port. Upon reaching an altitude above 40,000 feet, the carrier aircraft released Unity.

MacKay and Masucci then piloted the spacecraft in a roaring burn. The flight pushed Unity to a speed of Mach 3, which is three times the speed of sound, as it screamed into a climb.

After performing a slow backflip in microgravity, Unity turned, gliding back to land at the runway it took off from about an hour earlier. Unity is the name of the spacecraft built by The Spaceship Company, which Branson also owns. This rocket design is officially known as SpaceShipTwo.

When Beth was in high school, she said she wanted to be an astronaut. After a long career at NASA she joined Virgin Galactic as their chief astronaut instructor. And today, she made history.

Congratulations, Beth! You're officially out of this world.

Beth Moses, center. (Photo courtesy of Danielle Cosma.)