How Is ‘Go’?

Some time back, I said I was revisiting some old friends. One of them, was the Go Programming language by Google. Well, things have been awesome, I have been learning quite a bit of ‘go’ (for Go Lang). I haven’t done any projects yet, but my next project will definitely be in ‘go’.

I am currently reading the language specification again, after watching a ton of videos and doing some simple programs.

For example, this would be the conical “hello world” programing:

package main
import "fmt"
func main(){
     fmt.Println("Hello, world")
}

 

Pretty readable isn’t it?

Well, what about something more modern? What would an “hello world” look like for the web? Yup, you got it, an application that when run, behaves as a web server that says “hello, world” when you connect with your web browser.

Here it is, not too bad heh?

package main
import (
     "fmt"
     "log"
     "net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
      fmt.Fprintf(w, "Hello, world")
}
func main() {
     http.HandleFunc("/", handler)
     log.Fatal(http.ListenAndServe(":8080", nil))
}

Time To Revisit Old Friends

A few years ago, I heard of a new programming language from Google call Go (http://golang.org). I sent some time playing with Go and really really liked it. Unfortunately, like learning any new skills, if you don’t use it you lose it. I didn’t have any projects at the time I thought was suitable for Go. But I really could have started using it right there and then.

Fast forward a few years later, and I am back to learning Go again. I am not really starting at ‘square 1’, but very close to. This time, I am picking it up faster than before since I had seen the concepts and syntax before.

So why revisit Go now? Well, a few reasons. I really believe that Go is a great example of a well designed and balanced programming language. It makes certain easy, without being so simplistic. For example, Python and JavaScript will let you do string manipulation and some complex data structures, without you know just how much hoops they jump through. Now that might be what you want, but that comes at a cost. I am not talking speed cost here, the speed might be find for you. But the cost of you really knowing what is going on in your program. If that doesn’t matter to you, great.

I love writing web application in HTML, CSS, JavaScript using AngularJS. The reason being that I still get to see the details but benefit from the grunt work being done for me. I really couldn’t enjoy using a development environment that just allowed me to drag and drop components to create my UI and connect o the database like magic. I guess I am still too old time to believe and want all the magic.

Go is that nice middle ground between being fully naked and covered in burlap.

But it is not only go that I have revisited. I went back to a very very old friend, Neural Networks. Way back when, when I was in high school to be exact. I was interested in AI, artificial intelligence using Fuzzy Logic and Neural Network. I even did some generic algorithm at the time too. But the two things that really got me going was Neutral Network and Fuzzy Logic.

I was doing a simple robot for a science fair that demonstrated the use of Fuzzy Logic. I really didn’t need any kind of AI for what I was demonstrating. But my science teacher and adviser at the time was a great inspiration and someone who shoots for the moon.

Today, deep learning Neural Networks are all the rage. Neural Networks are being use for self-driving cars, drones (military, commercial, and hobby), sales, finance, social networks, etc. The number of places Neural Networks are popping up is simply staggering.

I am again not quire starting from square 1, but there is a lot of catching up to do. I am not going to try to get behind the theory and math of NN. Instead, I am going to try to learn enough and then find a few libraries and tools which will let me put it to use. For example, the TensorFlow tool from Google seems pretty promising. So far, the primary interface seems to be Python and I am not quite committed yet to playing with Python again.

Mind Blown – Alien Communciation

I was watching some top ten list video on YouTube recently. I don’t remember exactly what the name of the video is, but it was about planets we have discovered. They mentioned on planet that had an Earth Index of 0.88. Earth Index is a way of categorizing a planet’s likeness to Earth. So a planet that is exactly like Earth would have an Earth Index of 1.0.

The other interesting tidbit from the video was that we had sent a message in the direction of that planet. This is not the first time I have heard that we have sent message out into space or place them on spacecrafts like Voyager I and II. You can learn more about Voyager I and II here.

That was pretty cool in itself that we have found a planet that is out there, very far to be sure, but still with such likeness to Earth. But how to you send a message you know an intelligent alien life form would understand? So this question was at the back of my mind and you can see the messages we have included on Voyager I and II at the site above.

A few days later, after watching this video, I was at a customer site and saw that engineers at one company was playing the game ‘Hang Man’ with engineers at another company. There were two building separated by a parking lot, and each building were for different companies. Up on the third or forth floor, the engineer were playing this game on the glass of the buildings side facing each other. We can reasonable assume that those engineers have never met, didn’t just meet somewhere and planned playing this game, but yet they were.

So it is obvious, without knowing the specifics in this case, that communication or some for of it, can be established between intelligent beings. I was discussing this idea with a friend on how you can establish this communication. Assuming that instead of a parking lot separating the two buildings, the distance as much longer, like a mile apart. Engineers in each building, would have a mirror to reflect the Sun or a light they can use to shine to each other. Could the two group still communicate and establish some language that allows for the exchange of complex concepts. I think it is possible.

My buddy later sent this video that I found really exciting, https://www.youtube.com/watch?v=GDrBIKOR01c.

Better Than Humans

In my post about how our intuition can be misleading, I briefly mentioned self-driving cars. I said that ones intuition, might tell them that humans are better than self-driving cars. Not a day later, Google, one of the companies doing the most testing on self-driving cars, released raw data and a report on their self-driving cars.

Since 2012, the cares have been in twelve accidents. Fortunately, none of the accidents were serious. Interestingly, none of them was a result of the self-driving cars. It was always human error. Be it human drivers hitting the stopped self-driving car, or in one case, a human driver in control of a self-driving car causing an accident.

So, to my point in this post. Computers don’t have to be perfect, they just have to be better than us humans. Self-driving cars are showing that in that respect, in some limited situations, they already are. For now, human drivers are still my best option to navigate the unknown road condition here or there. But as computer vision, computing speed, and software gets more advance, computers will get better at that too.

I will point to two sources instead of rehashing the same points that have been cover there more concisely. Watch ‘Humans Need Not Apply‘ on YouTube and this interview on NPR’ Fresh Air with the author of a book about how robots are coming for our white collar jobs.

No Project Is Too Small To Stop, Think, and Plan

I mentioned a project I have been working on and off for some time now. Unlike before, I am actually making tangible steps forwards. And more importantly, I haven’t had to start over recently. For a good part of the project, I would get some work done, then hit some kind of road block in the technology I had chosen. My solution, start over with something else. But finally, I am using the JHipster web application stack and I am not doing that.

The one thing I do realized now though, is that had I done a bit more planning earlier, things would have gone a lot smoother. I did a lot of stopping and thinking about what I wanted and how I wanted it to work. But, by not writing it down on paper to see if it fits, it was just all in my head where if fits easily and consistently. Regardless of the project size, you will always have changes as it starts to material. So pretty much no amount of planning will change that. But, some planning will help with the number of restarts and stalls.

Yesterday, I realized that my page flow was just too confusing as I added more pages. That right there was something I would have noticed I had spent some time writing it down and going over it. I knew that I would be adding more pages, and in my head, it seemed to have worked so well. Once I thought it up, I just started coding one page at a time. Eventually, I have a few pages and the navigation didn’t work well.

Once I started doing what I should have done before, plan. The ideas I had in my head, I now had some more insight about how they might work. I am planning a bit more now before jumping off again.

There is a delicate balance so observe here. No project is too small for some planning. But too much planning and no work, will just keep you in the planning stage. Sometimes you just have to get going and only then you get some insights, you will know if what you are thinking is even feasible. Of course, that is when you figure out that things don’t work the way you think.

If I had to summarize it, I would say always do some planning, especially on paper. May be something like a Passion Planner journal. Easier than using some computer program and doesn’t take a lot of time. But don’t wait too long to start getting your hands dirty, else you might just lose interest. And once you start, it is ok to take breaks to plan. Even if you might have to back up a bit before going forward.

You will be making progress so long as you are thinking, planning, and doing something. If you are not thinking about your project, you are problem not interested in it anymore. If you don’t do any planning, that will make materializing it harder. Whatever you do, do something that helps your project materialize.

Final tip, as much as restarting a project might seem like running in the same place. Don’t be afraid to throw out something that is not working and start over. What you throw out or throwing out to early, will be something you will have to figure out. But don’t get bend out of shape for having to start over, if that is the smart thing to do. Better to correct going down the ‘wrong’ path as early as possible, than later.

Forget Intuition, Don’t Wash That Chicken

Are you afraid of flying? Do you know or have heard of someone who is afraid of flying? If you are not afraid of flying or never heard of anyone who is, then don’t be surprised that there are people afraid of flying. So what’s the deal here? Intuition.

Intuition, it is the thing that we feel gives us reasons for a question that we are comfortable with. For example, if you were to ask someone who is afraid of flying, “is it safer to fly or drive?”. They would probably say driving is safer. Yet, all the data suggests otherwise. Flying, is by far, safer than driving. Just looking at the number of accidents per people transported per million. Ok, that was a mouthful. Let’s say you told you that for every million persons transported by car, there was a chance of 2000 deaths. And for a million person transported by air, there was a chance of 100 deaths. Now I ask you, do you want to travel by air or road? Now you see just how safe it is to fly. But intuitively, that is not host most people feel.

Sometimes, we really can’t go by intuition. Case in point, don’t wash that chicken before you cook it. I will get back to this one in a bit.

Another is self-driving cars. When I tell people I can’t wait for self-driving cars to get here. They are alarmed. They might say, what if they kill someone? Well, people drive now and they kill others, a few hundreds easy across the United States every day. Yet, we don’t stop people from driving.

The truth is, self-driving cars would drastically reduce the number of vehicular accidents and would be more efficient both in time and energy used. Self-driving cars would merge and get off the highway without having to slow down. Merging in and out of traffic at high speeds is not something humans can’t do that very well, not most of us anyway. But all self-driving cars would be able to do this, time over time. What about if one got into an accident? Engineers would examine the data, and try to code around that if possible. But you can be assured that they will see if there is anything that can be done to prevent it. If they come up with some code change etc, all other cars would be eligible for that update. That is something doesn’t and can’t happen with humans. My wife was in a lil fender scrape the other day, someone else turned into her lane. No one else gets to learn from that. Had that been two self-driving cars, they would have been updated and all the others so that particular occurrence would be less likely.

Hopefully you will be a little suspicious of your intuition now. Especially on things like self-driving cars and flying. So why not wash that chicken?

As a practicing engineer, I would described myself as logical. I try to make most of my decisions on logic and not emotion. If I don’t have facts or data to back up my decisions, then I try to reason it out and then may be go with gut feelings. So when I learn some new scientific proof that counters my belief, I force myself to let go. I have been cooking for a long time, since my early teens. One of the things we have been doing in my family, is to wash meats. We would wash it with vinegar, lime juice, or lemon juice. The idea was to take away the “meaty” or “rank” smell if it was fish.

Yesterday on my local NPR’s station, Science Friday cover a few cooking myths. Including washing the chicken before cooking. I have the link to that episode if you want to listen at the end. The fact it, when you wash chicken, you are creating microscopic droplets with the harmful bacteria on the chicken. Some of those bacterias are drug resistant. Once in the air, the droplets lands on your clean dishes and other parts of your kitchen. What you have just accomplished was spreading the bacterias to places they probably won’t have gotten to without your obsessive washing.

So what if you don’t wash it? Well, you are going to cook it right? So why worry? So long as you cook it at the appropriate temperature, you would killed 100% of all the bacterias on the chicken. I haven’t had to cook since hearing this. It will be hard to resist not washing. But science said I don’t have to, so I will try not to.

The Science Friday episode on cooking myths is here. You can listen to the entire episode, but the part about washing is at location 16 minutes 16 secs in. If you happen to listen to the entire episode, the parts about beer can chicken and not eating pink burgers, applies to me too. We have the setup to hold up a chicken for beer can. We always believed that it was the beer that was making it nice and juicy. Problem, counter-intuitive thinking that the beer evaporates. But beer boils way higher than chicken cooks. So it will never, every boil. We were just wasting money putting a beer can in the grill. If you are a beer drinker, find something better to do with your beer than put it in the grill.

A Simple Solution

Sometimes, or may be always, it is best to just seek the simpler or even simplest solution.For some time now, I have been plagued by a problem. Plagued is quite appropriate, because this problem was very annoying. I won’t get into the details it is a programming things and will be a bit boring. But, essentially, I had a problem where every time I started a new web application project using JavaScript libraries. I had this fatal error.

The root cause will be boring, so I will put that last if you want to be tortured. But for my rather annoying problem, I tried to code around it. And since it would happen every time I created a new project. Well, I had to dig up the code and run it to fix the problem. This problem is months old for me, may be even a year.

Finally, today I found a very elegant solution. A setting I can put in a file, and I own’t have to deal with it every again for any project. All I had to do was add ‘safecrlf=false’. That was it. I had tried a bunch of other suggestions from time to time and none of them worked.

Lesson, keep it simple. Writing about it now will be the last time I would have to think about how annoying it was.

The root cause for the problem is that developers who are working on windows, would submit files with CRLF ending. CRLF mean ‘carriage-return & line-feed’. Why is that a problem? Well, back in the days of typewriters. Once could do a ‘carriage-return’, which would do two things. Rotate the drum up enough to move to the next line. Here next line really means a new line, and of course slide it over so you can start typing at the beginning of the new line. You could also do a ‘line-feed’, which would just rotate the drum enough for a new line, but it wouldn’t return it to the beginning. This might not seems like something useful. But imagine that you wanted to just travel down the middle of  page after moving the the desired column. Then all you really wanted was ‘line-feed’. Of course you could turn the drum manually too. But never, all that, that is why there is both ‘carriage-return’ and ‘line-feed’.

Ok, so 99.99% of the people or companies who developed an operating system, used ‘carriage-return’ to mean ‘go to the beginning of a new line’. Microsoft, in their infinite wisdom, use not ‘carriage-return’ or ‘line-feed’, but both.  Usually, interchanging documents between systems is not a problem.  A mild annoyance to some non-Windows developers as their text documents have a funny extra character, the ‘line-feed’, at the end of each line. For Windows users, lines won’t wrap as they should, since their system is expecting two characters. But over time, these things became less of a problem, as editors just easily code round the problem.

But code is still being development and submitted or save with either CR or CRLF. Now we are at my problem. JavaScript libraries are distributed in text format. JavaScript doesn’t have a compiled for, not yet anyway. And my version control software, had a setting that said, “don’t save file with CRLF on this system”. I was the idiot who set that. So when I try to version control several dozen libraries, many of which had a line or two edited on a Windows system. The whole versioning things would grind to a halt.

At first, being the programmer I am, I coded around the problem. Something like this, but in Bash:

while (failing to commit); run dos-to-unix util on failed filed; repeat

I would have to run the code from every project. The code did a lot more than the one liner I showed above. It had to, (a) tried to commit a file, (b) see if it failed, (c) extract the file name form the error message, (d) strip out the extra LF character, (e) try to commit again. Repeat until all the files can be checked in without complaints from Git. Phew.

HBaseCon 2015

Today and today only was HBaseCon 2015. This was my first HBaseCon event. Glad I could have attended. There were a number of very nice projects and learning opportunities.

One of the projects I am really excited about is Zen from Pintrest. Unfortunately, I am yet to find it on the net. So they must not have opened sourced it. They built a graph API on top of HBase. They laid out enough of the underlying tables to support the design. I think with a bit of work, one can implement the API. But that will be some work. This is actually a project I can start using soon.

Another project that looks really interesting too is Apache Phoenix. This is an Intel initiated project to do SQL like syntax on HBase. I didn’t get to play with it, but it looks pretty cool.

There was a presentation on tuning the GCG1 for HBase, but I don’t pay too much attention. I was busying updating my cases at work. Then I had to leave early to catch the train.

There were some other projects of interest. But like all conferences, there are sessions that requires you to have a few clones. Without clones, you just have to pick one.

 

Time To Avenge

I showed Ian the first Avenger movie from 2012, and he was so into it. Before showing him, I was hoping he would like it so we can go see the new one as a family. Victory, he was into it when we watched it on Friday night at home. I was so excited to go see “Avenger: Age of Altron” today.

Stacy, Ian, and I decided to go. Desiree as usual, opted to stay at home. I enjoyed the movie. But unfortunately, by mid-movie, Ian lost interest and got restless. Stacy offered to take him outside for a bit. I didn’t see them come back to our seats. But I figured they just decided to sit closer upfront instead of coming up to the back where I was.

It wasn’t until I got out of the theater and saw them in the hall. That I realized they didn’t come back in. The movie was fairly entertaining, so I don’t mind watching it again with Stacy when it hit video.

Progress, Slowly

There is this app I have been working on for some time, well. I am not sure if it the same app.

Let me put is this way. If you are building a house, but before you can finish. You tear it down, and start over. Possibly with different contractors and different materials especially. Otherwise, it would be really silly to be doing it the same house design, with the same material, if all you changed was the workers every time you started over.

Well, I am kind of in that boat. The look of the app hasn’t really evolved over the months since I conceived and started working on it. There are visual changes to be sure, but those are more like whether it was the mobile or the desktop version. Not so much between desktop versions.

What I found myself doing, is starting over a lot. I would get to a certain point, and stall. Basically, the technology I would be using for my backend, would have some hole that slowed me down. For example, I started out using Java backend based on Spring Framework. I have used Spring a number of times and I love it. But as I worked on my app, I was getting tired of spending time on house keeping. Like if I had an entity, I had to do a lot of work to protect it. I couldn’t just add and entity, and move on to make forms and services to use it. I had to say, well, how do I secure it and expose it appropriately.

That began to get to me and I felt like I needed a web stack that would do most of that lifting. Something that would free me up to work on the core features of the app. Instead of all that side stuff the app required but wasn’t really part of the problem I wanted to solve. that other stuff, user management, security, etc., that wasn’t part of what I had conceived. That just got bolted on as requirements for a modern web app.

Anyway, after many restarts, I am not once again pretty happy with where I am on how it is going. I finally landed on a framework stack that has taken away all that those keeping grunt work. JHipster is my new buddy. It is really filling the gap where MeteorJS, Angular + BaasBox, or Angular + Spring, or Ionic + BaasBox, or Ionic + Spring couldn’t fill.

The funny thing is, JHipster is Angular + Spring and then some. It is just that it has so many other things, that I don’t need to worry about security. That is taken care of. I don’t have to worry about metrics, that is taken care of too.  And the list just goes on.

The only thing slowing me down now is having time to work on it. Because, with a full work day and other things too do, there just isn’t enough hours in a day to get every thing I want to do, done.

In a few weeks, I might revisit just how JHipster is helping or not helping my project.