geeks have feelings http://www.geekshavefeelings.com proven by fossil evidence Sun, 07 Mar 2010 09:36:58 +0000 http://wordpress.org/?v=2.9.2 en hourly 1 Fastest HQ9+ Interpreter in the World http://www.geekshavefeelings.com/posts/fastest-hq9-interpreter-in-the-world http://www.geekshavefeelings.com/posts/fastest-hq9-interpreter-in-the-world#comments Sun, 07 Mar 2010 08:44:38 +0000 GHF http://www.geekshavefeelings.com/?p=385 For some bizarre reason I felt compelled to spend hours of night writing an HQ9+ interpreter. Not just any HQ9+ interpreter, I thought, but the fastest HQ9+ interpreter in the world. Is that useless, you ask? Of course it is.

Ends with S, too

The real purpose of HJMP1 (project page, GitHub page), which is what I’ve decided to call my new interpreter2, is of course for me to play with JIT compilation on different platforms.

Now that recent versions of GCC are freely available on x86 and AMD64 versions of Linux and Windows3, we programmers can use the same tools and code and target different platforms with the minimum of changes (and headaches!). However, those differences do accentuate themselves if you begin working closer to the metal, either because of requirements like performance or just for fun.

In this case, the distinction causing trouble was calling conventions. Regular 32-bit machines use cdecl, which is straightforward and passes parameters to functions on the stack. Newer AMD64 software use variants of fastcall, which passes some number of arguments inside registers to take advantage of the doubled register count in AMD64 over x86. To make things more complicated, Microsoft uses their own unique AMD64 calling conventions for Windows and related tools.

Part of this exercise was to abstract away the general nastiness of writing—or generating—assembly code through object-oriented design. I accomplished this through the magic of dynamic4 polymorphism. Different code emitters generating code for each platform talked directly with AsmJit, the code generation library I used, but were hidden behind interfaces from the token processor. In addition, the token processors—one with JIT and one that executed token directly—were hidden from the parser (the token generator) as well through an interface, so that I can enable or disable JIT at runtime.

Overall, this little project was a success. It isn’t exactly groundbreaking or very useful for day-to-day work, but the experience of making it was a valuable one.

Download HJMP from the project page

  1. pronounced “HIGH-JUMP”
  2. in addition to “The Fastest HQ9+ Interpreter in the World” :)
  3. under TDM GCC and MinGW-w64
  4. and static too, really
]]>
http://www.geekshavefeelings.com/posts/fastest-hq9-interpreter-in-the-world/feed 0
US International Dvorak http://www.geekshavefeelings.com/posts/us-international-dvorak http://www.geekshavefeelings.com/posts/us-international-dvorak#comments Fri, 29 Jan 2010 23:16:45 +0000 GHF http://www.geekshavefeelings.com/?p=378 Windows (and many other operating systems) include by default an interesting keyboard layout called United States-International. It is essentially a version of the prolific American QWERTY keyboard layout, with many popular symbols and characters not found in English accessible through the AltGr key (or its Windows substitute, the right Alt key or Ctrl + Left Alt) and through dead keys.

I saw fit to create a Dvorak version of US-International, with the same deadkeys and combinations, but with the three touch-type rows rearranged to fit ANSI Dvorak. It should be an easy switch for existing Dvorak users and great if you’re starting out learning Dvorak.

Keyboard layout installer for Windows 2000/XP/2003/Vista/7 (x86, x64, and Itanium): http://www.geekshavefeelings.com/files/keyboardLayouts/intldvrk.zip
Microsoft Keyboard Layout Creator source file: http://www.geekshavefeelings.com/files/keyboardLayouts/intldvrk.klc

The installer will add the layout to the Windows regional settings list of keyboard layouts, and is not some sort of driver, background service, or registry hack. It was made in Microsoft Keyboard Layout Creator.

