Tech

Catching Mono

Posted in Tech on May 17th, 2009 by Brian – 2 Comments

When I was up in Bentonville, AR speaking at the Northwest Arkansas Code Camp, I came across an issue of ASP.NET Pro magazine with the title “The LAMA Stack” (short for Linux, Apache, MySQL, and ASP.NET).  The article inside turned out not to be that interesting, but the idea of using ASP.NET with an otherwise completely open-source stack certainly is.  

One of the things that is said to deter many startups or other small shops from using the Microsoft platform is the licensing cost of its products, particularly SQL Server.  But since Mono allows us to run .NET code on Linux, all of those costs can be eliminated.  Also, since the ASP.NET MVC framework was released as MS-PL (Microsoft’s most permissive open-source license), the Mono team was able to quickly integrate that into their framework as well.  

Since I want to start my own business one day, it ocurred to me that this could be a great way to leverage my existing skills, but use a modern web framework (MVC) and not have to put up a huge upfront investment.  And yes, I know about BizSpark, the program that gives startups free Microsoft software, but that deal “expires” after 3 years.  And if your business isn’t exactly booming at that point, then you may be stuck with an application that you can’t afford the licenses for.

So I decided to start experimenting with Mono to see if it was easy enough to work with that it would even be a viable option for me.  I’m not the most Linux-savvy guy in the world (as you may already be aware from reading some of my previous posts), and there was a distinct possibility that it would simply be too much of a headache for it to be worth it.  

I started out with the  VMWare image that’s available on the Mono project site (www.mono-project.com), and tried some basic “Hello, World” stuff, and that worked just fine.  Even getting an app running under Apache rather than the MonoDevelop IDE was really easy with the AutoConfiguration feature they’ve implemented.  The problem started when I tried to run an MVC app under Apache.  Because AutoConfiguration depends on the ASP.NET file extensions (“.aspx” et al.) to work, and MVC apps avoid those extensions, they can’t be used together, so I had to delve into defining an Apache virtual host for the MVC app.  Thankfully, the Mono team has provided a great tool for generating most of the boilerplate configuration for a Mono ASP.NET app on the project site (http://go-mono.com/config-mod-mono/).  

The next problem was that the version of Mono that supports MVC (v. 2.4) wasn’t available yet on the Linux distribution that I run, Ubuntu, which only has a package published for version 2.2.  That meant that I would need to compile Mono and several other tools from source, which is a somewhat daunting proposition for someone not very experienced with compilation on a Linux system.  I found a great resource for this, though, on the blog of a BlogEngine.NET team member named Russell (couldn’t find his last name) here: http://blog.ruski.co.za/page/Install-Mono-on-Ubuntu.aspx.  This post gives step-by-step instructions on getting Mono 2.4 running on Ubuntu, and without it, I would probably still be banging my head against the wall.

After much trial and error, I finally achieved my desired result.  I was able to run an ASP.NET application that was created and compiled in Visual Studio on Windows, copied over to a Linux machine and executed under Mono.  It wasn’t the most frictionless experience in the world, by any means, but after having done it once, I think subsequent apps will be easy enough to set up.  I’ll be doing the setup process at least one more time in the near future; I’d like to get Mono apps running on the servers we have set up for the new open-source shared interest group that I’ve recently joined with several other Praeses employees, which we’ve decided to call Samurai Delicatessen ;-) .  If I can manage to do the setup remotely over SSH, I think I can safely say it’s a stack that I’ll be able to handle using in the future.

January SDNUG Meeting

Posted in Tech on January 26th, 2009 by Brian – 2 Comments

Last Monday (yeah, I know, I’m a week behind), the Shreveport .NET User Group for the first time this year.  I have to say, I think it went much better than last time.  Not only did we have an experienced speaker in David Penton, but we actuall had pizza, too!  Seriously, Brandy at Software and Services did a great job coordinating the food and drinks, and things went off without a hitch.

Everyone seemed to enjoy David’s talk on HttpRuntime.Cache Management.  All 8s and higher on the evaluations!  If you’d like to see his presentation slides and sample code, check it out here, or you can download it from the SDNUG site here.

Next month, we’re going to have another Microsoft MVP (and newly minted INETA speaker), Tim Rayburn come out and speak about parallelism features in .NET 4.0, which ought to be really interesting.  Come out and join us on February 16th at Centenary College!

A New Cert and a New Toy

Posted in Tech on December 16th, 2008 by Brian – Be the first to comment

