SimpleVM Improvements

Tomorrow I’ll be teaching a class on virtual machines. This particular teaching opportunity spawned the creation of SimpleVM as a way for me to get reacquainted to the pitfalls of writing VM’s. I’ve learned (or re-learned) a lot from working on this the last couple of weeks. SimpleVM now even has support for some basic arrays. You can’t nest arrays yet but that’s coming as well as mutability for arrays. Actually mutability may be up for discussion.

Right now, in order to create an array the use pushes however many items they want onto the stack and then another field that represents the number of items to take from the stack to create the array with. This seems to work well for now but some of the magic in the structures prevents me from nesting arrays for now. I’ve also got an operator for getting an array’s length as well as getting at a particular index of an array. Later I might add some way to mutate arrays but if I decide against that I’ll have to create a way to easily clone arrays so that changes can manifest by way of creating a new copy with the necessary changes. I’m not sure how sane this is yet but we’ll see.

Working on implementing arrays was actually the most difficult part so far in working on SimpleVM. There were several things I hadn’t thought through well and had to be modified in order to support arrays. Oddly enough I hadn’t actually thought to implement arrays until I started thinking about how objects would be implemented. Since I’m not familiar with how object systems are designed/implemented in languages, the first thing I could really think of as a solution is some sort of symbol table magic in the compiler that uses hash tables to access fields of an object and where the table itself was the object. This is probably a pretty naive way to do this but its the best I’ve got right now and I probably won’t have a better idea of what will work till I’ve had time to write a compiler that targets SimpleVM.

Its late though and it will be a busy week. Perhaps I’ll get around to digging deeper into this once I’m done with all this work and school.

Introducing SimpleVM

In the last 24 hours I’ve hacked up about 500 lines of code to build a simple virtual machine. It exists as a platform for teaching some basic techniques used in virtual machine implementation. This work stemmed from my time spent in a programming languages course this semester. My professor asked if I might teach a class or two about virtual machines as an area I’m especially interested in, more so than he.

I’d like SimpleVM to eventually contain multiple techniques for doing code execution. The first I implemented was actually a method I hadn’t tried implementing, goto dispatch. That is each operation is associated with a goto label and control flow just runs through goto’s rather than doing case matches to test what operation should be done. SimpleVM is a stack machine now, most opcodes take no associated data. Only PUSH, LOAD, STORE and JMP operations take arguments, everything else works on stack effects. That said, I’ve designed SimpleVM this way because I’ve been playing in Forth & Factor a lot lately so stack effects have been on my brain. I’d like to write a compiler for a basic Forth-like language that will translate to the assembly code in SimpleVM. We’ll see how long my interest in this particular VM sticks :) .

In the future I will add memory management and/or garbage collection as well as fix the jump map implementation. For whatever reason
was misbehaving and not retaining values I added to it so now the jump map is more of a jump list which does a linear search for line numbers associated with labels. This is stupid, I know but it solved my problem for now. I’ll investigate the
weirdness later.

If you’re interested in the SimpleVM code, its available at: http://github.com/zacbrown/simplevm

The code compiles on Linux and Mac OS X. It should compile on Windows as well with little effort, its mostly C with a smattering of C++ where it was convenient to use , and .

On the usefulness of Mac OS X’s Console Application

I have been spending a lot of time building packages in MacPorts for various things I need for work. Examples include ImageMagick and friends for using the rmagick gem with Ruby as well as building the ATLAS linear algebra library for use with Shogun (a machine learning toolbox of sorts).

Some of these things take forever to build *ahem* ATLAS *cough* so I periodically check to make sure the program hasn’t hung by checking Activity Monitor.app. During this time period I noticed ReportCrash repeatedly spiking to 100+%. This got me suspicious as I suspected something awry. So I dug around in Console.app, the tool for sanely checking your logs, and discovered to my dismay that something related to X11 was repeatedly crashing. A little more digging and I discovered it was a mistake I’d made with my DYLD_LIBRARY_PATH variable and overwriting OS X’s default libjpeg with one built in MacPorts. After fixing that, I was off to the races or something like that anyway.

The point of the matter is its nice to have something like Console.app. The hardcore *nix user in me tells me thats bollocks and that I should just be using cat and tail on the logs… but I must say accesing it this way was far more readable.

Try it out some time if you’re smelling suspicious behavior :) .

Installing Yi on Mac OS X

A little gotcha I ran into after following Jan Varwig’s tutorial on installing Cabal & friends on Mac OS X and then subsequently trying to install Yi.

When doing “cabal install yi”, cabal won’t find “alex” if you haven’t got $HOME/.cabal/bin in your $PATH. By adding it your $PATH, cabal will then nicely finish installation and go on its merry way.

MacBook

