Scott Hanselman

Programmer Intent or What you're not getting about Ruby and why it's the tits

May 23, 2007 Comment on this post [68] Posted in Ruby
Sponsored By

A user named yesthatmcgurk left a comment on DotNetKicks where he/she said:

I must be a complete loser, because I can't see where Ruby is such hot shit. I'd love to read a story, "What you're not getting about Ruby and why its the tits."

Such a great comment that I had to get involved. One of the other commenters pointed to a post over on "Softies on Rails" that's really worth reading.

Note: Forgive the use of "the tits" in this context. "Slang Definition: A description of something you show great liking to, or greatly appreciate..." Usually not a work-friendly phrase, but perhaps pub-appropriate.

There's a simple snippet of Ruby code:

def shutter_clicked
if @camera.off? || @camera.memory_card_full?
    return
end
  capture_image
end

Ruby folks have their own aesthetic and sense of beauty. They would say that the Programmer's Intent is better expressed like this:

def shutter_clicked
  capture_image if @camera.on? && @camera.memory_available?
end

These two functions identically express the Programmer's Intent and the second one expresses it better, many believe. This one simple example is subtle to some, beautiful to others. TunnelRat says:

What is this obssesion[sic] with "expressiveness"? Go write poertry [sic] if you want to be expressvive.[sic] 

Remember that ultimately our jobs are (usually) to solve some kind of business problem. We're aiming for a finish line, a goal. The programmer's job is translate the language of the business person to the language of the computer.

The whole point of compilers, interpreters, layers of abstraction and what-not are to shorten the semantic distance between our intent and the way the computer thinks of things.

Reginald "raganwald" Braithewaite links to the blog Agile Renaissance that absolutely nails it for me (emphasis mine):

If you survey the over 5000 different languages and dialects that humans speak, you find that there is no universal set of equivalent semantics between them. This fact implies that there can never be a computer language which will always have the shortest semantic distance between itself and any solution. Therefore there never will be a universally best programming language.

I'm just learning Ruby, personally. Like anyone making their way in a new language, be it a programming language or a spoken language, I can make myself understood, but not effectively. I'm certainly not writing poetry, nor am I able to "mince words" in Ruby.

You'll find lots of "smackdowns" on the .NET between different languages. This post isn't a smackdown post. Sure, if your language of choice doesn't have a particular function, it could likely be added.

There are some fun one-liner comparisons though and some folks think that paying a:

Java:

new Date(new Date().getTime() - 20 * 60 * 1000)

Ruby:

20.minutes.ago

In this example, the elegance is a combination of how Ruby works, and a Rails library called ActiveSupport that is a Domain Specific Language that extends Ruby. There's a special satisfaction when you read a well-written novel and you go over a turn of phrase and think, "wow, what a great way to express that. That was a perfect way to describe ____," and there's no ambiguity.

While programming, unless you have 100% code coverage via Tests, there's ambiguity. There's a lack of clarity in expressing what you intended vs. what you might get.

Cyclomatic complexity is just one of many software metrics that can help you understand what your code "says" it's going to do. Remember, your code always runs exactly as you wrote it.

Cyclomatic complexity may be considered a broad measure of soundness and confidence for a program. Introduced by Thomas McCabe in 1976, it measures the number of linearly-independent paths through a program module.[Carnegie Mellon SEI]

The most important word there, to me, is confidence. Can you be confident that your code is written to be express what you intended? If you have full coverage, there's a better chance you understand what it can and will do (although achieving full coverage guarantees nothing, but that's another post). If not, it often helps to have a language that makes expressing your intent very clear, concise, and above all, unambiguous. Unambiguous expression of intent gives you (and your customer) confidence that things will happen as expected. There are some things easier expressed in Zulu than in English. Folks who run Ubuntu should know that.

When programming (that is, expressing your intent to the computer) you should select a language that matches up with the program you're trying to solve. Every language is, in a way, a Domain Specific Language.

Regardless of what your language of choice is, you might be someone who says all languages eventually become, or try to become Lisp, or you might think Visual Basic is the best or that PHP is God's Language, you should learn a new language every year. I code, and have coded, for many years in C#, and before that C++, but it's important for me in my personal development to remember why I learned Haskell and Lisp (I suck at Lisp) and Smalltalk, and why I return to them occasionally for a visit.

