Expressiveness of a Thought

One of the greatest manager retires

Posted in Multilingualism, Polyglotism by mohanjune on October 31, 2013

It is heartening for millions of soccer fans around the world to hear that one of the greatest manager of football retires. No matter a supporter or fan or manager of the steepest opponent club’s envy of him, still deep down he is revered. Sir Alex Furgusson has penultimately declared to retire on the juncture of Manchester United being crowned 20th English Premiere League Champions. What an achievement !!! Sir Alex has been one the longest serving manager in the history of soccer leagues with lot of winning cups and making Manchester United banner flying across the world.

So, what makes him such a great manager and never to vanish in the oblivion in the history of soccer. He is childish, jumps with jubilation whenever United scores, rebukes his players on mistakes and commends on good performances,  having a penchant desire to win each and every game. Made each every soccer fan either to follow MUFC or envy. Consistently won several cups and took MANU to new level on the soccer world.

Hard working IT professionals and awards

Posted in Life of a programmer by mohanjune on January 30, 2013

Do you think giving away awards and recognition to hard working resources is enough to keep them motivated for long. No doubt they deserve it. Working hard necessarily doesn’t mean productivity is always good. How long can they continue in the manner. At some point of time either they will falter, fall sick or just quit feeling frustrated. Even if the person is till motivated enough to continue like that for couple of years, just imagine what might be the condition of the health and personal life.

Steep competition, market pressure, bad estimations with tight schedules, managerial pressure, client pressure are major reasons. Well there are other reasons also. Working hard for long hours reduces the productivity of any person. If the resource is really good and delivering good due to the reasons as stated earlier with mere spending several hours more than normal working hours for too long (too long duration over a period), it is time to ponder to think otherwise. Have we already accepted that working hours and hours has become de facto working timings?

Do we think that time has come to sit back and think of making such hard working productive person give some time to breathe, let him spend some time outside of work occasionally with family and friends. So, guys it is time to ponder how to get out of that and foster better and smarter deliverance rather than forcing sheer work hard culture for long hours. Contingency plan needs to be in place to avoid dependency of such person for very long time and sharing of the work load.

We agree that occasional extra hours are needed sometimes, such in cases of releases. If you are such person you need to consider about your long term goals and personal life. So, fostering awarding alone such cases will not help long term both for the organization and the resources. Also I have seen it is inculcating others to spend more time in office, just to be recognizable that they work hard, even if they don’t have anything significant to contribute. Amazingly and sarcastically some managers forcefully allow such culture to foster. If we believe that is how IT is and how it will be then I am sorry to put these points. Else change our attitude towards work and our fellow human beings.

Creating small apps while providing training sessions

Posted in Life of a programmer by mohanjune on January 7, 2013

I had to create a training road map in my new organization. That too I was the trainer. We have few projects which are using Spring Framework and some of the resources including  trainees were not that familiar with the framework. Hence decided to go with Spring Framework starting with Spring Core, Dependency Injection and several of the sub-systems of Spring including Web, ORM, Views etc etc.  As I started with Spring Core and then started creating slides and sample code for my presentation, somehow I thought why not create a small application and build on the same with the subsequent topics. That way the attendees would be the same context (will be able to digest the business case and its applicability of the sub-system) as well the sample code would end up as an application which can be useful subsequently. It can be turned into a training ground to enhance the app with hands on guide for the the attendees to work on and extend it in case needed.

So, what I though initially was to get a online feedback form (for whatever reasons, one of them being that my new organization was small and currently there were no such online tool). Getting feedback from any presentation is very valuable. Well it can be any application or tool which can be useful for you or someone else. Ultimately a complete application was my main intention which will teach end to end development using Spring Framework. And yes, it could have been any other framework or tool say for example the well establishing Typesafe stack (Play-Scala-Akka). Lot depends on the kind of projects and technologies you are targeting for your own products or clients. What I mean is if the training road map consists of a series of sessions focusing on various subsystems of the framework from presentation to the data access, then why not start creating a small application rather than wasting all the unrelated sample code in case it is so.