Anyways, with the US-International keyboard layout, nobody should have any excuse to type “u” or “ue” instead of “ü,” “2 x 4″ instead of “2 × 4,” or “General Xo’s Chicken” instead of “General Xo’s Chicken.” Heck, maybe we could have prevented the creation of the English neologism “uber.”

Of course, I do take issue with its lack of distinction between the hyphen (-), the en dash (–), and the em dash (—), and its lack of the prime marks (′, ″, and ‴) and the ditto symbol (〃). However, its existing variety of punctuation, accents, and other typographical symbols, including separate key combinations for the single closing quote (’), the typewriter apostrophe (‘), and the acute accent (´), are easily enough to overwhelm the neophyte to ultra-elitist typographical pedantry (the sort I smugly enjoy).

Also, the dead keys themselves do get annoying. For example, Ubuntu Linux includes a layout called “USA International (AltGr dead keys).” That moves the dead keys to their AltGr combinations, so hitting the ‘ key would produce a ‘ straightaway, but to get the á (acute a) symbol, which is encountered far less frequently than the apostrophe, one would need to hit AltGr+’  and then A. Also of note is Ubuntu’s “USA Dvorak International,” which is not to be confused with my US-Internation Dvorak layout. It is simply the ANSI Dvorak layout with a few symbols available by AltGr; it is not, like my layout, a Dvorak remapping of the full US-International layout.

With that said, I’m not even a Dvorak typist. Heh.

]]>
http://www.geekshavefeelings.com/posts/us-international-dvorak/feed 0
Objectives I Hope to Achieve http://www.geekshavefeelings.com/posts/objectives-i-hope-to-achieve http://www.geekshavefeelings.com/posts/objectives-i-hope-to-achieve#comments Thu, 24 Dec 2009 01:24:23 +0000 GHF http://www.geekshavefeelings.com/?p=344 Ah, the ol’ Common App. How your drab maroon and gray signaled your goal to compact the college application into a manufactured, quality-controlled product. Can’t I still recall that painful process by which years of my life were distilled and binned into your textboxes? My friendships and growing up became extracurriculars, my lessons learned at the soldering station became work experience, and my drowsy, hard nights scribbling away became AP, SAT, AIME scores.

And there was the essay—a quick scan (250 words minimum) of some deeply personal episode of my life into a desperate indirect plea to an anonymous admissions officer.

I doubt those in my generation really understand what sort of lossy compression the Common App asks of us to apply to our lives. Its goal is to concentrate a K–12 life, a real, live person, into a file, sandwiched within the confines of a manila folder. This is what looks like: Common Application 2010. That’s the paper copy, a perspective of it I’ve never personally seen1. It really is just five pages. Imagine that: you, on three (3) sheets of paper.

And yet, here I am again, applying for a transfer offer. Some schools publish their own application, or request a supplement to the Common App. What those schools asked of me last year helped me turn those mental tools I once used to solve equations, catch Frisbees, or inspected music with, on myself. I identified parts of me that weren’t crafted by the Common App assembly line: the one on which people are produced who can perfectly sum up hopes and dreams in a 250 words minimum personal statement.

Regardless, Common App dispenses with soul-searching and self-discovery, and for us transfer applicants, even with the open-ended choice of essay topics offered to high school seniors. Instead, it presents a straightforward demand for an enumeration of “reasons for transferring.”

Right then. A straightforward essay prompt deserves a straightforward answer, which I will administer immediately, along with a bulleted list of reasons:

