2010.10.29

zepto.js and mobile JavaScript

Ok, I know that writing this post is probably a bad idea but I will do it anyway, please note that this is my personal opinion and not from any company/client I work or worked for and that I respect other people’s opinions (that doesn’t mean I agree with them), I know that some things I’m going to write are going to sound arrogant and that some people are going to get it wrong… please try to keep your emotions aside and think rationally before getting into a conclusion and read the about page to understand the objective of this blog. I don’t want to start a flame war and remember that every person/project has different needs, my perspective and the kind of stuff I’m currently building may be completely different from your needs/desires/preferences… Having that said….

Starting from the beginning

I had plans to do something similar for while, was just starting a new mobile project that would require some basic JavaScript and since I saw that Thomas Fuchs was starting to do it too I thought that “combining forces” we could build something better and I would spend less time on it, specially since everything he does get some pretty big attention on the JS community, which means more people to help.. (since time is a really scarce resource nowadays)

First couple hours playing around and I had fully refactored the core structure and organized the files on a way that I think makes more sense for this kind of project and did a pull request (check the commit history to understand the changes and also my comments), he responded a couple days after and for his response and progress of the project I saw that the goals were similar (do a simple framework targeting modern mobile browsers) but we were approaching it with a completely different perspective, which means we couldn’t actually contribute to each others code… that kinda made me lose interest on the project a little bit, my motivation was coming from contributing to something bigger and not actually doing everything by myself, I just wanted to give the project some momentum and maybe keep adding new features as needed, specially since I don’t have enough time available to maintain a project like this by myself…

After finishing the project I was working on (around one week after that) I realized that I actually don’t need something like zepto/jQuery/dojo/YUI/etc to code a simple website if I’m only using it as an enhancement and targeting modern browsers.. the website already works without JS, so you don’t need that much JS anyways… using a library is handy and simplifies/abstract a bunch of stuff (specially if you don’t know how to do those things from scratch) but not actually a prerequisite… my interest on the project went down again and my commit frequency reduced a lot.

And another drop of water into the full glass

Couple days ago John Dalton sent on twitter that Thomas Fuchs branch of zepto.js (master branch of the project) didn’t used prototypal inheritance and that this was a major flaw (permalink) and I replied telling that on my branch it worked properly (permalink) – one of the reasons why I refactored zepto at the beginning besides organization -after that, they exchanged many messages over twitter and afterwards things got worse when John Resig (jQuery creator), Thomas Fuchs and a bunch of people started to discuss on hacker news

So why is it another drop of water? because I don’t agree with the direction that the project is taking and now my desire to contribute to it is even smaller, I’m not sure yet if I’m going to split it into a different project name and remove everything that was part of the original code – it is so different from the master branch (since my first commit) that we can’t even say that is the same project anymore (compare this with this) – or if I will just drop it completely (forget about coding something like this and just using one of the mainstream frameworks or not using a framework at all) or do it on a completely different way (not following the jQuery API), probably I will just switch to XUI since I think they are approaching the problem on a better way…

Just compare the way that Thomas Fuchs is talking about zepto.js to what I said on the pull request and on my branch page, basically the opposite… that’s the main reason why both branches are so different, every person has different needs and different opinions about things, it is really hard to develop open source projects together with other people, specially when the owner has an opposite opinion about core concepts…

What I think is wrong

Honestly? almost everything, but please don’t get me wrong, let me explain first.. The way the library is being advertised is not really honest (comparing pineapples to apples), “borrowing” jQuery API, supporting a single platform (small subset of mobile webkit browsers), the code structure (yes it is cryptic, yes it has many unnecessary “optimizations”, yes it has some flaws)… I know I’m being a jerk on this paragraph (and maybe with the whole thing), but I have to express my opinion especially since I’m one of the “contributors” of the project and I don’t want people to think I agree with all of that… (this is my personal opinion which doesn’t mean I’m right)

Why I contributed to the project if I don’t agree with many things?

