Quote of the Day – "We are Number One in a Number Two Business".

October 22nd, 2013 by Terrence Miao No comments »

Quote of the Day – "We are Number One in a Number Two Business".

-Midwest Plumbing

Google+: View post on Google+

Rewrite Java in Scala – Concurrency and Scalability

October 19th, 2013 by Terrence Miao No comments »

First Scala has this Actor concept, designed to overcome Java's Shared Memory Model issue when programming in concurrency.

An Actor is a mathematical model of concurrent computation that encapsulate data, code and its own thread of control, and communicate asynchronously using immutable message passing techniques. So the basic architecture in Scala is shared-nothing, each actor acts in its own process space.

However, it's not end of road. From Scala 2.10, Akka's actor implementation is included as part of the Scala standard library.

Akka uses Actors independently executing processes that communicate via message passing as the foundation for fault tolerant applications where individual actors can fail without crashing everything. Perfect for high volume applications that need to scale rapidly. Akka is an efficient foundation for event driven systems that want to scale elastically up and out on demand, both on multi-core processors and across server nodes.

Moreover, Akka has a STM implementation that is based on the same ideas as found in the Clojure language; Managed References working with immutable data.

Software Transactional Memory (STM) is excellent for problems where you need consensus and a stable view of the state by providing compositional transactional shared state. Some of the really nice traits of STM are that transactions compose and that it raises the abstraction level from lock-based concurrency.

Akka is not only offering good concurrency and scalability characteristics, but also is excellent for building event-based systems.

Google+: View post on Google+

An essential part of running web services in the modern world – Concurrency is more…

October 19th, 2013 by Terrence Miao 2 comments »

An essential part of running web services in the modern world – Concurrency is more important than ever

Scala, from its first draft of design, is to let you write concurrent code, and extremely fast concurrent code.

Embedded Link

The Second Coming of Java: A Relic Returns to Rule Web | Wired Enterprise | Wired.com
Raffi Krikorian, vice president of engineering at Twitter. Photo: WIRED/Alex Washburn Biz Stone called it “one of the most special days in the history

Google+: View post on Google+

Notifu – the notification application calls you when the food is ready

October 16th, 2013 by Terrence Miao No comments »

I always have a big trouble after kick off a lengthy running task on my PC. Maybe it's an integration test takes about a few hours, or make a tar ball of a 20GB folder with one million files under.

To show my colleagues I'm productive and multitasking person, rather than idly doing nothing and waiting for the job done, I'd like open the browser and go to Kogan to find out some bargains. But, there is a problem. I have to keep switching back to this lengthy job window from time to time checking whether it's finished or not. This make me lose my concentration and high quality time making shopping orders online.

Now, come with Notifu, a small notification application which can run any Microsoft Windows and has no dependency on any others. Just run it after lengthy job in the pipeline:

notifu.exe /m "Job is done. Time for dinner!"

in DOS Prompt or Cygwin window. You will receive standard Windows notification message after lengthy job is done. And you won't be bothered to whether the job is done or not again and again.

Read more - http://www.paralint.com/projects/notifu/

Notifu » Read more: Notifu – the notification application calls you when the food is ready

Rewrite Java in Scala - If developers have time to learn ONLY ONE language in year…

October 16th, 2013 by Terrence Miao 1 comment »

Rewrite Java in Scala - If developers have time to learn ONLY ONE language in year 2013, it should be Scala.

• Doesn't have "Void" like in Java which means "return nothing", but Scala has Unit "()". Think of "()" as a placeholder for “no useful value”. Void has no value whereas Unit has one value that signifies “no value”. This is better design Scala than Java, the difference can be described between an empty wallet and a wallet with a bill labeled “no dollars”.

• Has no checked exceptions. Exceptions handling in Java is one big headache, poisoning the codes, breaking OO design principles.

• Has functional programming built-in. Java ONLY has method, but no function. A method operates on an object, but a function doesn't. So in Java, you have to imitate function with static method.

• Different return. Return is invasive in Java, but in Scala you need to get used to life WITHOUT return. Return is like the breakout statement for functions, and it breaks out to the enclosing named function. So the less the better for immutable codes.

Google+: View post on Google+

Design of the Day – Vertical version of World Map (竖版中文世界地图)

October 15th, 2013 by Terrence Miao No comments »

Design of the Day – Vertical version of World Map (竖版中文世界地图)

Read more - http://haiguotuzhi.com/?p=2733

World Map

Google+: View post on Google+

Rewrite Java in Scala – companion object

October 13th, 2013 by Terrence Miao No comments »

The companion object basically provides a place where one can put "static-like" methods. Further more, a companion object, or companion module, has full access to the class members, including private ones.

Companion Objects are great for encapsulating things like factory methods. Instead of having to have Foo and FooFactory everywhere, you can have a class with a companion object take on the factory responsibilities.

Scala truly has nothing static.

One way in which Scala is more object-oriented than Java is that classes in Scala cannot have static members. Instead, Scala has singleton objects.

Google+: View post on Google+

Rewrite Java in Scala – implicit parameters and conversions

October 13th, 2013 by Terrence Miao No comments »

What to do if you are stuck with existing libraries and API's.

There's a fundamental difference between your own code and libraries of other people: You can change or extend your own code, but if you want to use some other libraries you have to take them as they are.

A number of constructs have sprung up in programming languages to alleviate this problem. Smalltalk has meta classes, Ruby has modules. These are very powerful, but also dangerous, in that you modify the behaviour of a class for an entire application, some parts of which you might not know. C# 3.0 has method extensions, which are more local, but also more restrictive in that you can only add methods, not fields or interfaces to a class.

Scala has implicit parameters and conversions. They can make existing libraries much more pleasant to deal with. 

Embedded Link

Pimp my Library
There’s a fundamental difference between your own code and libraries of other people: You can change or extend your own code, but if you want to use some other libraries you have to take them as they are. A number of constructs have sprung up in programming languages to alleviate this problem.
» Read more: Rewrite Java in Scala – implicit parameters and conversions