Click here to go see the bonus panel!
I originally had a hamster but that seemed mean.
I originally had a hamster but that seemed mean.
Look the fact that there's a misspelling in the votey panel just makes the point more strong.
If you look at some of my recent projects, you’ll notice I enjoy building lean websites with pure HTML+CSS.
But building UIs in HTML+CSS can be untenable. When making complex frontend experiences, I reach for Elm. Here’s why:
Modern web development seems hellish for some organizations.
For the past 10 years, I’ve watched teams struggle against NPM packages. I’ve been part of multiple migrations between moment.js, Luxon, and day.js. React applications drown in state management libraries that perpetually break something important. And don’t get me started on React hooks.
Every package on NPM seems (1) inundated with breaking changes or (2) completely abandoned. Codebase upgrades are terrifying after your team finds the perfect
package.lock that works for everybody.
The poor quality of NPM also leaks into the devops-side of frontend. Every Webpack/Babel/Vite/EsBuild/Parcel ecosystem feels like a delicate mess on stilts. I’ve witness countless engineering hours wasted on JS source maps, polyfills, and build errors.
Outside of React, the situation seems equally bleak. Frontend frameworks in JS, Python, Elixir, etc. look riddled with similar quality problems. There’s a lot of software out there, so please email me if there are any ecosystems I should reconsider.
Elm’s packages are generally well-documented, focused, appropriately named, and bug-free. But don’t take my word for it – pick any of these packages at random and see the quality for yourself:
This piece from Rakuten matches my own experiences with Elm:
- The performances of Elm applications are among the fastest. Internally Elm uses the concept of a virtual DOM, similar to React. The speed of the Elm virtual DOM is comparable to Svelte, which uses a different mechanism to update the DOM.
- The Elm compiler produces smaller assets compared to other frameworks. Among the various optimizations to achieve this result, there is the dead code elimination with granularity to the single function that works across the entire ecosystem. If you import a large package and use only one of the functions contained, the compiler will ensure that only that function ends up in your generated code.
- The Elm compiler per se is also fast. Our bigger codebase contains ~66,500 lines of Elm code, and it compiles incrementally in 0.3 seconds and from scratch in 2.5 seconds.
I want to add that Elm’s virtual DOM will obviously be strictly worse than an equivalent optimized vanilla JS program. But for modern browsers, Elm seems to offer the best balance of developer ergonomics and runtime speed.
Writing Elm in Neovim is wonderful. Everything feels snappy regardless of file sizes: types hints, tests, errors, autoformatting, and recompilation.
Thanks to the speedy and simple Elm compiler, I can keep my tooling extremely simple during development. Here’s my entire live webdev setup:
http-server dist \ & watch -p "**/*.elm" -c "elm make src/Main.elm --debug --output=dist/elm.js"
Debugging is straightforward. When my code behaves strangely, I use Elm’s time-travelling debugger to inspect the model at each state-change. From there, pure functions make errors obvious.
Most languages are too powerful for my palate.
Don’t get me wrong – I love Rust and many other languages! But sometimes they’re just too much for me.
When writing Rust or JS or Haskell or Python or Lisp, I’m overwhelmed by opportunity. Should I make this generic? Should I use classes or structs? Immutable or mutable? Macros? Functional or imperative array manipulation?
I try to please compilers and coworkers and customers, but all are disappointed. Give me a woodshop and I’m lost, but give me a simple chisel and I intuitively know what to do. There’s a certain freedom in restricted toolsets.
Languages like Go and Elm spurn extravagance. They resist overcomplication. They force me to solve real problems instead of fighting compiler errors and stylistic differences.
Furthermore, consistent code makes portable mental-models. Go and Elm codebases tend to be extremely readable.
I like shiny new features and predictability.
Unfortunately, there are tradeoffs. For compiler teams, bug-hunting steals time from feature-development.
I can live with landmines if they don’t change positions. Releasing patches reduces predictability. If a bug has a known workaround, I want the devs to focus all efforts on their next release instead of old errors.
But I’m also a patient person who loves ambitious visions. I would rather wait years for tightly-integrated featuresets than months for haphazard improvements.
Elm 0.19.1 has been the latest version since 2019. I’ve heard rumors of some new stuff coming in 2023, which is super exciting, but 0.19.1 remains wonderfully stable. I’ll be happy with future releases as long as they’re predictable, holistically designed, and relatively infrequent.
When it comes to building software, my first guesses are generally wrong.
In most languages, changing things is a brutal process. I tend to live with my mistakes because refactoring is too tiresome.
With Elm, I experiment and change everything with little resistance. As long as I watch wildcard matches in my
case statements, the compiler quickly guides me back to a working program from any change.
Theoretically, all static type systems should be able to do this, but they just don’t. I don’t know why, but my major changes in Haskell/Rust/Go always end up with unintended results. Elm’s error messages are really in a class of their own, and it has nothing to do with pretty formatting.
Elm’s mental models made me a better programmer.
If you haven’t already, take some time to browse Elm’s 1st-party libraries: core, html, json, browser, url, http, bytes, file, parser, random, regex, and time.
All the main libraries contain gems. They’re easy yet strict; simple yet powerful.
For example, consider the parser library. Parser pipelines are delightful to use, and teach you to think in terms of non-backtracking flows. When you’re ready, you can upgrade to
Parser.Advanced for extra contextual powers, but the complexity doesn’t get in the way when you don’t need it.
Even if you never seriously use Elm, study its libraries and build some toys with them. There’s plenty of wisdom to glean from its careful design.
Galileo’s book “proved popular amongst literati who were not astronomers [and] who enjoyed his very obvious polemic writing skills; but contrary to popular opinion it didn’t play a significant role in the contemporary scientific discussion.” (Christie, Galileo’s great bluff 2010) One could even make an argument that Galileo managed to delay acceptance, although TOF does not do so.
What it came down to is that the issue would not be settled by astronomical mathematics, but by a new physics.
Other objections made more sense, in that we can understand why people would have raised them.
|Those headwinds sure are strong!|
|As the earth revolves, the relative positions of the stars|
|As the earth turns a ball at the top of the |
tower has a greater eastward velocity
and will fall east of the plumb line
The problem of history, John Lukacs used to tell us is that we "must consider the battle of Salamis as if the Persians might still win." Meaning that you want to understand what happens in 1633, you can't consider things learned in 1687 or 1803. The mid-17th century had no clear concept of inertia, of gravitation, of forces, etc.; and while ontologically there may still be no clear concept of these (and therefore we are blind to the foolishness over which our descendents will one day mock us) the same is certainly true of 380 years ago. After all, the classical, medieval, and Renaissance folks laughed at the ancient belief that the world was flat. (The Chinese at this point still did believe.) But because Aristotle had demonstrated that the world was a sphere, the Scriptural passages describing the sky as a tent pitched over a flat earth were no longer understood as literal.
What was needed now was a new theory of motion.
1543 Benedetto Varchi publishes a book listing experimental evidence from Francesco Beato and Luca Ghini contradicting Aristotle's view of free fall.Aristotelian physics was tottering well before Galileo took up a sledge hammer.
1544 Domingo de Soto, a Dominican philosopher, publishes a book with the first correct statement of the law of free fall.
1570 In Opus novum de proportionibus, Girolamo Cardano, demonstrates that two balls of different sizes will fall from a great height at the same time.
1574 Girolamo Borro, one of Galileo's teachers, describes experiments repeated several times where a wooden and lead ball were thrown out of a high window and the wooden ball reached the ground first.
1575 Guiseppe Moletti, Galileo's predecessor at University of Padua, drops balls of the same volume but different materials and of the same material but different weights and discovers they hit ground at same time.
1585 Flemish Scientist Simon Stevin conducts an experiment dropping two balls, one weighing 10 times the other from 30 feet and discovers that they reach ground at same time.
1632. Bonaventura Cavalieri publishes Specchio Ustoria (On Burning Mirrors). Otherwise a book about mirrors, it's the first book to describe the parabolic nature of projectile motion. Both Thomas Harriot and Galileo Galilei had described this motion before Cavalieri, but in private notes never published. Well, Harriot never published nothing, but Galileo was not one for staying mum. Projectile motion does not sound very heliocentric, but folks are creeping up on a calculus of motion. For all practical purposes, up to now mathematics basically consists of arithmetic and geometry, with geometry having pride of place. No wonder Aristotle thought mathematics was unsuited to physics, which involved changeable matter.
1636. In Harmonie Universelle, Fr. Marin Mersenne diagrams the construction of reflecting telescopes in configurations similar to the Gregorian and Cassegrain telescopes. Parabolic mirrors are notoriously difficult to grind. Can we say "Hubble Space Telescope"?
1637. Galileo Galilei publishes Dialogues Concerning Two New Sciences. The two sciences are strength of materials, in which he describes the square-cube law, and the physics of motion, in which he confirms De Soto's law and Bradwardine's medieval observations. He even uses Nicole d'Oresme's graphical geometric proof of the Mean Speed Theorem. Without attribution, of course. (The Wikipedia article contains several infelicities.)
Technically, Galileo had been forbidden to publish any new works; but he started writing this while under house arrest in the palace of Archbishop Piccolomini and had arranged for Elsevier to print it in the Netherlands. The same three characters carry on the dialogue here as in his previous work, but curiously, Simplicio is no longer presented as a stubborn and foolish dork. (TOF wonders if this was a sort of peace offering to He Who Must Not Be Compared to a Simpleton.) No one came after Galileo for publishing a new work, so this may simply be an example of the old Renaissance game of official severity coupled with practical leniency.
|Jerry Horrocks spots Venus; forgets to tell|
(*) 24 November under the Julian calendar then in use in England.
|View straight down from the Torre di Asinelli|
8 Jan 1642. Galileo goes off to that great observatory in the sky. Urban's animus pursues him, and will not permit the Archbishop of Florence to bury him in the cathedral as proposed. Geez, can't he let bygonesbe bygones?
29 July 1644. Urban VIII finishes his bucket list and kicks off. Everything is much quieter now.
|I got an idea! Let's replace wars of dynasties with|
wars of nationalism! Then things will be peaceful!
All those weeks, all those days, all those last futile hours, they had been fighting at Prague, and went on fighting for nine days longer before they, too, had news of the peace. Then they, too, fired their salvo to the skies, sang their Te Deum and rang their church bells because the war was over.
Almost all -- one excepts the King of Sweden -- were actuated rather by fear than by lust of conquest or passion of faith. They wanted peace and they fought for thirty years to be sure of it. They did not learn then, and have not since, that war breeds only war.
-- C.V. Wedgwood, The Thirty Years War
|Tychonic and Copernican systems argue|
on the frontispiece to the New Almagest
while Ptolemy lies prostrate crying
"I will rise again!"
“Both sides present good arguments as point and counter-point. Religious arguments play a minor role in the debate; careful, reproducible experiments a major role. To Riccioli, the anti-Copernican arguments carry the greater weight, on the basis of a few key arguments against which the Copernicans have no good response. … Given the available scientific knowledge in 1651, a geo-heliocentric hypothesis clearly had real strength, but Riccioli presents it as merely the “least absurd” available model…”
(Graney, 126 Arguments Concerning the Motion of the Earth 2011.)
|You are here. Riccioli's lunar map.|
Actually, you are not here; but you once were
Unlike Galileo's Dialogue, which was a polemic written for the public, and like Scheiner's Rosa Ursina, Riccioli's New Almagest was a dense, scientific and mathematical tome written for scientists. It remained a standard text into the 18th century. In it, Riccioli also reports the value of g for gravitational acceleration, gives the geography of the moon*, shows that bodies do not fall at the same rate,** et al. He gave detailed descriptions of the experiments so that anyone who wished could duplicate them.
(*) geography of the moon. The New Almagest has the first detailed lunar map, with the sea and crater names that we still use. Riccioli named craters for Copernicus and his followers and for Tycho and Ptolemy and their followers, acknowledging in this offhand manner the collegial and cumulative nature of science.
(**) do not fall at the same rate. If two heavy objects of differing weight are dropped simultaneously from the same height, the heavier one descends more quickly provided it is of equal or greater density. If both bodies are of equal weight, the denser one drops more quickly. Air resistance does matter.
1659. Huygens studies Saturn some more and discovered the true shape of the planet’s rings. Galileo and others with less powerful telescopes had thought the rings were love handles
The 1660s. Nearly 120 years after
heliocentrism had been formally proposed, Kepler’s elliptical model has
won the contest. The astronomical
community has accepted the ellipses with nary a murmur and the Third Law
with positive glee. However, the Second Law (the Equal Area law) is
rejected as ugly and Kepler’s proof is deficient. But the Rudolphine Tables are just plain easier to use. In the
Platonic Renaissance, that carries weight.
There is a long-standing tension between Aristotelians and Platonists over the nature of mathematical physics. The issue is whether something is true simply because the mathematical model is elegant and "works." To the Platonists, the mathematics can be more real than the physics. We see that today in the reliance on complex computer models, in which the model output is sometimes, amazingly enough, called "data." So the Keplerian model was accepted because it was so damn elegant it had to be true and if we keep the faith, sooner or later we'll find the data. But as Einstein once said to Heisenberg, "Theory determines what can be observed."
|A chronology of Chronos.|
1672. Nicolas Mercator develops a correct mathematical derivation of Kepler's Second Law. (Christie, Galileo’s great bluff 2010)
1687. Newton presents his theory of Universal Gravitation. It’s hard for the Late Modern to grasp what a stunning achievement this is. Suddenly, everything makes sense! He does not use calculus to do this. The Principia is carefully structured in correct Aristotelian form, with axioms and deductive logic, to ensure that is true scientia. There is one elegant solution to all the planets, to all the motions! Kepler's laws can be deduced from the principle. Finally, a simple, elegant reason why Kepler’s model ought to be true!
Just one problem; or rather two:
• There is still no @#^$% parallax.
• There is still no *#^%$ Coriolis effect.
Dang! But we can’t let inconvenient facts get in the way of a really kool theory.
The lack of Coriolis is more troubling. Even though a rotating Earth had been more easily accepted than a revolving Earth, the rotation is still undetected. Newton had described an experiment – dropping a musket ball from a tower – and Hooke had carried it out. But he reported finding no deflection.
Then comes something really unexpected.
|If the earth is moving, the telescope will move during the|
time light from a star travels down the tube. Thus you have
to tilt the tube a little bit.
A similar phenomenon appears when you drive through a snow storm. Even though the snow is falling straight down, it appears to originate at some point forward of your car. This is because as snow falls, your car is moving toward the snow. Similarly, as the starlight falls down the telescope tube, the telescope tube is moving with the earth and the light ray will hit the side of the tube instead of the eyepiece unless the telescope is tilted slightly.
The effect is small, and detectable only with special instruments, but it counts as a proof that the Earth is moving.
Huzzah! Sorta. It may not convince non-specialists, however.
1734. Bradley’s paper is translated into Italian
1744. A "corrected" copy of Galileo's Dialogue is printed in Italy. Not a word is changed, but the term "if" is inserted in various marginal topic headers. This would have been all that was necessary had the original recommendation of the extensor been followed in the Galileo trial.
1758. Copernicanism is removed from the Index. Stellar aberration seems to have been sufficient.
Jun-Sep, 1791. In a series of experiments, Giovanni Guglielmini, a professor of mathematics at the University of Bologna, drops weights from the Torre dei Asinelli in Bologna -- the same tower used earlier by Riccioli and Grimaldi -- and finds an eastward (and southward) deflection. Concerned with windage, he repeats the experiment down the center of the spiral staircase at the Instituto della Scienze and finds a 4 mm Coriolis deflection over a 29 m drop; thus providing direct empirical evidence of the rotation of the Earth. These experiments are later confirmed in Germany (using a mine shaft) and in the United States.
1806. Giuseppi Calandrelli, director of the observatory at the Roman College publishes "Ozzervatione e riflessione sulla paralasse annua dall’alfa della Lira," reporting parallax in α-Lyrae. This provides a simple direct observation of the revolution of the Earth.
|Zeus: I've got a splitting headache!|
Courtier: Uh... Got wimmin on yer mind?
1820. Giuseppe Settele, astronomy professor at the Sapienza (now the University of Rome) incorporates these findings into the second volume of his Elementa di Ottica e di Astronomia, and tells his colleague, Benedetto Olivieri (who is then Commissary of the Holy Office) that this provides the demonstration requested by Bellarmino back in 1616. Olivieri agrees, and convinces the Office and Pope Pius VII.
12 Aug 1820. The injunction is lifted in light of the astronomical discoveries made since Galileo's time:
Decree of Approval for the work "Elements of Astronomy" by Giuseppe Settele, in support of the heliocentric systemThe Assessor of the Holy Office has referred the request of Giuseppe Settele, Professor of Optics and Astronomy at La Sapienza University, regarding permission to publish his work Elements of Astronomy in which he espouses the common opinion of the astronomers of our time regarding the earth’s daily and yearly motions, to His Holiness through Divine Providence, Pope Pius VII. Previously, His Holiness had referred this request to the Supreme Sacred Congregation and concurrently to the consideration of the Most Eminent and Most Reverend General Cardinal Inquisitor. His Holiness has decreed that no obstacles exist for those who sustain Copernicus’ affirmation regarding the earth’s movement in the manner in which it is affirmed today, even by Catholic authors. He has, moreover, suggested the insertion of several notations into this work, aimed at demonstrating that the above mentioned affirmation [of Copernicus], as it is has come to be understood, does not present any difficulties; difficulties that existed in times past, prior to the subsequent astronomical observations that have now occurred. [Pope Pius VII] has also recommended that the implementation [of these decisions] be given to the Cardinal Secretary of the Supreme Sacred Congregation and Master of the Sacred Apostolic Palace. He is now appointed the task of bringing to an end any concerns and criticisms regarding the printing of this book, and, at the same time, ensuring that in the future, regarding the publication of such works, permission is sought from the Cardinal Vicar whose signature will not be given without the authorization of the Superior of his Order.
Original Latin source: W. Brandmüller and E.J. Greipl, eds., Copernicus, Galileo, and the Church: The End of the Controversy (1820), Acts of the Holy Office (Florence: Leo Olschki, 1992), pp. 300-301.
That’s a long time to hold out for empirical confirmation.
HISTORY MUST BE CURVED, for there is a horizon in the affairs of mankind. Beyond this horizon, events pass out of historical consciousness and into myth. Accounts are shortened, complexities sloughed off, analogous figures fused, traditions “abraded into anecdotes.” Real people become culture heroes: archetypical beings performing iconic deeds. (Vansina 1985)
In oral societies this horizon lies typically at eighty years; but historical consciousness endures longer in literate societies, and the horizon may fall as far back as three centuries. Arthur, a late 5th cent. war leader, had become by the time of Charlemagne the subject of an elaborate story cycle. Three centuries later, troubadours had done the same to Charlemagne himself. History had slipped over the horizon and become the stuff of legend.
In AD 778, a Basque war party ambushed the Carolingian rear guard (Annales regni francorum). Forty years later, Einhard, a minister of Charlemagne, mentioned “Roland, prefect of the Breton Marches” among those killed (“Hruodlandus Brittannici limitis praefectus,” Vita karoli magni). But by 1098, Roland had become a “paladin” and the central character, the Basques had become Saracens, and a magic horn and tale of treachery had been added (La chanson de Roland). Compare the parallel fate of a Hopi narrative regarding a Navajo ambush (Vansina, pp. 19-20).This suggests that 17th century history has for the bulk of the population already become myth. Jamestown is reduced to “Pocahontas,” and Massachusetts boils down to “the First Thanksgiving.” And the story of how heliocentrism replaced geocentrism has become a Genesis Myth, in which a culture-hero performs iconic deeds that affirm the rightness of Our Modern World-view.
The reasons for the stationary Earth were rooted in empirical experience and successful modeling. The dual motion of the Earth is not sensibly evident and was difficult to establish on empirical grounds. Heliocentrism triumphed first of all because Neoplatonic number mysticism had become au courant during the Renaissance, and Platonists equated mathematical elegance with physical evidence.
Resistance to heliocentrism was rooted in the science of the day and religion entered the picture mainly because the Church Fathers had interpreted Scripture in the light of that science. They weren’t about to change until there was solid evidence that the science (and hence the interpretation) was wrong; not in the middle of no honkin' Reformation they weren’t. Thomas Huxley said after investigating the affair that “the Church had the better case.” But Pierre Duhem put it differently. The Copernicans were “right for the wrong reasons.” The Ptolemaics were “wrong for the right reasons.”
Science doesn’t follow a mythic positivist ideal but the plural scientific methods described by Feyerabend: a mixture of empiricism, flights of fancy, intuition, aesthetics, doggedness, and jealousy. Scientific theories are underdetermined. Any finite set of facts can support multiple theories, and for a long time the available facts were equally explained by geostationary or geomobile models.
In the Legend, the conflict
was between Science and Religion. But in the History, the conflict was
between two groups of scientists, with churchmen lined up on all sides.
Copernicanism was supported by humanist literati and opposed by
Aristotelian physicists; so it was a mixed bag all around.
Science does not take place in a bubble. International and domestic politics and individual personalities roil the pot as well. The mystery is not why Galileo failed to triumph – he didn’t have good evidence, made enemies of his friends, and stepped into a political minefield. The real mystery is why Kepler, who actually had the correct solution, constantly flew under the radar. A deviant Lutheran working in a Catholic monarchy, he pushed Copernicanism as strongly as Galileo; but no one hassled him over it. Too bad he couldn’t write his way out of a paper bag.
The end. Thank goodness. We now return you to your regularly scheduled blog.
Christie, Thony. (2013) The speed of light, a spin off from longitude research.
Christie, Thony. (2011) A small spot in front of the sun, a small step down the road to heliocentricity. Christie, Thony. But it doesn’t move! June 22, 2011.
Christie, Thony. Extracting the Stopper. June 2, 2010.
Christie, Thony. Galileo’s great bluff. Nov. 12, 2010.
Christie, Thony (2011) Spotting the Spots
Christie, Thony (2011) Questions on spots
Christie, Thony (2013) He didn’t publish and so he perished (historically).
Christie, Thony (2013) Apelles hiding behind the painting
Christie, Thony (2009) Astronomy and Astrology.
Christie, Thony (2013) Refusing to look
_I originally wrote the following for my Chainline Newsletter, but I continue to get tweets about this idea, so I'm re-publishing the article here on my blog. This version has been lightly edited._
I've been thinking about the consequences of the "wrong abstraction." My RailsConf 2014 "all the little things" talk included a section where I asserted:
duplication is far cheaper than the wrong abstraction
And in the summary, I went on to advise:
prefer duplication over the wrong abstraction
This small section of a much bigger talk invoked a surprisingly strong reaction. A few folks suggested that I had lost my mind, but many more expressed sentiments along the lines of:
This, a million times this! "@BonzoESC: "Duplication is far cheaper than the wrong abstraction" @sandimetz @rbonales pic.twitter.com/3qMI0waqWb"— 41 shades of blue (@pims) March 7, 2014
The strength of the reaction made me realize just how widespread and intractable the "wrong abstraction" problem is. I started asking questions and came to see the following pattern:
Programmer A sees duplication.
Programmer A extracts duplication and gives it a name.
This creates a new abstraction. It could be a new method, or perhaps even a new class.
Programmer A replaces the duplication with the new abstraction.
Ah, the code is perfect. Programmer A trots happily away.
A new requirement appears for which the current abstraction is almost perfect.
Programmer B gets tasked to implement this requirement.
Programmer B feels honor-bound to retain the existing abstraction, but since isn't exactly the same for every case, they alter the code to take a parameter, and then add logic to conditionally do the right thing based on the value of that parameter.
What was once a universal abstraction now behaves differently for different cases.
Another new requirement arrives.
Another additional parameter.
Another new conditional.
Loop until code becomes incomprehensible.
You appear in the story about here, and your life takes a dramatic turn for the worse.
Existing code exerts a powerful influence. Its very presence argues that it is both correct and necessary. We know that code represents effort expended, and we are very motivated to preserve the value of this effort. And, unfortunately, the sad truth is that the more complicated and incomprehensible the code, i.e. the deeper the investment in creating it, the more we feel pressure to retain it (the "sunk cost fallacy"). It's as if our unconscious tell us "Goodness, that's so confusing, it must have taken ages to get right. Surely it's really, really important. It would be a sin to let all that effort go to waste."
When you appear in this story in step 8 above, this pressure may compel you to proceed forward, that is, to implement the new requirement by changing the existing code. Attempting to do so, however, is brutal. The code no longer represents a single, common abstraction, but has instead become a condition-laden procedure which interleaves a number of vaguely associated ideas. It is hard to understand and easy to break.
If you find yourself in this situation, resist being driven by sunk costs. When dealing with the wrong abstraction, the fastest way forward is back. Do the following:
This removes both the abstraction and the conditionals, and reduces each caller to only the code it needs. When you rewind decisions in this way, it's common to find that although each caller ostensibly invoked a shared abstraction, the code they were running was fairly unique. Once you completely remove the old abstraction you can start anew, re-isolating duplication and re-extracting abstractions.
I've seen problems where folks were trying valiantly to move forward with the wrong abstraction, but having very little success. Adding new features was incredibly hard, and each success further complicated the code, which made adding the next feature even harder. When they altered their point of view from "I must preserve our investment in this code" to "This code made sense for a while, but perhaps we've learned all we can from it," and gave themselves permission to re-think their abstractions in light of current requirements, everything got easier. Once they inlined the code, the path forward became obvious, and adding new features become faster and easier.
The moral of this story? Don't get trapped by the sunk cost fallacy. If you find yourself passing parameters and adding conditional paths through shared code, the abstraction is incorrect. It may have been right to begin with, but that day has passed. Once an abstraction is proved wrong the best strategy is to re-introduce duplication and let it show you what's right. Although it occasionally makes sense to accumulate a few conditionals to gain insight into what's going on, you'll suffer less pain if you abandon the wrong abstraction sooner rather than later.
When the abstraction is wrong, the fastest way forward is back. This is not retreat, it's advance in a better direction. Do it. You'll improve your own life, and the lives of all who follow.
The 2nd Edition of 99 Bottles of OOP has been released!
The 2nd Edition contains 3 new chapters and is about 50% longer than the 1st. Also, because 99 Bottles of OOP is about object-oriented design in general rather than any specific language, this time around we created separate books that are technically identical, but use different programming languages for the examples.
The Baader-Meinhof effect is the common name for what scientists call frequency illusion. Suppose you are watching Star Trek’s Christopher Pike explain how he makes pasta mama, and you’ve never heard of it before. Immediately after that, you’ll hear about pasta mama repeatedly. You’ll see it on menus. Someone at work will talk about having it at Hugo’s. Here’s the thing. Pasta mama was there all along (and, by the way, delicious). You just started noticing it. We sometimes wonder if that’s the deal with Morse code. Once you know it, it seems to show up everywhere.
One of the strangest places we’ve ever heard of Morse code appearing is the infamous case of Tojo’s teeth. If you don’t remember, General Hideki Tojo was one of the main “bad guys” in the Pacific part of World War II. In particular, he is thought to have approved the attack on Pearl Harbor, which started the American involvement in the war globally. Turns out, Tojo would be inextricably tied to Morse code, but he probably didn’t realize it.
At the end of the war, the US military had a list of people they wanted to try, and Tojo was near the top of their list of 40 top-level officials. As prime minister of Japan, he had ordered the attack that brought the US into the war. He remained prime minister until 1944, when he resigned, but the US had painted him as the face of the Japanese enemy. Often shown in caricature along with Hitler and Mussolini, Tojo was the face of the Japanese war machine to most Americans.
When Americans tried to arrest him, though, he shot himself. However, his suicide attempt failed. Reportedly, he apologized to the American medics who resuscitated him for failing to kill himself. Held in Sugamo Prison awaiting a trial, he requested a dentist to make him a new set of dentures so he could speak clearly during the trial.
Jack Mallory, a young Navy dentist on loan to the Army, drew the duty of making Tojo’s new dentures. The 22-year-old had been at the 361st Station Hospital for about a month. His roommate, George Foster, had examined Tojo and brought Jack in to make an upper denture. Tojo had declined a full set because he did not expect to survive his trial.
The standard procedure was to engrave the patient’s name, rank, and serial number of any dentures made by the hospital. However, Mallory’s colleague suggested that it would be fitting to engrave Tojo’s with the common phrase “REMEMBER PEARL HARBOR.” At 22, you are often susceptible to bad ideas, but Jack knew that could get him in trouble. But he decided to do it any way but to make it less conspicuous, he used — you guessed it — Morse code.
At first, only Jack and his roommate knew the secret. However, two recruits had to be let into the secret because they were examining the dentures and were sure to notice. One of them wrote home about the incident, and, as you might expect, the military command was not amused. Mallory’s commanding officer ordered him to remove the markings, which he did, and everyone denied it ever happened. As far as anyone knows, Tojo never knew that his dentures had carried a secret message.
General Tojo’s trial didn’t go well for him, and he was executed late in 1948. Jack had been back in the states for over a year, reuniting with his wife and starting a dental practice. The story would only surface again years later, in 1995.
Of course, soldiers have a long history of using Morse code to communicate secretly, like Admiral Denton blinking “torture” during his appearance in a propaganda film made by his captors during the Vietnam war. The Colombian army encoded secret messages to captive soldiers in a pop song.
Even civilian songs get into the act. There are a ton of songs that have some Morse code embedded in them, ranging from London Calling by the Clash to YYZ by Rush and many others. The Capitol Records building sends out Morse code, although it seems most people don’t notice. Not many people realize that the beat of the theme music to Mission Impossible actually spells out MI, either.
Then there’s the Curiosity Mars rover. The wheels on that plucky vehicle leave the letters JPL in Morse code behind in the sand. However, our pet peeve these days is the “morse code bracelets” that use beads to spell out messages like “loved.” Why is that a pet peeve? Becuase there is no spacing between elements, so, for example, loved is “.-..—…-.-..” Of course, that could also be “aumski” or a bunch of other nonsense words.
As you can see, once you know Morse code, you can find it just about everywhere. You might even find it in your dreams. Too lazy to learn the code? Take the Blue Pill.