Writing CoffeeScript Modules for Browser and Node
by jacob on January 25, 2012
The other day I read this post, and liked how it solves something I’d been wanting to solve myself for a while. However, I can’t just adapt it as it is since I try to write as much of my Javascript as CoffeeScript as I can. So I decided to do an as straight forward and preferably short adaption to CoffeeScript as I could. Here’s the steps I took:
The original script expects to run in the global context, and only after a few lines will it do the now very common Javascript module pattern. Vanilla CoffeeScript inserts this pattern from the start, and sends this as a parameter. Sure I can run my compilation with the -b parameter (docs), but it’s considered somewhat bad form, and more importantly, if I did that the actual implementation would start at indentation level 1, and I’d like to avoid that. This implementation would look something like this:
foo = exports? and exports or @foo = {}
do(foo) -> # Being at indent level 1 here makes me uneasy!
class foo.Cls meth: -> 1
foo.func = -> 2
Running this in Node shows the “module”:
$ echo "var foo = require('./foo'); console.log(foo);" | node
{ Cls: [Function: Cls], func: [Function] }
And invoking in the browser with two script tags like this:
outputs on the console:
Functionally what I wanted, but let’s get rid of the unwanted indentation and the dependency on the un-elegant -b flag:
I decided to try to use the fact that this sent in by the CoffeeScript function wrapper actually is the same as Node’s exports global (docs). Knowing that I could construct this line (using short-circuit evaluation):
foo = exports? and @ or @foo = {}
That lets me put things into my module under it’s prosaic name I’ve used here, foo. Final result:
# See http://braintostring.blogspot.com/2012/01/writing-javascript-modules-for-browser.html
foo = exports? and @ or @foo = {}
class foo.ExampleClass method: -> 1
foo.func = -> 2
Assignment completed with 1 less effective line of code, no -b flag and intuitive indentation.
2012 python meme
by jacob on December 22, 2011
Not that I’m a famous Python programmer
like Tarek Ziade, but I still think this was an interesting exercise, and thought I’d give it a shot too.
Read the rest of this entry »
How To Decide on Mobile Operating System (and Finding the Right Service Provider for Your Next App Project)
by erik on November 8, 2011
Companies are increasingly pressured to deliver great mobile apps. Competing mobile operating systems and devices is making it difficult to select the right app development methodology and balance a great user experience with reaching multiple devices.
That’s some text from our recently published whitepaper
In this whitepaper you will learn:
- How to get your app onto multiple mobile operating systems
- What to look for in your next service provider
- The pros and cons of the different mobile operating systems
- How you can leverage the hybrid app development approach for your next app project
Have a great day!
Team Plexical
developer tip: install proper readline on a fresh Python 2.7 on older OS X
by jacob on October 13, 2011
Are you on OS X, coming recently from a Un*x world, and sweating over lack of readline in your Python?
Read the rest of this entry »
Mobile First, Mobile Only. (More and more people access internet from their mobile device)
by erik on September 29, 2011
Mobile First, mobile only . It’s true and there is no question that everyday, more and more of the world’s population access the internet from mobile devices. Even more interesting is that in a lot of Asian countries and across the Indian continent, people access the network solely from a mobile device, a lot of them has never even touched a desktop computer. Their first encounter with the internet is via a mobile phone.
We did an infographic to visualize this development, enjoy!
Read the rest of this entry »
There is a mobile web
by jacob on September 19, 2011
No mobile web? That’s certainly a claim that was bound to unsettle us a bit here at Plexical, where it’s our business to create apps and sometimes content targeting just that. Actually after looking a bit closer on what was said in the presentation by Jeremy Keith (I recommend Luke Wroblewski summary) I see that it was obviously a very good talk with a lot of radical points. I like radical.
But, the “there’s no mobile web” goes a bit over the top. I don’t think there are many who think it would be a “physically” different internet or whatever, but sure, it’s a provocative prelude, I appreciate the necessity of those to capture attention. But to critique the usage of a label I find too postmodern. I’m not one of these general everything-postmodern-bad people, but this is a bit too much paranoia about the bad effects of definitions and labels.
“Mobile web” is a language thing, but language is important. It enables us to talk about stuff. I assert that some signifier is needed to talk about web for the small screen. The necessity of a term to talk about various classes of display sizes won’t go away. The progressive thing to do would be to invent an alternative term and try to spread that instead (I could think of extending the concept of “smallscreen” from the moving picture industry as one option).
This is somewhat similar to the situation with term HTML5. Also inaccurate, but a term that has come to stuck and is useful. We must not forget that these kind of terms are used a lot in discussing with clients, design people and others who doesn’t read all about the latest development in browsers. Creating a term that’s theoretically pure have a tendency of creating terms that can only be understood by a small elite.
Two questions to get you started with designing for mobile
by erik on September 8, 2011
According to a study recently carried out in the UK almost 50% of Internet users are now connecting to the network via their mobile phones (source).
That’s a lot. A whole lot. One can only note that mobile usage is exploding and what more, a lot of digital strategies are in dire need of an overhaul. I’m surprised by, of the biggest websites out there, very few are designing experiences made to work on touch interfaces.
Because when 50% of your users interacts with your website using their fingers on a device with a screen size of 320×480 rather than a mouse, it does have its consequences.
One excellent first step towards designing digital products for touch interfaces is to embrace a mobile first strategy.
If you today are starting on a new project or just started one I recommend you to take a step back and think about your project objectives from a mobile first perspective.
Ask yourself:
- Am I focusing on only the most important data and/or actions?
- Am I leveraging the unique capabilities of the mobile platform?
Asking yourself these two very simple questions can get you a long way.
Why these two questions then?
As mentioned earlier, when your users are swiping their fingers across a screen with a resolution of 320×480 there really is no space for any superflous information or ornamental design elements. The user should be presented only with the most relevant data and be made to execute only the most important tasks. Not more, not less, just the correct data and tasks.
Building a webapp or a website starting with the mobile experience (or better yet, with a command line interface) in mind first and gradually add functionality or data as you move up the device stack makes for a much more focused design effort.
Asking yourself if for your project it makes sense to leverage the unique capabilities of today’s mobile browsers is the second question you should ask yourself. The browser that’s in the majority of the mobile phones are much more capable then their brothers and sisters of the desktop world.
Take GPS location for example, we just designed a dealer locator for a client of ours that asks the user to allow for the browser to pinpoint the users location and then we present the nearest locator based on the coordinates the browser gives back. That’s no-brainer really, but it’s interesting how so very few websites take leverage of a feature such as this.
There are more unique capabilities of mobile browsers, offline storage is another big feature of a mobile browser. Today you can basically store a whole website offline which your user can later can read offline. (The Financial Times just did some great things with offline storage.) . More impressive is how Amazon just leveraged offline storage technology with their Kindle Cloud Reader which let’s you read your Kindle books offline in your browser.
As you see it makes a lot sense to start designin for mobile first, if you’ve been hesitant before, just start asking yourself these two questions:
- Am I focusing on only the most important data and/or actions?
- Am I leveraging the unique capabilities of the mobile platform?
Acid, Steve Jobs and trying new things
by erik on August 26, 2011
I wish him the best, I really do. I just think he and Microsoft are a bit narrow. He’d be a broader guy if he had dropped acid once or gone off to an ashram when he was younger
As you know, Jobs resigned this week. I just wanted to share that quote which to me hints to the personality of Steve Jobs and what make him a great designer, be it of products or of complex systems such as Apple Inc.
Because to me that is what he is, the greatest designer of the industrial era (postmodernism is yet to come).
Now, the idea of that quote is of course not about dropping acid (well, maybe a little). It’s about trying out new stuff. In order to create new experiences, products or ideas you need to try out new stuff.
You need to talk to other people rather than only your own breed. It’s only then you’re able to synthesize ideas and connect the dots between experiences to form something new. You need to be curious and move out of your comfort zone.
It’s easy, introduce some new RSS feeds to your Google Reader, feeds that got nothing to do with your field of expertise. Do the same with Twitter, follow someone you’ve admired for a long time (or maybe better, despised for a long time) but never really followed because the person in question is not really active in your discipline.
It’s about the t-shape and you so;. Tune in, turn on, drop out
What’s the future of software consultancies?
by erik on August 23, 2011
I just read an article Marc Andreesen published on WSJ where he argues that software is eating the world. I completely agree, software IS eating the world, it is fast becoming ubiquitous.
Why? To me it’s an amalgam of http technologies maturing and the mobile phone establishing itself as a computational platform in its own sense.
Even though Marcs article takes a macroeconomic stance in general and is about tech startups in particular, I started thinking about one thing:
In an ever more softwareized world, is there space for a consultancy that specialize on “full stack web development” which embed teams of software engineers inside companies much like embedded engineers in the automotive industry?
linkedin gives “html5 apps”* a vote of confidence
by jacob on August 18, 2011
It’s nice to be proven right.
For about a year, we have been working to build up a software business centered around the idea that web technologies are mature enough to be viewed as another computing platform rather than a primitive presentation layer (check out our initial thoughts for example).
Soon after that we discovered Backbone.js, the Javascript MVC and data communications library that have been getting a lot of attention lately. Jacob’s tutorial have been the post on the blog with the most traffic.
So yesterday, when we (and apparantly the rest of the entire internet..) marveled over the new LinkedIn mobile app, we also saw it as a vote of confidence that we were right when we thought that using advanced web technologies in mobile apps makes a lot of sense. And it’s using Backbone.js to boot!
This is a very interesting app to analyze, and we predict that it will become a model that many other app develepers will be heavily inspired by. We for sure are going to have a very close look at touch.linkedin.com and see if we can find any interesting tricks apart from the very nice stack described in the Backbone example listing, or in this article. In another article linked from the FunctionSource article, future blog posts about the architecture of the app is announced. We for one are certainly going to keep our eyes peeled for them.
Congratulations to the LinkedIn mobile development team!
* We now, but it’s the name now, isn’t it?




