9th: The Honesty Game – Part Two – the support and punishment social system

This is the part two of 8th: The Honesty Game – Part One – the game

Part one discussed a gaming system relies on aggregating social data from the player to grow the game character. It assumes the players opt in to share their personal information, so they gain the benefits like, growing their game characters with the player’s real-life activities, and exploring more interesting plots in the game depending on what the player does in real world.

There is always debate in how much personal data we are willing to sacrifice.

Big Data

In case you haven’t heard this buzz word enough, we can now process more data than ever.

A few years ago, some universities use big data to provide financial support to poor students. It does make sense, for a few reasons:

  1. Universities are relatively closed. They are like individual communities.
  2. Poor students are likely to dine in school’s cafeteria more than rich students.
  3. It is not hard to use data-driven analysis to understand which students are more struggling financially than others.

Can we go further?

Social Support

I don’t really want to talk about the depressing topic about homelessness.

However, imagine a city, where everyone has to use a card for anything, such as buying groceries, taking public transits, and using any public service (like libraries, or going to a shelter).

It will be very easy to understand which family spends more and which family needs more help or doesn’t. Won’t it?

Hang on, I know some people will want to say something. Allow me to finish next section.

HOV/bus-only lane cheater

If you lived in Seattle, you would probably have seen HOV or bus-only lane cheaters, a lot! The government has decided to raise the fine for repetitive cheaters. However, even radio show had discussed people would not care, if they value the time more than getting stuck in traffic.

The solution? Personally, I feel it should be proportion based fine.

For example, the first violation fine will be a fixed number. The second violation fine (say within a year) will be all of the money this person has in the month. Let’s say we collect the monthly income and spending data of a person, so we can get an estimation of this person’s monthly spending amount. This person’s fine for second violation will be the entire estimated monthly remaining, which should already exclude the spending on food and living expense.

To be more precise, let’s say someone usually has $1000 income, which needs to pay $500 for rent and $300 for food. The fine will be $200. Now another person usually has $20,000 monthly income, $5000 for mortgage and $1000 for food, so this person normally has $14,000 monthly remaining. Then this person’s second violation fine will be $14,000!

I guarantee no one will violate second time.

Socialism, Communism, or what?

Now go back to the previous section, if we really collect everyone’s data and provide support accordingly, is it socialism, or communism, or some-ism?

I don’t know and I don’t really care.

As a normal citizen, I probably share the ideas with many others. I am guessing most people want:

  • living safely in this world, with food and a place;
  • raise a family, protect our children;
  • make sure our children and their children have a home to live;

People questioning what kind of -ism are the people who have been living way too happy and comfortable. In the time people have no food or no home, who would ask those questions?

Honesty Game, or the social credit system, will it really happen?

Will such a system really happen?

Will our data all be monitored and analyzed by the government one day?

Actually, I am not sure if it has happened already or not. Some people may think it’s already happening, and it’s not just in China.

I lean to believe we will eventually enter an era of no more personal privacy. Maybe in a long time, maybe in just a  few years. It will be a game changer (pun intended).


8th: The Honesty Game – Part One – the game

This week I am off, so I decide to probably post 2 ideas, which actually source from the same origin. This is the part one and part two is coming shortly.

In 2012 after I left Price Industries, I spent roughly a year on thinking about my life. I built a website, went back to school and participated some researches again, and talked to a few investors about my bullshit ideas. One of them is this idea called: The Honesty Game.

The Game

I did’t really have a story outlined clearly. But this game is like Diablo or Warcraft. It’s typical that a player can choose strength-based, agility-based, or intelligence-based character, kill monsters and collect treasure. Of course there will be a story line why doing so, I haven’t figured that out yet. However, what makes the game special is how the character grows.

Small portion of growth is through the game playing, like gaining experience by finishing a task (inside the game). But large portion of the growth can be dictated from outside of the game.

This game allows the players connect their additional social accounts with the game. Those accounts will aggregate all data in real life to improve their game characters. For example, if a fitness account shows the player has done a run in real life, the game character will gain some strength; an aerobic exercise may gain some agility; sleeping well will gain some stamina; finishing a book, or even checking in at a bookstore may gain some intelligence.

There are so many things we can link from real life to the game, like where does the player go to (check in), what does the player buy, what does the player post in social network, even if this player has been paying his/her debit, all can not only impact the growth of the game character, but also impact the story line.


I don’t think I was the only person who came out with such an idea in 2012; I like to think there were many people way ahead of my crazy nonsense.