I wish to transfer to so that I can be happier. With that said, the following are more specific reasons:

  • It’s lonely – Not lonely as in I can’t find friends or a party to go to, but because I’ve yet to find anyone with whom I could hold a prolonged conversation with on, well, anything to do with my everyday work. With the exception of upperclassmen and graduate students, who have received a college education and are prepared to enter work with the said education, does nobody really build robots or write software for fun? I really don’t have much more appetite for video games, guns, or the usual (politics, religion and school). A friend suggested that I was suffering intellectual starvation—but I wouldn’t dare call it that. Firstly, it’s extremely pretentious to claim oneself as intellectually starved, and secondly, if you feel intellectually starved, you’re not trying hard enough. You’ve got the Internet.
  • GT spirit is obnoxious – “Only at Tech.” The epitome of closed-mindedness of Georgia Tech students. Walk with a group of friends and start linguistically analyzing a tongue-twister somebody had just improvised. “Only at Tech.” Figure out that it’s implausible to fit $9 billion in denominations below $20 inside a standard shipping container, as presented in some TV show. “Only at Tech.” Maybe it was cute, clever, or something you fancy to find in xkcd2, but that’s no reason to be so closed-minded and elitist. Heck, OAT is even a website. I, of course, appreciate QDBs—the classy way to capture campus humor. I run my own for Stuy. My reply to “Only at Tech?” “Which Tech?”
  • I’m still in high school – I like that GT is the closest I’ll ever be to the real American college experience, with the football games, the fraternities, and the parties. After all, I suppose that I never did experience the suburban high school fantasy of Sixteen Candles3. Even with the bit of regret I feel about that, Stuy has certainly primed me for the bureaucracies of college and of life. Requesting budget allocations from a committee? Online course registration? It’s all déjà vu to me. Now, with the college apps I’ve placed upon myself, I feel more than ever that I’m still living my life as a superannuated high school senior. Also, the real American college experience? It got a little old already.
  • I love engineering – I also love computer science, building robots, and getting into discussions on finance, economics, and linguistics. So, I’m looking for a better education. Is there something wrong with that?
  • Big, public, metropolitan – I associate much of my life with a 3,000-student school in downtown Manhattan. I’ve really had enough of the big city school. I came to Georgia Tech because it was the best education I was offered (I was rejected from nearly everywhere else I had applied to). The huge campus and the callousness with which the administration treats undergraduates is beginning to get me down a bit. The astoundingly huge lectures, nigh-unavailable professors, online homework and RF clickers—hey, they’re all things I could actually stand (though not necessarily enjoy) if it weren’t for the worst travesty of the public university: major restriction. I mean, what kind of a horrible system would prevent students from taking a class he wanted to take?
  • Gender… imbalance – I’m all for the egalitarianism and meritocratic spirit GT admissions tried to show—I doubt they consider naught but the SAT Math score; heck, I think the essay was even optional—but trust me on this one. Diversity is not something you can skimp on. Other guys, textbooks, and Skype contacts (the three most common sources of dialog for the average GT student) make for terribly monotonous conversation after the first week.
  • I got mugged and stabbed – Only at Tech!

If only I could express my anguish seeing my friends elsewhere having the simple things at college like having fulfilling conversations with other students. If I could go around showing everyone that yes, one can be quite clever even in places beside the Georgia Tech campus. If I could explain the shock, humor, and self-reflection of surviving a stabbing, and more, all within a personal statement… well, then I guess I wouldn’t now be applying for a transfer.

Maybe I was better off with one of these?

  1. except maybe on my older sister’s desk, from a generation past of Stuyvesant strivers
  2. possibly all three, of course
  3. see the story of Pajama Day at Stuy
]]>
http://www.geekshavefeelings.com/posts/objectives-i-hope-to-achieve/feed 0
Raxo http://www.geekshavefeelings.com/posts/raxo http://www.geekshavefeelings.com/posts/raxo#comments Tue, 15 Dec 2009 23:53:37 +0000 GHF http://www.geekshavefeelings.com/?p=294 Besides studying for final exams and getting stabbed, which seems a bit of a self-fulfilling prophesy at this time, I’ve been getting some work done on Raxo, my software modeler and rasterizing renderer.

Raxo is, as described, a way for me to learn about all the compsci stuff I’m interested in: graphics, low-level assembly generation and optimization, and design.

