Posts

Cache, Query, or Calculate

Image
Memoization, tabulation, even dynamic programming could be considered a kind of local memory caching.  A nice front end JS pattern is the interceptor in Angular for caching .  I use caching generously on the server side in most APIs I write.  Most ORMs have it built in and even offer second level caching .  Out on the web  CDNs and mirror sites are caches.  In fact caching has even more uses than it has names. Caches are useful in many places.  Real world application bottlenecks are almost always around I/O.  You can optimize your algorithm till the cows come home but if you haven't first looked at your I/O, you're improvements will likely be a drop in the ocean.  Often a quick and easy way to alleviate I/O bottlenecks is to slap on an  appropriate  cache. A particular problem where we see caching is in the classic Fibonacci problem.  The Fibonacci sequence is a pattern frequently occurring in nature, but in Computer Sc...

Cliche Detection with the Rabin-Karp Algorithm

Image
One of my favorite algorithms is the Rabin-Karp algorithm .  There are other string searching algorithm's that are more efficient, but this one builds naturally from understanding the hash datatype and is simple enough to quickly grasp and recall. txtHash = (d * (txtHash - ord (txt[left]) * h) + ord (txt[left + patternLen])) % q The genius of the Rabin-Karp is how it builds hashes of strings from prior hashes, removing the component that contributes to the portion of the window that's fallen off and adding the portion that's come into the window.  This reduces Big O complexity substantially.  Personally, I find parsimonious yet effective code like this aesthetically pleasing. As I understand, the algorithm is often used for plagiarism detection, which makes it a natural fit into the AuthTools library I've been building .  Rabin-Karp really shines when doing a simultaneous multi-pattern search.  One limitation however, is that it's a closed-end search...

Licks for Syllables - Entropy & NLP

Image
When I was in high school we had a trend where anytime someone used a word of more than three syllables they'd get punched in the arm for the number of syllables.  This was a physical manifestation of the general social pressure prevalent in high schools to not stick out.  I learned to dumb myself down a little to get by. At my first job I started to notice I had trouble being interrupted and talked over.  The problem continued until I was thrust into a sink or swim environment in the financial services industry where my livelihood depended on effective communication. I had the opportunity to ask my company's chief economist how to effectively communicate in an international but technical setting.  At times I'd continued to dumb down my English for the sake non-native speakers but found myself getting interrupted again.  He offered readability scores as a way to practice the right balance. [Code here] I fiddled with them a bit and noticed tha...

Logos: Mind Your Ps & Qs

Image
Growing up my mother would frequently tell me, "You're too literal."  I'd often says things in perfect seriousness and be surprised to get a resounding belly laugh in response.  In my twenties, I taught myself Japanese and it opened my eyes to aspects of human interaction that I had been quite oblivious to.  Japanese is a high context language.  It's far less explicit than English.  The onus is on the listener to understand rather than the speaker to make themselves clear.  It's consequently far less verbose.  In fact the ability to communicate significant meaning in only a few words gives the speaker a touch of sophistication.  In fact this is largely the point of Haiku, to conjure a romantic image of nature while being constrained to a terse form.  The culture is rather homogeneous so there's a shared common knowledge.  It's a far departure from the heterogeneous, chaotic, and therefore necessarily direct style of communication we ha...

Hashing

Image
I always enjoyed math as a kid.  The objectivity of the content pushed opinion to the margin.  All I had to do was understand and repeat the steps to do well.  Unfortunately, that's how I approached learning.  Understand the logic and repeat the steps.  Goal focused grade optimization helped me perform well on paper without thinking deeply about the topic. After entering the work force I had the good fortune of working with people who had developed a strong intuition with math.  Watching them solve problems made me realize the power of having an intuition around mathematics and CS concepts.  Considering the prevalence of computers in our lives, repeating the steps of a formula is a skill that's been commoditized. What's left for most of us engineers is the creative application of tools to solve problems. In this article I want to consider hashing with the purpose of gaining some intuition.  While it's a familiar everyday concept, it's a la...

We Don't Need Another Hero

Image
There's a misconception about engineer quality that states that good engineers are orders of magnitude better than average engineers..  As I understand, it began with  Bill Gates  saying, "...a great writer of software code is worth 10k times the prices of an average software writer." I've known a lot of smart people, but in my experience genius itself is a bit of a suspect concept.  Everyone has their gifts and weaknesses.  Even those publicly labeled as genius may simply be freed by eccentricity to express themselves openly when others would hold their tongue.  In my mind "genius" is really a parental strategy to propel children toward survival in a world of scarcity.  An extreme variant of what Japanese call "親バカ" or "imbecile parent," a parent so lovestruck by their child that they're incapable of seeing their faults. Let's say we take "genius" as a concept at face value though.  Even geniuses are not 10k mo...

What to Expect Along the S Curve

Image
As engineers, it's a good idea to get exposure to some business concepts.  Even if you were a born coder and want to eventually be buried with your laptop, taking the opportunity to work in a product and/or management role during your career can really boost your effectiveness.  Once you understand the basics you can often predict features and risks and design to accommodate them before ever being asked.  You can also contribute to the partnership from both sides of the table, offering strategic insights that the business themselves may not have considered. We engineers are doers.  We're usually workhorses, not show ponies and we often pride ourselves on this spartan aesthetic.  There's all kinds of speculation as to why Steve Jobs always wore a simple t-neck and jeans.  Part of it's surely attributable to brand building and decision fatigue  but part of it's probably because if he was dressed to the 9s like 007 he'd likely lose credibility amon...