The whole idea is a little like Black Mirron – Nosedive, aired in 2016. But with more!

That’s why the game is called: The Honesty Game.

Everything you do in real life, needs to be honest, and will change how you proceed inside the game.

But of course, people will ask, where is the privacy?

I will always think this way:

  1. Do we really have privacy nowadays, or do we just have an illusion of having privacy?
  2. Are people willing to sacrifice their privacy, in exchange of benefits or convenience?

I give away my personal information (to a certain degree) when shopping on Amazon; so is using any other website, in exchange of the service I am receiving.

History tells us, shutting down the border of a country with other countries would not help growth (yes, I may be hinting something). I was referring to the Qing dynasty in Chinese history. They were so ignorant at the time and eventually got invaded by Western Countries hard.

Maybe today, people will still try to fight to protect privacy, actually they just try to fight to have the illusion longer. Eventually, maybe no one will care any more. Or maybe, one day, the controversial Social Credit System will be implemented. Even many Internet discussion are still laughing at it, it may not be a very bad idea after all. I will elaborate another idea related to it in Part Two.

But here is the thing:

Privacy or not?

We should always be allowed to have a choice.

People can choose to live off the grid, in a cave, social-account-less, or not to have any service, such as playing The Honesty Game.

Or they can choose to be enrolled.


I actually went back to China and presented The Honesty Game to a few people. They all liked it. Interestingly, they did not consider privacy as an issue. It’s China after all. Most companies are collecting people’s data already, and China is now almost a cashless country, which means many people rely on their smart device in daily life already.

The biggest issue, however, is having strong connection with the big player in the market, such as Tencent, Alibaba, etc.. Those companies control most people’s data, and then it’s the Internet censorship in China. We discussed how government will have to allow the game to be connected with all other data providers, and what type of challenges we may encounter. Not very straightforward unless we have big players involved.

The second issue was: I was not a game developer. I don’t really have any prototype or design to show. I only have a pile of BS.

Anyway, I still like this idea. I read a story a few days ago, and came to realize that this idea could actually be used in a different way. Check the Part Two.

BTW, if you are looking for a laughter. I just rewatched IT Crowd and found this episode about “Friendface” very hilarious. Kind of related to this topic.


7th: Can kids write a book?

I want to say the answer is definitely yes.

Totally biased opinion: I can’t describe how creative my little one can be. She is truly remarkable.

The other day, I told her I will be working in a different company. BTW, today is my last day of working at Starbucks. Enjoyed my years there, but ready to move on the next chapter.

I told her, the cafeteria in my new company serves unlimited pickles. I can bring you a pickle when I pick you up. (context: I am usually the one picks her up from school and she always wants a small piece of snack after school).

Next, she started talking non-stop with pickles. She always talks too much, which is annoying. People always say it’s better than a kid does not like to talk to people. I guess it’s right. She started talking pickles, making up conversation between two pickles. Yes, you read it right. She was using two different voices talking,

“hello, I am a pickle, my favorite food is pickle”;

“I have a sister and she is a pickle too”;

“you are a pickle, can I have a bite?”

Pretty much like that, non-stop. I was driving at that time, it’s hilarious and I told her, “you should write a book about it”.

I almost immediately regretted it, because she started making up background of the story and more pickles coming up.

It was annoying, but still hilarious; OK, I admit it, it was pretty awesome.

The Pickle Family cover

Once we got back home, she started her project. First, the book cover. It was very impressive, I particularly love the black dots she used, over the green color she chose. It is very pickle-ry.

The Pickle Family – first page

She tried to introduce the background of the main characters, i.e. the pickle family, who live inside a pickle house. Hmm, I don’t know how that will work, but it’s kind of interesting.

Then she made additional 4 pages, so basically it’s a book with 5 pages. The story is about the two little pickles go to school and then get a detention, after home, their parents are mad… but overall, the plot is completely not making sense. Every time we go to a trip and live in a hotel, she loves watching Disney channel (we don’t have cable at home), some of those shows on Disney channel are very off the chart. We just came back from a trip, it must be influenced by one of those shows she watched.

Anyway, now it’s the core of this week’s idea.

I love what my little one has done. It is very rough, strange, and the story is boring; however, I love it. I want to make it a real book.

There are apparently many companies doing it, of course

Interesting stuff. But I notice something: all of those providers are designed for adults. They all just offer the users to upload a picture, and then select materials, finally pay. These are all adult activities.

Of course, there are some other tools seem to design for kids:

