COMPUTER SCIENCE, TECHNOLOGY

Android – Picasso vs UniversalImageLoader vs Glide vs Fresco

Someone asked a question on Stackoverflow the other day about the existence of so many image libraries in Android .

Since this is a pretty opinionated topic, I made a table to represent what I thought about the libraries based on personal experience of having used them or working with people who used them

Screenshot 2015-04-16 19.42.09

(Click on the image for better visibility)

Its interesting to note that Fresco seems to be a new library that is doing some interesting optimizations to memory use and could be worth checking out.

COMPUTER SCIENCE, STARTUPS, TECHNOLOGY

Interview engineers like a reverse bloom filter

Hiring is hard. Hiring great engineers is harder. But cleaning up bad engineering work from bad hires is the worst!

If you are an engineering manager like me, its your responsibility to hire engineers and generally set the bar very very high for candidates. The most obvious well known trick is to hire people smarter than you(The whole A’s hire A+’s, B’s hire C’s thing). But many a times, especially in startups or service companies, due to high pressure demands, this bar can go down and there is nothing worse.

There a lot of the times engineers can be false positive -i.e. they come across as brilliant in the interviews. Many a times this is because engineers are extremely well prepared specifically for interviews(having gone through the thousand of resources available online, the data set of available questions,unheard of yet, is bound to get smaller)

So , interviewing has to model a bloom filter in reverse

Background on a bloom filter:

During the process, you are probably involved in a couple of rounds with the interviewee, but in general its your engineers who interview potential candidates. Engineers understand engineering terms better. Hence we should be modelling the process and communicating to the engineer similarly.

Bloom filter.svg
Bloom filter” by David Eppstein – self-made, originally for a talk at WADS 2007. Licensed under Public Domain via Wikimedia Commons.

A Bloom filter is a space-efficient probabilistic data structure, conceived by Burton Howard Bloom in 1970, that is used to test whether an element is a member of a set. False positive matches are possible, but false negatives are not.

The idea is that a query for an item returns either “possibly in set” or “definitely not in set”. Elements can be added to the set, but not removed (though this can be addressed with a “counting” filter). The more elements that are added to the set, the larger the probability of false positives. Plus a bloom filter is a great data structure particularly if you are using strong caching mechanisms. Hence you’d do good getting your engineers to learn a swanky data structure while they interview other candidates.

How does this apply to interviewing:

Applying this to an engineering candidate is interesting. You have to be biased towards false negatives, false positives should not make it. Ala a reverse bloom filter, which could say a candidate should be looked at as  “Great but wont make it” and not “OK should make the cut” or False negatives are possible but false positives aren’t.  Essentially this says, its OK to lose very very good engineers who don’t make the cut(but certainly are great), but its absolutely not ok to hire bad eggs on a false curve. The cost and time spent on training and cleaning up behind these engineers can get exponentially higher than the time spent carefully interviewing candidates and selecting the right one. 

Might be a convoluted way to think about it,  but it’s worked so far for us. 🙂

Comments welcome. Ok maybe instead of a reverse bloom filter I could have said a lossy hash table or a LRUCache or even a direct mapped cache. But they don’t sound as catchy 🙂

COMPUTER SCIENCE, STARTUPS, TECHNOLOGY

16 Things

Andreessen Horowitz

We don’t invest in themes; we invest in special founders with breakthrough ideas. Which means we don’t make investments based on a pre-existing thesis about a category. That said, here are a few of the things we’ve been observing or thinking about; we’re especially grateful to our founders/companies, and the entrepreneurs we meet with everyday, for their insights here…

[For other trends we’ve covered already elsewhere, please see our series on mobile eating the world (with lots of charts!), you bet your SaaS, and government x tech.]

View original post

COMPUTER SCIENCE, TECHNOLOGY

Will the real RESTful API please stand up

First things first – I am interviewing engineers for Pengala for the fast growing engineering team. This is the job link, so please apply if you are interested.

I’ve interviewed about 60-70 people so far,but during the all of the interviews(yes all of them) no one could really define RESTful API’s correctly. I realized that developers have a very convoluted understanding of what RESTful API’s are and in fact many of them use these API’s blindly. I know a lot has been written about it but most of it is either very large documentation or just shows best practices.

