Wednesday, December 10, 2014

Trying Meteor



Trying       


I was told about Meteor about a month ago and was told it was the next big thing,so it intrigued me. I figured I'd read up on it and try it out for myself. On most of the forums many were touting it as the framework to rule them all - "its so easy and intuitive"....blah blah. Ok Im curious lets give it a hurl. Besides if it could make things easier for me when developing a prototype or when developing a web project, then why not give it a shot. The more tools you have in your tool belt the greater variety of things you can build.

In the past I have used PHP, Ruby on Rails, and Django. I have mostly used Django for my side projects and even prototypes I built at work. I wanted to see what the difference was with Meteor.

DISCLAIMER: I don't claim to be a certified expert on Meteor nor Django but rather these are my humble opinions based on what I have learned and played with. I leave it open to readers to correct me where I am wrong.

For those who are unfamiliar with Meteor, it is a web framework that resides on top of Node.js. Everything is completely written in Javascript to be run on Google JavaScript Engine V8. As JS is typically run on the client side/browser  Node.js uses the JS Engine so that it can be used as a standard interpreted language such as Python,Perl etc... except in JavaScript of course.. There are a couple reasons that this framework has gained such popularity:


  • Real Time Updates: With the explosion of Big Data and the Analytics, there is a real need to have the most up to date information at the user's fingertips asap so that they could make the most informed decision based on the data. That's where Meteor excels above other frameworks. It allows you to use the notion of Publications and Subscriptions to allow a template on a web page update automatically. So you publish a data set ( Collection ), the client side code subscribes to this collection and so there is a callback to the page whenever the Collection changes. No need for messy AJAX calls, this is included in the standard Meteor install out of the box. Pretty cool the first time you create a collection and watch it change before your eyes. Oh the power you wield!
  • Event Loop: A general design pattern that is used for high performance is that of an Event Loop. Typically with IO, often time code cannot be executed because it is waiting on IO to complete. Perhaps its reading from a Hard Disk, Sensor,  or controlling an actuator. With Syncrhonous calls code is blocked until the IO is completed. This does not neeccsarrily waste CPU time as the CPU will swap out the process when its waiting for IO, but rather it means no other code in the calling code can be executed until the IO is complete and returns. For a more complete description of the event loop based on Node.js see Understanding the node.js event loop .  So now you can provide a callback function to your IO calls, continue executing your code, then have it perform an action when its complete without having to worry about it. This is a huge benefit when dealing with highly used web applications. It scales well as code isn't left hanging for a variety of things.
  • Code Caching: A good portion your code will be cached onto the client side, such that incremental changes are communicated minimally rather then having to download all of your JS, CSS, HTML,Images,etc.. every time. This results in a faster loading and generally a better user experience. 


So these are at least 3 of very compelling bullet points for using Meteor. I jumped right in and am reading a book about it. I built the demo app they walk you though in the tutorial off the main site. I am feeling good. Then I started trying add a bit more complexity to the app, I found the following to be downers.

  • Only Supports MongoDB: I think MongoDB is a good DB, but what if I want to use MySQL( which is still the predominant DB out there), Hive, or Cassandra. Nope out of luck. Some whispers of it being on the list for the next release.
  • NPM: Now I know many people love the Node Package Manager and I did like it initially but I found it a bit annoying that a variety of basic functionality that other frameworks offer out of the box have to be installed via NPM. For example, you need to install Iron:Router. I imagine 95% people would use this, unless you are designing a single page. Rather then a complete set of base libraries to get your initial project done, it requires grabbing a variety of JS libraries from a host of options. I found this to be a bit annoying. Seemed hacky to me.
  • Callbacks Callback Callbacks: It seems to get a majority of communication between the server side and the client side, require a callback. Additionally nested functions in callbacks in nested functions in callbacks easily build up. Sure this is alleviated by creating variables for callback functions and making sure to use a good coding style, but this doesn't change that you need to pass in a callback. You are just masking it with nice readable variable names and style to be able to follow it.
  • Codebase seems immature: Now while I think it has incredible potential and its an exceptional code base, I think there is a lot of gaps to it, that the more mature frameworks  I think it needs a couple more revisions before I'd consider using it in a real  product and not just a prototype or small side project.
  • Good for front-end developers: Based that its JS based, it has a natural feel to those that have been using JQuery/JS all along. If you are more a backend sw developer, I'd recommend learning Node.js first to get comfortable with JS and the system libraries Node.js provides. Not saying its crazy hard but rather an adjustment.
  • Not a large community: When looking for answers there are some responses via StackOverflow but in general knowledge and expertise about it seem a bit thin. Not saying you can find an answer to your question, you can, but itll take a bit of googling and using the right keywords.
  • Easier thing become hard, Hard things become easier: As eluded to before things that should be easy or intuitive in other languages become a bit convoluted in Meteor. Want to unzip a file in Python use the unzip library. Want to unzip in Meteor, download the right zip library submitted.  Now id like to say that this last one is probably because I don't know how to use it fluidly just yet

So yeah that's my experience. A cool new language. Does it have potential undoubtedly - YES. Is it awesome sauce right now? Definitely not. Its a framework ill keep my eye upon, but it wouldnt surprise me if someone built a competing framework addressing the gaps it has, that more mature languages typically have.