But after I gave them a little try, ugh… not sure any child will really fall into it.

When I look at my kid’s book, I can see she put the most effort in her cover page, and then the first page. Later pages became more and more scribbled. It’s easy to understand: kids can be easily distracted, become inpatient, and lose focus and interest. I want to say most kids are like that, except some gifted ones.

The question then is: how do we keep the kids feeling intrigued during their work?

I  am a big admirer of Bret Victor. He is super smart and chill.

His this talk was my favorite:

Two take-away from this talk:

  1. We should have a principle for ourselves, believe in what we are doing and keep doing it.
  2. Seeing what we are working on is very important, because it provides instant feedback.

Both points have made a big impact in how I work.

When my kid was “writing” the book,

  • she was not receiving the instant feedback;
  • she had to do too much: thinking, writing, drawing and coloring;
  • she became tried (aka, bored) quickly after just couple pages;

That is it, we need an application for kids, which will provide instant feedback and keep the kids feeling interested!

I am calling it: I can draw a book

You can tell I am not very creative.

Application: I can draw a book


  • tablet;
  • stylus;
  • physical keyboard (very important, so kids can learn how to type);

Target Users

At least older than 6 years, who can spell some simple words and use stylus to draw.


The application is designed to allow anyone to create a drawing story book with computer assistance. By computer assistance, I mean using artificial intelligence to help create characters when typing or drawing.

If you haven’t seen it, try something like this first:




Basically, we almost have a certain level of intelligence to understand what the user tries to draw, or predict what the user wants to draw based on text.

Now imagine my daughter is writing a story about pickle family. She is typing (yes, her school is teaching them typing, she seems to like it):

“There is a town called pickle town…”

Computer will try to generate a small model of town, which matches the concept of pickle town, say having a flag with a pickle in it, or the town is all green, and so on.

When my daughter is writing down:

“Papa pickle….”

Computer will generate possible model of a pickle that looks like a man.

If the user likes the computer generated model, they just drag to use it in the book. Or the user can draw a shape of something, computer will generate what this shape might be. The prediction can change if the user keeps adding details to it.

Every model the user has used in the book can be saved to be reused later in another page. In the case the user wants the model to have a different gesture, the user can drag the existing model, starting draw shapes around it, the computer can try to predict a drawing with the existing model.

A quick mock-up may look like this:

If this application is initially designed to be used by kids, it needs to be very simple. It seems to be an interesting idea to run a user study with it.


6th: House hunting with matching furnitures

We have been house hunting lately, because I am about to switch job, hopefully we can move to somewhere in the middle of where my wife works and where I work. If we stay where we live now after I switch, both of us will be driving almost 2 hours a day. Sigh…

We have been seeing houses over a few months now. We both hope this next house will be our home for at least next 10 years, so we really want something perfect and give us a homey feeling. It will be OK to be less ideal or require some work, but we still have our visions and would need the bone of the house meet our expectation.

There are a lot of house listing website, such as Redfin, Zellow, or even MLS, they just give you a set of pictures. Most of those pictures are photoshoped, or taken from an angle giving the best impression. Once you are there physically, you will realize it’s actually smaller, or the layout is completely off the chart.

Some websites do provide a 3D walkthrough view, which is very nice. It does help us to understand the layout before going there. However, I always feel something is missing.

I think most house buyers will share the same intention:

We want to see ourselves living there.

But it will be dumb to put our pictures or hologram inside the 3D viewer. I am going to make this statement here: if technology is really evolving to a point that a home user can do a full body scan to generate a hologram, don’t use this technology to sell houses. That’s dumb.

What I want is: if I put our ideal stuff in the house, will it look like my home?

For example, I really want a pool table and a bookcase with ladder, such as this one:

Quick question: Has anyone else notice something annoying when looking for furniture, the furniture is never placed in your home?

Right, that’s why there exists AR application helping furniture buyers to place the furniture digitally in their own home to experience it. It is close to what I am looking for, but this requires the user must physically be there and own the place.

Now, I want an AI to fuse the house picture and the furniture picture together, using the data of both items, intelligently place the furniture at the most ideal room.

More exciting features are:

  • the AI will recommend if I should change the color of the wall, or choose a different color of the bookcase;
  • the AI will detect there is no room fits the bookcase I select, but will try to recommend a similar style bookcase (with a ladder) that is smaller and will fit in the house I am looking at;
  • the AI will recommend other furniture that can match the bookcase I just pick, with the understanding how much space I have in the room; for example, recommending a piano in a big room with such a bookcase is acceptable, but it will not do so if I move the bookcase in a small room intended as a library. And also, it will never recommend a dining table under this context.