So I want to debunk some myths about what RESTful API’s are.

  1. REST is a protocol like HTTP ==> Incorrect, REST != HTTP
    1. Let me explain in bullets
      •  REST stands for Representational State Transfer. It is a framework – this can get confusing again, what the hell is a framework. So think of REST as a SET OF CONSTRAINTS(we’ll get to what those constraints are) to build highly scalable fault tolerant client server systems. The world wide web is actually a great example(and the biggest, but again slightly flawed) of REST.
      • It IS NOT A PROTOCOL. A protocol in web parlance is a communication interface or rules that define how components communicate on the interweb (from types of data to the interface types)
      • HTTP is a protocol. Hence REST ! = HTTP. But its the most used transport protocol with REST. You could as well use FTP or SMTP, but nobody likes those.
  2. But most probably in your case and in most cases HTTP API == REST API, i.e. almost certainly your REST API’s aren’t pure REST, hence you really cant call them those
    1. Let me explain again in bullets
      • Let me drill down the idea again – REST is a set of constraints. What are those constraints
        1. CLIENT – SERVER – Quite obvious
        2. Stateless – Every request you make must contain state information, this is the clients responsibility and the server is stateless
        3. Cache – Response messages from the service to its consumers are explicitly labeled as cacheable or non-cacheable.This way, the service, the consumer, or one of the intermediary middleware components can cache the response for reuse in later requests.
        4. Layered architecture – A REST-based solution can be comprised of multiple architectural layers, and no one layer can “see past” the next. Layers can be added, removed, modified, or reordered in response to how the solution needs to evolve.
        5. Code on Demand(optional) -This optional constraint is primarily intended to allow logic within clients (such as Web browsers) to be updated independently from server-side logic. Code-On-Demand typically relies on the use of Web-based technologies, such as Web browser plug-ins, applets, or client-side scripting languages (i.e. JavaScript).
        6. Uniform contract – Probably the most important of the lot and defines the REST aspect of REST API’s.
      • Lets look at Uniform contract and what that means.The diagram essentially shows the important concepts. 
      • Lets now focus our attention on the word REST shall we. Representational State transfer. So clearly there It’s about transferring representations of the state. Of what though?  Of Resources. Now what the hell are resources. A resource is a contextual mapping of entities that can fit into the URL model of the client – confused yet ? Example . Lets say I want to view a bank account from a database table on a remote server. My resource entity here is an account. Now if I want to get the detail of my account, how do I get it? I make a call over HTTP like this  => serverurl/v1/account/acc_number which inturn is doing this
        • GET /account/acc_number HTTP/1.1
          Accept: application/json
        • The resource here is account, the Accept:application/json portion is basically the representation of data that is being transferred. And we are doing this using the HTTPVerb GET.
      • So most important concepts here are Resources, Representations(Media Types) and HTTPMethods
      • Now REST Calls for HATEOAS – a really weird acronym that stands for Hypertext As The Engine Of Application State. This basically means that a main constraint of any restful api is that the responses drive the API usage directions. i.e. because the server is stateless and the client has to know what the endpoints are to call , this data must be transferred back in the response as hypertext i.e. URL’s. Confused. Lets take the previous example.
          • GET /account/12345 HTTP/1.1
            Accept: application/json
          • Now with HATEOAS the expected response would be something like this(scroll sidewise to see the response)
            HTTP/1.1 200 OK                                          <?xml version="1.0"?> <account>  <account_number>12345</account_number> <balance currency="usd">100.00</balance>   < link rel="deposit" href="/account/12345/deposit" />    <link rel="withdraw" href="/account/12345/withdraw" />   <link rel="transfer" href="/account/12345/transfer" />   <link rel="close" href="/account/12345/close" /> </account>
            
          • As you can see, the reponse, the “link”-tags allows us to find out the URLs that are needed for the specified actions for say Deposit or withdraw. THIS INFORMATION YOU WOULD HAVE NO CLUE ABOUT AT THE BEGINNING unlike most “REST API’s” today which document these. Getting the point?
      • So for a RESTful API to be truly RESTful it has to have the uniform structure of Resources, Representation and Methods as well as conform to HATEOAS.
      • IN GIST – HATEOAS basically implies that the only thing the client knows is the URI endpoint and everything from then on has to be driven by hypertext responses. This is violated the moment you document and expose individual. Another example is, lets say I am on STACKOVERFLOW. The only thing I know is the URL, I know who/what a user or a question is (resource), I know the media types(Representation) and the website itself provides you hyperlinks to navigate through the website. This pretty much represents HATEOAS and lends the architecture to decoupling of logic of client server, and this is what I mean by www i.e. the web is RESTful in itself. If STACKOVERFLOW was not built conforming to HATEOAS, and like most of the documented “REST API’s” these days, then instead of links, you would have to type in stackoverflow.com/questions/<id>, replace id with the Question.id and paste that on your browser. MEH, see what I mean?
  3. I am using JSON , that makes my API RESTful ==> Incorrect , if anything using JSON violates constraint 6 of REST, hence killing the fact that your API is RESTful
    • If you look at the HATEOAS component defined before, its clear that JSON is not Hypermedia, and hence one of the constraints is lost and essentially your API is not pure REST anymore. There is work going on this area – particularlyJSON Linked Data – http://json-ld.org/ that makes the attempt to confirm to HATEOAS.
    • So you could use XHTML to make your REST API Purely RESTful
  4. I should be using REST because SOAP sucks – or thats what they tell me.  ==> Incorrect
    • This might come as a shock to many who seem to have convinced themselves that REST is in someway the absolute holy grail of Webservices. Firstly REST and SOAP are two very different things. Here I go again – REST is a set of Constraints for good service architecture while SOAP is a protocol. Simple object Access Protocol. I think the whole REST is a protocol nonsense stems from the constant comparisons made between these two words. Its highly dependent on your business needs. SOAP is tightly coupling, both the client and server need to be clear on an interface of communication, but in large systems that have tightly coupled business logic and legacy applications, this is quite useful to have and certainly wouldn’t be needed to be replaced by REST.

