Cleanly representing and programming state machines is something I’ve tried a few approaches to in the past and I’ve never been fully satisfied with the results. Given that the world is increasingly driven by async programming models and complicated program control flows tend to produce less than beautiful code in an async callback or lambda  programming models this becomes a problem that is getting worse, not better.

One (the?) big problem is that control flow and composition across multiple async events/callbacks complete with proper error handling is messy. I’m not going to explain this as well as this video explaining Microsoft Rx, so just watch it:

So life gets better if you happen to be using .NET. As it turns out Microsoft brought all this to Javascript programming via Reactive Extensions for Javascript.

There are other folks doing the same things in JS, there is Flapjax

and Arrows or Arrowlets

I suspect some of the emerging Javascript MVC libraries and frameworks are accomplishing some of the same stuff in the interface between the model and controller, but I’m not sure yet, I need to look at them all again with this in mind. I would love to hear from anyone that can discuss some of the other JS frameworks or libraries in these terms!

“…that reasoning was not designed to pursue the truth. Reasoning was designed by evolution to help us win arguments. That’s why they call it The Argumentative Theory of Reasoning. So, as they put it, and it’s here on your handout, “The evidence reviewed here shows not only that reasoning falls quite short of reliably delivering rational beliefs and rational decisions. It may even be, in a variety of cases, detrimental to rationality. Reasoning can lead to poor outcomes, not because humans are bad at it, but because they systematically strive for arguments that justify their beliefs or their actions. This explains the confirmation bias, motivated reasoning, and reason-based choice, among other things.”
Now, the authors point out that we can and do re-use our reasoning abilities. We’re sitting here at a conference. We’re reasoning together. We can re-use our argumentative reasoning for other purposes. But even there, it shows the marks of its heritage. Even there, our thought processes tend towards confirmation of our own ideas. Science works very well as a social process, when we can come together and find flaws in each other’s reasoning. We can’t find the problems in our own reasoning very well. But, that’s what other people are for, is to criticize us. And together, we hope the truth comes out.
But the private reasoning of any one scientist is often deeply flawed, because reasoning can be counted on to seek justification and not truth. The problem is especially serious in moral psychology, where we all care so deeply and personally about what is right and wrong, and where we are almost all politically liberal.

So, as I said, morality is like The Matrix. It’s a consensual hallucination. And if we only hang out with people who share our matrix, then we can be quite certain that, together, we will find a lot of evidence to support our matrix, and to condemn members of other matrices.

They say, “here’s how you do the calculation to figure out the right thing to do, and just do it.”  Even if it feels wrong. “Tell the truth, even if it’s going to hurt your friends,” say some deontologists. “Spend less time and money on your children, so that you have more time and money to devote to helping children in other countries and other continents, where you can do more good.”  These may be morally defensible and logically defensible positions, but they taste bad to most people. Most people don’t like deontology or utilitarianism.

“I believe that morality has to be understood as a largely tribal phenomenon, at least in its origins. By its very nature, morality binds us into groups, in order to compete with other groups.”

If you’re interested in how different cultures around the world affect organizations and products you need to look into Hofstede’s work.

“Note the differences in the two groups of Websites. The Malaysian Website features strong axial symmetry, a focus on the official seal of the university, photographs of faculty or administration leaders conferring degrees, and monumental buildings in which people play a small role. A top-level menu selection provides a detailed explanation of the symbolism of the official seal and information about the leaders of the university.

The Dutch Websites feature an emphasis on students (not leaders), a stronger use of asymmetric layout, and photos of both genders in illustrations. These Websites emphasize the power of students as consumers and equals. Students even have the opportunity to operate a WebCam and take their own tour of the Ichthus Hogeschool.”

Not to be underestimated.

Sam Pullara was wondering if Java’s modern JITing and resultant performance improvements over Objective-C dynamic dispatch would give an edge to Android over iPhone. I contend the high level language isn’t where performance question will be answered, but rather in the API designs, let me explain…