The training sessions and sample code not only had created a nice useful tool but also few new things which I learned in the new release of Spring framework, also building on the same code base helped the attendees understand better in terms of usage of the various modules of Spring.

Scala Data Structures – Lists

Posted in Data Structures by mohanjune on January 4, 2013

Lists in Scala are immutable. Not only lists but almost all of the data structures in Scala are immutable by default. This is where the main difference between Java and Scala. This gives a power to build concurrent applications rather than programming it explicitly. List construction and parsing is also different in the sense this gives the power of functional programming features. Learning and working with Lists gives a good foundation work to learn other data structures available in Scala.

Lets start with the fun in working with Scala lists. First of all Scala Lists are not index based. Instead a operator  “::” (double colon) which is called as ”cons” is used to construct Lists.  The cons works as infix type operation. Means cons is kind of method call with two operands;  cons(operandhead, operandtail) or rather ::(Operand1, Operand2). Significant thing to mention here is the Operand2 is the rest of the list which also contains “Nil” which is end of the list. We will come back to Nil later on its importance of being in the list and what it represent. Operand2 is the rest of the list means the Operand1 is added to the list. So, the elements are added as head rather to the tail. A list which is represented as x::xs represent x as head and xs as tail (Important thing to be remember and understand of functional aspect, though not that tough). Understanding this basic pattern is important because this will be a kind of building blocks of implementation.

 /*
 * 1. The way create Lists is use a 'cons' operator (:: double colon)
 * 2. The next list creation is actually a syntactically easier one
 *    but underneath it uses the cons operator.
 * 3. A simpler syntactic sugary list definition
 */
 val nameswithcons: List[String] = "Mohan" :: ("Jack" :: ("Tommy" :: Nil))
 val typesafenames: List[String] = "mohan" :: "jack" :: "tommy" :: "nerd" :: Nil
 val listofdouble:List[Double] = List(11, 7, 30.00, 99)

The above examples make the lists type safe at compile time.  However if you don’t specify the type then the Scala compiler would infer the type depending upon the highest type, for ex. if the list contains a Double value like 30.00 as an element in the above example, it would infer the list of type Double. Another important thing to remember here is in case you don’t specify the type and add String as well as numeric elements then Scala compiler would infer it to type Any and it will become a Tuple (a list which contain any type of element). We will come back to Tuple later.

Now, how do you operate on your lists.  Scala has got only three basic operations which are head, tail and isEmpty. head gives the top element, tail gives the rest of the list and isEmpty is a nice way to check if the list is empty and pattern matching. Quite perplexed right. So, this brings another concept of processing in functional style where recursion comes into picture. Recusrion gives a good way with less code in processing Lists in Scala and for that matter in other functional languages as well. Lets see an example to digest it properly.

Lets see two functions which multiplies with itself from the given list. The second function uses recursion to break the list into head and then construct a new list sent to the same function for further multiplication with the remaining list so forth.

/*
* A trivial example of doing self-multiplication of list elements
* using isEmpty and head and tail.
*/
def selfmult(xs: List[Double]): List[Double] =
   if (xs.isEmpty) Nil
   else mult(xs.head , xs.tail)

/*
* This function is to augment the above function in oder to process
* the head and tail.
*/
def mult(xs: Double, ys: List[Double]): List[Double] =
   if (ys.isEmpty) xs * xs :: Nil
   else(xs * xs :: mult(ys.head, ys.tail))

Scala List are perfectly eligible for Pattern matching. An easier way to do the above functionality is below.

/*
* Pattern matching in List processing and using recursion.
* Gives a cleaner way of implementation.
*/
def selfmultilypatt(xs: List[Double]): List[Double] = xs match {
   case List() => Nil
   case x :: ys => x * x :: selfmultilypatt(ys)
}

Become a better programmer

Posted in Life of a programmer by mohanjune on December 25, 2012

Here are some of the important aspects.

Though these are not unique and you might have read this somewhere else also, but keeping them in mind helps a lot.

1) Keep learning and always update yourself.

