Feeling of Go(lang)

  1. I like the interface {}, menurut gue itu unik
  2. Gue suka gue bisa define type yang gue mau
  3. Procedural, nggak. Functional, nggak juga. Apaan yak?
  4. Gue bisa associate function ke type, dan struct
  5. Bahasanya static, tapi ala-ala dynamic (thanks to {})
  6. Susah, dan manual kalau mau bikin konkurensi ala Elixir (yang ada parent, terus ada reset strategy, dsb).
  7. Gampang dipelajari, tapi mungkin susah dikuasai. (Channel, go-routine, ?)
  8. Cumbersome, meskipun bahasanya terlihat simpel. Tapi dikit-dikit lu harus check err != nil. -_-‘ males banget. Kode jadi kelihatan panjang, terus, alasan gue milih ruby: biar gue¬†punya kode yang lebih reflective ke yang gue mau.
  9. Banyak proyek open source keren dibuat pake Go.
  10. Single binary, really awesome!

0149fe8756b471b6e47ec5e1051e023e1e602749

Kalau gue nge gopherize diri gue sendiri, jadinya harus kayak di atas. Hahaha. Sebenernya gue nulis post ini biar bisa majang gambar diatas sih. Point-point ke-10, itu cuma selingan wakakak. Tapi gw lebih suka elixir by the way, kalau gak kepaksa/dipaksa makai Go, either gue bakal pilih Ruby atau Elixir. Sayangnya Elixir/Ruby gak bisa custom logo kayak Gopher. Itu aja gak enaknya.

Advertisements

JSON! Don’t use StringBuilder

I almost raged by the not-ability of the new .NET 4.0 to accept a single-quote (‘) character, instead, they automatically convert it to its escaping character, makes my JavaScript won’t work.

Well, it happens when I want to feed a FullCalendar control with a definition of activities, its schedule, its property and so and so. The feed is in form of String generated from a StringBuilder for performance reason. Previously I thought it was okay to set it all as a String, to be noted, I was never program in C# before and I not really sure with the behavior of the framework. Turn out, the single quote is converted–for security reason, Microsoft said.

I found out that this is something new that single quote is converted. In the previous .NET version (.NET 2) this behavior is not exist at all.

My supervisor come to see me, I explain that everything was okay. “Whoa… you study and open so much tab what are you looking for?” then I explain my problem. I was researching how to let .NET framework pass a single quote from controller to view. My supervisor went to see my controller, understand it, and then let me show him my CalenderData() function. Then my supervisor said “Hey, don’t use StringBuilder in this case, or any other String. Try to use JSON. You create a class that handle all the required data, then call JSON to return to the ActionResult”

Oh. Nice. Now I know about it. JSON. I also did a little research about it, found that XML is equivalent to JSON. However, ‘they’ should be use in their own respective proper place. Of course it is not preferable to use XML to feed data to a JavaScript array, right?

Okay. I will continue my coding.

A Day at the Races (and Source Code)

A Day at the Races is a challenge project in the book “Head First C#”. The source code is not disclosed, but the application (the executable form) of it is available to download in the headlabs website.

Here is my remake of the application, some feature is added like a Reset button. Hardly remember what else, I think the Reset button is the only feature I did add. Hohoho.

Download:

  1. Source code
  2. Application installer

Hit The Keys Game in C#

This is a Hit the Keys game where challenges given by computer for you to type any appearing character. You get it right, correct incremented otherwise missed incremented. The game is coded in C#.
This game is improved from the example given in the Head First C# book. The improvement is that:

  1. When you lose the game, any key you pressed will not be recorded.
  2. There is a bug in calculating the difficulty in the example given in the book, fix is done by changing to “Ease level” and use different formula to calculate the level.

To download:

  1. The executable
  2. The source code

Both are compressed in ZIP which can be opened using Windows Explorer or any zip extractor (the free one being IZarc and 7Zip).

Static Readonly vs Const

There is no such Static Readonly in Java. Somehow, it is a cool concept in C#. The both different in how compiler treat them. If const, during compilation, the value is baked and will never change. Let say program X uses library Y, when Y’s field programVersion is a const, X will absorb the value baked. So, next time we have newer Y, the old value is still used. Different than static readonly where the program will always refer to its value, however, it limits the ability to change as if like in the const.

Confusing?

It is like PI (const) and programVersion (better static readonly).

Find the nth element from the end of the node in LinkedList

Supposed that there is a linked list with this content:

  • 5: Rafsan Adam
  • 4: Andre
  • 3: Cindy Patricia
  • 2: Stephen D. Burd
  • 1: Nyoman D. Nata
  • 0: Freddy Aries

When I enter ‘3’ it will return the 3rd element from the end of the list, counted from 0, it returns “Cindy Patricia” which key itself is 3. The thing is, we can’t use key to determine the position as the key may not be integer.

Continue reading

Removing Duplicate Node From A Linked List

This is actually a question from careercup.com. At first, I thought this question is easy, but later it seems it is harder than what I think. Sometimes, when you think something is easy, it is not that really easy, especially talking in computer programming languages: a world that is not real.

So. I already try to solve this last night, but I can’t. However, it seems that my energy is not wasted. After breaking for a while from ‘memorizing’ (I hate it) for software project management, I try to do the question again and I solved it!

Continue reading

Plain English Explanation of Binary Tree with Java Code

Binary Tree is one of the most amazing data structure some one has come up with which I have a chance to learn it right now. Actually this was the most amazing of data structure I had to know. Guys, I really regret that during high school I think it was never be possible to learn linked list, hell, linked list is so easy :D. Okay, let’s learn binary tree!

Continue reading

Java Complete Application for Singly Linked List

Today’s tutorial class, I got a question for the lecturer to implement a singly linked list into a complete, working example of Java command line program. The whole class get 2 hours for programming this, and I completely finished within the first one hour. In my opinion, this program is not so challenging, maybe a doubly linked list would make this program a bit more challenging.

Continue reading

Implementation of Stack for Checking Incorrect Braces Used to Validate HTML Source Code in Java

HTML is a page-format language which is used to format how an internet browser should deliver a content to the user. HTML (and CSS) is not really a programming language. However, HTML is important here for illustration of how stack can be used to detect mismatch opening-closing braces.

Continue reading