I am actually not a big fan of houses with all the staging furniture. They usually look very nice, and once I move my own stuff in, the house suddenly is not so pretty (don’t judge my taste of furniture, if I know how to stage a house, I am not writing this idea at this moment).

This engine (fusing an empty house with furniture) will significantly improve the buyers’ experience (mostly, me). I will see how the house look like if I put my ideal items in it, can I see myself living there?

Of course my wife has some her own flavor as well. She also wants a study place for our kid. And we have some existing furniture. So the engine will allow users to upload some custom picture with dimension attribute (or hologram scan furniture, now this use case will not be dumb), and smartly place them in the house.

You may ask, wow, it sounds cool, but who would invest building such a thing? I believe home builders, real estate companies, or even designers, contractors, furniture companies all of them can benefit from such an application.

From my superficial understanding of AI and 3D rendering, this application sounds very complicated, but should be still feasible to do. I will leave this idea for other people to do. I was going to call this application “HomeFusion”. Ugh, the name is taken!

5th: Save my car

This is one of my old ideas.

In a nutshell, it’s like Uber of roadside assistance.

I once experienced a dead battery on a highway. After I called my roadside assistance service, who generally dispatched the request to a near towing provider. It took over 5 hours for the tow to come. We could not do anything but waiting under the sun and busy highway.

The idea is very simple, first, for the user, there will be a smartphone app.

The app is used to send request for assistance to a server, information include:

  • car model
  • problem description
  • photo
  • auto GPS location

The app will show how many providers nearby, accepted the request, and provided a quote to provide the service.

In the car service provider side, there will be a tablet placed in the shop. It will display a request sent to the shop with all the information. It will ask the provider to bid, or decline the request.

The service provider can offer an estimate based on the limited information, the bid could be a range, but must include how long it will take them to reach the client.

Once the provider starts leaving the shop and heading to the client, the feedback will be provided to the client so that the user knows the help is coming.

The benefits of this idea could be:
– save time to make phone calls (did I mention I had to wait for the phone to connect with the service provider?)

save time to describe problem and location (we could potentially use AI to determine what the problem is and sen save time to describe problem and location d the request to the service provider)

know who is coming (feedback is very important, did I mention when I was waiting, I had no idea how long it would take and if the help was coming?)

offer multiple providers (because the request is sent automatically to the nearby shop, we are not relying on a single point of provider. In fact, I would be so happy if a help could come earlier with some extra cost at that time).

Honestly, this sounds like a good idea. Unfortunately, I never get the chance to implement it. The real issue is, chicken and egg problem. How do I convince car shop to participate when I don’t have any client? How do I convince user to join the program when there is no provider?

I guess the most important problem is: I don’t have any funding to support this idea.

4th: My idea of presenting functional programming

Today I want to talk about programming, particularly, programming paradigm.

A quick background

I spent a year learning and writing Scala, which is a fascinating language. But I could not get my head around why we wanted to write functional way. And Martin Odersky even said this in one of his talk:

“if you have to inject dependency to your code, something is wrong”.

Probably not exactly the same words, but close enough.

After that year, I switched back to writing C#. Then I suddenly got a hit about why writing functional is such a joy. The code can be much more concise, so easy to write test, and naturally supports concurrency without using lock because no state is shared. Everything starts making more sense.

Give a talk about it

My current director asked me to give a talk about using functional in the project I have been working on. I told him yes, but I am not sure when I will have the time to do so. I actually like giving talk to the team. It feels like sharing your thoughts and learn from each other.

I did it on a few different topic after I joined Starbucks. I gave a presentation about my research long time ago in front of couple hundred people, I enjoyed it. Unfortunately, I always find it challenging to make the commitment  to become a regular speaker in conferences. I admire those people who can.

But how do I really talk about functional programming to the people who have never done this before, when myself is not even a guru of functional programming?

The other day when I was running, a few slides came up in my head. So my idea is using them, hopefully.

My potential slides

It is just a tool

First, forget about the word “functional programming”

forget about the word functional programming
forget about the word functional programming

It is possible that some people will be offended. So I have to make the claim that this is only my personal opinion.

Second, it is important to remember, “functional programming” is just another programming paradigm. It is a style, and it is a tool to write code.

We use the right tool at the right time for the right job.

It is the same idea that I will probably not use a hammer to mow lawn, even though it might work. I will use a knife to chop vegetable or meat, not a scissor, even a scissor will definitely do the job as well.

