The next generation: Objective-C 2.2 or Objective-C 3.0?

According to a recent post by Big Nerd Ranch Weblog, the most recent Clang build now support Objective-C Literal feature.

WOW!

This is gonna be the most exciting part of this year’s WWDC! I believe Apple will announce this feature in this year’s WWDC. Damn it, I can’t miss that!

What’s Objetive-C Literal syntax feature?

According Ted Kremenek from apple who committed a large patch to llvm repository recently(On March 6th, 2012)

Add clang support for new Objective-C literal syntax for NSDictionary, NSArray, NSNumber, and boolean literals. This includes both Sema and Codegen support.
Included is also support for new Objective-C container subscripting.

My apologies for the large patch. It was very difficult to break apart. The patch introduces changes to the driver as well to cause clang to link in additional runtime support when needed to support the new language features.

Docs are forthcoming to document the implementation and behavior of these features.

Is it just like the boxing/unboxing feature in Java?

Yes, it is.

This feature makes Objective-C much more easy to use and much more like a modern high-level programming language while maintain the downward compatibility with C.

NOTE: Java introduced auto boxing/unboxing in 2004 with Java 1.5.0.

How to use Objective-C Literal feature?

Here are some examples:

Before we start to use Objective-C Literal

NSArray *myArray = [NSArray arrayWithObjects:
                    @"string", 
                    [NSNumber numberWithInt:1234],
                    [NSNumber numberWithFloat:12.34],
                    [NSNumber numberWithLongLong:123456789012345],
                    nil];

NSDictionary *myDict = [NSDictionary dictionaryWithObjectsAndKeys:
                        @"Value1", @"key1", 
                        [NSNumber numberWithInt:1234], @"key2", 
                        [NSNumber numberWithBool:YES], @"key3", 
                        nil];

After using Objective-C Literal

NSArray *myArray = @[@"string", @1234, @12.34, @123456789012345, nil];
NSDictionary *myDict = @{
    @"key1":@"Value1",
    @"key2":@1234,
    @"key3":@YES
};

Super easy, super fast! right?

What’s the next version number?

Last time Apple updated Objective-C language with block syntax, and a fantastic library for concurrent computing. There is an official version for block, that’s Objective-C V2.1.

This time, it brings some nice features which are common in Java and other dynamic language lick ruby, php, python. What’s the version we should call it?

I predicate that Apple will proudly call it V3.0. Yes, Objective-C V3.0. Let’s wait and see!

Want to have a try?

Goto clang’s page, checkout the most recent source code, build it and try to run a test case!

NOTE: if you downloaded the source in a folder with a space in the name, you might not be able to build the llvm and clang.

So, DO NOT put the source code in a folder with space


Finally, you can reach me at twitter: @tonnyxu or facebook Tonny Xu

Tips – Using janus to manage your Vim settings.

What is janus?

From janus‘s official Github page:

This is a distribution of plug-ins and mappings for Vim, Gvim and MacVim.

Just as it statement says, it packaged some popular plug-ins and mapping for you, so you can to use a full featured Vim after you installed Vim(If you are using Mac and Lion+, that means you just need to run a command and start to use a luxury Vim).

If you are in a rush, just copy the line below and paste to your terminal.

$ curl -Lo- http://bit.ly/janus-bootstrap | bash

Why bothering janus?

There are many famous plug-ins for Vim. But searching and installing plugins could be a painful work.

Usually, you google it, then go to vim.org to download it, then you config it and use it. This process is fine for one plugin, what if you want to install the top 10 vim plugins for coder, what if you want to install another 10 popular plugins?

For me, I can’t go through this process again and again. Don’t even think about the weird errors popped out when you installing your plugins.

What’s the merit I can get?

With janus, all you need to know is run a command and then use it. Oh, maybe you still need to remember some command for the plugins.

Where to start?

If you have enough patient to read to here, I suggest you to take a look at janus’s Github page.

What? you just want to use it? OK, open your terminal and paste the code below.

$ curl -Lo- http://bit.ly/janus-bootstrap | bash

Good luck!

And, don’t forget to follow my twitter @TonnyXu

Using purge command in Mac

Have you ever heard about the command purge? Hmmm, never heard about it? Well, that’s means you are view the right page.

Let me change the question.

Have you ever met a situation like this?

8GB, but full
figure 1

Holy shit, 8GB DDR3 memory is still not enough?

WTF?

Most of the time, I will blame my default browser: chrome! Usually, when I quit chrome, it will free 3GB+ memory, and my Lion system will go smoothly again.

But, chrome is not always the reason of high consumption of my physical memory. I don’t know which one is using a huge bunch of memory then leave it as INACTIVE, just as figure 1 looks like. The blue pie is huge! and the most important thing is it is INACTIVE.

What’s next?

OK, here purge comes to rescue, open your terminal, then type:

%: purge

BOOOOM! my system looks like as below, and feels much more faster!

after using purge

What happened?

The story behind the scene is relatively complicated, you can read Apple’s document. But anyway, it’s a shortcut to free your valuable INACTIVE memory.


Don’t forget to follow me @TonnyXu

3 great videos you must see

 

The Carbon Economy

(View high quality video on YouTube)

It’s time for real

Hellmann’s – It’s Time for Real from CRUSH on Vimeo.

The State of The Internet

JESS3 / The State of The Internet from Jesse Thomas on Vimeo.