Difference between LINQ and lambda expression

I have stuck at this field for a long time. Today it suddenly becomes clear to me: LINQ and lambda expressions are to very different things (though they complements each other on many occasions).

Lambda expression

Lambda expression, to sum up, is only about the operator “=>” (read as “goes to”). It serves as a shorthand for anonymous function (usually used to write short expressions like “x => x % 2 == 0” to find even numbers). It will be automatically typed as either an Expression, a delegate or a Func depending on where it is used.

LINQ

LINQ is like SQL for objects. It can query arrays, list or any other enumerable objects. It’s sort of an advanced for loops with SQL-like operations like sorting, grouping and of course, lambda expression support. Usual syntax is “from <iterator name> in <data> where <condition on iterator> select <iterator>”

Best setup to conveniently type English Dvorak, Vietnamese, and Korean (or any other East Asian language)

At first I thought I have to define three languages, because Unikey automatically made Windows switch to Vietnamese when I type, the default keyboard switching shortcut also conflict with Unikey’s (Ctrl + Shift); so every time I want to switch between QWERTY and DVORAK, I have to check whether I had accidentally turned Unikey off, and I have to press the language switching shortcut two times to switch between the two most used language (English and Korean). Believe me, that’s a lot of hassle right there.

So, after a lot of fiddling, I figured out I could just have it like this

My setup

(To add Dvorak to Korean, select “show more…”)

This way, I just need to switch between korean mode and English mode by pressing Ctrl + Shift (Microsoft IME still uses the QWERTY layout, which I don’t want to use, so I left it in 영어 mode). Conveniently, when I switch to Korean, Unikey is also turned off so I won’t accidentally put accent on Korean characters.

So, to summary:

  • To Type English, I can just type in Dvorak
  • I can also type Vietnamese, since VNI typing does fit really nice with English
  • Press Ctrl + Shift to switch to Korean, which also turns Vietnamese off

 

 

about:programmingLanguages

“Which programming language is the best?” It’s the kind of question that you will keep getting from aspiring programmers (maybe with some minor variations but it’s essentially the same problem). It’s a difficult question to answer. Although as old as the question itself, the debate is still alive today as evidenced by:

this
this
… and this

I’ll have to warn you, if (just in case) you don’t have a sense of (developers’) humor: they are just jokes, really. There’s no such thing as a “best” language. Everything is there for a reason, including programming languages. So the answer to the question above is: it depends on what you really want to do. All the languages involved in the debate are general-purposed, which means they can be used to do just about anything. For example, you may think that C++ could never be used to produce web pages, Actually, you can always write a C++ program to listen for  HTTP GET requests and then send HTML to the client. Alternatively, if you are Microsoft-savvy, you can always write an ISAPI application for ISS to intercept requests and process them.

A second thing worth noting in the arguments used is the ability to bootstrap the language with itself, that is, you can make a compiler for a language by writing code in that same language. I agree with a contributor on Wikipedia:

The definition of a language by a self-interpreter is not well-founded (i.e., cannot be used to define a language), but a self-interpreter tells a reader a lot about the expressiveness and elegance of a language. It also enables the interpreter to interpret its own source code, the first step towards a reflective interpreter.

Why bother really? PHP and Ruby did their jobs well with the compilers written in C.It’s a waste of resources both in manpower and computing power’s term trying to reinvent the wheel.

Someone have sum up the desirable characteristics for an ideal language

The language should

  • Have an intepreter for rapid prototyping, ease of debugging, and maximum fun.
  • Have a native code (not just byte code) compiler that produces fast code that can be run stand-alone or be called from the interactive environment.
  • Have good support for vectors, multi-dimensional arrays, strings, hash tables, etc. in the standard library.
  • Have a free implementation.
  • Work under Linux and Windows (so I can transfer code easily between my desktop and my laptop).

But that’s a person dream. For most of us who doesn’t have quite enough formal description enough to write anew language, we’ll have to make it with existing ones. Below is my stance on some of the (more popular) languages but if you wont a more detailed comparison of each language’s characteristics, this may be interesting to you.

C and C++

They are used to make just about anything. The difference between them is C++ have a more extensive set of libraries, which is expensive in term of storage space to implement so it’s not as popular on embedded devices as C. Their application may range from programming microchips to a whole operating system (you name it. Linux, Windows and Mac may seems all different but they are all in C and C++).

A common misconception is that there’s something a language cannot do. If you haven’t seen anyone write web pages in C and C++ then try to type your DSL modem’s address into your browser. You should see a web page that allow you to configure the device. Such a device wouldn’t have enough processing power for the additional abstraction layer of a web server’s but instead its role is encompassed by the firmware. The firmware itself, is of course, written with you-know-what.