Choose the tool wisely.

So choose functional paradigm when the situation is right.

I particularly like  Anjana Vakil’s talk about programming across paradigm, if you never watch it, I strongly recommend it:

Different perspective

The following is how I believe most people consider a good software product:

If you Google “characteristics of good software”, pretty much the same thing.

  • Workable: the software is usable, in a working state, and it can realize business values;
  • Scalable: the software can be scaled in terms of performance, the number of users, as well as the number of business cases.
  • Testable: the software can be tested from the unit level.
  • Changeable: I like to say the word “changeable”, which means the team (not just the individual who originally writes it at the first place) can comfortably make change to the code. Others may prefer “extensible”.
  • Readable: The code is readable and understandable, or the software itself is well documented on the business case.

Note: extensibale and scalable are 2 different things here. If you notice, scalable is referred to the software can scale to more business cases, while extensible is referred to any developer can make change to the source code.

There is a reason a triangle being there.

The bottom is always “workable”. A software must work. If a software does not function, constantly crash, or does not deliver business values, nothing else matters.

Therefore, from a company’s perspective:

It is paying for a workable software that can deliver business values and meet business requirements. The biggest expectation from a company’s perspective is “it works”.

Next expectation from company’s perspective is, “can the software scale to meet more requirements”.

Generally, a company cares less everything else in the source code, unless that is a software company (maybe, hard to say, we all have heard how poor Oracle is written anyway). Therefore, no one will care how beautiful the code is written, or if it is using functional, procedure or imperative.

Only developer cares.

Actually, I probably should say only developers with self esteems care.

In contrast to the previous slide, the following is from software developers’ perspective:

Developers still care about the final product work. But we all know how easily a developer can be distracted in his/her own interest:

In the reversed order, developers care more about the things like how beautiful the code is written. Interestingly, the more ego the developer has, he or she is likely more focusing the things on top of the triangle.

Having developer ego is normal, in fact, it may be a good thing sometimes. It may not be sometimes though.

The funny thing about those things are important to developers, are naturally supported by functional paradigm:

  • Readable: small and single purpose functions, easier to reason the code logic, thanks to deterministic fashion.
  • Changeable: this may not be true for someone is new to functional programming; however, since FP advocates function composition, it is actually true that it is easy to make a change to composite existing function to make a change. Additionally, because it is designed to have no state shared and ideally each function is pure, it is less likely to impact existing business logic when making a change.
  • Testable: I did not believe this before, but it is definitely true that writing unit test for functional code base is way much easier and faster than writing unit tests for imperative style. No mocking framework is needed, and property-based testing is supported.
  • Scalable: One big advantage of functional paradigm is its strength in concurrency handling. Because it is so easy to make change, the source code can also be scaled to meet different business requirements.
  • Workable: nah, who cares if it works, it is beautifully written.

Not: functional code is generally/arguably considered hard to understand. That is actually caused by developer ego. As I mentioned earlier, it may or may not be a good thing. If the ego is too high, abusing functional style can be intimating for others to read. But it does not have to be that way.

What does it mean?

So we see company and developer have different perspective when looking at a software and its source code, but what does it exactly mean?

Of course, writing a workable software is the most important thing, because that’s what developers are paid to do. Also, because developers have ego, and different people like to use different paradigm, how do developers work together building a workable software product?

The answer is: modularization.

Other people may see it as Microservice architecture.



No matter we are building a client application, or a backend application, we will write it into small modules. Each module represents a business feature, and then we stitch them together.

Each module is communicated through contracts, i.e. events driven. Now each module can be coded in different paradigm.

Some module may be good to use functional paradigm because it has a lot of asynchronous processing, another module might be better to use imperative. It does NOT matter. A paradigm is just a tool. Use it in the right situation. I recommend to adopt functional paradigm in pure business logic.


This is an angle I haven’t seen very often:

  • writing modularized application so developers can avoid paradigm difference….

3rd: A painting in my dream

Only the 3rd idea in my journey, and I missed the date.

Initially, I planned the posting would always happen in Friday, so it would not interfere with my weekend activities. I guess I should now remove this rule. Friday I was busy in working out another idea at work, which seemed to be more important at that time. Saturday I was with the kid all day, since my wife had to work.

It comes out, it is actually a good thing.

Earlier I was going to post an old idea if I did it on Friday, but today (Sunday) I have a different idea.