For fun (I like to reinvent the wheel and to refactor), I don’t like loading a bunch of code that is not going to be used (even if the performance gain is questionable), I only needed a small subset of features, “everyone” knows how to use jQuery, I was curious to see what it would become later, I didn’t knew how to implement some of the features and wanted to learn how to do it, etc… I would say that curiosity was the driving energy…

Why I’m not using jQuery mobile, Sencha touch, etc..

The kind of sites/applications I’m building doesn’t require most of the features and some things doesn’t even make sense (scaffolding, UI components, pre-built templates). Those frameworks does a really good job at providing fast ways to handle repetitive tasks and simplify a lot the development process, but again, for the kind of stuff I’m doing right now it doesn’t make sense to use it, I’m usually building highly customized pages that would’t fit with the style and workflow of these tools… - it may be perfect for future projects or for other people though…

My opinion about JavaScript on mobile websites and web-applications

I really believe that mobile sites shouldn’t rely on JavaScript, complex CSS or even images to work if you want broad support… too many bugs, many devices doesn’t even support it properly, slow processing speed, low memory, too hard to test/debug, etc. – Opera Developer Community has some good articles about it – I believe that JavaScript should be used always as an enhancement, specially for mobile browsers, and I try to do it as much as possible… (sometimes it isn’t possible though..)

Again, personal opinion, not really trustable information, I know a lot of smart people that disagree with it and I’m sure most of the people that will read this will also disagree. – Different problems, different backgrounds, different experiences, different opinions…

About the JavaScript community and other dev communities

It doesn’t matter which language or which community, people will always have different opinions, and “religious wars” are going to happen. But let’s try to accept that even if you don’t agree with some people thoughts/opinions it may make sense on their context and things that you value more may not be as important for them…

There are a bunch of different libraries that does similar things, each one has a benefit or disadvantage over another and usually they inspire each other… remember that for the person who created it was probably the best solution that he could think to the kind of problems he was trying to solve with the available time and knowledge… – I usually find myself looking to code that I wrote 1 year/month/week/day ago and finding many things that could be improved or that are plain wrong, it’s usually easier for someone that is from outside to spot errors, don’t be too critical, remember that everyone commit mistakes and that opinions/preferences/skills changes often.

I think that disagreeing with other people is a fundamental thing for the development of any technology/community, it motivates people to be creative and try to find “better”/different solutions to problems and specially to think about it… but ego, is something that people should try to suppress…

Every software/platform has bugs and can be optimized – “People who live in glass houses should not throw stones” – unfortunately I just threw a huge one straight up with this post, I hope people don’t get it too wrong…

To Thomas

Thomas, sorry for the post and for the things I said here, I really have to thank you for all the knowledge you share on your blog, all the open source code that you created, etc… I learned a lot from you (I’m not kidding, I follow your blog since forever), it’s just that I disagree with some of your opinions and decisions – the same way I disagree with a bunch of other people and that you probably don’t agree with me – and I thought I should explain why I’ll probably stop developing my branch of zepto…

I also have to thank you for motivating me to put my ideas into practice, if I haven’t seen that you were starting zepto I probably wouldn’t code most of the stuff I coded and wouldn’t learn what I learned while doing it (since I would probably use jQuery, XUI or just plain JS)…

After trying to replicate jQuery API is that I realized how many different methods and method overloads exist and how “expensive” and “unnecessary” some features are (for what I’m doing, not for everyone), and how some features that I never thought would be useful are really required on the “internals”. It was a really good exercise…

Cheers.

PS: I really don’t want to start a flame war, check the about page to understand the way I think and the objective of this blog before getting mad with me.


Comments

Leave a Comment

Please post only comments that will add value to the content of this page. Please read the about page to understand the objective of this blog and the way I think about it. Thanks.

Comments are parsed as Markdown and you can use basic HTML tags (a, blockquote, cite, code, del, em, strong) but some code may be striped if not escaped (specially PHP and HTML tags that aren't on the list). Line and paragraph breaks automatic. Code blocks should be indented with 4 spaces.