Raxo uses AsmJit for Raxo’s equivalent of vertex shaders, rasterizing loops, the image buffer postprocessing/filtering, and maybe more. AsmJit generates actual executable functions from calls to its API at runtime, then allows them to be called from your C/C++ code. Why is this useful? It allows conditional branching (if, while, and for statements) to be eliminated from inner loops—the parts of the software that are executed millions of times every second, and that need to be as fast as possible—whenever they can be determined ahead of time.

For example, if you have a set of say, 8 lights in a scene to be rendered, but not all of them are on. A non-JIT compiled renderer would need to check through each light to see if the programmer has turned on the light, every time the lighting equation needs to be calculated. That could be once per vertex or even once every pixel! Raxo, however, can recompile its rendering function so that it generates lighting equation code only for the lights that are on, eliminating wasted CPU cycles evaluating those ifs and mispredicting branches.

This of course means that state changes are expensive. But then state changes are expensive with hardware too—much more expensive.

Having AsmJit prevents me from having to write a lot of parts of the library in C++ template metaprogramming. Using templates would allow conditionals to be evaluated and optimized out as the code is compiled. But then Raxo would be extremely difficult to understand and use, not to mention state changes would be impossible. How would you like to use a renderer that you have to make a new instance of from another class, just to turn on another light in the scene?

So, I avoided hardcore C++ templates, even if it meant having to generate assembly code. After all, I can abstract assembly generation through my own API, but it’s very hard to hide an ugly template API. See Anti-Grain Geometry if you want to see an example, as the API for it entails using nested templates parameters to generate an entire 2D graphics pipeline (filters, transforms, geometry transformation, etc.). Though I must say, AGG is blazing fast, accurate, and extremely high-quality. It is definitely a library that inspired me to write Raxo.

Raxo is also currently using PixelToaster as a floating-point color framebuffer (get this: Raxo—and my final project for the Stuyvesant course—renders to single precision floating point pixel buffers, for precision and dynamic range beyond those displayable with a computer screen). In addition, a separate file format, SPRx (Single Precision Raxo err… something) was developed based on Industrial Light & Magic’s OpenEXR HDR image format. In comparison, SPRx is significantly simplified because EXR was so much more than I needed.

]]>
http://www.geekshavefeelings.com/posts/raxo/feed 0
You See What Happens? http://www.geekshavefeelings.com/posts/you-see-what-happens http://www.geekshavefeelings.com/posts/you-see-what-happens#comments Sat, 12 Dec 2009 09:27:32 +0000 GHF http://www.geekshavefeelings.com/?p=274 It’s a hectic time of year. All of us university students struggling with final exams. I remember last year at this time, I was waiting for the results of my Early Action application to MIT. Right now, another class of Stuyvesant students is experiencing that same excitement, stress, and more likely than not, trauma and depression. I got this on a wall post to my Facebook from a friend rejected from Cornell, also known as Stuy v2.0 for the massive number of Stuy students making up its class every year:
2009-12-12_04-14-35
Well, guess what? I’m the right guy to ask, because I got rejected from nearly all the schools I applied to, and I have a better piece of advice for you than those other chumps that tell you, “They missed out on some great talent!” or, “You’ll get in somewhere else that you’ll like more!”

Well, guess what. I got in somewhere else. I didn’t like it very much. And I got stabbed here.

Link: Georgia Tech student stabbed in Midtown
Link: GA Tech Student Stabbed Near Campus (they got my name wrong1)

You see what happens when you get rejected from the school of your choice? This happens. I hate this fucking place.

I can’t believe I didn’t apply to Brown.

I’m leaving tomorrow.

  1. No surprise there, but I actually do have quite a bit to say about FOX News’s skills at hunting me down
]]>
http://www.geekshavefeelings.com/posts/you-see-what-happens/feed 0
Clubbing Science Olympiad http://www.geekshavefeelings.com/posts/clubbing-science-olympiad http://www.geekshavefeelings.com/posts/clubbing-science-olympiad#comments Sun, 01 Nov 2009 05:11:20 +0000 GHF http://www.geekshavefeelings.com/?p=233 My views of the October Spectator article, “Committed to Clubbing.”