I had a dream last night. A dream about a painting. I don’t know why I had such a dream, and I am also less interested in understanding what it implies. But it is an idea, which is, I should try to paint it in my later stage of life.

The painting in my dream is much sophisticated and complete. But overall, it looks something like this:

the painting in my dream
the painting in my dream

Basically, it is a person with a huge head, but very small body. In my dream, the person is simply just thinking. Yes, something like the thinker. But the illustration is much exaggerated (expanded). Unfortunately, when I sketched it, I had to put a desk and a computer in front of person, otherwise, it looks very weird.

The painting should be in oil. I am not sure if it is really the case in my dream, but that is what I think I will do.

The background, I am thinking I can use different shade of blues. I also want to make it a little more interesting. Maybe I first use light grey to carve some text first, and then on the top of it, I put the blue color. So through the shade, I can still see the text. Regarding the text, all I was thinking (at the moment I woke up and decided to put this as my 3rd idea) was the lyric from this song. However, to be further interesting, I want to have one line of the lyric, and then another line of source code in either Scala or F#. Random code, or real code from a real project, haven’t decided it yet. Or maybe just Javascript, which may expose more pain points.

A very close painting (I quickly search on Internet) is probably something like this one:

Unfortunately, when I showed my sketch to my wife. She asked if I was trying to draw this guy:

It gave me a double face palm.

Anyway, that concludes the idea of this week.

2nd: An App just pretends interacting with you

Ever since I decided to have this 1000 unrelated (aka useless) ideas, I was really looking forward to it. But then when Thursday comes, since I need to put one up on Friday, I get a little nervous, because I don’t know which one I should write.

So I dug my idea folder. I used to have a folder storing all those useless ideas. I found something laughable.

The original idea was:

An app similar to Slack. You create a channel in it. Next the app pretends many users joining your channels. But those are just bots. Now every time you (the owner) post anything, those bots will add reaction to your words, some bots will post a meme to the thread, and some bots may even post a comment to the thread.

However, it is important to note, all those bots will respond positively, such as “LOL”, “that is awesome”, “you are the best”, etc.

This app is called “Feel-Good-Channel” – an app with encouraging bots.

I even made a mock up of it:


  • Any user can create a new channel anonymously.
  • Any user can enter an existing channel to see (but no right to post anything).
  • A channel is automatically deleted after the owner leaves.
  • A channel can only be persisted if the owner is a registered user and chooses to do so.
  • A channel will automatically attract bots to join.
  • A registered owner can configure if the channel allows other real users to post.
  • All bots will make only positive comments, reaction, or memes.
  • The owner will be given a short survey to rate his/her happiness level when exit the channel.

Additional Features

In my original notes, the bots will slowly learn from what the real users post and then improve the “feedback” style. Once the bots become mature, the bots may even leave if the owner does not produce enough information or does not appear to require encouragement. Finally, the bots could learn from multiple channels, and find people with similar problem and connect them, if consented by the users.

Why is it interesting?

I still find this idea interesting because it touches 2 intriguing areas:

  1. Natural Language Processing
  2. Artificial Intelligence

NLP is always a hard problem to tackle. I am guessing with the Cloud-based machine learning, at least now we have more choices and tooling.

AI plays a key role in this app. If you think about it, we are building a robot that can understand natural language as well as human emotion. That is pretty interesting and challenging.

In fact, there are studies and discussion around the world

I also remember when I was working in the HCI lab, I helped research on a project that uses computer game to track and improve children’s emotion.

Many paper focus on facial recognition to determine the emotion. It is relatively easier than relying on only text. However, there are some old studies in psychology talking about how to do so with people’s handwriting:

Pretty interesting read.

Is it really useless?

After I expand this idea a little bit, is it a really useless idea? I am not too sure now.

First, we know in modern age, people are more inclined to text instead of face-to-face communication. Second, we know teenage suicide rate has been increasing.

And teenage feel more comfortable to use app and text.

Assume a user really feels down and start using this app, and assume we have an engine that highly accurately interprets the user’s emotion through wording. Due to the privacy agreement, the app will not know what this person is and where he or she is. However, if the app is able to derive the emotion level and the user’s physiological state, maybe we can do something:

  1. The bots can determine this user needs a listener or not, if yes, respond accordingly.
  2. The bots can determine the right moment to be funny to cheer the user up.
  3. The bots can connect another user (if there is one) with the similar problem and prompt to connect them.
  4. The bots may send an alert to someone to monitor the scripts.

How can such an app really help? I am not sure. But hey, I can only put that much nonsense at a time.

