Join us on freenode.net channel #utah, the IRC channel for all LUGs in Utah. View channel stats.
skinniestman
100 Balls, etc.: The Exciting Conclusion!
[When we last visited our intrepid hero, he was engaged in a battle of wits atop the tallest turret of Fallacy Fortress. The fate of the world is again in his hands. We join him now...]
Dr. Destructor: Wait till I get going! Where was I?
Capt. Constructor: Australia. Oh wait. I mean, you were just telling me about spheroids, buckets, and a scale.
Dr. Destructor: Right! I, like many non-virtual Destructors out there, suffer from occasional memory leaks. Don’t tell me you Constructors are immune. Australia? Ha!
Capt. Constructor: Memory and Australia are both quite entertaining topics. But if you’ll excuse me, the world is on the verge of collapse and I hear some spheroids calling my name.
Spheroids: O Captain! my Captain!
[Our hero dashes to the Table of Doom whereon are arranged the spheroid-filled buckets and the badly damaged scale. He buries himself in thought for a full 100 milliseconds, which is an eternity to a modern microprocessor.]
Capt. Constructor: Aha! The solution is simple. One can conceptually number the buckets 0 through 9. Once that is accomplished, the following algorithm should suffice:
void transferSpheroids(int howMany, Bucket& from, Bucket& to) { // The contents of this function are left as an exercise // for the reader. } const int numBuckets = 10; const float normalWeight = 1.0f; const float abnormalWeight = 1.01f; const float singleWeightDiff = abnormalWeight - normalWeight; // See http://en.wikipedia.org/wiki/Arithmetic_progression on why // this works. const float expectedWeight = numBuckets * (numBuckets - 1) * normalWeight / 2.0f; int findHeavyBucket(int buckets[]) { for (int whichBucket = 0; whichBucket < numBuckets; whichBucket++) { transferSpheroids(whichBucket, buckets[whichBucket], this.EmptyBucket); } float actualWeight = scale.Weigh(this.EmptyBucket); float totalWeightDiff = actualWeight - expectedWeight; return (int)(totalWeightDiff / singleWeightDiff); } int main() { // Set up the buckets, etc. // … int bucketContainingHeavies = findHeavyBucket(buckets); }Capt. Constructor: Of course there may be a syntax error or two in there. You’ll forgive me for not bringing my pocket compiler.
Dr. Destructor: Arg! Foiled again! How were you able to solve it so quickly?
Capt. Constructor: You made the mistake of labeling each of the buckets 0 through 9. That was just the clue I needed. It otherwise might have taken me 300 milliseconds or more.
Dr. Destructor: Curses!
Capt. Constructor: Remember, Destructor, nefariosity does not pay.
Dr. Destructor: I believe you mean nefariousness.
Capt. Constructor: Whatever.
RoR is NO Silver Bullet
Fábio Akita talks about being pragmatic when deciding whether to use Ruby on Rails:
It is here now and many people are already benefiting from it. But, does it make it suitable for every web application? Definitely not. For that you have to decide yourself through hands-on experience. The result for your situation will differ from someone else. There are several reasons to choose one framework over the other: some are technical, some are economics, some are cultural. Whatever the case, there is no Silver Bullet. How many times do we have to repeat that. Fred Brooks warned us 3 decades ago! And this time is no different: RoR is NO Silver Bullet. Nor is ASP.NET for that matter.
Is RoR right for you? Choosing a platform is rarely a simple decision. However, you have a good chance of making the right choice if you start by putting down your requirements for your project. Write down what you want your application to do for users, and then start looking for a framework that will help you accomplish those goals.
Choosing the technology first is like buying a spring form pan before finding out whether your customer prefers pie over cheesecake, or perhaps would just like to buy a loaf of bread, thank you very much. There’s a very good chance you will guess wrong.
RoR is a great framework and has sparked developers of other web application frameworks to get their act together. Just make sure you look at the pros and cons surrounding Ruby on Rails and any other platform you evaluate.
Random
Ruby on Rails: Let’s Get Real
Good, objective summaries of the pros and cons surrounding the Ruby on Rails platform are rare. What you do find is plenty of fan boy buzz. So with a nod to 37signals, let’s get real for a moment. What is Ruby on Rails all about? Why do people love it? Why do people hate it (yes, these people really do exist)? And why does it make certain people (Bigslow Traditional, Inc.) very, very afraid?
Due to the nature of my employment, I’ve had the opportunity to work extensively with several web application frameworks, including Ruby on Rails. I’ve outlined my first-hand experiences below. Fat-free, but loaded with sugar.
Ruby on Rails: DevelopmentPros
- Very good OR/M – This is the best part of Rails. Saves a ton of work, and there is very little setup to be up and running (no nasty XML files, etc.)
- You feel like you are a hippie, rebelling against the system. J
- MVC, filters, etc. very useful
- Ruby is a terse language (compared to more tradition c-style languages), well thought-out, and very readable
- Lots of useful code generators
- Deployment is a snap with Capistrano
- Lots of interesting plug-ins and gems you can use to save time.
- Active, friendly, helpful community.
- Lots of good documentation
- Built-in testing framework
- Encourages good programming patterns
- Built-in support for AJAX
Cons
- Scaffolding is too basic to be very useful other than for learning and basic testing
- Easy to do things the “wrong way” if you rely too much on your experience with older web app models. I highly recommend getting some Ruby and RoR books and immersing yourself in the culture
- Hard to prove correctness of your code. Requires mounds of unit testing (which can easily take more time than coding the app itself).
- Large web apps become rather unwieldy. Rails is better suited to smaller, tighter code bases. Because it uses a dynamically typed, interpreted language, risk of regression bugs in your app increases exponentially with the size of the code base. Recent advancements in VMs (JRuby, Rubinius) and IDEs (Komodo, IntelliJ, Ruby in Steel), may help alleviate some of these problems.
- Hard to debug, step through code, etc. Again, new IDE support may help some with this, but it will be some time before it is on par with, say, ASP.NET.
- Rails development in a Windows environment is not as well supported as on a Mac.
- Development philosophy relies heavily on “magic” and “assumptions”. Coming back to a code base after a month or two will leave you confused until you remember everything that is going on behind the scenes.
Pros
- Capistrano makes deployment to multiple machines straightforward
- Runs on inexpensive *nix boxes
- Multiple DBMS’s supported
Cons
- Have to keep gems, plugins, rails library all up to date and deployed along with your web app
- Capistrano’s SSH tunnel doesn’t always work the best when deploying from a Windows box
- You will be needing multiple servers earlier than you might expect. This obviously complicates deployment, but Capistrano is a big help there.
- When the app or server crashes, Mongrel & co. doesn’t (reliably) automatically restart (mod_rails AKA Passenger may be more reliable, but it is still fairly new and not as well tested).
Pros
- Runs on inexpensive *nix boxes or you can use a VPS cluster
- Capistrano designed with clusters in mind
Cons
- You have to use clusters to handle even moderate traffic.
- Database can quickly become the bottleneck (this is what happened to twitter). No built-in support for multiple DB backends.
- Eats up tons of RAM.
- Lots of CPU time spent, esp. in the OR/M layer. Much of this is due to heavy use of reflection. Rails 2.0 uses caching to improve this considerably, but still slow
- Rendering XML for REST/SOAP is very slow. In my tests, C#/WCF was at least 5x faster.
- Ruby is one of the slowest dynamic languages known to man
- Page and partials caching can speed things up a lot, but is a pain to maintain when you make changes to your code
- Serious problems with piping files greater than a couple MB (i.e., PDFs, downloading a purchased product). I had to use PHP because Rails would crash every time.
- You have to use something else for serving static files, such as images and CSS. I highly recommend Nginx. Also makes a great proxy to Mongrel.
Rails is a fun framework that takes a lot of the drudgery out of web programming. However, it’s lack of really great IDE support and static code analysis makes large apps difficult to maintain. There are also some serious scaling issues, even after recent developments speeding up rails 2x or so. I would recommend this for smaller projects with low to medium traffic loads. For very small projects, lighter MVC frameworks also based on Ruby would probably be more appropriate. If you are creating a web service (REST or SOAP), I would stay away from Ruby altogether.
That being said, the critical weaknesses of the language and the framework (e.g., performance) are actively being addressed. So, even if you don’t choose to use Rails today, you would be quite foolish not to keep it on your radar.
Random
May Software Pick: Dual Monitor Wallpaper Nirvana
Anyone who uses dual monitors for a few days ends up wondering how they ever lived with only one screen. All that extra space is lovely. You can put your reference material, email, etc. on one screen while using the other for your workspace. It doesn’t take long before your ALT and TAB keys start getting lonely.
There’s just one problem, and we have the solution.
Windows doesn’t give you much love when it comes to dual-monitor wallpaper. The nice folks at ATI and nVidia aren’t much help, either, with their drivers. All that screen real-estate and no good way to display widescreen images.
This month we bring you a solution to your dual-monitor wallpaper woes. It’s called DisplayFusion. It automatically scales and crops your favorite images to fit your setup, very handy even when you only have a single monitor. And, as a bonus, your can download images directly from Flickr. Use it to draw from your own personal photos, or try searching for something like “HDR” to pull down some great art from other folks.
So what are you waiting for? Go check it out.
May Software Pick: Dual Monitor Wallpaper Nirvana
Anyone who uses dual monitors for a few days ends up wondering how they ever lived with only one screen. All that extra space is lovely. You can put your reference material, email, etc. on one screen while using the other for your workspace. It doesn’t take long before your ALT and TAB keys start getting lonely.
There’s just one problem, and we have the solution. (more…)
Hackers Need Good Books
It seems that we are not alone in our opinion that great hackers read books:
http://www.codinghorror.com/blog/archives/001108.html
Jeff makes a great point about there not being a lot of really great programming books out there. The bad news is that it can be hard to get at the information you need without a lot of trial-and-error and about 23 million google searches. The good news is that your reading list is actually tractable.
Please, vote with your wallet and reward great book publishers such as the Pragmatic Programmers.
Random
Hackers Need Good Books
It seems that we are not alone in our opinion that great hackers read books:
http://www.codinghorror.com/blog/archives/001108.html
Jeff makes a great point about there not being a lot of really great programming books out there. The bad news is that it can be hard to get at the information you need without a lot of trial-and-error and about 23 million google searches. The good news is that your reading list is actually tractable.
Please, vote with your wallet and reward great book publishers such as the Pragmatic Programmers.
Random
Life-Changing Books
Last week I ran across a quick little article entitled “Life-Changing Books: Recommendations from 17 Leading Scientists“. Few things in life excite me anymore the way a really good book does (I could tell you “tales of the glories of Christmases long, long ago”), so this definitely piqued my interest.
I knew I was in for a treat when I noticed that the fourth one down was Isaac Asimov’s Foundation Trilogy. I was a big Asimov fan “way back” in high school. If I had been asked to participate in the making of the aforementioned list (alas, I am not yet considered a “Leading Scientist”), I might have selected Asimov’s I, Robot. Let me tell you why.
- I was and still am fascinated by how literarily fertile his 3 laws of robotics are. (If Asimov can invent the word “robotics”, I can invent “literarily”.) I lifted the following from Wikipedia: “SF scholar James Gunn writes, ‘The Asimov robot stories as a whole may respond best to an analysis on this basis: the ambiguity in the Three Laws and the ways in which Asimov played twenty-nine variations upon a theme.’”
- I didn’t quite realize it at the time, but it now occurs to me that the stories in I, Robot are engineering at its finest. Here’s a problem, now solve it. That’s really what I’ve been doing since I got my first programming job.
- Who doesn’t like robots?
Random Boy posted a few days ago asserting that “Great Hackers Read Books“. I totally concur. It’s really one more way to exercise your mind. Not only that, books are a great source of ideas! New ideas, for the most part, are just new combinations of existing ideas. The more combinations you have available in your brain, the more likely you are to be able to come up with something new and cool.
Some of my recent favorite nerdy-ish books are:
- Gödel, Escher, Bach: An Eternal Golden Braid, by Douglas Hofstadter
- I Am a Strange Loop, also by Douglas Hofstadter
- Chaos - Making a New Science, by James Gleick
- Code Complete 2nd Edition, by Steve McConnell
- Machine Learning, by Tom Mitchell
- The World Is Flat, by Thomas L. Friedman
- The Design of Everyday Things, by Donald Norman
In the famous words of Levar Burton, “don’t take my word for it.”
-ANSI Pants
Life-Changing Books
Last week I ran across a quick little article entitled “Life-Changing Books: Recommendations from 17 Leading Scientists“. Few things in life excite me anymore the way a really good book does (I could tell you “tales of the glories of Christmases long, long ago”), so this definitely piqued my interest.
I knew I was in for a treat when I noticed that the fourth one down was Isaac Asimov’s Foundation Trilogy. I was a big Asimov fan “way back” in high school. If I had been asked to participate in the making of the aforementioned list (alas, I am not yet considered a “Leading Scientist”), I might have selected Asimov’s I, Robot. Let me tell you why.
- I was and still am fascinated by how literarily fertile his 3 laws of robotics are. (If Asimov can invent the word “robotics”, I can invent “literarily”.) I lifted the following from Wikipedia: “SF scholar James Gunn writes, ‘The Asimov robot stories as a whole may respond best to an analysis on this basis: the ambiguity in the Three Laws and the ways in which Asimov played twenty-nine variations upon a theme.’”
- I didn’t quite realize it at the time, but it now occurs to me that the stories in I, Robot are engineering at its finest. Here’s a problem, now solve it. That’s really what I’ve been doing since I got my first programming job.
- Who doesn’t like robots?
Random Boy posted a few days ago asserting that “Great Hackers Read Books“. I totally concur. It’s really one more way to exercise your mind. Not only that, books are a great source of ideas! New ideas, for the most part, are just new combinations of existing ideas. The more combinations you have available in your brain, the more likely you are to be able to come up with something new and cool.
Some of my recent favorite nerdy-ish books are:
- Gödel, Escher, Bach: An Eternal Golden Braid, by Douglas Hofstadter
- I Am a Strange Loop, also by Douglas Hofstadter
- Chaos - Making a New Science, by James Gleick
- Code Complete 2nd Edition, by Steve McConnell
- Machine Learning, by Tom Mitchell
- The World Is Flat, by Thomas L. Friedman
- The Design of Everyday Things, by Donald Norman
In the famous words of Levar Burton, “don’t take my word for it.”
-ANSI Pants
Great Hackers Read Books
Great hackers continuously expand their minds and discover new principles that make them stand out among their peers. Books, blogs, lectures, etc. are all great sources for new ideas. Just remember to take everything you hear with a grain of salt, and compare it to what you already know.
Here are some books and blogs you can use to get started. I highly encourage expanding this list with other reputable resources as you come across them. Many books and essays will reference other materials that can aid you in your search to become a great hacker.
Books on Creating Great Software- The Art of Programming
- The Mythical Man Month
- Slack: Getting Past Burnout, Busywork, and the Myth of Total Efficiency
- Code Complete 2
- Writing Effective Use Cases
- Agile Software Development
- The Design of Everyday Things
- Emotional Design
- The Non-Designer’s Design Book
- The Goal: A Process of Ongoing Improvement
- Critical Chain : A Business Novel
- Founders at Work
- The Wizard of Menlo Park
- Life Is a Series of Presentations
- Sketching User Experiences
- Purple Cow
- Leadership and Self Deception: Getting Out of the Box
- Tog on Software Design
- Tog on Interface
Random
Great Hackers Read Books
Great hackers continuously expand their minds and discover new principles that make them stand out among their peers. Books, blogs, lectures, etc. are all great sources for new ideas. Just remember to take everything you hear with a grain of salt, and compare it to what you already know. (more…)
Blogging is Good for the Soul
A few years ago, Stevey at Amazon wrote about the benefits of blogging, even if nobody reads what you write. Paul Graham said something similar when discussing how and why he writes Essays. Elsewhere, Joel related the same principle to writing specs.
So here’s the principle: one of the best ways to exercise your brain and explore ideas is by writing. This works even if nobody ends up reading your stuff, and works even better when there is any possibility (however likely) that your writing will be read by others. For some reason, we humans do better when we feel accountable.
When I ran track and cross-country with some friends in high school, we learned early on the value of having a running partner. When you have someone to “pace” yourself against, suddenly you have more motivation to run harder and longer (basically until you puke). Writing essays or creating software works the same way. You need a great team of people to motivate you and keep ideas fresh. You also need readers or users for the same reason.
Writing down your thoughts and creating real solutions to peoples problems not only makes the world a better place, but it also makes you a better person.
Share what you know. Be good.
Random Boy
Blogging is Good for the Soul
A few years ago, Stevey at Amazon wrote about the benefits of blogging, even if nobody reads what you write. Paul Graham said something similar when discussing how and why he writes Essays. Elsewhere, Joel related the same principle to writing specs.
So here’s the principle: one of the best ways to exercise your brain and explore ideas is by writing. This works even if nobody ends up reading your stuff, and works even better when there is any possibility (however likely) that your writing will be read by others. For some reason, we humans do better when we feel accountable.
When I ran track and cross-country with some friends in high school, we learned early on the value of having a running partner. When you have someone to “pace” yourself against, suddenly you have more motivation to run harder and longer (basically until you puke). Writing essays or creating software works the same way. You need a great team of people to motivate you and keep ideas fresh. You also need readers or users for the same reason.
Writing down your thoughts and creating real solutions to peoples problems not only makes the world a better place, but it also makes you a better person.
Share what you know. Be good.
Random Boy
100 Balls, 10 Buckets, 1 Single-Use Scale
[We join our hero, Captain Constructor, atop the tallest turret of Doctor Destructor's hidden hideout: Fallacy Fortress...]
Dr. Destructor: You’re too late, Constructor! Before the next clock cycle, all of those mortals you call friends will be destroyed! And your little dog, too! [Maniacal laughter...]
Cptn. Constructor: Close your handle, Destructor. Just tell me how to interrupt the detonation kernel … er … process … sequence … thing.
Dr. Destructor: The sequence is perfectly synchronized and it cannot be pre-empted! Unless, of course, you are able to correctly identify the set of slightly-heavier-than-the-rest spheroids. But it is a task that is surely intractable to your puny single-core mind.
Cptn. Constructor: YOUR FACE IS SINGLE-CORE! [Our hero clears his throat, embarrassed. He is not generally given to such base language. Quickly he recovers his composure.] Tell me more about these spheroids.
Dr. Destructor: Over here you will find I have sorted 100 spheroids into 10 buckets. Each bucket holds 10 spheroids, as you can plainly see. 90 of these spheroids all weigh 1 gram each. The other 10 weigh 1.01 grams each and they have been placed all together in the same bucket. You should also have noticed by now that all 100 spheroids are visually indistinguishable from one another. Shall I go on? Your stack is beginning to look overflowed.
Cptn. Constructor: I have stack space you could never even dream of. continue;
Dr. Destructor: Immediately next to the buckets I have placed a scale. The scale has been badly damaged from overuse. I keep telling that furry PHP elephant he’s too big! Never mind that, though. I assure you that the scale is still perfectly accurate. However, it only has one good measurement left in it.
Cptn. Constructor: What does all of this have to do with the spheroids?
Dr. Destructor: It should be quite clear that to interrupt the sequence of destruction, you must identify which bucket contains the heavier spheroids. You may take any combination of spheroids you like from these 10 buckets, place your selection in this empty bucket labelled “this.EmtpyBucket”, and place “this.EmptyBucket” (which at that point will no longer be empty) on the scale. The scale will tell you the weight and you must then tell me which of the 10 buckets contains the heavier spheroids.
Cptn. Constructor: Truly, you have a dizzying intellect.
Dr. Destructor: Wait till I get going! Where was I?
[Join us next time for the exciting conclusion...]
100 Balls, 10 Buckets, 1 Single-Use Scale
[We join our hero, Captain Constructor, atop the tallest turret of Doctor Destructor’s hidden hideout: Fallacy Fortress…]
Dr. Destructor: You’re too late, Constructor! Before the next clock cycle, all of those mortals you call friends will be destroyed! And your little dog, too! [Maniacal laughter…]
Cptn. Constructor: Close your handle, Destructor. Just tell me how to interrupt the detonation kernel … er … process … sequence … thing.
Dr. Destructor: The sequence is perfectly synchronized and it cannot be pre-empted! Unless, of course, you are able to correctly identify the set of slightly-heavier-than-the-rest spheroids. But it is a task that is surely intractable to your puny single-core mind.
Cptn. Constructor: YOUR FACE IS SINGLE-CORE! [Our hero clears his throat, embarrassed. He is not generally given to such base language. Quickly he recovers his composure.] Tell me more about these spheroids.
Dr. Destructor: Over here you will find I have sorted 100 spheroids into 10 buckets. Each bucket holds 10 spheroids, as you can plainly see. 90 of these spheroids all weigh 1 gram each. The other 10 weigh 1.01 grams each and they have been placed all together in the same bucket. You should also have noticed by now that all 100 spheroids are visually indistinguishable from one another. Shall I go on? Your stack is beginning to look overflowed.
Cptn. Constructor: I have stack space you could never even dream of. continue;
Dr. Destructor: Immediately next to the buckets I have placed a scale. The scale has been badly damaged from overuse. I keep telling that furry PHP elephant he’s too big! Never mind that, though. I assure you that the scale is still perfectly accurate. However, it only has one good measurement left in it.
Cptn. Constructor: What does all of this have to do with the spheroids?
Dr. Destructor: It should be quite clear that to interrupt the sequence of destruction, you must identify which bucket contains the heavier spheroids. You may take any combination of spheroids you like from these 10 buckets, place your selection in this empty bucket labelled “this.EmtpyBucket”, and place “this.EmptyBucket” (which at that point will no longer be empty) on the scale. The scale will tell you the weight and you must then tell me which of the 10 buckets contains the heavier spheroids.
Cptn. Constructor: Truly, you have a dizzying intellect.
Dr. Destructor: Wait till I get going! Where was I?
[Join us next time for the exciting conclusion…]
101 Easter Eggs
On Friday I came across The 101 Coolest Easter Eggs Hidden in Your Software, DVDs and Video Games. Although I haven’t hunted down more than a handful of them, some of them appear to be fun (OpenOffice.org: Star Wars Game), some are funny (Firefox: Firefox’s Revenge for IE5’s Joke), some are lame (Winamp: Spinning Fish), and some are quite intriguing (IRIX: Hidden Recipes in Release Notes).
That’s all IMHO, of course.
Happy hunting!
101 Easter Eggs
On Friday I came across The 101 Coolest Easter Eggs Hidden in Your Software, DVDs and Video Games. Although I haven’t hunted down more than a handful of them, some of them appear to be fun (OpenOffice.org: Star Wars Game), some are funny (Firefox: Firefox’s Revenge for IE5’s Joke), some are lame (Winamp: Spinning Fish), and some are quite intriguing (IRIX: Hidden Recipes in Release Notes).
That’s all IMHO, of course.
Happy hunting!
Challenge Your Inner Nerd
At work our software development team allocates 30 min each day to skill development. It’s a great way to keep our minds fresh and full of new ideas. Today I just came across a gold mine for anyone looking to challenge their inner nerd. It’s called OpenCourseWare. It’s from MIT. It’s nerdy.
What you get is free, open access to 18K of MIT’s coolest courses in the form of lecture notes, outlines, videos, and problem sets. Didn’t have time to take a flippin’ sweet course on AI when you were in school? No problem. Robotics? Machine vision? Algorithms? Rock on. Develop your skills to the max.
I don’t see this as a replacement for actually going to college (face-to-face human interaction is still important; you can’t hide behind texting and email), but it is a great supplement. Even if you are already in a great engineering or CS program, why not use these lectures to get a different angle on the same material? I can guarantee you’ll be light years ahead of your fellow students. And when it comes time to apply for a job or start your own business, you will have a huge competitive advantage.
For example, say you are a smart hacker wanting to start your own business. Well, you better learn something about business management. MIT’s OpenCourseWare can help you get your feet wet.
So go ahead and give it a try. Let me know what you think.



:: Recent comments :.
26 weeks 4 days ago
39 weeks 4 days ago
40 weeks 3 days ago
40 weeks 3 days ago
47 weeks 3 days ago