So, in my infinite wisdom and grace managed to slap a cup of water onto my 6-month old ThinkPad last Thursday. To say this was a bother, is well… an understatement. I did all the necessary precautionary things like shutting it down, pulling out the battery, dismantling it and generally just trying to take care of it.

However, I did need some files off of it so I let it dry out for a few hours, booted it up (was kinda surprsed it did), then proceeded to copy off those files I needed. In the mean time, I was stuck sharing a laptop with the girlfriend which was not really a good setup as I tend to customize everything to my liking.

All the while, I had been secretly wishing that I had a Mac of some sort. I’ve started to get into more development that would be made easier by using Mac, I was tired of fighting with Linux for a half-assed *nix solution on a laptop, and the Windows CLI just isn’t good enough.

Which brings us to Friday night, when I bought a MacBook. Basic White model, the new one though with 802.11 a/b/g/n and the Nvidia 9400m graphics chipset. I’m loving it. Its an excellent computer. Its nice to have a decent command line interface and now that I’ve got it configured the way I like it, I’m not sure I’ll willingly use any other hardware for laptops at least.

Hopefully though, my ThinkPad will recover and then I can give it to my dad to use. That would be nice. Hopefully :)

Ruby…

In the past I’ve vehemently argued against using Ruby. My encounters with it had shown a shoddy VM, decent libraries but my greatest grievance was the lack of any clear standard. It was really just whatever Matz felt like, or at least that was my understanding. Others may correct me if I’m wrong.

Despite my distaste for Ruby I always sensed that at some point I would pick it up when it became clear that the language was stabilizing, the VM was ready for the big leagues and when I actually had some time to make sure my past encounters weren’t just issues of my own ignorance (which I’m prone to as much as anyone else).

That said, I am picking up some Ruby now and am enjoying it. Unlike most these days, my primary interest wasn’t in Rails/Merb or I guess what is now “Rails 3″ but rather _why’s Shoes framework. I have long been irritated by GUI programming. In almost every language it feels incredibly… unwieldy (I think thats the word I want to use). It seemed as though no matter the language and how graceful it generally is to work with, there were always things that made its GUI toolkit interfaces ugly to work with.

Shoes on the other hand has been quite enjoyable. Its minimal and still has a ways to go but in a couple days I was able to learn enough Ruby and enough of how the Shoes framework works to write a pretty simple application to solve a long-standing issue that my mother has had with trying to copy her music to her MP3 player. She’s not well suited to navigating multiple Windows Explorer windows and copy/pasting her way to victory. With that, I wrote a really simple Shoes app that basically shows two panes, the “all the music you have” pane and the “music thats on your MP3 player” pane. It only shows files not already on her MP3 player so you just click the file you want and it will “move” the file in the window to the other pane as well as actually copying the file.

If anyone is interested in this brain dead app, I’ll post it later once I’ve attached all the license information for it, etc.

Vista Media Streaming

I recently built a new media center PC. I’ve wanted one for a while along with also wanting a computer that would be capable of playing the “Latest and Greatest” computer games. The specs looks something like this:

  • Processor: AMD Athlon X2 6000+ (2 x 3.10 GHz)
  • Motherboard: Foxconn A7GM-S – a good motherboard, has integrated HDMI though I have a vid card with that too
  • Video Card: Power Color AX4830 (ATI Radeon 4830 with 512 MB DDR3 + HDMI audio/video)
  • Memory: 4 GB, soon to be 8 GB whenever I get my hands on x64 Vista or Windows 7
  • TV Card: Hauppage HVR-2250 – dual digital/analog tuner with an MCE remote
  • HDD: Western Digital Caviar 640GB w/ 16MB cache
  • Operating System: Windows Vista Ultimate x32 using Vista Media Center to record the TV stuff. Gotta say, thats some brain dead simple software to setup with my TV card.

Obviously not the best computer on the market but it can play Fallout 3 on Ultra High settings and I can’t seem to really slow it down. I anticipate an upgrade this summer whenever the novelty of the Phenom II chip comes down a bit. This new computer fits both niches nicely though I did find an interesting caveat with streaming my recorded TV to other computers in the house.

I don’t always like to be in the study watching TV, partly because my Dad works in there as well so unless its fairly late at night I can’t watch things I’ve recorded. In these cases I head to my room with my laptop. My laptop has Vista Enterprise on it and it immediately picked up the media sharing of my desktop/htpc.

However whenever I tried to play an episode of Southpark I found I was only getting audio, no video output whatsoever. My first suspicion was that the files were to big to be transferring over wireless at a rate that would transfer video but after thinking about that a moment I realized that was idiotic as it would have shown the video in some choppy fashion.

After some cryptic searching on Google I found that I was missing the DScaler MPEG Filter for Windows Media Player. After installing this codec, I was getting video playback fine. It seems odd to me that with all this media sharing between the different computers that Vista does so well that it doesn’t include the codecs to playback the PVR files recorded by Vista Ultimate or Home Premium.