1st Idea: 1000 unrelated ideas

For years I have been trying to write a blog. However, I was never able to find a topic and stick to it.

Sometimes I want to write about coding as that is really primary daily activity. Unfortunately I am really not a very smart programmer. After all, there are way too many of these blogs all over the places and they are way more helpful.

Sometimes I want to write about user experience, as that is what I studied at grad school and my passion. I once even came out this thought that I would take photo of every poor experience I encounter in the real world and share in my blog. This is definitely not a novel idea, because I am pretty sure I have seen someone’s website exactly like that. Later I realize that I will have to a person who constantly travel the world to make that blog work.

One night, for no reason I suddenly woke up around 4AM. I checked my phone. In retrospect, it is probably a better idea not to put your phone near where you sleep. I noticed the phone recommend a post about Howard Shultz’s president run. I opened it and read it (again, didn’t know why I even did that). I felt pretty disappointed after reading it, so I seriously made a comment. If anyone is curious, here is the link to the comment and the post.

After making that comment, I closed my eyes, but all I was thinking was to say something about what I would do to the health care if I were the president of United States. Can you believe that?

Also, guess what, no surprise, I lost the sleep for the rest of that night.

The good news is, the very next day, I realize that who kind of person I have always been. I am a:
– day dreamer
– fantasizer
– unrealisticness

Basically, I am very good at nonsense, exactly just like my 7-year old daughter!

I should write a blog with nonsense as the topic!

I used to have so many nonsense ideas, some totally useless ideas, some Startup ideas, some funny ideas, maybe some even good ideas. I should put them together and write them up!

So here comes the first idea:

Writing a blog with 1000 unrelated ideas.

From 2019, March 1st, each week I will try my best to write up 1 idea (either I used to come up, or I will come up in the future), to 1000 of them. This should be fun. It serves no purpose or any intention, simply just want to see what I would gather in the end.

A simple question: how do I execute a command every minute?

This sounds like a trivial question, using a Timer of course.

However, here is a caveat: whenever the timer starts, we want the command to happen exactly at the beginning of a new minute.

This means, if the application starts at 10:30:05, we want the command to execute at 10:31:00, NOT 10:31:05. The next command should execute at 10:32:00.

Therefore, we cannot really just start a Timer with interval of 1 minute, because that does not really meet the requirement.

In this case, Observable.Generate comes to rescue.


DateTime previousExecute = DateTime.now; // initial time
var end = previousExecution.AddMinutes(3); // this is just a dummy end

	var obs = Observable
			previousExecution, // initialState
			x => x < end, //condition 
			x =>
				var diff = GetSecondsToNextMinute(x);
				var y = x.AddSeconds(diff);
				return y;
			}, //iterate
			x =>
				previousExecution = x;
				return previousExecution;
			}, //resultSelector
			x => TimeSpan.FromSeconds(GetSecondsToNextMinute()) //timeSelector
		, TaskPoolScheduler.Default.DisableOptimizations(typeof(ISchedulerLongRunning)));

obs.Subscribe(i =>

double GetSecondsToNextMinute(DateTime curr)
    var diff = (60 - curr.Second);
    return diff;

The above code will calculate the difference between the previous execution time and the next minute. The scheduler of Observable will tick after the selected time passes until the stopping condition is met.

Why is it useful?

This is interesting because we can now create a scheduler in code to execute a command exactly at midnight.

Here is the complete code:

        public static IObservable DynamicDaily(DateTime startTime, IScheduler scheduler = null)
            double d = GetSecondsToNextDay(startTime);
            Log.Debug("Daily Observable starts at: {StartTime} and waiting for {Tick} seconds from next day", d, startTime);

            DateTime lastExecutionDateTime;
            IScheduler sc = scheduler ?? TaskPoolScheduler.Default.DisableOptimizations(typeof(ISchedulerLongRunning));

            var obs = Observable
                    startTime, // initialState
                    x => x < DateTime.MaxValue, //condition
                    x =>
                        double diff = GetSecondsToNextDay(x);
                        DateTime retval = x.AddSeconds(diff).Date;
                        return retval;
                    }, //iterate
                    x =>
                        lastExecutionDateTime = x;
                        return lastExecutionDateTime;
                    }, //resultSelector
                    x =>
                        double diff = GetSecondsToNextDay(x);
                        return TimeSpan.FromSeconds(diff);
                    , sc);

            return obs;

        private static double GetSecondsToNextDay(DateTime dateTime)
            DateTime nextDay = dateTime.AddDays(1).Date;
            double diff = (nextDay - dateTime).TotalSeconds;
            return diff;

