aboutme
Hi! My name is Mitchell Hashimoto, a computer science student at the University of Washington. I am a developer for CitrusByte and do some work for Zend. This is my blog where I write about my recent work, life, and thoughts. More about me »

From The Blog

Oct
30

Lua, a Taste of Genius

Posted at 10:36 PM by Mitchell Hashimoto

I’m going off my normal web development track here to just mention something which happens very very rarely. Let me start by making an outrageous claim: Lua is a work of a genius. If that interested you at all or if you just want to see how I support this claim, then please continue reading. Otherwise… read anyways? ;)

A project (which has to do with the web, really!) which I’m currently working on personally has some backend written in C which is pluginnable using Lua. Originally this was in Ruby with… plugins being in Ruby, but Ruby is… like… impossible to sandbox. All Ruby has is crappy $SAFE levels. So I made the decision, a little late (after the tool was written), to rewrite it using old fashioned C and Lua, since Lua was built for these things.

Let me throw up a quick disclaimer and assure everyone that I’ve never used Lua extensively. But I do play World of Warcraft quite a bit (shame on me!) and I know that their addons are written in Lua, and through a few google searches I’ve come to find that a lot of big name companies use it for plugins. It is what Lua was made for afterall.

First of all… Lua the language itself is pretty cool. Its functional, it can be object oriented, it supports these wacky but powerful things called coroutines, and its fast (for a scripted language). It has a few things that take a while to get used to (metatables et al), but I picked it up in about 2 hours.

Next, Lua was built in mind with being a super light-weight, extensible language built for plug-in type jobs. So it comes with basically no standard libraries straight out of the box, you’re expected to add them in via the C API. Doing this is super simple…

OKAY BLAH! ON TO WHY ITS SO GENIUS…

It uses this really ingenious idea of a stack to store everything. Want to call a function? Push the function name onto the Lua stack, followed by the arguments, call the function. So they’re not genius for coming up with this idea, since this is all that computers do under the covers with every application, but they’re genius for choosing to use it to talk with C. Why? Because what I would have done is come up with a ton of nice little functions like “lua_call_func(name, …)” where … are the args to cover up all the dirty internals. But then… how would you know the types of the variables given? How would Lua know whether to garbage collect them? (It is a garbage collected language) Plus, Lua has some abstract types like “tables” which can get even more abstract with metatables! Ahhh!

Using a stack keeps it simple stupid! There are only a few types you can push onto a stack (integer, string, nil, c function, basically). Then using various tricks of the stack, complicated structures can be created such as entire objects with inheritance, private variables, and more, using… 3 data types? AWESOME.

And I never have to think whether I own the memory or Lua. I know that whatever I push onto a stack, Lua owns. I may have to pop it myself but I can free my HEAP-allocated memory after pushing it onto the stack. I never have to question anything.

Anyways, that was my quick 5-minute unedited heart-pouring to Lua. :)

time Posted at 10:36 PM | written Written by Mitchell Hashimoto | comments No Comments made.

latest blog entries

Aug
31

Bye Textmate. Hello Emacs.

Just a quick post to let you all know I’ve given up TextMate and have gone full emacs for my text editing needs.

Hint for OS X Users: Did you know in the “Keyboard and Mouse” section of your system preference you can remap your control keys? Well if you plan on using emacs I highly recommend you remap your caps lock key to control, it will make using emacs much more enjoyable :P

And to those who wish to start a vim vs emacs war: I chose emacs since it has an “official” erlang mode which is distributed with the erlang source.

time Posted at 1:14 AM | written Written by Mitchell Hashimoto | comments 8 Comments made.
Jul
26

iPhone 2.0 - Unacceptable Quality

I feel terrible as I type this post right now. I’m an avid Apple user, I’ve had my MacBook pro since it came out (it is the original!) and I’ve had iPods and everything in between. I also got an iPhone later last year after becoming an Apple Store retail employee.

This year I decided to sit out and get the iPhone 3G! It was a lot of fun sitting out and was quite an experience but unfortunately the phone itself does not deliver.

In addition to getting the iPhone 3G I had been acquainted to the iPhone 2.0 software early since I was in the developer program. When I heard that the build number on the 3G was the same as last beta of the iPhone 2.0 software, I was terrified. My beta build was riddled with crashes, hangs, slow-syncs, and more.

I hoped this was specific to the iPhone and that the 3G hardware would somehow magically fix this.

It did not.

Just now I received a phone call and “swiped” to answer it and the phone CRASHED. That’s right, it crashed. I restarted it, got another phone call, answered it, and this time it froze for a solid 5 to 10 seconds before answering. After finishing the call, I moved the phone away from my ear, awaiting the screen to turn back on so I could “End Call.” Unfortunately, the screen never turned back on! And the person on the other line (luckily a family member) heard me cussing and hitting my screen to get it to hang up.

This crossed the line.

I can deal with my touch keypad hanging up, I can deal with painfully slow syncing, I can deal with a few instabilities with user-land software. But I can NOT handle that the iPhone — which as I remember Steve Jobs saying the most important part was the PHONE — cannot be a reliable phone.

I will not get rid of the phone, it is far too valuable to me with my contacts, calendars, software, etc. to throw away so easily, but I just have to say: Shame on you Apple, shame on you! How could such poor quality software ship out the door so quickly?

time Posted at 1:38 AM | written Written by Mitchell Hashimoto | comments 3 Comments made.
Jul
18

Ruby Enterprise + Phusion Passenger on Slicehost Screencast

Still relatively new, although they are on version 2.0, Phusion Passenger (mod_rails) and Ruby Enterprise Edition look like the easy-to-configure and preferred way to deploy rails applications. I won’t go over the benefits of passenger, since there are many resources available already. And if you want true performance without using too much memory, Phusion Passenger + Ruby Enterprise Edition is the way to go.

And despite the relatively easy installation, some people are reluctant to try out new scary things. Below, I have a screencast of me setting up Phusion Passenger + Ruby Enterprise Edition on a new slice and deploying a fresh rails app.

You can view the low-quality video inline below or you can download the high quality quicktime movie.

Get the Flash Player to see this player.

Note: If you didn’t watch the movie, some features I use in my sprinkle script are experimental features from my own fork of Sprinkle. Therefore, in the download below I have the .gem file which can be installed locally to get the benefits of all these features. Hopefully they will soon be merged into the main Sprinkle release branch.

For the customized sprinkle gem and files used with the screencast above, click here to download it.

NOTE: The package linked above is outdated. Read the comments to see how to fix the couple problems with it. I will update it when I have time but they are fairly trivial fixes so check below.

time Posted at 2:49 AM | written Written by Mitchell Hashimoto | comments 17 Comments made.
Jun
3

“Request Expired” error in ElasticFox

I just want to make a quick post regarding this error to help fellow google searchers since I could not find anything to help me :( If you are constantly getting an error saying “request expired” in ElasticFox, it is because your system time is too far forward or too far back! My Mac’s system time gets messed up all the time thanks to boot camp and I’ve gotten to the point where I just ignore it. However, if you want to use ElasticFox, make sure you fix it!

time Posted at 10:25 AM | written Written by Mitchell Hashimoto | comments No Comments made.