Pages

Tuesday, December 18, 2018

Facebook Messenger and Telegram are the solutions for WhatsApp problems

Social networking, instant messaging collaboration tools are much advanced in consumer internet than enterprise tools. Actually, tools available for consumers were much advanced than the apps available for enterprises. The moment the product gets launched in the tech app store, the adoption rate is significant, creating a new necessity for the urban utopia to download from app store. In fact, these tools, in turn, caused a ripple effect in enterprises, redefining their collaboration strategy.
There are so many out in the market like Google Wave(email invented in web 2.0 era), Facebook, WhatsApp(SMS & VOIP for internet age), Telegram. The popularity of tools depends on solving people’s need at that point in time in an easier way, perhaps addressing the shortcoming of the existing product.
WhatsApp made the communication extremely simple, kept the people’s nervousness high by the live status of typing, blue tick acknowledgments, multi-message to multiple groups forwards at ease of convenience. It made the communication extremely simple & incredible at the same time exploiting the universal weakness of our brains through constant validation of our messages & replies.
The primary concern of the WhatsApp is local storage of media files where storage space gets filled with media junk apart from the inability to retrieve media at later point of time. This is due to the fact that WhatsApp does not store anything on their servers apart from 30 days since the message is posted. This post is meant to address the concerns of WhatsApp & propose alternatives — in terms of the functionality offered, cloud storage and seamless experience with the desktop version.
Though there are so many alternatives, here I am going to propose Facebook Messenger & Telegram along with pros and cons.
Facebook messenger offers quite comprehensive features almost to that of WhatsApp.
Pros :
  • offers individual chat.
  • group chat.
  • allows media uploads.
  • allows message forwards to multiple groups.
  • integration with facebook.
  • allows group chat even with anonymous.
  • desktop(web app) and mobile app access.
  • audio & video call. audio recording.
  • reactions to a particular message using emojis.
  • media shared are stored in facebook cloud. Can be retrieved at any given point even years later.
Cons:
  • requires facebook id.
  • chat communications are like a mail without a subject in a form of threaded conversations.
  • facebook groups and instant messenger groups are different and confusing.
  • group communications are a mail with multiple facebook recipients and the group name being the names of those recipients.
  • no mobile web access.
  • does not support forwarding of multiple messages though supports forwarding individual messages to multiple groups.
  • does not have search feature in individual chats though search is available for overall contacts and messages.

Figure 1a. Facebook Messenger Mobile app showing individual chats, groups.

facebook messenger android app

Figure 1b. Facebook Messenger web app.

Figure 1c. Facebook Messenger Inbox.




facebook messages web app © Image source — www.emgigroup.com
Telegram not only offers close to the capabilities of WhatsApp but also the usability experience and other form factors are as same as that of WhatsApp along with the cloud storage.
Figure 2a. Telegram mobile app.
Telegram mobile app — chats, groups & messages.


Telegram not only offers close to the capabilities of WhatsApp but also the usability experience and other form factors are as same as that of WhatsApp along with the cloud storage.
Figure 2b. Telegram desktop app.
Telegram desktop app — chats, groups & messages.

Pros :
  • offers individual chat.
  • group chat.
  • allows media uploads.
  • search individual & all messages.
  • allows multiple messages forwards to multiple groups.
  • seamless interoperability with the desktop version. Apps available for popular mobile platforms like iOS, Android, Windows Phone & desktop platforms like Windows, Mac & Linux. Access desktop version without switching on the mobile version unlike WhatsApp, which demands mobile internet to be enabled on the installed device.
  • media files deleted in mobile and desktop to free up storage space can be retrieved later from the servers as media and messages are stored in cloud i.e. in Telegram servers.
Auto-deletion of media in mobiles and desktop with appropriate settings to free up storage space. In order to do that, change the default settings of Keep Media from forever to 3 days as shown below( Setttings -> Data and Storage -> Storage usage -> Keep Media). Though deleted, these media are stored in cloud, can be retrieved later from Telegram Servers. This prime feature of Telegram addresses the limitation imposed by WhatsApp.