It’s a good article for those of us involved in clubs and teams, especially as officers. Leaving behind a dedicated core of officers and a mindset for leadership is particularly important for competitive teams. Their performance at tournaments when they represent Stuyvesant mirror the abilities of the officers of team to recruit, train, and organize.

Aside from that, I really take issue with how little exposure Stuy’s Science Olympiad team receives, especially in the Spectator.

I competed in SciOly for seven years (since 6th grade at middle school), and I’ve learned more about physics and electronics by building competitive devices for it than in any class. As a captain of the Stuy team, I took care of my share of recruitment and finances. SO was second only to Stuy itself in its impact on me. Now I help run a twelve thousand user community website for Science Olympiad and I volunteer at tournaments local to my university.

All the same, Spec covers Stuy SO less than Key Club, even though they’re about the same size and SO certainly does more for Stuy’s image and community impact. That’s not to mention kids in SO genuinely care about their education, not the line they could put on their college apps (BURN).

While I was on the team, the sort of questions we got from Spec and Standard were along the lines of, “why didn’t you guys win first at so-and-so tournament if your team name has Stuy kids in it?” (As an aside, the Standard was worse about that snobbery.) Well, if maybe we got a bit more name-dropping, we might have some more cred with the elite Stuyvies1, some clout with the administration2, and some more SU/PA/AA money3.

Stuyvesant’s newspapers need to realize that they are more than tabloids for SING! gossip or tirades against the Teitel administration. They actually matter to the community, and need to take responsibility when . The newest Science Olympiad president, Wei-Jean Chang, has been doing a great job getting the word out about the team, with the stuy.edu news posting, gratuitous advertising, and huge head start in the school year, which are all things our team has lacked.

Still, the team’s image has not gained the lustre of respect that Math Team has among the giants of Stuy nor among the science departments and administration, except with the superb biology section of the team. It will be a long while yet before Stuyvesant Science Olympiad attracts the wunderkind frosh and has its own schedule slot set aside4.

  1. So then the best and brightest at Stuy won’t think Math Team is the only place for the biggest nerds
  2. Maybe our SO program then can get the supported as well as those at other schools
  3. So the SO team can actually afford to build robots and airplanes they need to compete.
  4. Heck, this may not even suit Stuy’s loose, student-run SO team
]]>
http://www.geekshavefeelings.com/posts/clubbing-science-olympiad/feed 0
Stuy Czar http://www.geekshavefeelings.com/posts/stuy-czar http://www.geekshavefeelings.com/posts/stuy-czar#comments Sun, 11 Oct 2009 03:57:09 +0000 GHF http://www.geekshavefeelings.com/?p=232 I got really passionate at some point and posted this to the comments of a Spectator editorial. I thought to edit it, but I got lazy, so I’ve just cross posted it here:

One of these days, you guys can just do the entire issue on this stuff. Even though I’m now an alum, I still now feel your pain when the Teitel administration slowly degrades Stuyvesant to just another ghetto city school. This must be what my sister (Bicentennial class of ‘04) felt when she heard about my servitude at Stuy.

It may be elitist to say, but I really do believe that Stuy students deserve every privilege they’ve had in the nearly two decades since the new building. It’s not just because I now think of Stuy as “that college I transferred out of,” or that our students are superior to any others, but because it’s a damn shame to strip away tradition and trust from a name that stands above high schools and prep academies, and among universities and institutes.

When this administration takes a step towards turning Stuy into the minimum security prisons that house those who are unfortunate enough to attend zoned schools, it justifies it with shouts (ears closed) that we are in the big bad city, and a comparison (minds closed) to those “other” NYC public schools. Why can’t we be compared to private academies or college prep schools? Other top-ranked Specialized high schools in the nation? Heck, I invoked this petty comparison just by having a website with “Stuy” in its name. “This would never fly even in Bronx Science,” I recall (and paraphrase) one Ms. Weinwurm rationalizing robotically.

