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.

Sears sues Eddie Lampert

While waiting for the Mueller Report to download (spare a moment to pity the Justice Department's servers), an alert came in from Crain's:

The bankrupt estate of Sears Holdings Corp. sued Eddie Lampert and his hedge fund ESL Investments Inc., claiming they wrongly transferred $2 billion of company assets beyond the reach of creditors in the years leading up to the retailer’s bankruptcy.

“Had defendants not taken these improper and illegal actions, Sears would have had billions of dollars more to pay its third-party creditors today and would not have endured the amount of disruption, expense, and job losses resulting from its recent bankruptcy,” lawyers for the estate said in a court filing.

The complaint, filed as part of the retailer’s ongoing bankruptcy case, asks that the transactions be ruled fraudulent transfers and says creditors should be compensated.

Lawyers for the estate also allege that ESL stripped Sears of the real estate under 266 of the retailer’s most profitable stores, undervaluing the land by at least $649 million. “Moreover, the culpable insiders arranged for Sears to lease the properties back under blatantly unfair terms,” according to the complaint.

No kidding.

It's interesting to me how people who claim that the government has no right to interfere in private affairs seem to make that claim to avoid scrutiny of shady behavior. And Lampert seems to be one of the shadiest.

P is for Pachelbel

Blogging A to ZThis morning, my Blogging A-to-Z challenge post will discuss a composer whose music I absolutely loathe because of its insipid, simplistic, earwormy pabulum, Johann Pachelbel (1653-1706).

You have, no doubt, heard his Canon in D, which, thanks to its inclusion in an otherwise forgettable film 51 years ago, continues to besmirch weddings and other cultural events with its demonstration of what happens when you strip music down to the essentials and add nothing back. In a way, the Canon in D resembles a lot of modern music by providing nothing more than a repeating theme of such simplicity that only a performance by 3rd graders on recorder could do it justice.

So why did I include this composer in a series on music theory? Because in that simplicity is just about all popular music of the last half-century.

Here are the first few bars of the piece:

It is I-V-vi-I6-IV-I-IV-V, repeated endlessly, until someone in the audience starts yelling "Please, for the love of Dog, make it stop!" Notice that the string parts are also boring, and (because this is a canon) repetitive.

When I say it has infected music in the last 50 years, I mean it's like a staph infection that can shut down an entire hospital. Here, to make the point better than I can, is Rob Paravonian:

O is for Ornaments

Blogging A to ZThis morning's Blogging A-to-Z challenge entry will take a quick turn and possibly trill your heart with a brief overview of ornaments.

You got a glimpse of two of the most common Baroque ornaments on Saturday as the Bach snippet I posted contained a grace note and a mordent:

The grace note tells the performer to add the note within the duration of the main note. For example, the grace note in the first measure would be played out as shown in the second measure:

A mordent tells the performer to do a little flip up from the written note (or up if it's got a line through it). This example shows a mordent, then its written-out equivalent, followed by a rising mordent and its equivalent:

The turn comes up frequently as well, and does exactly what it says on the tin:

Let's not forget the trill:

If only there were a single piece of music that put all of them together brilliantly...like maybe Bach's Sinfonia #5 in Eb major, BWV 791? Why, yes:

More than €700m pledged to rebuild Notre-Dame

Yesterday's devastating fire in the Cathédral de Notre-Dame de Paris fortunately left the walls and bell towers intact. But the destruction of the fire and roof could take 10-15 years to fix, according to Le Monde. So far, corporations and other European governments have pledged over €700m ($790m, £605m) towards rebuilding it:

  • La famille Arnault a la première annoncé un "don" de 200 millions d'euros par le groupe de luxe LVMH et a proposé que l'entreprise mette à disposition ses "équipes créatives, architecturales, financières" pour aider au travail de reconstruction et de collecte de fonds ;
  • La famille Bettencourt a annoncé deux dons de 100 millions d'euros, l'un via L'Oréal et l'autre via sa fondation ;
  • La famille d'industriels Pinault, qui possède le groupe Kering, a annoncé débloquer 100 millions d'euros via sa société d'investissement Artemis ;
  • Le PDG du groupe Total, Patrick Pouyanné, a annoncé sur son compte Twitter, que le groupe, qui se présente comme le "premier mécène de la Fondation du patrimoine", allait faire un "don spécial" de 100 millions d'euros.

In the past few weeks, 9 churches in France have burned; however, the Paris Police have opened an accident investigation, suggesting they don't believe it's related. Also, firefighters appear to have saved not only the bell towers but also the grand organ:

The culture minister, Franck Riester, said religious relics saved from the cathedral, including the Crown of Thorns and Saint Louis’s tunic, were being securely held at the Hôtel de Ville, and works of art that sustained smoke damage were being taken to the Louvre where they would be dried out, restored and stored.

He said three stained-glass “rose” windows did not appear to be damaged but would be examined more closely when the cathedral was made safe. Photos from inside the monument suggest Notre Dame’s grand organ, built in the 1730s and boasting 8,000 pipes, was spared from the flames.

Sixteen copper statues that decorated the spire, representing the 12 apostles and four evangelists, had been removed for restoration only a few days before the fire. Relics at the top of the spire are believed lost as the spire was destroyed.

Still, the damage is appalling. I join with the people of France in hoping that they will be able to rebuild, even if it takes until the 2030s.

N is for Notation

Blogging A to ZToday's Blogging A-to-Z challenge post will, like yesterday's, take us back in time.

Almost every day I've shown samples of music using modern notation. Any contemporary musician should have no trouble reading them.

Almost a thousand years ago, in 1025, the monk Guido d'Arezzo decided to record music on paper in a way that would enable people to read it even if they'd never encountered it before. He used blocks on lines with stems indicating how the notes were connected, and it looked like this:

The innovation here is that the note heads convey absolute pitch, and the stems convey timing, just as they do today. Someone who has never seen this before could (if they understood the language) produce the music intended by the composer.

During the early 17th century, as instrumental music came to dominate the scene, musical notation became much more complex. By the 1620s and 1630s, scores looked almost the same as they do today.

Specialized music uses specialized notation schemes, however. And non-Western music, which may use entirely different tonalities, sometimes has entirely different ways of notation.

M is for Modes

Blogging A to ZToday's Blogging A-to-Z challenge entry goes back in time a little bit. Before there were keys, there were modes: the original scales used in Ancient Greece that still pertain today.

Our C-major scale roughly corresponds with the Ionian mode. (I say "roughly" because while the fifth, octave, and probably fourth notes would have sounded the same back then as they do now, the rest of them probably would have sounded slightly out of tune to modern ears. This is a topic for next week.)

If you start on D, you get the Dorian mode:

It's not quite D minor, because instead of a flat 6th and natural 7th as in a minor key, we have a natural 6th and flat 7th. You can hear Dorian mode in Deep Purple's "Smoke on the Water."

Next comes Phrygian mode, starting on E:

If you start on F, you get Lydian; G, Mixolydian; A, Aeolian (corresponding closely to natural minor); and B, Locrian.

I mentioned Deep Purple because everything old is new again. A lot of modern popular music has reached back to modes, mainly (I think) because they sound cool. Lydian mode has a tritone instead of a perfect 4th; Locrian just sounds...off.

In fact, while Ionian, Dorian, Phrygian, and Aeolian pop up a lot, there aren't many examples of the others. But they're out there.

Homework assignment: Find modal pop songs (LMGTFY). Then listen to them.

L is for Legato

Blogging A to ZI don't always have time to write Blogging A-to-Z challenge posts ahead of time. This week I've had almost no free time until just now.

Today I'm going to slide into the topic of  markings. Music involves more than just the notes on the page; it's an artistic expression. Composers use a whole palette of markings and (usually Italian) words to convey to performers how to express the music.

Take this snippet of Bach's Invention #1 in C:

First, I should point out that Bach famously almost never added expression markings. In this example, I added a few to convey how I think someone should perform the Invention.

Start with the Italian at measure 1. The word "allegretto" above the staff indicates the tempo. It's a diminutive form of the word "allegre," which means happy; so allegretto means kind of happy. In practice it means a pretty quick tempo but not overly quick. "Allegro" (happy!) would be a little faster. Tempo markings range from "larghissimo" (really big and slow) to "prestissimo" (really fast). Classical FM has a good roundup of tempo terms.

The little "mf" under the staff is more Italian, but this time an abbreviation indicating how loudly to play. It stands for "mezzo forte," or middling-strong. Typical dynamic markings range from "piano" (quiet) to "forte" (loud), which helps explain why the instrument everyone knows and loves is called a pianoforte (because it can play both quietly and loudly).

The lines connecting the first 8 notes and the notes in measures 3 and 4 indicate phrases that should be played legato, or connected. Legato's opposite is staccato, from the verb stacciare, meaning to sift.

Finally, the little squiggle over the B in measure two is called a mordent, indicating a rapid articulation down from the B to an A and back. The little C next to it is a grace note, indicating that actually the mordent should start on the C. (Listen to the midi file for clarification.)

There are thousands of markings in musical scores that assist performers. But dynamics, tempo markings, phrase lines, and ornaments (mainly in Baroque music) are the most common.

Jallianwalh Bagh, 100 years later

One hundred years ago this hour (Sunday 13 April 1919, 17:37 HMT), Brig. General Reginald Dyer order his men to fire on 10,000 unarmed Indian civilians within an enclosed space from which they had no escape:

On the afternoon of April 13, a crowd of at least 10,000 men, women, and children gathered in an open space known as the Jallianwalla Bagh, which was nearly completely enclosed by walls and had only one exit. It is not clear how many people there were protesters who were defying the ban on public meetings and how many had come to the city from the surrounding region to celebrate Baisakhi, a spring festival. Dyer and his soldiers arrived and sealed off the exit. Without warning, the troops opened fire on the crowd, reportedly shooting hundreds of rounds until they ran out of ammunition. It is not certain how many died in the bloodbath, but, according to one official report, an estimated 379 people were killed, and about 1,200 more were wounded. After they ceased firing, the troops immediately withdrew from the place, leaving behind the dead and wounded.

The shooting was followed by the proclamation of martial law in the Punjab that included public floggings and other humiliations. Indian outrage grew as news of the shooting and subsequent British actions spread throughout the subcontinent. The Bengali poet and Nobel laureate Rabindranath Tagore renounced the knighthood that he had received in 1915. Gandhi was initially hesitant to act, but he soon began organizing his first large-scale and sustained nonviolent protest (satyagraha) campaign, the noncooperation movement (1920–22), which thrust him to prominence in the Indian nationalist struggle.

The government of India ordered an investigation of the incident (the Hunter Commission), which in 1920 censured Dyer for his actions and ordered him to resign from the military. Reaction in Britain to the massacre was mixed, however. Many condemned Dyer’s actions—including Sir Winston Churchill, then secretary of war, in a speech to the House of Commons in 1920—but the House of Lords praised Dyer and gave him a sword inscribed with the motto “Saviour of the Punjab.” In addition, a large fund was raised by Dyer’s sympathizers and presented to him. The Jallianwalla Bagh site in Amritsar is now a national monument.

At an inquest after the event, Dyer had no remorse for his actions, and volunteered that had he managed to get the tank he had with him into the square, he would have used its cannon to further attack the civilians.

Both the massacre and the inquest were dramatized in the 1982 film Gandhi, which won Best Picture that year.

The Commons debate about the incident that took place on 8 July 1920 offers some context for the current Commons debate about Brexit. Indeed, the massacre and its aftermath should put paid any notions that the United Kingdom has always stood up for human rights, even in the last century, or has a particular sensitivity to its own citizens who come from outside the British Isles.

In the debate, the Secretary of State for War, a Mr. Churchill of some repute, gave the view I should hope all Britons would have had:

If the road had not been so narrow, the machine guns and the armoured cars would have joined in. Finally, when the ammunition had reached the point that only enough remained to allow for the safe return of the troops, and after 379 persons, which is about the number gathered together in this Chamber to-day, had been killed, and when most certainly 1,200 or more had been wounded, the troops, at whom not even a stone had been thrown, swung round and marched away. I deeply regret to find myself in a difference of opinion from many of those with whom, on the general drift of the world's affairs at the present time, I feel myself in the strongest sympathy; but I do not think it is in the interests of the British Empire or of the British Army, for us to take a load of that sort for all time upon our backs. We have to make it absolutely clear, some way or other, that this is not the British way of doing business.

Reading through the debate, however, it almost seems as if Churchill were in the minority. He wasn't, but only because the less-racist MPs in the House at that moment largely kept quiet.

The thinking behind Dyer's mass murder led directly to the thinking behind Lord Louis Mountbatten's precipitous and disastrous withdrawal from India in 1947, whose principal consequence has been 72 years of nonstop hostilities between India and Pakistan. And it leads directly to Brexit.