On Dec. 2nd, I passed my second Microsoft exam, 70-536 – Application Development Foundation.  The test was honestly more difficult than I expected it to be.  When I started studying for it I thought, “Foundation… well, I’ve been programming in .NET for about 2-3 years, so I figure I’m probably good on the ‘foundation.’”  Well, it turns out, “foundation” didn’t really mean what I thought.  Based on the subject matters covered on the exam, I have deduced that foundation in this case means “APIs that you’ve never used before professionally and may never have occasion to, but ones that we feel are important enough for you to know down to parameter order.”  A large part of the exam covered Code Access Security, which honestly still confuses me, and for which I continue to try to find a reasonable use case.  I’m sure one is out there, and it may have greater usefulness in the desktop realm, but for me right now in ASP.NET land, it seemed like an odd choice of emphasis.

I didn’t do nearly as well on the test as I would have liked, but, hey, a pass is a pass, right?  I think my initial thoughts about how difficult the test would be caused me to study a bit less than I should have.

But I did pass, and so afterward, I got myself a new toy.  That’s right folks, I am the proud owner of a new iPhone 3G (16Gb).  I’ve been wanting a smartphone for a while, and my account was finally eligible for a phone upgrade.  My old phone, a Motorola L6… well, let’s just say if the iPhone is “smart”, the L6 would be on the mobile phone short-bus.

Having never owned a smartphone before, I didn’t come into things with the expectations or priorities of a veteran WinMo user, and I have to say, I’m quite satisfied.  The three things I wanted out of my new phone were: 1. mobile access to email, 2. mobile web browsing, and 3. ability to hold all my music and podcasts so I can eliminate a separate device from my life. The iPhone does all three of those things to my complete satisfaction.  Everything else is just a bonus, really.  One of the things I was pleasantly surprised about is how well I’m now able to keep up with my RSS feed reading.  I don’t have to actually be sitting down at a PC to keep that “Unread” total to a manageable number.

The one thing that I had reservations about was the ability to program the device.  Since I’m a developer, I’m used to being able to write small tools for myself if I can’t find something out there that fits my needs, but it’s not quite as easy to do this for the iPhone as it would be if I had gotten a Windows Mobile device.  The only Mac I have is currently hooked up to my TV as a media server, and programming over VNC is not really the best experience.  Plus, I’d have to learn Objective C and the Cocoa Touch library, and that’s just one more thing that I probably don’t have time for.  I’m excited to see what Miguel de Icaza and the Mono team are doing to get .NET code running on the iPhone, and I’m looking forward to being able to write in a language that’s familiar to me at some point.  They’re doing it in a legit way, don’t worry.  They get around the “no JITed code” device restriction by using a static linker (I believe that’s the correct term), so that the code that’s executed is 100% native instructions.

Once I’ve had the device a bit longer, I may have some more comments, and be able to list of my favorite apps.  Right now, though, I have to get my two newest WoW characters to level 60 before the account link runs out!

Adventures with Forks, Boxes, and Ibexes

Posted in Tech on November 26th, 2008 by Brian – 4 Comments

As I’ve posted before, I’ve been trying to help my pastor with a church management system written in Rails, but I’ve been hitting some roadblocks.  First, I tried developing on my Mac Mini, since Macs are what all the cool kids use to develop for Rails.  Well, that Mini ended up being a media machine, and developing using a television as a monitor was not very pleasant. It’s not an HDTV, and so only capable of 800×600, but even at that resolution, the screen is practically unreadable. 

The most convenient thing for me to do would be to develop on my laptop, since I can take it with me and work with Lowell (my pastor) up at the church on the system when I have problems.  So, I started trying to get the app set up on my Windows machine.  This actually worked fine for a while, but then Lowell ended up adding a couple of gems called “starling” and “workling” that basically create a task queue that you can farm out long-running tasks to.  It works great on Lowell’s Mac and in the production environment.  However, I soon discovered that starling uses “fork()” to achieve its ends, which meant a no-go for me on my Windows machine.

Since I can’t exactly install OSX on my laptop, the only option left was Linux.  As I’ve written about before, at one point I had Ubuntu installed on a partition on my laptop, so I’d been down that road before.  However, I had actually recently removed the Linux install, since I really wasn’t doing anything with it, so I had to go through the install process again (which is actually not all that bad on Ubuntu, for what it’s worth).  I installed Ubuntu version 8.10 (Intrepid Ibex) on a 15 Gb partition and began the environment setup process.