In short, they are good if you are going to deal with hardware programming.

C#/Java

Considered high-level languages, they are the most promising platform to implement 4th generation languages. Notice that I wrote “platform” and not “language”. This is because C#/Java is merely an interface for a lower language, the common language for .net and bytecode for Java. The additional abstraction gives the developer the freedom to move the application across platform. Input and Output are not necessarily specific devices anymore. You can output to a screen or a printer, it’s the same to the language. You can have a language run on a mobile device or a PC without changing anything in the code, the virtual machine took care of it. You can use a module in a desktop application in a web service without any modification, increasing reusability and reduce the amount of work required to write code.

Because these language was designed later than C and C++ and targeted developer instead of computer scientists, you are no longer required to remember the difference between pointer and variable, don’t have to freak out with memory management and other trivial matters. Package and variable names are also neatly named according to a naming standard, since these language is controlled by a singe entity.

In a nutshell, choose them if you want to properly apply development paradigms and produce quality software that run fast and reliable, anywhere. But you will grow dependent on the managing companies though (namely Microsoft and Oracle)

Ruby and Python

Developer-to-developer languages. They are written with only one goal: get things done, as fast as possible. And as such they employ a vast number of libraries and add-on (and you will have to remember all their syntax). Professional developer seems to have no problem with that though, so they are quite popular among the web community. That’s why ruby thrives on rail and Google is built off Python. They have a different syntax from C (which is also different from all the languages above) though, so switching to them may be a problem for newcomers.

PHP

Started as a collection of script and the result of a developer disgruntled with his boss, PHP is released for free because it can’t be sold at first but accidentally, it’s just that that make it popular. Because it’s free, it’s a convenient platform to implement open-source projects that the user can download a whole platform off the Internet and have it running free-of-charge. Googling for WordPress and Joomla is enough to demonstrate PHP’s popularity.

Since PHP seems to have matured (its main version number stayed at 5 for two years now and had no significant changes since), it’s a good language to learn if you are intending to go freelance serving small and medium enterprises (SMEs) who doesn’t have enough financial ability to employ powerful servers and expensive softwares.

http://www.cs.ubc.ca/~murphyk/Software/which_language.html

Simplified Vietnamese

If you are thinking about some other language that have “simplified” before its name then no, Vietnam is not going to use that language as it official language, at least not in this year.

I recently read this article (For a side note: This site copies most of its content from blogs, and doesn’t ask for the author’s permission of course). I simply couldn’t get whatever it’s trying to tell me =)), so as a reflex I asked Google and found this. In short, the “program” and the “new language”, as they identified themselves, are going to change Vietnamese completely, so Vietnamese can be typed faster. They are first planned to be used in the Vietnamese computing society.

Completely impractical.

Vietnamese is a mixed language; it contained elements from both European and Asian roots. This “research” referred only one or two papers and end up creating a “better” language? Apparently its author has neither previous experience nor care to get some about constructed language. The idea of creating the “perfect” language, easier to write, easier to understand isn’t new. Some have tried and fail silently. If you live in Vietnam have you ever heard of “quốc tế ngữ”? Probably not. I’m not even sure which language that noun is referring to: Interlingua or Esperanto? Constructing a language and put it into wide use isn’t an easy problem. The two languages above have multiple contributors, even have their own lingual institute to research and introduce new principles into the language and still, they aren’t as success as they wanted.

What make that guy think one man is going to change history that easy, arrogance or ignorance?

Furthermore, Vietnamese is completely unorganized. There is no formal organization to regulate the use of new words yet (which have been hindering access to newest technologies for most Vietnamese, what would you call a blog or a shell in Vietnamese? =)). Vocabulary differentiates between regions to – North, South and the Central; even the pronunciation is different! (The “simplified” language claims it is based on pronunciation – which will make it easier to learn) Which region’s pronunciation is it using to simplify?

Well, to say how impractical it is, it may as well get 1st prize for that competition. I’m not a judge for that matter.

Faster Vietnamese

Searching for the above, there seemed to be a similar effort before, but it doesn’t dream as big, its main purpose is to allow you to type unpunctuated Vietnamese faster  

Qui ước gõ tt

Ví d

f  = ph

 Gõ fai  bung ra
(→)  phai

j  = gi

       ju jn jay j giu gin giay gi

 B bt h  : – gh

                    – ngh

      gi gn ghi gn         ge  ghe          

      ngi      nghi              nge nghe

c  = k *

       đ  k  = kh

      cim kim                    ce ke             

      ki ko kan    khi kho khan

Hmm, what a pity the author didn’t publish how this method was born, what’s its advantage, estimation of benefits etc. Otherwise more people would have been convinced to use and contribute to it. :/