Telegram not only offers close to the capabilities of WhatsApp but also the usability experience and other form factors are as same as that of WhatsApp along with the cloud storage.
Figure 2c. Telegram Storage Usage auto clearing media files.
Telegram Clearing Storage Space Settings. © Image source — https://i.imgur.com/HRU8Daq.jpg
Figure 2d. Telegram Storage Usage using desktop app(Settings -> Advanced).
Telegram Storage Space Settings. © author
Cons:
  • requires a mobile number to sign in.
  • does not support video call at the moment.
  • does not support Snapchat’s stories feature at the moment(they might roll out in near future).
  • no mobile web access.
  • Uses homegrown MTproto protocol for encryption.
Ifyou ask my personal opinion of which tool to use, I would suggest opting Telegram for close-knit circles, that keeps users at fidgety and keep Facebook messenger for extended circles.
Note — The intent of the post is not make you quit WhatsApp and uninstall from the phone. Apart from lamenting on the problem of inability to retrieve media content at a later point in time and polluting the phone memory, have suggested suitable alternatives to overcome the limitation of WhatsApp.






Wednesday, November 23, 2016

One dollar solution to avoid null pointer exception in Java

This post is all about the null pointer exception, which we usually counter in our everyday programming. Before diving into the nitty-gritty of null, I want to go into why I named my post the $1 solution to avoid the null pointer exception.
Tony Hoare invented the null reference, later admitting that it was a billion-dollar mistake. Rather than making the same mistake of a null dollar solution, it would be apt to title my post the $1 dollar solution.
Let's consider an example for the paid dollar:

T t = null;

What do we actually mean here? Is 'null' a type of T or its subtype? It is just as valid a piece of code as typing what's below way and expecting the compiler to work for us.

T t; // compiler compels me to assign, huh?
Now, the variable 't' is just a reference without any object. 'Null' just explicitly endorses that convention. Accessing any of the properties of 'T' would make the compiler spew the famous 'NullPointerException.'
I recently got to know about the various remedies offered to salvage this problem. Among them is a way introduced in Java 8. My views vary slightly from the principles introduced. I was expecting Oracle to come up with a Null-Safe operator, similar to the Ternary operator, but again, they messed up and made another instance similar to bloated JEE non-wisdom stack.
Rather than me ripping that apart, let's head straight to some examples. Consider three classes A, B, and C, with A having a collaborator B and B having C:

class A {
  private B b;

  public B getB() {
      return b;
   }

}

class B {
  private C c;

  public C getC() {
      return c;
   }

}

class C {
  private int count = 0;

  public int getCount() {
      return count++;
   }

}

The general null check would be:

if(null != getA() && null != getA().getB() && null != getA().getB().getC()) {
     LOGGER.debug("The count is ", getA().getB().getC().getCount())
}

But using a null-safe operator like the one we have in Groovy...

int times = getA() ?. getB() ?. getC() ?. getCount();

Elvis' operator goes even further in returning the default value if it's null,

int times = getA() ?. getB() ?. getC() ?. getCount() ?: 0

Isn't it simple and natural? But Java complicated their design by compelling us to wrap it with the Optional<> construct and relying on flatMap and streams, thereby fabricating and garnishing code more with angle brackets.

a.flatMap(A::getB).flatMap(B::getC).map(C::getCount).orElse(0)// internally using if?

A mix of flatMap and scope resolution operators make the code cluttered and unreadable. But in the interest of doing more that viciously attacking null pointer exceptions, I just want to consciously be aware of null checks and their consequences when coding.
In fact, I love the design of the Kotlin language — keeping their design simple and straight, admiring the KISS principle.
Now, what if I use Java and still want to find a cleaner way of doing? Of course, we use IntelliJ or Eclipse, we can customize them to work for us by using annotations provided by them. Below, we'll get into how to use them and customize their severity level.

Using Intellij

IntelliJ provides two annotations, @Nullable and @NotNull.
How and when do we use the above two annotations?
For Java primitives, sensible defaults should be returned as something akin to 0, false, StringUtils.Empty.
For non-primitives, the method should convey the possibility of returning null. For example:
@Nullable 
findEmployeeById(int EmployeeNo) // may return null if there are no employee with the number

@NotNull
getCoursesOffered() // returns list of courses offered by a university which can be never null.