No, but really, you should do a whole issue on it sometime. It’s pretty much the core of Spec, as it were; it’s the only story that runs every year without fail. ;)

]]>
http://www.geekshavefeelings.com/posts/stuy-czar/feed 0
Better Spheres, Fewer Triangles http://www.geekshavefeelings.com/posts/better-spheres-fewer-triangles http://www.geekshavefeelings.com/posts/better-spheres-fewer-triangles#comments Sat, 25 Jul 2009 22:55:11 +0000 GHF http://www.geekshavefeelings.com/?p=223 Generating spheres through recursive subdivision of icosahedrons

UV spheres are one of the easiest and most commmon ways to generate a sphere for computer graphics.

UV sphere generated by revolving a circle about an axis planar to itself
UV sphere generated by revolving a circle about an axis planar to itself

It has its charms: it looks kind of like a globe, with its clear longitudinals and latitudinals, it’s ridiculously easy to imagine and create, and it works well with UV texture mapping. Still, its uneven distribution of points can cause wasted texture resolution as well as computation time at best, funny-looking bunching of points near the “poles” at slightly worse, and disgusting visual artifacts at worst due to having to render many slivers of triangles often of widths less than a pixel.

A far better solution is the geodesic sphere, created by dividing up the faces of a platonic solid and then projecting the vertices onto a sphere*.

Icosphere
Icosahedron after two iterations of subdivision

To be completed…

*Of course, following this logic, you could make a spherical looking mesh by basically taking any convex mesh and projecting its points onto a sphere. But then its points wouldn’t really be even distributed. That’s why we subdivide an icosahedron.

]]>
http://www.geekshavefeelings.com/posts/better-spheres-fewer-triangles/feed 0
Donald Knuth Finally Sells Out http://www.geekshavefeelings.com/posts/donald-knuth-finally-sells-out http://www.geekshavefeelings.com/posts/donald-knuth-finally-sells-out#comments Tue, 21 Apr 2009 03:56:25 +0000 GHF http://www.geekshavefeelings.com/?p=217 Donald Knuth finally sells out

]]>
http://www.geekshavefeelings.com/posts/donald-knuth-finally-sells-out/feed 0
Eclipse + MinGW + gtkmm http://www.geekshavefeelings.com/posts/eclipse-mingw-gtkmm http://www.geekshavefeelings.com/posts/eclipse-mingw-gtkmm#comments Sun, 01 Mar 2009 20:27:00 +0000 GHF http://www.geekshavefeelings.com/?p=166 Hurrah! Last night, I was able to set up Eclipse with CDT, have it recognize my MinGW (with GCC 4, thanks to (these unstable MinGW builds) toolchain, and build gtkmm (the C++ interface for GTK+) programs through make. This was all so I could do my Computer Graphics project on my Windows machine instead of Linux. Not that I have any gripe with Linux, only that my Linux box has no display connected to it, forcing me to use it by remote desktopping.

Building gtkmm application on Windows using Eclipse CDT + MinGW

The image shown above is my entry for the first project in the Graphics course, which is to create a program that can represent points/edges in space in a 4×n (homogenous coordinates) matrix, and apply various transformations (rotate, scale, translate) to that matrix through matrix multiplication against a 4×4 transformation matrix. The list of edges should then be drawn to an image file or displayed onscreen.

Project 1: retardedtranforms

The end result is that you can put a bunch of coordinates in and rotate them around to see how 3D they are. :D

Octa

Anyways, I don’t think I was supposed to use C++, Windows, gtkmm, or cairomm for my project, but then I doubt anyone will complain. After all, I believe that the output of it is probably better than the reference output in the project specs.

Project output:
script2 script3

Reference output:
refscript2 refscript3

]]>
http://www.geekshavefeelings.com/posts/eclipse-mingw-gtkmm/feed 1