The very next day at work, a coworker happened to mention a virtualization tool he was using called VirtualBox.  I can’t believe I hadn’t heard about this thing before.  I knew about Virtual PC, which Microsoft now gives away for free, but that obviously only allows Windows guest OSes.  VMWare does have a free VM “player” that supports different kinds of guests that they give away, but as far as I know the tools you have to use to create a VM cost money. VirtualBox, developed by Sun, is completely free and allows for a whole slew of both host and guest OSes.  Anywho, I gave it a try, and I was very impressed.  It’s quite performant, and has support for just about everything I think I’d want (networking, USB devices, etc).  Another nice feature is that the virtual disk file can be set up to grow dynamically so that the VM is only taking up the space it needs; no more, no less.

It then became obvious that the 15 Gb partition I was using for my Ubuntu install was kind of a waste of space.  So I started the process of removing the partition I had added just days before.  I want to record what I did to achieve this, mostly as a record for myself in case I need to do it again later.  I used a free tool called GParted, which comes as a bootable CD image, to delete the partition Ubuntu was installed on and resize the main partition to take up the newly freed space.  After that comes the part that I usually forget, which is fix the master boot record.  When you install Ubuntu, you get this thing called GRUB, which is a boot loader that will let you choose which OS to boot up when you turn on your machine.  When you delete the partition with Linux on it, GRUB freaks out and won’t load up an OS.  To fix this, you need your Windows install CD.  Boot from the CD, then (depending on your version of Windows) either start a Recovery Console (XP), or choose “Repair Computer” and then open a console (Vista).  On XP, type “fixmbr” (no quotes), and on Vista, type “bootrec /FixMbr” (again, no quotes).  This will repair your master boot record, and you should be all set after a restart.

Since I’ve been having all this fun the past couple of evenings, I have not gotten as much sleep as I need.  I’m greatly looking forward to the two holidays off work I’ve got coming, as I’m sure you all are.  I hope everyone has a happy Thanksgiving!

November SDNUG Meeting and My First Presentation

Posted in Tech on November 21st, 2008 by Brian – 1 Comment

The whole meeting this past Monday was kind of an interesting experience for a couple of reasons.  First of all, the pizza never showed up.  I confirmed with the sponsor earlier in the day, but once we had been waiting in the room for about 20 minutes, it was clear there wasn’t going to be any food that night.  It was an honest mistake on the sponsor’s part, but I think I’m going to do things a bit differently from now on.  If I (or another group leader) pay for the pizza, we can be sure it’s going to be there, and I can just work out reimbursement with the sponsor later on.  That way, if there are issues, I’m the only one who has to deal with them, and the group gets to eat.

Also, it was my first time to present at a User Group meeting.  My talk was titled “Debugging Evolved:  An Introduction to Automated Unit Testing”.  I used Roy Osherove’s forthcoming book on the subject, “The Art of Unit Testing”, as an inspiration for the topics I covered, and I highly recommend it.  It’s not due to be published until March ’09, but the unedited draft is available in PDF format through Manning’s MEAP program.  I learned several things based on the experience, plus the feedback I got from the group members.  For one thing, Comp Sci students and user group members are two very different audiences.  This may sound obvious, but it was important in my case. 

I was scheduled to go on a recruiting trip to Harding, my alma mater, around the same time as the November meeting, so I figured I’d kill two birds with one stone.  I wished we had covered automated unit testing in school, so I wanted to give the students there some exposure.  Also, I wanted to be able to bring in some speakers to the Shreveport DNUG to speak on TDD and related practices, but I wanted to make sure that the members had had some exposure to testing frameworks so they wouldn’t get caught up on tools during a presentation on what is really a design topic (TDD, BDD, etc).  I wanted to avoid the scenario of the first Fort Smith DNUG meeting, where we had a great topic and speaker (Raymond Lewallen on BDD), but a lot of people there had never seen a testing framework before, and I think they may have had a hard time following the presentation. 

In the process of creating my talk, however, I had to try to balance the content for students (some of whom had never seen a managed language before, let alone a testing framework in .NET) and the experienced developers at the Shreveport .NET User Group.  In the end, I think it might have been a better idea to do two different presentations, or at least have a much more fleshed out version for SDNUG.  I think a lot of the stuff I was talking about went over the students’ heads, but I got the impression the SDNUG members (understandably) wanted a bit deeper dive into more practical scenarios and potential business value of unit testing. 

I also learned that I need to work on my presentation skills.  I pretty much expected that, though, given that I haven’t given a public presentation since college.  One of the feedback forms I got suggested that I start attending the local Toastmasters group (which is actually held in the same building where I work).  I’ve been to one meeting, but the heavy emphasis on procedure kind of turned me off.  I realize that it’s there to help you learn how to behave appropriately on occasions where such procedure is the standard, but it just seemed a little silly to have someone introduce the person who was going to be introducing everyone else when there were about six or seven people in the room.  I will admit, though, it’s probably a good idea if I’m going to be presenting with any frequency in the future.