The findEmployeeById method has to be annotated with @Nullable, and getCoursesOffered should be annotated with @NotNull. It means that IDEs will enforce checking for null when findEmployeeById is used, and the null check would be redundant for getCoursesOffered.
The below picture (click on the pictures to get the full view) shows how to make use of @Nullable and @NotNull for the first example that we looked at. Just annotate the method with the respective annotation, and you get to see the warnings/errors. Picture #3 shows how to customize the severity of the Nullable warning message.







Depending on the severity level we set, the compiler in IntelliJ can show us Warning or Error upon inspection, highlighting the syntax.
Once the respective null checks/redundant check is placed/removed, the IntelliJ warning messages start to fade off.

Using Eclipse
For programmers who use Eclipse and reluctant to deprecate it for some reasons, it also provides two annotations @Nullable and @NonNull. The below pictures shows how to make use of @Nullable and @NonNull in eclipse and hopefully it should be self-explanatory.







Note: Despite encapsulating the code with a null check, the warning messages in Eclipse would continue to remain undisciplined, not like IntelliJ, where it uses its own brain deciding to display the message. 
I hope this helps keep log files pretty and ease the work for operational engineers!

Wednesday, March 12, 2014

Delicious social bookmarking Addon for firefox from Yahoo and AVOS

Many products for a given objective always enrages fierce competition and comparison which results consumers bewildered.

Post browser war, one compelling reason that mandates me to use firefox browser is, presence of standard addons which sets itself distinguished from others. eg - firebug where the same variants in other browser is yet to yield the kind one experiences in firefox.

Earlier where I was insane in promoting Ubuntu and Firefox to every mammal in this terrestrial, they lack fundamentals like driver problems with ubuntu linux and firefox plugin update. The only alternative is to go for mac and safari/chrome browser.

Meanwhile, for the users who still pertain to firefox, there was an social bookmarking addon 'Delicious' and it is no more available in firefox addon repository. Intially Yahoo bought delicious to wet their users with social products and could not make butter out of water. Later AVOS ghastly bought delicious bookmarks and tortures its users with their rough skins. Only savior is to use firefox addon, to get rid of horrible skins. Now even that has been chopped.

For internet addicts, who install firefox fresh and crave for delicious addon in firefox repository, I believe post google search would land you here.

Download zip file and rename the extension to xpi. Hopefully this should work!! Enjoy!



Sunday, January 13, 2013