Read books. There are hell lot of very nice books which will change the way you understand programming.

Approaches to how you solve problems. Will list some soon.

2) Write unit tests. If you write code write unit tests (very important)

3) Lookout for best practices

All languages or frameworks/tools have some best practices. Ex. being Hibernate Fetching Strategies in case of using an ORM

4) Don’t jump into coding, first understand the requirements properly.

Just jumping into coding then realizing that this might not work or even this was not even needed later on is not good.

5) Write code with good comments so that fellow developers can understand.

Let others understand what your piece of code does. Good naming conventions also helps a lot.

6) Be a good communicator, improve soft skills.

7) Be humble, generous and helpful.

8) Don’t jump into conclusions, become a good listener

9) Ask questions even though they are stupid.

10) Be answerable. No matter how many times someone asks, never hesitate to answer politely. Some people might take more time to understand.

11) Be passionate about your work and programming.

Optional to become better programmer

Become a polyglot  (Different languages will teach you different things and language features and constructs)

Share your knowledge. Because knowledge is short lived and it goes away as the time passes.

Experiences with 7th IndicThreads Conference

Posted in Conferences by mohanjune on December 16, 2012

This was my first attendance of Indicthreads conference http://pune12.indicthreads.com which I not only attended but also had given a speech on the topic “Polyglot and Functional Programming on the JVM”. As expected the conference went really nice. The action packed sessions and topics were really enlightening and interesting. I could see the enthusiasm among the speakers as well as the delegates. Check the full schedule. The Conference started with a nice talk on focusing on business and the end-user experience of the products which we develop  by Mr. Suhas Kelkar, then a giving away of IndicThreads CommuKnitter award to Navin Kabra from Punetech for his exemplary initiatives in building communities around technology.

Then came along my topic, which was OK. It is like sharing my experiences and knowledge to others and not keeping within myself or within the boundaries of my company. At the end it was contempt in trying to convey the same. Anyways it would have been great if I had got any  feedback.  I also enjoyed and learned (processed lot of incoming data) lot of things as an attendee for the subsequent topics for the day and the day after.

The conference also had lot of other activities like Go Green, Quizzes (luckily I won a book through one of the quiz), interactions between the sessions. etc. What I felt is there should have been more participation from the developer community from Pune and around. Attending such conference gives immense pleasure in sharing and knowing what others are doing. Here are the slides for reference Slides.

The delegates were not just techies. Interestingly two Professors came down all the way from Surat and Nagpur respectively to attend to know what is going around of technology in the IT industry. His main intention was to understand and align the academics with the industry. I believe there a lack of Academics and Industry interaction in chalking out next generation Computer Science students and as well innovation. Their thoughts towards this is really appreciable.

Finally would like to thank each and everyone. See ya again !!!

Criketization of Music in India

Posted in In general by mohanjune on October 20, 2012

“Sa Re Ga Ma” doesn’t apply for just singing. It is applicable to many other instruments especially those native to our country or the subcontinent.

Why there is only “Sa Re Ga Ma” on vocals in India. What about all other Instruments. I believe so many young enthusiasts are pursuing in learning a Sitar or Tabla or Flute. Is there any platform to bring in all their novice to amateur musicians in global forum like Zee TV’s Sa Re Ga Ma. I understand budding singers all across India are getting a huge benefit in showcasing their singing talent and people watching all across the globe. And eventually some of them have become international singers in Bollywood.

Why cant we have similar platform for a fair competition for other musicians. Here, musicians I want to say just Classical Instruments like Sitar or Tabla. Now if such kind of realty show starts will it have similar fan following and viewership as good as “Sa Re Ga Ma”. Do realty TV shows and especially we Indians would really like hearing a tabla competition. There might be some, but will be as much as the singing competition.

It might be or might not be the case. If it is not and if the TRP ratings very less.What do we understand from that. Do, we like to follow on singing competition as good as majority of us follow on Cricket more than any other game. Even the realty channels are pessimistic in starting a show for Instruments, because they fear it might get lesser attention from Vox Populi. Do we really would to follow the footsteps of Cricket and only cricket and forget about all other sports.

