Tuesday, April 25, 2017

Javascript and us

Programming languages are getting as sophisticated as us!

Javascript, for instance, has "callbacks" that let us call the operation back when the output is ready. According to Dr. Venkat Subramaniam, if you are waiting for a callback (like you wait for your girl to call you back), you will either be in a pending state (waiting in the stack of execution leaving way for all unimportant processing to take place) or an unprocessed state (till you end up with a white beard!). So, we typically set a timeout and proceed with our expected chain of responsibility.

Javascript also provides a very beautiful "Promise" object that can nicely wrap the callback paradigm. Promise let's you transition seamlessly between synchronous and asynchronous chains of execution. A promise clearly sets the expectation on whether you can
  1. wait, 
  2. throw an exception (error) OR
  3. exit/proceed
Very much similar to real world promises.Only these promises are slightly better than the real world ones. At least, you can debug. 

Libraries like RxJS provide ways to listen on to a (emitted) stream of objects. This emitted stream is processed in various ways using map, filter and reduce. This will let us sanitize/cleanse, transform and aggregate UI data. This is more like extending the previous promise paradigm to a stream of objects. Can't wait to get hands dirty with some code!

Parting with some residual thoughts from Scott Davis on false dichotomies of perception. Not everything is binary, most real problems may not be "Rocks Vs Sucks". Strongly reminds me of my dear friend, who says "The real world is not digital, Naveen. It's analog!" True he is! 

No comments: