tag:blogger.com,1999:blog-1781749203477657712024-03-14T08:57:23.584-07:00One Div ZeroAn exploration of software development.James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.comBlogger53125tag:blogger.com,1999:blog-178174920347765771.post-62150600538132320362016-03-02T08:33:00.000-08:002016-03-02T08:46:47.983-08:00The Yak Shaver's Creed
This is my yak. There are many like it,
but this one is mine.
My yak is my best friend. It is my life.
I must shave it as I shaved the one
before.
Without me, my yak is hairy. Without my
yak, I am productive. I must shave my
yak cleaner than the previous yak.
I must shave him before his hair grows
back. I will...
My yak and I know that what counts in
code is not the lines we write, the
James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com0tag:blogger.com,1999:blog-178174920347765771.post-55351335356175225282013-03-26T12:53:00.000-07:002013-03-26T13:05:40.425-07:00King Null the StubbornIt's mostly pretty easy to eliminate null in a language: just replace it with Maybe/Option types. Unfortunately it's only mostly easy to get rid of null that way in class based OO languages. There's one corner where null is surprisingly stubborn without limiting OO languages: initialization. I'll demonstrate using Java but I'll show that the same or similar problem can manifest in most class James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com15tag:blogger.com,1999:blog-178174920347765771.post-46193878141527148022013-02-15T10:41:00.001-08:002013-02-15T10:43:25.475-08:00The Best-Laid Schemes O' Mice An' Constructors Gang Aft AgleyLast time I talked about how the Scala compiler currently translates try/catch expressions used as arguments to method or constructor call into separate method definitions which in turn may require boxing of mutable variables. That's because an exception in the try would blow away the local stack of stuff needed to make the original method/constructor call. So I proposed a plan for the Scala James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com9tag:blogger.com,1999:blog-178174920347765771.post-29129172428002852412013-01-25T10:08:00.002-08:002013-01-25T10:26:43.817-08:00Scala Try/Catch Lifting ProposalTL;DRScalac currently deals with try/catch on a potentially non empty stack by lifting to a def. But that can lead to more boxing of vars captured in the lifted defs and a second pass to deal with try/catches that get put into the boxing constructor. I propose we use local vals to lift try/catch expressions instead of using defs. That will prevent the extra boxing and, perhaps later, allow us to James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com1tag:blogger.com,1999:blog-178174920347765771.post-64568818113515429732012-03-07T11:24:00.009-08:002012-03-07T12:20:48.036-08:00QR Flyer(click to embiggen)James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com5tag:blogger.com,1999:blog-178174920347765771.post-30655161483922067392012-02-15T15:29:00.000-08:002012-02-15T15:30:02.951-08:00Checked Exceptions Might Have Their Place, But It Isn't In JavaIn Java's more than 15 years no language has repeated Java's experiment with checked exceptions, other than some languages designed as Java extensions (e.g. MultiJava and GJ). Certainly no mainstream or even nearly mainstream languages have. Notable languages that don't bother with checked exceptions include C#, which started as very nearly a clone of Java, and Scala, which borrows many Java James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com11tag:blogger.com,1999:blog-178174920347765771.post-84350112684478667022012-02-15T09:29:00.001-08:002012-02-15T09:29:56.365-08:00Too Dense?With this post I want to ask a question: what does it mean for code to be "too dense?" This question has implications on everything from languages to APIs to coding style.I've seen debaters defending Java's verbosity precisely because it isn't "too dense." They say the sparsity of the code makes it easy to understand what's going on. Similarly it's common to bash programmers for playing "golf"James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com19tag:blogger.com,1999:blog-178174920347765771.post-62434570489156285512012-01-05T16:03:00.000-08:002012-01-06T13:01:24.023-08:00Type Errors as WarningsPaul Snively and I are having a bit of disagreement about the value of treating type errors as warnings during development. It's hard to make anything like a cohesive point on Twitter so I thought I'd write a quickie post on what I mean and why I think it's valuable.What I'm talking about is not revolutionary. Eclipse JDT does it and I'm sure others do as well. The idea in a nutshell is that James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com29tag:blogger.com,1999:blog-178174920347765771.post-13981859080643974312011-06-17T09:38:00.000-07:002011-06-17T11:40:14.672-07:00Sleep Sort! With Actors! For No Reason!The world's stupidest, racy sort algorithm ported to Scala actors for no good reason.import scala.actors._
import Actor._
def sleepSort(xs : List[Int]) : List[Int] = {
def sorter(aggregator : Actor, n : Int) = actor {
reactWithin(n * 1000) {
case TIMEOUT => {
aggregator ! n
exit
}
}
}
xs map (sorter(self, _)) foreach (_.start)
val James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com2tag:blogger.com,1999:blog-178174920347765771.post-17197195436370529592011-05-09T14:32:00.000-07:002011-05-11T08:02:54.812-07:00Why Eager Languages Don't Have Products and Lazy Languages Don't Have SumsIn The Point of Laziness, Bob Harper mentioned a core duality between lazy and eager languages[1]. Eager languages have sum types but not product types and lazy languages have product types but no sum types. I've seen a few questions about what he means. I thought I'd try to explain. It all has to do with non-termination, our old friend "bottom" which I'll write ⊥. In this entire article I'mJames Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com15tag:blogger.com,1999:blog-178174920347765771.post-38197565745452790582011-01-19T07:49:00.000-08:002011-01-19T08:14:37.025-08:00The Read Eval Print LieIt's a common misconception that a language must be "dynamic" or "interpreted" to have a REPL, a Read Evaluate Print Loop (also sometimes confusingly called an interpreter), or to have an "eval" function. That's not true at all.Haskell, OCaml, F#, and Scala are all statically typed languages with very sophisticated static type systems, yet all have REPLs. All are usually compiled although James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com4tag:blogger.com,1999:blog-178174920347765771.post-6465739681693709972010-11-10T09:32:00.001-08:002010-11-10T11:34:04.970-08:00Local Version ControlMy company uses a centralized version control system. It works reasonably well, but of course has all the downsides of centralized VCS. So I wanted to explain how I use a local version control system to supplement even if there isn't a real "bridge" like git-svn.WhyBefore I start let me sum up why you might want to.It's not uncommon to work on task A only to have it interrupted by super James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com3tag:blogger.com,1999:blog-178174920347765771.post-36196840655505574572010-10-18T15:07:00.001-07:002010-10-18T15:58:46.912-07:00Phantom Types In Haskell and Scala
/*
Some literate Haskell and Scala to demonstrate
1) phantom types
2) I am a masochist
3) ???
4) profit!
The code is probably best viewed with a syntax colorizer
for one language or the other but I've colorized all my
comments.
> {-# LANGUAGE EmptyDataDecls #-}
> module RocketModule(test1, test2, createRocket, addFuel, addO2, launch) where
*/
object RocketModule {
/*
None of these James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com4tag:blogger.com,1999:blog-178174920347765771.post-40387977882654187332010-10-15T08:50:00.000-07:002011-06-17T08:09:39.647-07:00Systems Design: Making a New Feature (Nearly) Too Much TroubleEDIT: Since I wrote this BART has finally implemented an integration between parking payment and the Clipper card. It's a little more complicated to set up than it should be, but it works. I'll leave the rant up because the meta-point still stands.This article will look like a random rant about public transportation, but it's really a random rant about bad systems design, especially when James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com1tag:blogger.com,1999:blog-178174920347765771.post-83932669788402188142010-10-08T16:18:00.000-07:002010-10-11T13:36:21.033-07:00How To Estimate SoftwareA guide to estimating percentage complete and remaining time.I haven't looked at the problem. Completed: 0% Time esimate: about 2 weeks.I've looked at the problem. Completed: 50% Time estimate: about 2 more weeks.I've implemented almost everything. All that remains is the difficult stuff that I don't really know how to do. Completed: 90% Time estimate: about 2 more weeks.I've done everything.James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com14tag:blogger.com,1999:blog-178174920347765771.post-30659458947545040302010-09-13T15:51:00.000-07:002010-09-14T07:52:26.590-07:00Moron Why C Is Not AssemblyIn response to a previous article a poster in some forum called me an idiot and said "everybody knows that C is a portable assembly language with some syntax sugar." The idiot insult hurt deeply and I cried, but once the tears were dry I resolved to write a bit more on why C isn't assembly, or is at best an assembly for a strange, lobotomized machine. Also, I may have misspelled "more on" in James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com50tag:blogger.com,1999:blog-178174920347765771.post-25893558828701960972010-08-27T13:55:00.000-07:002011-02-07T08:11:35.751-08:00Why Scala's "Option" and Haskell's "Maybe" types will save you from nullCedric Beust makes a bunch of claims in his post on Why Scala's "Option" and Haskell's "Maybe" types won't save you from null, commenters say he doesn't get it and he says nobody has argued with his main points. So I thought I'd do a careful investigation to see what, if anything, is being missed.First, right off the top here: Scala has true blue Java-like null; any referenceJames Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com25tag:blogger.com,1999:blog-178174920347765771.post-33864859613992232010-08-13T13:18:00.000-07:002010-08-13T13:21:59.088-07:00Sometime in 1977Kernighan: "I know, let's open the book with a program that displays 'hello, world.'"
Ritchie: "Great idea! I'll start the patent search."James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com3tag:blogger.com,1999:blog-178174920347765771.post-9098104781786883192010-08-02T07:43:00.000-07:002010-08-02T15:29:52.768-07:00On Removing Java Checked Exceptions By Means of Perversion/*What do you do in Java when you need to throw a checked exception in a context where it's not allowed, for instance when implementing a third party interface with no declared throws clause? If you're smart and its allowed you just write the code in another language. Otherwise you probably just wrap the bastard checked exception in an unchecked exception and be on your way.But the wrapping James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com12tag:blogger.com,1999:blog-178174920347765771.post-91204678418018384592010-07-20T12:36:00.000-07:002010-07-31T07:22:17.590-07:00When CONSTants Vary/*Occasionally somebody will suggest that statically typed language X (Java, C#, Scala, F#, whatever) would be better off with C++'s "const", a type qualifer that supposedly makes objects immutable in certain contexts[1]. I'm not convinced. Const requires a fair amount of work and provides fairly small guarantees. This post is a bit of literate C++ program demonstrating some of the weaknesses James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com6tag:blogger.com,1999:blog-178174920347765771.post-91523487246357481022010-07-09T09:24:00.000-07:002010-07-11T20:17:24.789-07:00Code Monkeyism's Post Is Unfit For Serious ReadingStephan Schmidt makes several points in Scala Is Unfit For Serious Development . Some are even valid. Unfortunately, the valid points are buried in over-generalizations and attacks on the attitudes of the developers and community.It's unfit because the developers and the community are unwilling.At the end of his little diatribe he thanks 2 members of the community for helping him with his James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com13tag:blogger.com,1999:blog-178174920347765771.post-70411421136367472632010-05-27T06:54:00.000-07:002010-05-27T14:42:18.808-07:00Who Will Throw the Hammer This Time?During the 1984 Super Bowl, Apple released an ad where gray, drab people are transfixed on a giant screen with a talking head who tells them how utopian their uniform world is. A female athlete jogs in and throws a hammer at the screen, the screen explodes, and a new voice announces the release of the Apple Macintosh.The ad riffed off of the George Orwell dystopian novell Nineteen Eighty-Four. James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com5tag:blogger.com,1999:blog-178174920347765771.post-29332523205652172292010-05-25T07:32:00.000-07:002010-05-25T09:53:51.407-07:00Anatomy of an AnnoyanceThe warning "Type safety : A generic array of T is created for a varargs parameter" is so irritating it makes me want to beat Java with a snoracle, an implement that allows defunct tech companies to breath while underwater. This article will explain what the warning is, where it comes from, and why it is pretty boneheaded. The warning also shows just how hard it is to extend an existing language James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com15tag:blogger.com,1999:blog-178174920347765771.post-56713211006390974842010-05-05T08:43:00.000-07:002010-05-10T08:18:02.010-07:00Types à la ChartI recently saw a debate on whether a certain language had a "weak" or "strong" type system. Naturally the debate ended in flames. As far as I could tell neither side knew what the other was talking about which isn't surprising as I've almost as many definitions of "weak" and "strong" typing as there are developers who use the words. Frankly the words have too many meanings to be useful.If the James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com19tag:blogger.com,1999:blog-178174920347765771.post-44795983682622265832010-04-12T15:23:00.000-07:002010-04-13T16:18:39.734-07:00C Is Not AssemblyIn my last article I dug down into some of the joys of undefined pointer behavior in C. But I did it in the context of an architecture that most developers aren't too likely to ever see again, the Intel 8086. I wanted to show that this stuff matters even with more mainstream architectures because compilers are free to do a lot of non-obvious things. C is not assembly.The United States Computer James Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.com11