The original promise of Java in the 90’s was to provide a ubiquitous write-once, run-anywhere platform for applications. With the rise of network-centric computing, where applications were increasingly delivered over the web rather than in shrink-wrapped boxes, the need for such a platform was growing tremendously. For numerous reasons, Java failed to live up to its original promise (although has successfully thrived in other server-side roles). But fast-forwarding to 2011, we ironically see that Javascript (long considered a toy language for gratuitous visual bells and whistles) nearly perfectly realizes Java’s original promise.

Because of its sheer ubiquity, immense resources have been thrown at Javascript interpreters in the past decade, resulting in extremely efficient JIT-based implementations (c.f., Google’s V8, which powers Chrome and node.js), to the point where it is now among the fastest dynamic languages around. Because of its ubiquity and highly optimized performance, it is increasingly being used as the underlying platform for complex applications, even those not hand-written in Javascript.

It has been referred to as the “Assembly Language of the Web“, because it is used as the target output for various compilers (e.g., Google’s GWT, CoffeeScript, Pyjamas). More radically, Emscripten actually provides an LLVM->javascript compiler. Since LLVM is in turn an intermediate format (IF) that can be generated with gcc from a variety of languages such as c/c++, this means Emscripten effectively allows c++ code to be compiled to Javascript! And taken a step farther, since interpreters for many interpreted languages (such as CPython for Python) are themselves written in c, which can be compiled to LLVM, which can be compiled to Javascript, this means languages like Python can be interpreted with a pure Javascript-based interpreter. It will be very interesting to see how this flexibility will influence the future of languages for client-side computation. But Javascript seems firmly entrenched as the base layer for making it happen.


Adding drop shadows to photos in Photoshop Elements

The below is for Photoshop Elements 8 (for Mac), although I assume the steps are largely similar in other versions of Photoshop.  The below assumes that in the end, you want a jpeg for a web page.

  1. Load your photo in Photoshop
  2. In the Layers pane, double click on the single layer that’s there corresponding to your photo.  When the dialog pops up, just click Ok to name your layer Layer 0.
  3. In the Layers pane (bottom right pane), in the bottom toolbar, click on the little circle icon (‘create new fill or adjustment layer’)
  4. Pick solid color.
  5. Enter the hex color of the background of the webpage that you will eventually put your photo on.
  6. In the Layers pane, drag your photo layer (Layer 0) to the top, so that it appear above your new Color Fill layer. If this doesn’t work, did you check to see that you followed Step 2?
  7. Go to Image->Resize->Canvas Size in the top menu.
  8. In New Size, choose pixels.  Add 100 pixels to width and height.  Click the top-left arrow under Anchor.  Click Ok.
  9. In the Layers panel, select your photo layer (Layer 0)
  10. In the Effects panel, choose Layer Styles (the little overlapping windows icon).  Then from the dropdown menu to the right, select Drop Shadows.  Select the drop shadow effect you want (probably low or high).  Click Apply.
  11. Your drop shadow should appear.  If you want to adjust the effect, double click on the little fx icon in your layer’s entry in the Layers panel to open the settings dialog for that effect.
  12. If you mess up, right click on your layer’s entry and Clear Layer Style.
  13. Save your psd file.
  14. Go to File->Save for Web, pick your preferred jpeg quality and image size, apply, and click Ok.

Note: if you want a png, then instead of creating a new fill layer in Step 6, you would add a normal layer, and make sure in Step 14 you save the png with transparency enabled.)

Tech Blog

I plan to post here on technical topics related to software development and computer science.  You can find my other blogs and posts on general topics elsewhere.

The point of a (developer-centric) tech blog is two-fold:

  • Tracking notes to one’s self on how to do something, for future reference.  When you set up a toolchain, or fix some obscure bug in your setup, etc…, you might have to do some of it again in future, so having some notes to refer to comes in handy.
  • Other people searching for how to do something specific, or how to fix a specific bug, might benefit by finding your post.

Even if the same info can be found elsewhere, as long as your posts are succinct and accurate, you’ll only increase the chances that at some future time, you or someone else will benefit.  Just keep in mind the likely query that someone who might benefit from your post might issue when they encounter that specific information need. These points may seem obvious to developer types, but others might wonder why so many techies have blogs with posts on seemingly obscure topics.  They’re likely not for daily consumption, but rather meant to add to the pool of useful reference material on the web.