So,

REST – Representational State Transfer – Set of Constraints for building scalable fault tolerant client server systems, architectural framework

RESTful – Webservices that use the REST architecture

SOAP – Simple object access protocol

But here’s the thing, its hard to follow all the principles of RESTful services to the letter, and in many cases harmful. But hopefully this clears up some of the myths of what defines pure REST API’s. Its not ok when developers basically follow the myths I’ve presented, and are in the dark about what RESTful services really are. As long as what developers build are HTTP API’s that follow some best practices(another post on this to follow just for best practices for writing API’s- RESTful or otherwise) things should be fine in the webservices world.

Bonus Reading and Credits:

A word on Richardson Maturity Model – http://martinfowler.com/articles/richardsonMaturityModel.html

And the original Fielding dissertation on  Rest – http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_2_1_1

SO links: http://stackoverflow.com/questions/19843480/s3-rest-api-and-post-method/19844272#19844272 and  http://stackoverflow.com/questions/19884295/soap-vs-rest-differences

REST Cook Book: http://restcookbook.com/

STARTUPS, TECHNOLOGY

An Engineering View of Zomato

 

view my food journey on zomato!

 

This is me on Zomato. And like the widget says I’m a big foodie.

Frankly I don’t really like apps that ask me to do stuff like take pictures of the food I’m eating, or rate the place I’m eating at, or post reviews about the place etc., I really only use such apps for place discovery and rating. I’m not really a participant. You could call me a leecher in torrent parlance – but thats slowly changing with zomato. I really find it useful to read reviews and ratings on restaurants and want to give back to the community.

Things I love about Zomato.com – the website:

1.) The UI and UX – Probably one of the best websites out there. Everything you need is right there where you need it to be. Clean, neat, great!

2.) Collections and suggested searches- Yes I might not want to search a lot of the times , I’d rather see a list of the highest rated places depending . Mine and Spock’s favorite collection is “Pet friendly”.

3.) Speed dial – Yep, this is a life saver. Particularly in a startup where I work, with no catering, I just call up someone from the speed dial and have food ordered.

4.) Turn off the background lights on clicking  the menu – nice(small things matter) 😀

Things I dont like on the site:

1.) Gamification – Yes its the ‘in’ thing, and drives user engagement, but for me gamifying food reviews doesn’t make too much sense unless there is an incentive for large scale gamification. And really gamification shouldn’t drive reviews which can easily go haywire(Yelp anyone?), whereas good reviews should drive the site. The good thing is that everything is modded, but that system needs to improve.

2.) Numerical rating system – I understand the logic behind having this, but quite literally . I dont know whether Sattvam, a place I went Earlier is 3.5 or 4.0 . No real objective way for me to rate. My suggestion, do A/B testing with a 5 star feature, and also with one with no decimals points. And get feedback. Rating systems are hard to master.

3.) A bit too ballsy marketing campaigns – Hit/Miss as we know by now. Generally, mathematically, misses are costlier.

What’s missing:

1.) Open tables like reservation system – If I am going to use the website religiously, I need to be able to reserve tables in crowded restaurants for sure.

2.) Offers Zone – Hey if you are going to have a website on which are the best restaurants might as well tell me where I might get a good offer tonight.

 

Things I love about  Zomato – the android app:

1.) Again great UI/UX , The app is very very neat, and it shows you everything you need on the front page. Plus on a slow connection it still manages to pull through, though its quite image heavy

2.) Nearby – Of course, you gotta love this one. Very accurate, which is the biggest need of this feature.

 Things I hate about the app:

1.) Nothing yet really. Maybe it needs the old splash screen image back, but thats about it 😀

Whats missing:

From a UX standpoint, for the android app,  I’d love to have the complete restaurant experience with Zomato app. i.e. Search for a great restaurant that suits my needs(or better yet, suggest them to me based on maybe my mood), tell friends about it and make plans, Reserve tables at the restaurant, Split bills with my friends and see who owes who and what, rate and review the restaurant once done.  This is where maybe Zomato should head towards in my opinion. Not just another Yelp wannabe.

So there. I’m not an iOS User, but I’m planning to make the transition at some point this year, so no inputs there.

Disclaimer: This post is only 20% motivated by the prize.