So, here comes my main theme of the subject. If we want to have the thriving of musicians of various instruments to survive then we would definitely would like to see some good larger platform. In order for them to showcase their talents, also others to be inspired as well the instruments are given their due respect.

Object Oriented – Scala for Java Developers

Posted in Scala for Java Developers, Scala Objects by mohanjune on June 11, 2012

Learning Scala – Objects

How Object Oriented programming is different in Scala than in Java.

First thing first, it is just a passion to learn another programming language. Of-course learning another language definitely gives a view of the other side of the coin and help us understand different programming constructs for our betterment. Java is not a pure Object Oriented programming language as it allows primitives and imperative style of programming  (many would consider as it’s drawbacks but it has to do with Imperative style of programming and support of expressiveness with the primitives as well). Java language provides one of the easiest language constructs to represent real world with objects and change the state within the its methods. But this not the end of the tunnel there are different ways to do it.

Argument between Imperative and Functional or even with other styles of programming may continue, but Java is in its existence since around 20 years and it would continue to grow here after.

 Scala is pure Object Oriented as well Functional. Also it mixes both the styles very well to take the advantage of both the worlds of Imperative and Functional. I assume you are already a Java developer and would like to learn some Scala. Though learning Scala Classes and Objects might be a good start for a Java developer, sooner or later you might need to learn functions and functional programming concepts in order to leverage the language’s beauty of conciseness, modularity and hell lot of other features.

So, lets begin to learn another language on the JVM

Scala Class syntax is almost similar to Java.

package scala.prog.objects

Scala doesn’t need semi-colons. And this is how you define packages.

/*
 * Define a simple class HelloWorld
 * val is static field.
 * Define methods using def methodName = expression
 * of def methodName = { for multiple expressions }
 */
class HelloWorld {
   val welcome: String = "Hello World "
   def message(name: String) = println(welcome + name)
}

Good advantage of using is that you’ll get Scala Worksheet, where in you can type in your code as in REPL and just saving it generates the output. It is kind of REPL on the Scala Project file.

Create a Scala Project and package and create a Scala Object from the Eclipse.

Enter the following code to to the Object file including the HelloWorld Class definition as mentioned above. Click on the File and run as Scala Application.

package scala.prog.objects

/*
* Objects are singleton by default
*/
object objectsworld {
   def main(args: Array[String]): Unit = {}
   println("Welcome Scala Object Oriented World !!!")

   /*
   * Create a new HelloWorld object and store
   * it in a variable. You may want to access the
   * variable of the object from the instance assigned to
   * directly using .operator as these are instance variables.
   */
   val helloworld = new HelloWorld()
   helloworld.message("YourName")
   println(helloworld.welcome)
}

Scala doesn’t need you to specify semi-colons.

In order to make member variable restricted access just use private keyword. This would restrict the access as instance variable as an example shown above.

/* To protect variable to restrict access make
* them private.
* Scala doesn't have public access specifies.
*/
class HelloWorldWithAccess {
   private val welcome: String = "Hello World"
   def message(name: String) = println(welcome + name)
}

Scala Constructor Classes need not be part of a Class with Constructor as another member.

/*
* Scala class with constructor.
* Constructor of Class doesn't need a Class and then
* Constructor definition as method for a class.
* A Simple Class with Constructor is kind of a Class with Constructor
*/
class HelloWorldWithConstructor(name: String) {
    def message = println("HelloWorld  " + name)
}

Methods with return value and the famous Scala Type Inference.
Scala Compiler will infer return type based on parameter. In case you need to return then need
mention after the method closing braces.

/*
* Class with return value.
* See there is no return statement explicitly mentioned.
* Scala evaluates the last expression value to be the return value.
*/
class HelloWorldWithReturn() {
    def sum(x: Int, y: Int) = x + y
}

If you have to return some other return type need to mention as below

   def sum(x: Int, y: Int): Double = x + y

To instantiate the above Constructor Class and the Class with return value you can try out like this