Reading further into its rule:

Trăm năm trong cõi người ta            

Gõ phím:
       Tram nam trog coi nguj ta               

Bung ra       Tram nam trong coi nguoi ta

 

Ch tài ch mnh khéo là ghét nhau          

Gõ phím:        Chu tai chu meh keo la get nhau
         

Bung ra       Chu tai chu menh kheo la ghet nhau

 

Tri qua mt cuc b dâu                        

Gõ phím:        Trai qa mot cus be dau                       

Bung ra      Trai qua mot cuoc be dau

 

Nhng điu trông thy mà đau đn lòng     

Gõ phím:        Nhug diw trog thay ma dau don log      

Bung ra       Nhung dieu trong thay ma dau don long

 

Even though this method doesn’t seem to have wide usage, I can’t help notice similarities between this and the so-called “9x language”. Is there any chance those kids have seen their parent using this method but failed to learn properly and thus a new language is born? :))

2008 in Google’s terms

2008 is almost over, and Google has released Zeitgeist 2008. A good time to blog about it, since it’s still quite fresh and if I don’t do it now, I would postpone it on and on and on, right? 😛

Zeitgeist | Pronunciation: ‘tsIt-“gIst, ‘zIt | Function: noun | Etymology: German, from Zeit (time) + Geist (spirit) | Date: 1884 | Meaning: the general intellectual, moral, and cultural climate of an era.[1] [2]

This year the chart is not as colorful as before but it was enhanced with annotations 😛

Economy

Since the first release in 2001, the Zeitgeist progressively does a better job reflecting situations of the world, from regional to international.


Trends for Layaway

And no, that’s really a burst, a sudden increase in term of 8 times the original volume; not because the chart is scaled! The turkeys did quite a good job!

Over the hedge comics @ overthehedge.com

Oil

Gas price contributed is part, oh well…

Look at how consumerism has taken over the world. People care about the environment not for their children but instead for their pocket. What if one day the earth stood still? 😛

Who, what and how

I comment only for what I feel like commenting 😛

Who is…

  1. who is Obama
  2. who is McCain ~ Google is becoming one of the criterion for presidency 😛
  3. who is Palin
  4. who is lil wayne
  5. who is miley cyrus
  6. who is dolla
  7. who is jonas brothers
  8. who is chris brown
  9. who is biden
  10. who is martin luther

What is…

  1. what is love ~ How can you define love 😛
  2. what is life ~ 42
  3. what is java ~ Americans doesn’t seem to use that much coffee 😉
  4. what is sap
  5. what is rss
  6. what is scientology
  7. what is autism
  8. what is lupus
  9. what is 3g ~ Proof of Apple’s influence (j/k, 3G standards are in active development)
  10. what is art

How to…

  1. how to draw
  2. how to kiss ~ Isn’t this stuff best practiced than learning
  3. how to write ~ Blog is growing, right…
  4. how to cook ~ Restaurants are now expensive for Americans
  5. how to tie
  6. how to hack ~ Adults are taking their kids apart from the fun…
  7. how to run
  8. how to cite
  9. how to paint
  10. how to spell

International queries [3]

Nothing that much interesting, since Google themselves is quite lazy to translate the international queries this year 😛

What a pity Vietnam still haven’t generated enough data to appear in the yearly list, or is it some kind of classified data? Because I’m quite sure not only Vietnam are contributing to that infamous #1 query, while the second and third appeared in the Zeitgeist…

It’s not something that makes you proud when you searched for blog the most… ;))

Loneliness

Technology takes people nearer to each other… less and less lonely since 2004. The world is getting better! 🙂 You’ve got to love it!

Translation

Google released Vietnamese support for Google Translate this year together with a couple of useful enhancements (translated search, dictionary, etc.). Before that I have always been in doubt that all the Vietnamese pages on Google is machine translated; but that’s countered by the fact that nobody in Vietnam ever succeeded in writing such a translation engine; and the translation looks natural enough :-/ Time to put that to the test 😛

Web history in Vietnamese

Same page, translated from English

Sure enough, you can see the apparent similarity: the wording is the same; the grammar on the static page is a little better than the translated one but is still far from perfect. My guess is Google has someone with basic Vietnamese knowledge, and the person’s responsibility is just to check whether the translated text is readable. Oh well, even though people has to turn to English if they want to read the TOS, this may help kids and give a good example of how hard to translate Vietnamese (O’ great language =)).

Also, since I received complaints that my English is so terrible, this blog has just been enhanced with a translator thanks to David Pozza and Google for providing the API, hope it is more readable now 😉

(Look to the right)

~ And that’s another day with Google