Last week, President Obama made headlines by suggesting that every American in school should learn how to code. Predictably, the comment sparked some heated discussion across the web from Fred Wilson’s blog to several threads on Hacker News. Surprisingly, some of the viewpoints were extremely polarized ranging from “its useless, some people will never get it” to “of course!”. Personally, I think everyone should definitely be exposed to some form of programming while they’re in school.
An inescapable reality is that in 2013 computers are a part of everyone’s personal and professional day to day. From non-technical roles in technical fields like account managers or project managers to traditionally non-technical jobs, like teachers, everyone is ultimately interacting with computers on a daily basis. With that in mind, having a basic understanding of how computing abstractions and programming work will benefit everyone. From being able to modify a VBA macro to construct a complex Gmail search query, having a basic understanding of how the pieces fit together certainly can’t hurt.
Looking back at high school, drawing an analogy between studying programming and studying a foreign language isn’t really accurate. A better analogy is really the general experience people have studying math in middle and high school. For people that don’t take a math class in college, that’ll normally be the last time they study math in an academic setting. Although most people forget most of the details they learned, they still retain the overarching fundamentals of how things like algebra and geometry work. Because of this, when people are faced with a basic math problem they generally know what they need to look up in order to solve it. Extending this, if people were introduced to basic programming early on they’d have a sense that there might be an easier way to approach certain tasks. Need to format a list of names in Excel? There might be a function for that.
So how can we make this happen? The good news is there’s already a push to make high quality, programming focused education material available to everyone. There are already dozens of masively online open course projects including Khan Academy, Coursera, and Code Academy providing free, interactive, computer science resource for everyone. The next step is pushing states and school systems to actively adopt CS education for their middle school and high school students. Hopefully it’ll prove and easy and effective step to keeping everyone competitive in an increasingly technology powered workplace.
Posted In: General
In the last post, we walked through how to install HipHop PHP on a Ubuntu 13.04 EC2. Well thats great but it now leads us to the question of how fast HipHop PHP actually is. The problem with “toy benchmarks” is they tend to not really capture the real performance characteristics of whatever you’re benchmarking. This is why comparing the performance of a “Hello World” app across various languages and frameworks is generally a waste of time, since its not capturing a real world scenario. Luckily, I actually have some “real world”‘ish benchmarks from my PHP: Does “big-o” complexity really matter? post a couple of months ago.
Ok so great, lets checkout the repository, run the benchmark with HipHop and Zend PHP, and then marvel at how HipHop blows Zend PHP out of the water.
Well so that is weird, in 3 out of the 4 tests HipHop is an order of magnitude slower than Zend PHP. Clearly, something is definitely not right. I double checked the commands and everything is being run correctly. I started debugging the readMemoryScan function on HipHop specifically and it turns out that the problem function is actually str_getcsv. I decided to remove that function as well as the array_maps() since I wasn’t sure if HipHop would be able to optimize given the anonymous function being passed in. The new algorithms file is algorithms_hiphop.php which has str_getcsv replaced with an explode and array_map replaced with a loop.
Running the same benchmarks again except with the new algorithms file gives you:
Wow. So the HipHop implementation is clearly faster but what’s even more surprising is that the Zend PHP implementation gains a significant speedup just by removing str_getcsv and array_map.
Anyway, as expected, HipHop is a faster implementation most likely due to its JIT compilation and additional optimizations that it’s able to add along the way.
Despite the speedup though, Facebook has made it clear that HipHop will only support a subset of the PHP language, notably that the dynamic features will never be implemented. At the end of the day, its not clear if HipHop will gain any mainstream penetration but hopefully it’ll push Zend to keep improving their interpreter and potentially incorporate some of HipHop’s JIT features.
Per Dan’s comment below, HHVM currently supports almost all of PHP 5.5s features.
Well benchmarks are all fine and well but I was curious why str_getcsv was so slow on both Zend and HipHop. Digging around, the HipHop implementation looks like:
So basically just a wrapper around fgetcsv that works by writing the string to a temporary file. I’d expect file operations to be slow but I’m still surprised they’re that slow.
Anyway, looking at the Zend implementation it’s a native C function that calls into php_fgetcsv but doesn’t use temporary files.
Looking at the actual implementation of php_fgetcsv though its not surprising its significantly slower compared to explode().
Posted In: PHP
A couple of weeks ago, a blog post came across /r/php titled Wow HHVM is fast…too bad it doesn’t run my code. The post is pretty interesting, it takes a look at what the test pass % is for a variety of PHP frameworks and applications. This post was actually the first time I’d heard an update about HipHop in awhile so I was naturally curious to see how the project had evolved in the last year or so.
Turns out, the project has undergone a major overhaul and is well on its way to achieving production feature parity against the Zend PHP implementation. Anyway, I decided to give installing HipHop a shot and unfortunately their installation guide seems to be a bit out of date so here’s how you do it.
To keep things simple, I used a 64-bit Ubuntu 13.04 AMI (https://console.aws.amazon.com/ec2/home?region=us-east-1#launchAmi=ami-e1357b88) on a small EC2. One thing to note is that HipHop will only work on 64-bit machines right now.
Once you have the EC2 running, Facebook’s instructions on GitHub are mostly accurate except that you’ll need to manually install libunwind.
After that, you can test it out by running:
Awesome, you have HipHop running. Now just how fast is it?
Well you’ll have to check back for part 2…
Posted In: PHP
Scala is an object-functional programming and scripting language for general software applications, statically typed, designed to concisely express solutions in an elegant, type-safe and lightweight (low ceremonial) manner. Scala includes full support for functional programming (including currying, pattern matching, algebraic data types, lazy evaluation, tail recursion, immutability, etc.). It cleans up what are often considered to have been poor design decisions in Java (e.g. type erasure, checked exceptions, the non-unified type system) and adds a number of other features designed to allow cleaner, more concise and more expressive code to be written.
So what makes Scala interesting? Personally, a couple of things stand out. First, the type system looks powerful while also being unobtrusive enough to not offend my dynamic sensibilities. I’ll butcher any explanation of how it works but this presenation does a much better job. Another interesting Scala feature is its rich support for functional programming techniques. I’m excited to try out things like currying and pattern mathing. The last Scala feature that is particularly appealing is that it can be run through the interpreter or compiled to a JAR. Because of this, it would facilitate writing simple “one off” scripts and running them through the interpreter.
Go has been making the rounds on the blogosphere lately so naturally its piqued my interest. From Wikipedia:
Go aims to provide the efficiency of a statically typed compiled language with the ease of programming of a dynamic language. Other goals include:
- Safety: Type-safe and memory-safe.
- Intuitive concurrency by providing “goroutines” and channels to communicate between them.
- Efficient garbage collection “with low enough overhead and no significant latency”.
- High-speed compilation.
At face value, Go looks familiar and comfortable primarily because of its C inspired syntax and imperative style. The big ticket Go features that look the most interesting are concurrency support and its package and dependency management system. I haven’t written much (or any?) concurrent code and exploring Go’s “goroutines” seems like a great place to start. The official docs provide a great overview of the concurrency features Go exposes. Managing dependencies is painful and nothing is worse than getting stuck in dependency hell. Go has a unique approach to solving these issues, favoring convention over configuration. This post has a great rundown of why Go’s solution looks like a win.
Lua , from Portuguese: lua meaning moon; explicitly not “LUA”) is a lightweight multi-paradigm programming language designed as a scripting language with “extensible semantics” as a primary goal. Lua is cross-platform since it is written in ISO C. Lua has a relatively simple C API, thus “Lua is especially useful for providing end users with an easy way to program the behavior of a software product without getting too far into its innards.”
Anyway, that’s my list – I’d love to hear about any other languages worth checking out.
Posted In: General
Lately, I’ve become interested in the concept and process of structured brainstorming. What makes “structured” brainstorming distinct from its passive cousin is that it has some sort of process and is organized at a specific time. I’d argue that the goal of a structured brainstorming session should be to go in with a loose set of big questions, brainstorm, and then come out with a set of refined questions, themes, and next steps. In our experience, the best way to mentally organize a brainstorm is to group things like ideas, questions, and links under “themes”, continually add to the them, and then sort and prune at the end. Unfortunately, we haven’t really found a software tool that makes this process awesome, let alone easy.
So using this framework, what would make the ultimate brainstorming tool?
One of the most powerful aspects of a brainstorming session is that its non-linear. You easily be able to add “first act” ideas at the same time as adding “late stage” themes without disrupting the flow. In addition to adding, being able to organize information in a non-linear fashion avoids introducing a rigid structure, before the data is really understood.
Organizing data in a non-linear format is one of the primary issues of using a regular text document for a brainstorm. It makes it difficult to add things “out of order” and immediately introduces a rigid structure, since everything is flowing top to bottom.
Successful collaboration is a key point in any team activity and brainstorming is no different. An effective tool should effectively involve all participants by making it easy for everyone to contribute. Since the goal is to eventually prune down anyway, capturing input from everyone involved strengthens the process since it gives a voice to viewpoints that might otherwise go unheard. In our experience, collaborating around a whiteboard works well until 4 people are involved and then it quickly degenerates. By 6 actors, including key stakeholders, some people are hesitant to contribute since they’re afraid of “looking dumb”.
An ideal tool would allow everyone to easily contribute without disrupting active conversations and also without fear of embarrassment.
Having a ton of great data is awesome but without any way to develop links between the nodes you’re really just left with a massive list. Linking as a feature would let you “chain” pieces of data together, similar to “a href”s in an HTML document, allowing you to develop richer connections within your data.
Current digital tools like Trello or Evernote support linking and I’d imagine an ideal tool supporting it in a similar fashion. The primary concern would be making it easy to visualize the connections between nodes to drive a better understanding of how things fit together.
Ok so we’ve laid out some features, now what does this thing look like? I think ideally this is a SaaS product with a mobile client that looks like a giant table top. The table top would let you add themes, elements within those themes, and also let you create links between anything you’ve added to the table. So does this tool exist? Unfortunately, I don’t think so – or at least I haven’t found it yet.
Anyway, I’d love to hear about your experiences with brainstorming, especially what tools you’ve used.
Posted In: General
Tags: fun stuff