We can use a TestScheduler to test the above function.

The difference between Immutable and Readonly Data Structure

Persistent Data Structure

A persistent data structure is referred to a data structure whose underlying structure cannot be modified. Every modification will result in a new instance of the type with the updated values. In another word, such a data structure is immutable.

Why do we care?

In short, it’s all about parallelism. Google and read why we want to write code running in parallel.

Because immutable objects cannot be modified, it forces each thread of the program uses its own copy of data, which facilitates safe, correct, and concurrent code support parallelism.

Shared and mutable data structures, on the other hand, require synchronization, which is accomplished by locking the object, and normally has the following challenges:

  • very hard to reason about what will happen in run time;
  • very hard to debug and write unit test;
  • potential race condition;
  • possible deadlocks;

What about Readonly Collection?

In C#, Readonly Collection, is a wrapper for the underlying collection type. For example, ReadOnlyCollection<T>, which is a wrapper of List<T>. The ReadOnlyCollection will prevent being modified; however, if the underlying collection is modified, the ReadOnlyCollection is changed too. The following code snippet shows how to update a ReadOnlyCollection (run this in LinqPad):

List dinosaurs = new List();
ReadOnlyCollection readOnlyDinosaurs = new ReadOnlyCollection(dinosaurs);
readOnlyDinosaurs.Dump("Readonly Dinosaur");
dinosaurs.Dump("modified dinosaurs");

// this so-called readonly collection is now modified
readOnlyDinosaurs.Dump("Readonly Dinosaur");

In contrast, ImmutableList is a Persistent Data Structure. It will return a new instance of a list with the updated values, but the original list is intact.The following code snippet shows what the difference is:

List dinosaurs = new List();
ImmutableList immutableDinosaurs = dinosaurs.ToImmutableList();
immutableDinosaurs.Dump("Immutable Dinosaurs");
dinosaurs.Dump("modified dinosaurs");

var modifiedImmutableDinosaurs = immutableDinosaurs.Add("T-rex");
immutableDinosaurs.Dump("Immutable Dinosaurs");
modifiedImmutableDinosaurs.Dump("Immutable Dinosaurs");

What about performance and memory space?

Since updating an immutable list returns a new list, does it mean it will take more memory space? Not really. To understand this, the best way is going through the implementation of ImmutableList at here: https://github.com/dotnet/corefx/tree/master/src/System.Collections.Immutable/src/System/Collections/Immutable

Internally, ImmutableList is a LinkedList with a strategy called “Shared Structure” or “Structure Sharing”. Basically, it means, all (Immutable) copies of the original list  share some nodes. In the above example, immutableDinosaurs and modifiedImmutableDinosaurs share 4 nodes, but modifiedImmutableDinosaurs has one additional node. The variable of an immutable data object is just a reference of the head of the linked list. Therefore, there is really no significant extract space allocation.

How can it be thread-safe if we can actually update it?

You may notice that multiple threads can access the same immutable object. Because it always stays the same, “updating” it from multiple threads is safe with requires no lock. After all, all threads will simply perform just read operation. However, when a new list is constructed, a technical called Compare-and-Swap (CAS) is used. This operation is atomic and the outcome is either done or not done. CAS is a machine level instruction that requires no lock using a shareable object. Google for more details if interested.

Other Thread-Safe Data Structure?

.NET has many other data structure support thread-safe processing, including Concurrent Collection (ConcurrentBag, ConcurrentDictionary, etc), which is designed to work better in concurrent computation.

Concurrency vs Parallelism

To understand those 2 concepts, we first should understand what sequential computation is. Actually, I believe everyone can easily understand what a sequential computation is:

Concurrency, on the other hand, is referred to 2 or more tasks are executed at the same time. Using Barista taking orders at a coffee shop as an example:

The barista can perform grinding bean and boiling water those 2 tasks concurrently, and then move to next task(s). Those 2 tasks are independent to each other.

Finally, Parallelism can be seen there are more than 2 baristas, so we can server more customers in parallel.

Final Words

In sum, using immutability offers

  • lock-free and thread-safe implementation;
  • enabling shared structure to minimize GC effort, resulting higher performance in parallel computation;

C# has mutability as default behavior, but interestingly, the implementation of string, is actually immutable.

F# on the other hand, is default to immutability, meaning, every variable is immutable. Changing it will result in a new copy of it. There is no null. There is no need to lock.