val helloworldcons = new HelloWorldWithConstructor("Constructor")
helloworldcons.message;

val newsum = new HelloWorldWithReturn;
println(summ.sum(10, 20))

Note: An Important aspect of the keyword “val” here in the examples.
val is used for Immutable references. Concurrent programming is good without mutable Objects and values. That is how it should be.  However in case situations arise to handle state changes and you need mutable values, then you might consider using var. In the examples above in case you try to reassign a val to some other object the compiler would show an error as “reassignment to val

[..Will continue to more about Case Classes and Pattern Matching.]

References: Programming in Scala (Martin Odersky, Lex Spoon, Bill Venners). This is the best book so far according to me.

Get a Scala IDE

Posted in Scala Getting Started by mohanjune on June 11, 2012

Most of the functional programming languages have REPL (Read Evaluate Print Loop), a kind of command prompt where in you type in your code and it evaluates your code and runs immediately. Gone are the days when Scala Plugin for Eclipse was not that good. But the Plugin has improved a lot and is more fun now.

The best Scala IDE which I liked and one may start is Scala IDE for Eclipse from Typesafe. You can download from the page   Scala IDE. Scala Plugin is also available for IntelliJ and Netbeans as well.
Typesafe Scala IDE has got Worksheet which gives and wonderful tool which is in my terms REPL+Scala Editor. Where you write Scala code and save it gives the output immediately on the same editor on the right hand side.

1) Download Scala IDE and follow the Installation requirements and steps.

2) Open the IDE as you do with Eclipse.

3) You can start off creating a Scala Project from the File->New->Scala Project. Once you are done.

4) You can either create a Scala Class within a package or start a new Worksheet. Worksheet is similar to Scala Class Editor with dynamic evaluation of your code. A good place to start as it file which you can save for further learning and adding code, which you might be able to do in the REPL.

scala-worksheet

Figure – Scala worksheet in Action

worksheet

Hope you are through with all the get set go steps. Now lets do some coding..

Being Multi Linguistic

Posted in Multilingualism, Polyglotism by mohanjune on January 29, 2010

Multi-linguistic person is who is able to manage to speak in more than two languages.  It is also named as Polyglotism. Well we can manage to communicate with people of those languages easily.  Indians are by default manage to learn more than one language as there are plethora of languages available in each state.  It might be easier for a person to learn as most of the languages are similar as they are born from one mother language i.e Sanskrit. As India by itself has become global within itself and people moving to different states for employment and business people tend to learn the language where he has migrated to. Leaving apart English which British Empire induced into the sub-continent and which in turn exploded into as a mainstream language which helped the new generation step into global foray so did it help India grow as an outsourcing hub and helped out Multi Nationals Companies opening up their shops. Europeans also especially from some counties are multi-linguistic.

But all depends upon the person’s interest and ability to learn so. It is true that children have the ability to pick up languages easily. If your parents speak different languages it’s a boon for you. Even young to elder people can also learn language. I have picked up most of the languages during my college days and while working in a different state. To start learning a language just reading is not enough. Listening carefully to what is spoken between two persons of the language. I have picked up learning several of them by carefully listening and understand the construction of the sentences. I ask my friends and colleagues to continue speak in their mother tongue rather than bothering about me not understanding their conversation. With that, has improved my listening skills tremendously. I attentively listen to what kind of words, grammar they use to construct sentences The industry I work for needs extra care in listening skills apart as part of communication skills.  Therefore listening or receptivity is an important quality one must have to learn something new and not just a new language. Also we shouldn’t shy off asking even basic questions. Asking questions about words or the context of using the same. Asking basic questions is regarded to be good for any purpose and not just about words in a language.  Increasing vocabulary and the grammar makes you better communicator of the language.

It is also observed that people who are multilingual have enhanced executive function in learning languages.

More reading on the topic:

http://en.wikipedia.org/wiki/Multilingualism

THE LANGUAGE INSTINCT – STEVEN PINKER (I found the book very interesting)
The New Science of Language and Mind
PENGUIN