I’ve worked on many different software systems that implement different parts of the system in different languages and runtimes for various reasons, but there is a general pattern in all of them that I’m going to call the Traffic Cop Pattern; The higher level languages/runtimes have APIs exposed to them that are implemented in a lower level language, or perhaps the functionality is even implemented directly in silicon. The higher level language/runtime ends up playing traffic cop to large amounts of data that actually gets crunched by faster code and/or dedicated silicon. The traffic cop orchestrates the flow, it doesn’t do the actual driving of every vehicle, much less the loading and unloading of the passengers. This conducting, driving, and passenger management is increasingly happening in parallel, possibly not even on the same box. What enables this to work well is the APIs between the layers, not the implementation choices of the highest level language.

Example: A web browser. Javascript orchestrates the native implementations of the DOM and CSS, it orchestrates the resource loading system, which in turn orchestrates the network stack and various levels of caching. The markup, an even higher level “language” than JS if you will, is directing the construction of the DOM, CSS structures and instantiation of the JS contexts. In turn the parsers and the runtime instantiations of the DOM and CSS engine are implemented in faster languages. Increasingly those systems in turn are calling APIs for hardware acceleration of animations, image decoding, compositing, video decoding, etc. Each level of the system is orchestrating the layers below it to work together to get higher performance all the way down to hardware acceleration.

Given that, the real performance wins will be from APIs that allow the programmer to coordinate all these systems from a higher level language, and get their (almost certainly) slower high level code out of the way. You don’t want to write another XML parser, do you? There is probably a faster version already. If you’re lucky it works well with the resource loading system (network, disk, whatever) to stream the data as it gets it. Maybe it doesn’t allocate memory to avoid causing a GC as XmlPullParser does on Android. You get the idea.

At this point I feel compelled to point out that Apple hasn’t yet exposed the H.264 hardware decoder to other developers on iPhone. Only in the last month did they expose it on MacOS, and Adobe immediately revved Flash to use it. Flash alpha on Android isn’t yet using hardware acceleration and it shows. If you control the OS, frameworks, sandbox and the hardware you can seriously put anyone else on your platform at a disadvantage at will.

The compiled vs. interpreted language question is interesting, but it is less relevant now that the V8 team has proven that you can use JIT techniques successfully even on a language as dynamic as Javascript and still get good results because the actual executing code is almost always reducible to a set of states, call graphs, and types that are finite and knowable. If you’re tracing you don’t even have to worry about anything other than what actually is executing as Dalvik and TraceMonkey do. After that it’s just a question of how many clever optimizations can you pull off, and do you have enough with one language vs. another that doing it up front (static lang compile) justifies a language choice. Yes, I know the Obj-C runtime hasn’t gone here yet, but I think one of the points Sam was making is that it could…

Lest you think this Traffic Cop pattern is new, think again:
The entire architecture of the IBM Cell processor

I’d like to call out Microsoft as perhaps having the best understanding of this pattern and applying it to the brave new multicore world

John Gruber on the Apple licensing changes:

“…such a meta-platform would be out of Apple’s control. Consider a world where some other company’s cross-platform toolkit proved wildly popular. Then Apple releases major new features to iPhone OS, and that other company’s toolkit is slow to adopt them. At that point, it’s the other company that controls when third-party apps can make use of these features.”

The problem with that argument is that the choice of API adoption, or platform adoption for that matter, is really already out of Apple’s control; Adoption is the choice of the developer, although Apple can clearly veto that choice during the app store approval process. The only thing Apple can do is make the APIs and platforms attractive as possible so people choose to use it.

Software engineers have known for decades that abstractions, libraries, utilities and OSes themselves distance them from the system below that abstraction. Sometimes this is a benefit, sometimes it is a liability, and that’s understood. Apple need not play overly protective parent, just let free market economics work it out; If the apps depending on 3rd party APIs take longer to update because of the dependency, well, that’s the price they presumably pay to get the other benefits the 3rd party provides.

Let’s push the argument all the way, let say someone develops something like Google Web Toolkit, but for the iPhone/iPod/iPad OS and APIs. An intermediate tool that rewrites code, let’s say “originally” written in Objective-C, to be more efficient. Now using that tool is banned because  it falls into this category: “Applications that link to Documented APIs through an intermediary translation”

That would be a loss for Apple, a loss for the developers, and a loss for the users.

No surprises

« Previous PageNext Page »