Nasty Skepticism




       Though a non technical post, a series of post about questioning traditions and blind belief, myth, in the name of skepticism, made me to write about meta-skepticism.

        Skepticism being a hot cake in today's DNA, younger generation feels as if they have found and executed some ground breaking idea by calling themselves skeptic. If I interrogate and inspect, I tend to not to phew-phew their illiteracy and ignorance.Their skepticism is all about questioning the tradition, which is according to them defined by some wave length. I mean they try to question the wearing of under wears imposed by their fathers. When they spew some few questions about religions and Lord Ram without basic understanding of any, they raise their T-shirt collar and say to the world "I am far more superior than any one else. Even Einstein(pity fellow just invented e=mc^2 and not knowing to pull the threads of Hinduism) or Jagadish chandra bose(Unsung Hero) is under my feet". High time sigh no, when we endure in to million number of problems and nuke our skepticism?

        Everyone wants to become popular right from Anna Hazare to Nonda Bizarre. But ways of becoming popular only comes not more than two ways. One really really being a prodigy, living for and breathing it like Steve Jobs, Tesla, Ramanujam, Sachin, G.D.N. The other cheap way is plunging in to some controversies, delivering their verdict with out knowing what it is(A beautiful vadivelu comedy where he tries to mediate in selling second hand bike, having no clue about it). Recent storms by Lawyer Mr. Ram jethmalani about Lord Ram and Priya Ramani about her take on Ram worship, fit the latter. What all they need is the sheer publicity, gaining traction in the media. If I conduct a exam on Hinduism, most of the folks who write in TNIE, Livemint, would deliberately fail even to score a decent failure rank. Their idiotic skepticism never helps them to realize that they are digging out a buried set of values and popularizing it. Of course, comedian exist in many forms not only actors.

         When Atheism meeting happens around my area, they applaud Ravan, by accusing Ram without even knowing that Ravan is a devotee of Lord Shiva. Kamal haasan rationalism is another ultimate high, where Dosa-avatharam  movie is alone enough to combat his atheism. Other skeptic thoughts(they are calling that way, don't blame me) were male chauvinism that Hindu religion supports, blaming Indian Origin and tradition quite often. Perhaps India is a democratic secular country no, where govt sponsors money for the religions apart from Hindu and at times giving a heavy blow to Hinduism. India almost being made absurd by politicians, our so called skepticians take advantage of that and post their voice, adding some spice to it. My post here is not to give explanation for Ram Jethmalani or Priya Ramani questions, but to reveal their bruises on their skepticism. My understanding of their bruises more or less fell in to the pattern I am about to describe below,

- A rational mind is about solving fundamental problems, worrying about present and solving the problems that future generation needs. But their skepticism is about choking tradition. Sigh!

- Their skepticism of taking illegal untested drugs from multinationals, usually claiming lives of people. Further, accepting pluto as a planet and hiding a pumpkin - Kappa Adromedae in the system.

- Having dis-taste for purity in Carnatic Music and enjoying pure Beethoven and Mozart classics. Knowing not to appreciate sheer brilliance of St. Muthuswami Dikshathar, but beethoven. Skepticism is not about to question Western, if India and Indian, then OK. 

- Having a Mac book/Mac air with a highly coupled Mac OS, Apple being a biggest monopoly player, and cribbing about Microsoft. Waw! what a skepticism?

- Literate/IT professionals are the biggest players of Polythene bags. Shop vendors find tough to sell and convince customers without plastic bags, where an tribal in Yelagiri knows his right not to sell bags and harm environment. Wow! What an skepticism of our urban?

- Kancha ilaiah says Lord Ram is a killer and being regarded as a epic hero where he shot down Ravan and saved Seeta, though Ravan did nothing to seeta, besides Lakshmana cutting Surpanakha's nose. Kancha ilaiah's skepticism guarantees every one has right to kidnap his wife and can keep her safe and he would not mind it.

- A popular blogger, who dismissed Telecom Raja's scam, saying everyone has Raja inside, brave what a skepticism!. His skepticism says large quadrants of money and infinitesimal amount are equal and identical.

- Kalaignar's rationalism where he knows to make trips to center to demand cabinet position for his family members and not for tamil Elam. What a Periyar Rationalism. Probably his rationalist Guru Periyar might have come in his dreams asking him to distribute free TV and shut off the power supply so that programs aired on his kalaignar TV programs could be well received with TiPi technology(Television without power).

- Government which privatized educational sector and under took TASMAC as a govt sector. Their skepticism is nothing much apart from producing solid waste of 21 year old talents, unless the students themselves masturbate their minds.

- Central Govt started imposing restrictions on Cylinders, Electricity, hike in fares. Life sophistication became significant, some how appliances was capitalized in the name of civilization. Money has been swindled and swallowed. now its time to de-civilize and de-generate. Their skepticism is just watch it.

- Our cultural, scientific innovations and urbanization has lead to a million dozen problems, climate crisis, global warming, weak monsoons. Water and breathing air are being bought at cost. Mr. Ratan Tata being nano in thought, worries about nano being not parked in everyone's house. Every innovative solution as well creeps problems too. Skeptic ones calls this as 'life transformation'. 

- Go green initiatives in the IT sector is high time comedy, where their periodic mail about raising awareness on greenness frequently crashes my unstable outlook(outlook will be adamant some times not receiving it, some how sensing my pulse). Gandhi Mahatma, started Khadi to preserve villages, people and nai talim movement is one enough to alleviate problems. Whereas corporate skepticism is all about building and polluting urban by dumping people and more screw one's life.

Last take, skepticism is all about what one has been destined for, doing it right, give something to this world, country, this people, working for the benefit and up liftment of community. More essentially 'Simple Living and High Thinking'. Living examples, Bhagat singh, Subash Bose, Narendra Modi. But the people and skepticism I am talking about just just reveals their weakness where they need pillars of Hinduism and Hindu Gods for their cheap publicity and gaining popularity. My meta-skepticism says this vastness, diversity won't usually allow them having long, just to troll on the subjects they are empty at and increase idiotic follower count.

- Finally be skeptic enough such that when I release TortoiseMQ, be mind that it would not run slower than RabbitMQ just because of name. Ha Ha


Wednesday, September 19, 2012

Scala Functions Apply

This is a short post about sweet spots of scala functions such as apply, update and case classes using these constructs.

Coming from a Ruby world, developers usually snub at Java claiming Javascript and Java, substring of JS are a mere naming coincidence, without any functional relations. Hmm, perhaps recent hot cake Functional programming which has been tombed in Egypt several thousand years back is a mirage in Java community, where java is targeted for non functional, non mathematical people, who well mutate everything in their life apart from Java. Apparently some serious thought breakers ice sandwiched Java and started exploding JVM that catered to beautiful languages like Scala and Clojure.

Scala bieng a functional language believes in functions being first class citizens with a slight mix of object oriented programming orthogonal to it. This helps in writing clean, concise, expressive code.

Here are some experiments by firing scala REPL,

To define an anonymous function,
val cube = (x:Int) => x * x * x
#cube: (Int) => Int = <function1>
cube(5)
#125
Its clear that it takes an argument Int and returns an Int. Further we can explicitly specify return type say Double,
val cube: (Int) => Double = (x) => x * x * x
#cube: (Int) => Double = <function1>
When I started exploring function1, I landed on to interesting landscape, behind the scenes scala does million number of things by providing this sugar coated pill.

function1 is actually an interface with apply method and anonymous class out of it is created copying the method definition inside apply method. In fact the above cube function could be written in this way too,
val cube: Function1[Int, Double] = (x) => x * x * x
#cube: (Int) => Double = <function1>

cube.apply(5)
#res2: Double = 125.0

cube(5)
#res3: Double = 125.0
look how scala beautifully desugars cube(5) to cube.apply(5).

The Function1 would probably be a interface like this
public interface Function1<A, B> {
    B apply(A a)
}
and creating anonymous class at runtime, copying method definition inside apply method like below(note - below I refer Scala types and not Java)
cube = new Function1<Int, Double>() { Double apply(Int a) { a * a * a }}
cube.apply(5) #actual way
cube(5) #sugar coated pill in Scala
now if I have a polynomial equation, say x^2 + y^2 the thing would be even more beautiful,
val square: Function2[Int, Int, Double] = (x, y) => x * x + y * y
#square: (Int, Int) => Double = <function2>

square(4,5) #square.apply(4,5)
#res0: Double = 41.0
The deduction here is, if n is the size of arguments with last being return type, then the interface name would be function{n-1}.

In the last example we had two unknown variables x, y and return type - hence Function2.

In fact any class with apply method works same way,
class ApplyTest {
    def apply(in: Int) = in + in.toString
}

val applyTest = new ApplyTest()
#applyTest: ApplyTest = ApplyTest@5292e6

applyTest(5) #applyTest.apply(5)
#res0: String = 55

Usage of apply method in real time applications

apply function syntactic sugar could be used to fetch domain object  or model object from a singleton, example
object Employee {
    def apply(id: Int) = "retrieving from database employee object id " + id
}

Employee(5) #res1: java.lang.String = retrieving from database employee object id  5

There is another sugar coated pill in scala - update function which I will cover it in next post.

Sunday, June 17, 2012

to_proc working magic

I had an interesting puzzle in ruby to capitalize words with in a string.
text = "this is an interesting blog post about to_proc"

text.split.map(&:capitalize).join ' '

# "This Is An Interesting Blog Post About To_proc" 

Just was nailing down the answer I got, with the internals wired.
Normally single argument block comes after a map like this,
{ |arg| arg.capitalize! }

But how does ruby allows us to use syntactic sugar coated pill like passing a symbol to a map?
Explanation can be found here, symbol to_proc.
Need to smell some samples & create your own version of it? Here below...
class MyString < String

  def double
    self * 2
  end

  def triple
    self * 3
  end

  def map_char(&p)
    result = []
    self.each_char do |c| 
      result << p.call(c)
    end
    result.join
  end

end


name = MyString.new("hariharan")

#usual way
p name.map_char { |m| m * 2} # "hhaarriihhaarraann" 

#syntactic sugar coated pill
p name.map_char(&:triple) # hhhaaarrriiihhhaaarrraaannn

On whole, the mist here is class 'Symbol' has a to_proc method, that accepts  object  as an argument and passes the message of 'symbol' to that object.

Stay tuned for my next blog about scala magic sugar coated stuff...

Saturday, February 4, 2012

Java 8 Lambda a terrible troll and Java is lame duck

            Nothing more to scare about the title, and more, this is not a post to slam or defamatory content against java. The Recent announcement about java 8 to support lambda and introduce functional programming abilities to java made me to wonder, really do we need this? Once my friend Mr.Balan said its Steve Jobs ,not apple and apple would had not been great without steve jobs. Its all about people who make things great rather than believing group or companies.

            Thanks to Mr. Cedric Beust whom  I respect a lot, his outstanding creation TestNG. The title of this post is the tweet he mentioned on me noting 'Terrible troll' when I asked 'Why google endorses java and why not something better than it'. Google employee tweeted saying that 'Google would had invented java if not exist'. More, google employees does not show overwhelming response to new JVM/CLR languages like scala and clojure. However Cedric can write some disappointing post like coding in high level type system languages would eclipse if not using eclipse from  scala back to java. This post made my adrenaline going. In fact prestigious, proud ruby developers use vim, yes honest authentic passionate ruby developers use vim, while some use textmate for ruby coding.

            Then I looked back at my poor java announcement that any chance for atleast java 8 to swing the theories of Functional programming. But in vain, where my respected oracle developers traveled with camels to thar desert, sat under khejri tree, intensively thought about building expensive lambda islands in par to what Dubai tries to. Unfortunately they failed like creating Indian Mumbai building constructions with poor quality material. In 2002 C# finished chapter, Scala moreover finished in providing lambda in 2005. Then, what is the point in creating a huge buzz about lambda in java 8 by the year 2012, then saying 'Java will adopt C# syntax'? This should have been wisely copied or taken 8 years back.

            Java already screwed with some concepts like anonymous inner classes. Though I am not object oriented or based specialist, but really I could not connect with reality about class nesting inside a class. Can a person nest a  person inside? If so what is the use of that.

            Actually speaking, this is what happens with sorting a collection, where comparable interface is implemented and collection.sort in turn calls the comparaTo method for status, to swap the element positions. But where is the thrill?

            Java 8 lambda is a lame duck. Because there are no first class functions. Functions are not senior citizens. Otherwords, its more or less same way of achieving to sort a collection by implementing comparable interface. Whereas in scala, functions are senior citizens. Let me get straight to examples.

Open scala prompt, to find a minimum element in an list,

val values = List(1, 2, 3, 4, 5)
println(values.foldLeft(0) { (acc_res: Int, index: Int) => if(index < acc_res) index else acc_res }) 
//prints 0 //To find maximum, (just change the comparison symbol :)) def maxi(acc_res: Int, index: Int) = { if(index > acc_res) index else acc_res } println(values.foldLeft(0) { maxi }) //prints 5


What the same to do in Java, to find the minimum element, comparable interface must be implemented or custom interface is created in favorite naming in favorite eclipse, that hangs windows xp for 5 mins, a method declared in interface, and then defined to return status in implementation class. Finally call made to implementation class that implements of type 'comparable' sort of interface(or custom interface)

Now coming to Java 8 Lambda, serious comedy fuels, just look at the sample lambda program

public class SimpleLambda {
  interface HelloWorld {
    void greet();
  }

  {
    HelloWorld greeting = () -> System.out.println("Hello World!");
    greeting.greet();
  }

  public static void main(String... args) {
    new SimpleLambda();
  }


}


Type of anonymous functions or lambda? Its the same as interface.
Hence interface should be defined prior to assigning a anonymous function which is not the intent of lambda in other languages.

To add, a question already in heavy discussion on quora for oracle to declare explicit support to scala instead of spreading fad.

Since Java ones are tamarind to declarative programming, scala itself more sufficient.

Microsoft .NET can better declare explicit support for clojure, as I believe C++ and C# programmers be intuitive and pick up clojure on CLR.

James gosling intent of java is just to please the average coders, I am not one and you too.,,

Enjoy functional programming, DSL and kudos to Scala and Clojure.