So with that, I make a humble request to the group in charge of Media Center or the Media Codecs (in fact the team I’ll be on next summer as an Intern):

Dear Future Employer:

Will you please include this codec on all versions of the operating system in the future. It would make life a lot nicer for those of us not using the same version of Windows on all our computers. Kthxbai.

With love,

Your humble (future) minion

To Do for December 2008 – Revisited

This is my brief todo list for December 2008 revisited, also known as the first vacation I’ve had since I started college.

  1. Build the new PC I bought and get Windows Vista Ultimate (Super Fantastic) Media Center running.
  2. Turn 21 and become a drunkard overnight (hah). (T-minus 2 hours)
  3. Reinstall the laptop to repartition the operating systems. In the process of this, also install Ubuntu 8.10. (Still haven’t done this… will wait till I’m done with a few things.)
  4. Play a lot of video games. (Bought the two Guild Wars expansions, Factions and Nightfall)
  5. Sleep… this hasn’t been consistently done in a long time. (Still need more of this)
  6. Learn C++ better, especially proper template design. (Heh, this is work, haven’t started on that yet.)
  7. Finish leftover things for my bioinformatics research work. That is, build a database for the organisms for doing phylogenetic classification. Maybe play more with SVM’s…  (Same as 6)
  8. Sleep more. (Working on it)
  9. Play more games. (Working on this too)
  10. Setup the new Roku Soundbridge M1001 I bought for my parents for Christmas. (Have to return the one I ordered and wait till they have more of these available….)

There are probably other things that should be on here… like my senior project work. I suspect I’ll start that Tuesday as tomorrow is my birthday and I will be eating and drinking merrily.

To Do for December 2008

This is my brief todo list for December 2008, also known as the first vacation I’ve had since I started college.

  1. Build the new PC I bought and get Windows Vista Ultimate (Super Fantastic) Media Center running.
  2. Turn 21 and become a drunkard overnight (hah).
  3. Reinstall the laptop to repartition the operating systems. In the process of this, also install Ubuntu 8.10.
  4. Play a lot of video games.
  5. Sleep… this hasn’t been consistently done in a long time.
  6. Learn C++ better, especially proper template design.
  7. Finish leftover things for my bioinformatics research work. That is, build a database for the organisms for doing phylogenetic classification. Maybe play more with SVM’s… 
  8. Sleep more.
  9. Play more games.
  10. Setup the new Roku Soundbridge M1001 I bought for my parents for Christmas.

WEX: Devices and Media – SDET

The title of this blog post is the official team I’ll be joining next May at Microsoft as an Intern (and hopefully fulltime after that). It turned out that after my interviews at the beginning of November, each team expressed interest in having me join their teams (I didn’t really think they all would).

The teams I’d chosen to interview with before I flew up were FNO (Find and Organize), CoreUX, and DNM (Devices & Media). Originally my interests in each group were roughly in the aforementioned order. That is I was most interested in working for FNO and least interested in DNM. As I spent more time learning about DNM and what they do, it became apparent that I’d learn more there than I would in any other group.

Each group was interesting in its own ways. FNO has a very young group of developers and is a very high energy group. They own the Explorer and Desktop interfaces with anything that has to do with file manipulation included in that. They also own the indexing service used for desktop search. Had I chosen to work with that group, I probably would have tried to get in on the indexing side of things. Its a lot of coding (what I like) and its at the core of my interest in that group.

CoreUX on the other hand owns the start/taskbar, the window framing, sidebar, and so on. Things that make Windows look like… well Windows. The team members I met with were all very encouraging and a group of really interesting individuals. Their manager, John Cable, was the guy I interviewed with during my first round interviews and was indispensible to me through the whole process in helping me make decisions about my time with Microsoft.

Finally, DNM manages the pipelines that serve up audio/video to the screen and speakers, interfacing with devices like the Zune, cellphones, bluetooth devices and things like the Roku (look it up, its sweet). They are a “foundation” team, meaning that a lot of other groups in WEX build on top of what they provide. For example, CoreUX is in control of Windows Media Player which has to use the media technologies supported/owned by DNM. This type of exposure to different technologies inside Microsoft as well as outside (like Roku) is what attracts me to the team. They get a lot of face time with a lot of products which means there will never be too little for me to learn. 

Since I will be at Microsoft to learn, I figure picking a group like DNM is a good way to learn a lot. Thats not to say I wouldn’t learn anything in the other groups. I just feel that at the point that I am now with my education, my weakest points are in the areas that DNM is focused and in the end would provide me with the most “bang for my/their buck” in my time at Microsoft. Hopefully that time will be a long time as the culture is very attractive.