This year, I'm learning Ruby. Does that mean my team is moving to Ruby?  Probably not, but it does mean I'm learning Ruby this year because I believe in sharpening the saw. You might be too busy sawing to sharpen, but I'd encourage you - no matter what brand or type of saw you use - to remember that there are other folks out there cutting wood successfully with a different kind of saw. Maybe they know something that you don't.

Either way, it's clear that the jury is still out on all these technologies. Hedge your bets and learn as much as you can. There's more than one way to express yourself. Give it a try.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Twittering my Diabetes - Conclusion and Complete Transcript

May 23, 2007 Comment on this post [5] Posted in Diabetes
Sponsored By

Last week in order to increase awareness of Diabetes and raise money for the ADA I twittered my diabetes. I twittered (tweet'ed) every blood sugar test, every time I stuck an needle in me, refilled my pump, had a low, had a high, went for a walk. Every time Diabetes stuck its nose in my life, I twittered it.

Here's the transcript. Thanks to everyone who donated! The transcript is ordered NEWEST twitters first, so read it from the bottom up if you want the full experience. Finally, a use for Twitter. ;)

Big thanks to the folks at Twitter for featuring me on the their home page last week in support of the idea.

Please do note this is experiment was designed to generate empathy and turn that emphathy into action. No one's looking for pity and this wasn't intended to inspire fear, only to spread understanding.

For more information on why one ought to manage their diabetes closely and an analogy that explains how insulin and blood sugar relate to either, do check out "Diabetes Explanation: The Airplane Analogy" and the Diabetes section of this blog.

---

The day (++) of Twittering for Diabetes is over. Thanks everyone. http://hanselman.com/fightdiabetes 05:27 PM May 19, 2007

Blood sugar is 110mg/dl but heading low fast. I'm off to burgerville. *http://hanselman.com/fightdiabetes/donate* 03:22 PM May 19, 2007

Blood sugar is 150mg/dl...crept up some before lunch. 12:53 PM May 19, 2007

Sugar is 122. Nice stable night. Don't get to many of those. *Twittering my diabetes* to raise money for the ADA - http://hanselman.com 09:04 AM May 19, 2007 from web

Blood sugar is 110mg/dl...looking like I'll be in for a stable night. Thank goodness. 01:23 AM May 19, 2007

Looking stable at 140mg/dl. Never a good idea to go to sleep with blood sugar that's "moving"...makes nighttime dangerous 11:27 PM May 18, 2007 

Blood sugar starting to inch up...now at 140mg/dl. I'd like an apple, so I need to do some calculations. 10:42 PM May 18, 2007

*Twittering my diabetes* to raise money for the ADA - http://hanselman.com 09:00 PM May 18, 2007

Salad was a good choice. Don't want to have a low while putting the baby down. 08:50 PM May 18, 2007

Blood sugar heading up, turns out tortilla strips have more carbs than I thought. 07:34 PM May 18, 2007

Going to have a chicken salad...should not be much insulin, but it's HUGE 07:15 PM May 18, 2007

Italian food tonight, but going to try lower carbs...I'd rather not "disturb" good blood sugar. 07:00 PM May 18, 2007

Getting ready to drive home....gotta check sugar before I drive. Looks like a lovely 105mg/dl. Don't want to have a low while driving. 06:49 PM May 18, 2007

Had to have a 15g granola bar to "level off" blood sugar. In a good position to start dinner with good numbers. 06:43 PM May 18, 2007

Blood sugar are 96mg/dl...kind of "sliding" into a low blood sugar...no action now, but soon. 06:09 PM May 18, 2007

Levelling off nicely. 108mg/dl, fitting nicely in the 80-120mg/dl goal that you, dear reader, the non-diabetic has. 05:53 PM May 18, 2007

Blood sugar is 122mg/dl...looking much better, but still "coming down hot." Don't want to have another low. 05:30 PM May 18, 2007 from web

Blood sugar is 177mg/dl...the delta/slope is great....40 points drop in 20min...I need to soft land this plane.... 04:59 PM May 18, 2007

*Twittering my diabetes* to raise money for the ADA - http://hanselman.com 04:44 PM May 18, 2007

Blood sugar starting to fall...224mg/dl now. Aiming for 100mg/dl, remember. Not sure why lunch was a failure. 04:43 PM May 18, 2007

I think my blood sugar has topped out (apexed) at 232mg/dl....I hope I'm heading back down... 04:24 PM May 18, 2007

Crap...totally messed up lunch...sugar is 228mg/dl and climbing... 04:14 PM May 18, 2007

Alarm just went of...blood sugar is 177 and heading higher. 03:39 PM May 18, 2007

There's free granola bars at a booth here at the conference. I'm grabbing 4 in case I have a low later. 03:34 PM May 18, 2007

There's lots of candy here...snickers, piles of the junk. Everyone's eating. Not I. 03:29 PM May 18, 2007

Blood Sugar 138mg/dl. Nasty low, now I'm afraid I'm going to "overshoot" my low and now I'm going high. 03:26 PM May 18, 2007

Found a cookie in the exhibit hall...gotta wait 10 min to see... 02:14 PM May 18, 2007

Insulin has a "half life" in the system...I've underestimated the power of the walk...I've got 2.5U still "pending"... 02:10 PM May 18, 2007

Alarm just went off...I can feel it, having a low. Shouldn't be...meter says 65...pump says 70... 02:09 PM May 18, 2007

Starting to get really nauseous...the secondary drug, Symlin, causes an hour of seasickness after injection... 01:41 PM May 18, 2007

Just walked 0.5 miles, back from the Restaurant. Can feel the sugar rising... 01:21 PM May 18, 2007

Blood sugar is 155mg/dl. Took 5U of Symlin, that slows digestion. Set pump to deliver 5U with 2.5U now and the rest on going. 01:07 PM May 18, 2007

Most insulin starts working in 2 hours, but most food starts raising your sugar in 10 mins. 12:34 PM May 18, 2007

Blood sugar 120mg/dl...good start to have Ethiopian food. Going to take insulin now in anticipation of a large meal. 12:18 PM May 18, 2007

At Queen of Sheba, trying to count carbs. 12:09 PM May 18, 2007

Walking to Queen of Sheba Ethiopian....walking takes the edge of blood sugar... 11:54 AM May 18, 2007

It's always a good idea for a diabetic to enter a meal with stable blood sugar... 11:31 AM May 18, 2007

I'm well positioned for lunch, blood sugar seems stable at 120mg/dl. Good for a diabetic. 11:02 AM May 18, 2007 

Blood sugar is 110mg/dl...trend is downward... 10:43 AM May 18, 2007 

My insulin pump is currently set to deliver 0.6U of insulin per hour. I take 30U a day total, including this "background insulin." 10:20 AM May 18, 2007

Doing more walking today than anticipated...I may need to take less insulin. 10:19 AM May 18, 2007

My continuous meter just alarmed, says I have to calibrate it with a blood test within 2 hours. Have to keep them in sync. 10:02 AM May 18, 2007

Blood sugar is 140mg/dl. Coming down, good. Safe to drive. Under 80 would not be safe. 09:56 AM May 18, 2007

Driving somewhere, gotta check blood sugar first....diabetics can lose their licenses if they have a "low" 09:55 AM May 18, 2007

I'd like to get my blood sugar back to a more normal level before eating lunch... 09:43 AM May 18, 2007

Sometimes when you have high blood sugar, your mouth tastes sweet, like you're marinating in your own juices. 09:36 AM May 18, 2007

Refilling my insulin pump reservoir. I don't "trust" this bottle of insulin. Insulin only lasts 28 days unrefridgerated and sometimes "dies. ... 09:32 AM May 18, 2007

Sugar is 160mg/dl. The goal is always 80-120. 160 is too high given I haven't eatten yet. 09:30 AM May 18, 2007

Sugar is 172bg/dl. That's high for a fasting number. Has the correction I took not hit yet, or do I need more insulin? 08:56 AM May 18, 2007 

Out of the shower, reconnecting the insulin pump tube to me. The tube is 43" long. The pump has 4 days worth of insulin. 07:20 AM May 18, 2007

*Twittering my diabetes* all day to raise money for diabetes research. Info at http://hanselman.com 07:14 AM May 18, 2007

Getting in the shower. I can disconnect the tube that connects my insulin pump, but then there's no insulin...can only d.c. for 30min. 07:09 AM May 18, 2007

Blood sugar went up around 5am, now 166bg/dl. Taking 1.25U to 'correct.' This is called the "pre-dawn effect," and is hormonal. 07:05 AM May 18, 2007 

Sugar is 104. Got to remember to refill my pump, and change batteries. http://hanselman.com/fightdiabetes 03:13 AM May 18, 2007

Took a 1/2 unit too much insulin...alarm just went off, having a fig newton. 02:02 AM May 18, 2007

Blood sugar seems ok after the apple an hour ok, I'll go to bed now. I'll wake at 4 to check. 01:20 AM May 18, 2007

When eatting large meals, I use the pump *and* take an additional shot of a drug to slow digestion, and slow the sugar rise. 12:58 AM May 18, 2007

Some diabetics take shots, I'm connected 24hrs a day to a pump. I keep it under the pillow. 12:56 AM May 18, 2007

Running out of insulin in my onboard pump....I need 30U (units) for 24 hours. Got 14U on board...change the whole thing now or in the mornin ... 12:06 AM May 18, 2007

Going to eat an apple. Blood sugar is 102mg/dl. Gotta take 2U of insulin, but I'm also eating cheese, so I'll do 3. 12:05 AM May 18, 2007

blood sugar is low...74mg/dl. Starting to feel it. I took too much insulin for dinner. Damn low carb soup. 10:39 PM May 17, 2007 from web

A non-diabetic's blood sugar is between 80mg/dl and 120mg/dl (milligrams/deciliter of blood). 10:23 PM May 17, 2007

Tomorrow I'm going to "twitter my diabetes" - all day, to help raise awareness. hanselman.com/fightdiabetes 07:10 PM May 17, 2007

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Explaining CyberGeek Fame to my Wife

May 21, 2007 Comment on this post [35] Posted in Musings
Sponsored By

DHH, Fowler, HanselmanIt was fun this week to meet Martin Fowler and David Heinemeier Hansson at RailsConf. It's always cool at a conference to meet someone who's done great work, chat with them, and try to figure out how you too, can do great work. If only others appreciated it also...

Wife: How was the conference?

Geek (Me): It was excellent. I got to meet and chat with Martin Fowler and David Heinemeier Hansson, and they were both very cool.

Wife: Ermm...that's nice...

Geek: Ya, David created a Web Application Development Framework called Rails using a rather obscure Japanese gentleman's language called Ruby, and came up with a number of new and synthesized ideas in a way that no one had yet. It's sweeping the 'net and folks are digging it. Martin is one of the pioneers of Object Orientation and agile methodologies, as well as an Extreme Programming Guy.

Wife: I've never heard of these guys, but I'm glad you're glad!

David Heinemeier Hansson, Martin Fowler, and Scott HanselmanGeek: Well, meeting Martin is kind of like meeting Michael Caine, he's a very respected guy, talented actor, he's been around for a long time, done a lot of great work, and you're never disappointed with any thing you see him in. Meeting David is kind of like meeting Tobey Maguire, because Spiderman kicked butt and everyone enjoyed it, but it's unclear if he'll get a lot of work and do great stuff after Spiderman. But, still, he's Spiderman, so he'll always have that.

Wife: Ah, well, that is cool!

Geek: Darn right.

Wife: Some Geek People out there seem to know who you are also...what actor are you in this analogy?

Geek: I'm Bruce Campbell, of course.

Wife: Who?

Geek: Exactly.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Is Microsoft losing the Alpha Geeks?

May 21, 2007 Comment on this post [70] Posted in ASP.NET | Musings | Programming | Ruby
Sponsored By

I'm here at RailsConf in Portland (where I live, so that was nice, eh). As with all conferences, in my experience, the real "conferencing" happens outside the sessions. I stopped by the ThoughtWorks booth and started chatting with a number of folks.

I've been increasingly concerned with the "Web Developer Stack" that we're (the collective We) using. I started a conversation in the ThoughtWorks booth (because they had free granola bars) where I expressed this concern, and it turned into quite a large and very spirited conversation between the ThoughWorks crowd, DHH, Martin Fowler, myself, and a pretty decent-sized crowd egging it on. It was multi-faceted chat and covered a lot of area. I haven't had so much fun at a conference in a while.

The next day, Chris Sells (unintentionally) got a crowd going that also included the ThoughtWorkers, and we talked about what Alpha Geeks want. I asked if there was a coming diaspora of the Alpha Geek towards developer tools and developer experiences that feed their passions, perhaps more than tools and experiences from Microsoft and Sun. At this conference, the general feeling was that a migration of Alpha Geeks had already started. Just as Alpha Geeks forced to develop using Waterfall migrated to more agile shops, these folks feel the same kind of migration is happening around Web Development.

I propose that newer (somtimes younger) programmers may have less "tolerance" for development pain or frustration present in existing stacks just as a frog doesn't like being thrown into a hot pot. Perhaps we older frogs are starting to notice some heat and are considering other, cooler pots to spend time in.

The one thing I learned about Rails and Rails/Ruby folks at this conferences is that they are enthusiastic and passionate. Not just because many are young (I suspect the mean age to be about 26 at this conference) but because they feel that Ruby and Rails expresses their intent in a clean and aesthetically pleasing way that avoids repetition. The code is DRY (Don't Repeat Yourself.)

In the blogosphere, David Laribee proposed a term I've heard bandied about in the last few years - ALT.NET, to describe developers like this:

What does it mean to be ALT.NET? In short it signifies:

  1. You’re the type of developer who uses what works while keeping an eye out for a better way.
  2. You reach outside the mainstream to adopt the best of any community: Open Source, Agile, Java, Ruby, etc.
  3. You’re not content with the status quo. Things can always be better expressed, more elegant and simple, more mutable, higher quality, etc.
  4. You know tools are great, but they only take you so far. It’s the principals and knowledge that really matter. The best tools are those that embed the knowledge and encourage the principals [sic] (e.g. Resharper.)
Why does this have to be ALT.NET? Why is this alternative? Seems that this should be mainstream and baked in by the tools and "dogma" that comes down from on high. Microsoft needs to make ALT.NET attitudes Mainstream.NET attitudes, through leadership, openness, and a lot more prescriptive guidance.

Rails appears to be very prescriptive. It says, by its very nature, "do it this way," but still allows developers to do creative things and extend the framework in ways not previously thought of by DHH.

It's important to remember, I think, that Rails is a Web Application Development Framework that enables one to make Web Applications that talk to Databases really fast. It's not the end-all-be-all development stack, and it's better to compare Rails to ASP.NET than it is to compare Rails to .NET proper.

That said, there's a sense of striving for true beauty, beauty in tests, beauty in expression of code, in markup, that .NET developers should drink in.

I'm an Alpha Geek, and you likely are too. I'd love to have the Ruby on Rails developer experience, the gems, the libraries, as well as the ability to bring in .NET libraries, and run the whole thing on IIS and SQL2k5. I'm not the only one who thinks this way. Sun knows it, and JRuby will (is) bringing "pure" Ruby to the Java-based datacenter.

The collective group in the discussion at RailsConf seemed to agree that Microsoft should make not just the DLR source available, but actually create a non-profit organization, ala Mozilla, and transfer the developers over to that company. They should allow commits to the code from the outside, which should help get around some of the vagaries of the GPL/LGPL licensed Ruby Test Suites. "IronRuby" should be collectively owned by the community.

Why? Because as the Wu Tang Clan said, "Protect Ya Neck." This isn't about Microsoft making money on developer tools, but rather about the platform, where the money is made. An open CLR-based implementation of Ruby on Rails would be a great way to introduce Rails into the Windows-based Enterprise, and would encourage more Alpha Geeks to code on Windows.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

ATI Radeon 9800 Vista Drivers - Flash and Windows Video Stops or Stutters

May 21, 2007 Comment on this post [13] Posted in Musings
Sponsored By

I've googled my brains out about this and I can't find anything. For some reason, on my Vista Desktop Video only plays for a few frames, then stops. Sometimes it stops completely, other times it just stutters severely. This happens in both Flash and Windows Media video.

At this point, I'm debating a new Video card. Does ANYONE else have this problem? I've tried contacting ATI and it's virtually impossible to get a straight answer from them.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.