Though it was far from the optimal situation, I hope that both the user group members and the Harding students

enjoyed the exposure to unit testing, and that it will pay off when SDNUG brings in some speakers on some more advanced topics.

Why Developers Hate Security

Posted in Tech on October 15th, 2008 by Brian – Be the first to comment

I’m working on my 70-536 (Application Development Foundation) certification right now, and yesterday I was schlogging through the multiple chapters on different types of security.  (And by the way does anyone actually use Code Access Security? Bleh.)  It occurred to me as I was reading why I didn’t like dealing with security-related issues. 

As a developer, my primary goal is to make software that is useful to people.  Nothing makes me happier than when someone enjoys using somthing that I built.  When I do things to expressly prevent people from using my stuff, I feel like I’m working directly against that motivation.  I think a lot of developers probably feel the same way, and that may be why security has a reputation as being unpleasant to work on. 

Consequently, it ends up getting pushed to the end of a project, or even ignored entirely.  Unfortunately, I can’t think of a way to make this more enjoyable. But hey, some people hate all aspects of their jobs, so I feel lucky that I really enjoy most of the things I get to do in mine.

Repaving Sucks

Posted in Tech on October 11th, 2008 by Brian – 1 Comment

During the LSU-Florida game this evening, right around the time it became apparrent that the Tigers were not going to come from behind and win as seems to be their preferred way of doing things, my laptop froze up.  I was working on a new website for the Shreveport .NET User Group using the new MVC framework (plus Dynamic Data for CRUD operations), and I was testing on my local machine with Chrome, and when I tried to open a new tab at one point, everything screeched to a halt.

“No problem,” I thought.  ”This has happened before.”  I am a Windows user, after all. Wink  So I forced a hard shutdown, and booted back up.  After I logged on, everything seemed to start up fine, but when I clicked on a link in my quick launch, everything froze up again.  After I repeated this process several times with the same results, I acknowledged that there might be something genuinely wrong here.  Booting up in Safe Mode, I tried doing a chkdsk, then a System Restore.  Neither seemed to fix the problem.

I was beginning to suspect a hardware problem (which there might actually yet be, the jury’s still out), but I did notice that things seemed to work fine in Safe Mode.  ”Well,” I thought, “things were starting to feel a little cluttered anyway.”  So, I bit the bullet and copied Rachel’s and my User directories to an external hard drive and began the repave.

As I sit and watch the Windows install screen, I pray to the Hardware gods that they might be merciful to me and my laptop, and that all my trials may be Software Related.  Please join me in my supplication.

First Shreveport .NET User Group Meeting

Posted in Tech on August 21st, 2008 by Brian – 2 Comments

We’re finally off the ground!  On Monday August 18th, the Shreveport .NET User Group held its first meeting in the science lecture auditorium at Centenary College.  We had 26 people in attendance, and Chris Koenig, developer evangelist from Microsoft, gave a great presentation on Silverlight 2.0.  I thought he struck a good balance between high-level feature descriptions and technical detail.  (I think the feedback forms bore this out; the few suggestions for Chris were about half “too detailed” and half “more detail.” ;-)  )

The projector situation kind of made me sweat for a bit.  The one in the room hadn’t been working, and I couldn’t get the spare one I brought to work right.  Fortunately, the AV crew at Centenary was there about an hour before the meeting, and had the projector working by the time they left (about 15 minutes before people started showing up).  Other than that, there weren’t any logistical difficulties to speak of.

Chris also gave us some great stuff from Microsoft for door prizes at the next few meeting, including a licenses for Visual Studio, Office, and Vista Ultimate, so we’ll have some pretty high-dollar stuff to give away.  In addition, we’ve got some books coming from Microsoft Press and O’Reilly.

In retrospect, getting swag from software vendors was just about the easiest part of the process, and finding a good (read: “free”) location turned out to be the hardest part.  What I really need to work on, though, is delegating some of the administrative tasks to other people.  Chad Morgan and Chris Benard both helped out a lot with making this thing happen, but I probably should have recruited more help.  On Chris’s Koenig’s advice, we may institute specific roles for people who want to be involved with leading the group.  Someone to handle swag, someone to coordinate with the venue, someone to find local sponsors so we can continue to have pizza, etc.

All in all, I think it went pretty well, and we’ve at least got a start at increasing the level of involvement of local .NET developers in the programming community.

ASP.NET MVC Reusability Revisited

Posted in Tech on July 18th, 2008 by Brian – Be the first to comment

A few weeks ago, I wrote a post about the lack of a mechanism to seperate a unit of both logic and presentation (like a UserControl in WebForms) in ASP.NET MVC.� Well, it turns out that Rob Conery had actually come up with something called a ComponentController that took care of that, and used it in his MVC Storefront application.� (Note to self: need to catch up on those videos he’s making.)�

It actually took the removal of that feature in Preview 4 to alert me that it existed.� Not to fear, though, it’s been replaced by something called RenderAction, which will allow you to call a regular old controller action from a view like so:

<% Html.RenderAction(x=>x.MyControllerAction()) %>

Isn’t that awesome?  I sure think so.  Be warned, though, this particular feature may be even more likely to be changed than the rest of the MVC framework.  It’s part of a separate assembly called Microsoft.Web.Mvc.dll.  Stuff in there won’t be in the initial RTM, but in a future release of the framework.

Phil Haack has some reservations about this violating the purity of the MVC pattern, so I think the likelihood that this will change is close to 100%.  They’re working on some other ideas, though, so hopefully the MVC team will come up with some magic that better adheres to a mindset of separation of concerns.

For the moment, though, I’m happy!  :-)

How I Got Started in Programming

Posted in Tech on July 13th, 2008 by Brian – 2 Comments

I haven’t really been tagged, per se, but enough of my blogroll has participated in this meme, so I thought I’d weigh in.

How old were you when you started programming?

I was about 10, I think. Read on for the details…

How did you get started in programming?

A year or two after my dad bought us an Apple IIgs, I pulled out the BASIC book that came with the computer.  As many people did, I just started typing in the programs listed in the book.  Not everything worked on the first try, I would usually make a typo or two as I transcribed the code.  When I got to the checkbook balancing program, I tried for days to get it to work correctly, but failed.  I got so frustrated that I just put the book down and never picked it up again.  It turns out that I wouldn’t program again until I got to college.  The enjoyment I got out of the programs that I did get to work stayed with me, though.  Enough that I knew by the time I graduated from high school that I wanted to major in computer science.

What was your first language?

This seems to be just about the same for every person who answers this question:  some flavor of BASIC.� I have to say though, I think C++ (the first language I coded in at college) had more influence on the way I think about programming.  Maybe that’s why I chafed at having to use VB at my previous workplace;  C# just seems more natural.  I need them curly braces!  :-)

What was the first real program that you wrote?

I’m not exactly sure what “real” means in this case.  I’ll take it to mean, “having some actual value outside of academic exercise,” in which case the first one would have to be my senior capstone project, Shticks.  At Harding, every semester the participating seniors are split into teams and given a board game to turn into a computer game.  Our semester, it was a game called Creeper, published by Out of the Box Games.  (You may know them as the publisher of Apples to Apples.)  We used a Flash control hosted in a C# WinForm.  The game engine, AI, networking, etc. were coded in C#, and the animations and presentation logic in ActionScript.  (Yeah, I know, yikes.)

What languages have you used since you started programming?

I feel I need to distinguish languages I only used in college from language’s I’ve used in real-world projects.� In college only: C++, Perl, Java, x86 Assembly.  Real-world: C#, VB.NET, JavaScript, COBOL, VBScript, PHP, and currently learning Ruby to help out my church with a Rails-based church management system.

What was your first professional programming gig?

I got my first programming job right out of college, at a company called Data-Tronics, the in-house IT shop for Arkansas Best Freight.  I did lots of mainframe COBOL, quite a bit of classic ASP, and some VB.NET, all related to the transportation industry.  I worked there until about two months ago, with some of the nicest people I’ve ever met.

If you knew what you know now, would you have started programming?

Absolutely!  I think that I wouldn’t have taken the break between 10 and 18.  I also wouldn’t have waited as long to really tune in to the programming community, which I only did about a year and a half ago.  Before that it was just kind of a job.� One that I enjoyed, more or less, but not one that I was truly passionate about.  I have to credit Dot Net Rocks, Hanselminutes, and Jeff Atwood of codinghorror.com for being my gateway drugs, showing me that building software was something that I truly could be passionate about.

If there was one thing you learned along the way that you would tell new developers, what would it be?

Plug in to the community.  Read blogs, listen to podcasts, go to user group meetings, start your own blog.  You can get so much more out of software development than just a paycheck if you’re willing to put in just a small bit of extra effort.

What’s the most fun you’ve ever had… programming?

I have to say, making that game in college was a blast.  It was my first taste of building something of substantial size and something that other people could (theoretically) use.  Plus, making games is just fun anyway.  :-)

Tag, you’re it!

I’ve enjoyed hearing other people’s stories, so I think I ought to keep this going.  I’m going to call out: