Performance of Swift

People started to raise questions on Apple’s Swift language.

Performance of Swift vs. Objective-C

Some nice sorting tester written in Swift.

Apple’s Swift is not swift after all.

Among those, the last article caught my eyes. ( the 1st one is also good starting point. )
As far as I know, the inventor of the Swift actually is the core person in LLVM/Clang.
I’ve heard that he wrote Swift while making LLVM/Clang. So, if it is right, Swift language would be architected to get most performance out of clang/LLVM.

However, it was very questionable to Apple’s claim that Swift is x-times faster than Objective-C at WWDC.
Probably there can be such case. Sure! Java is also faster than C/C++ in certain case. ( Especially when they don’t count the time to load a program at first or whenever page-in happens. ) However, Swift is native and Obj-C is native. Obj-C has its root in C.
So, there is no reason that Objective-C is refined and modernized inside to achieve the performance of the Swift if they want.
Objective-C implementation has legacy model or old idea and tied with old GCC architecture. When Apple adopted clang/LLVM, the front-end of the compiler (GCC at that time) was redesigned until backend was ready. So, Now, on the both frontend and backend, Obj-C is written for clang/LLVM. I don’t mean that they refined all every part of Obj-C for clang/LLVM. It’s not realistic to wish that they did it perfectly for all aspect of the language. I expect Objective-C can be refined more. Yeah.. they got rid of the garbage collector, they changed here and there for properties. ( There are more versions in terms of properties than it is documented. Believe me. i tested 32bit, 64bit, Mac OS X, iOS, PowerPC, Intel, and ARM targets as well as modern and legacy Objetive-C. )

So, one of the thing I was really frustrated was that they touted Swift as better performing language than Objective-C. It gave an impression like “Objective-C is the language of yesterday. Now folks, jump on a new language, Swift!”
No.. it depends on how they think.
You know.. things human makes are always like that. Bill Gates said, PC era was ended when he put MS tablet machine on his hands. At that time, Steve Jobs said NO. And he proved that how cool PCs still can be by pushing out new MacBooks (Pros) and new Macs.
But suddenly, Apple announced iOS and kind of declared, PC era is ended. Do you really think so?
Trend-wise, yes. But it’s manipulated reality. It’s because Apple put more energy on iOS not on Mac.

It looks to me that people get tired of iPad, for example, nowadays. Why? iPad growth is slowed down, while PC form factor gained some popularity for recent months. Google’s Chromebooks are said to be sold very well. Actually it was the best selling ‘notebook’ computers in the US in the last December. Why? Yeah.. one of the reason is that it’s cheap. ( Well.. without many features.. the absolute price is cheap. But considering its missing capabilities compared to normal notebooks, it’s kind of expensive. )
Another reason is that people look to be tired with one-app-at-once style OS.
Also, if you decide to write a lot, then you need a keyboard for your iPad. Then.. isn’t it better to buy a notebook computer?

Look at Apple fanatics. They just buy everything. iPhone, iPad, MacBook/Pro, iMac or any other desktop Mac.
Why? I know that sometimes using iPad is more convenient than using MacBook Air or MacBook Pro 13″, especially in crammed place like on a bus or in an airplane. Then folding out LCD screen and sparing keyboard area is kind of pain.. and it’s hard to type or do anything. However, do we really need to spend our money for that very occasional moment?
I would rather have one smartphone and one notebook. That’s it. When you need mobility and are shopping or waiting for bus, etc, smartphones are good enough and more handy. iPad? Any tablet? They can easily slip out from your hand.
Holding a tablet while stepping on a bus.. it’s dangerous. You can drop your expensive tablet.
On a bus.. if there is really important information you need to know, smartphones are good enough.
If you are at some place where you can do more serious things, notebooks are better than tablets.
Between those transition times from mobile phones to notebooks? Just daydream! Just close your eyes and give your eyes chance to take rest! Look at what others are doing. Do eye-greeting to other people! That’s better.
Actually recent research revealed that daydreaming is good for recovering your memory, etc.

So, tablets killed/are killing PCs? Maybe.. or can eventually. But.. it all depends on what plan the manufacturers of PCs/tablets think about. Cool features of iTunes U program on your iPad? Wouldn’t it be better if Apple make one for Mac and PC?
Yeah.. They introduced discussion feature in the latest version. I believe it would be more convenient to use if the iTunes U is available on PC/Mac! Or any killer mobile apps? Evernote is more comfortable when used on PCs/Macs than Android/iOS mobile devices.
Should you divide when you produce and when you consume information? And should you spend your money for more “information consuming-oriented” device? They are not cheap.

That is the point I like about MS surface. People around me don’t look to like Surface, but I like it. Windows 8.1 looks better and more refined OS than 7 and 8.0. Especially on ‘Desktop’ mode of 8.0 and 8.1, 8.0 looked like half-baked environment. 8.1 looks completed one. Resolution-semi independence or high DPI mode is better with 8.1.
Just like the failure of old Mac didn’t mean that the technology was inferior ( the cooperative multitasking was inferior, but before that time, Mac was more advanced than PC. ), the failure of Windows 8.x nowadays doesn’t necessarily mean that its technology is bad.
Social atmosphere, trend, etc controls whether a platform gains popularity or not as well as technology itself.

(Mac fanatics are just like Windows fanatics.)

Anyway.. for that, I like MS’s approach more than Apple’s approach.
Ah.. let’s go back to the original topic.
So.. everything depends on what they want to sell and market. It’s not that PC era is ended. It means that it became hard for PC manufacturers persuade people to open their pocket, because nowadays even old PCs are faster for most of jobs. Should we buy a new PC? Game worked on that before. Still it does. But.. not for most of people.
Then they have to make people to open their purse. So, it’s the reason they declare PC era ended!.

Language is the same.. is Objective-C old language? Yes. But it doesn’t mean that it can’t be modernized or rewritten for clang/LLVM to juice out every small sacks of orange. I like the clean syntax of Objective-C as much as C++. C++ is known to be bloated. I agree with that view. But still.. C++ language designers can make it slim if they want.

I don’t understand if there is any strategic decision on why they pushed so hard the Swift at WWDC.
To make people apart from other platform and stick to iOS, just like MS tried and did with their Windows?

Usually such effort eventually turned out to fail.

 

미국에서 기술 서적을 쓰는 사람들의 전반적인 행태 변화..

80년대, 90년대 중반과 그 후를 비교할 때, 미국에서 기술 문서를 쓰는 사람들은, 진짜 프로그래머에서, 비전공자들, 변호사 혹은 말빨로만 먹고 사는 사람들로 바뀐거 같다. 1판,2판의 C++ Primer (웨이츠 그룹)과 그 후 약 4판인가 5판부터의 것만 비교해봐도 쉽게 알 수 있고, Cocoa Patterns나 Core Data 같은 책을 봐도 알 수 있다. 에디슨 웨슬리의 Core Animation은 저자가 한국 고등학교 수준의 행렬도 못하는 상태에서 쓴 티가 팍팍 난다. 예제를 보다보면 어떻게 어거지로 회전/변환을 맞추기는 하는데, 수학적으로 제대로 되지 않은게 보인다.

OpenSSL 0.9.8za for x64, Windows

OpenSSL 0.9.8za was posted at OpenSSL.org site on Jun 5, 2014.

Although there is a version in 1.0.x, the post dates for them are the same.
For some open source project, they may require 0.9.x version of OpenSSL.

So, I share 0.9.8za built for x64/Windows here.
It was built using Visual Studio 2010 for x64 architecture and contains DLL and static version of libraries.

 

C/C++ refactoring module for Visual Studio

http://www.klocwork.com/products/insight/refactoring/

Is there anything for Xcode?

Converting ‘created at’ time from Twitter to the time format of Facebook

Just because Facebook time format is closer to the UTC standard format, and I need to sort posts from Facebook & Twitter...
void normalizeTime( const char *twitterTimeToNormalize, char normalizedTime[] )
{
    // normalized format : 2014-06-20T06:27:00+0000
    // twitter time format : Thu Jun 12 15:52:58 +0000 2014
    
    char temp[5];
    char month[4];
    int day, hour, min, sec, offUTC, year;
    
    sscanf(twitterTimeToNormalize, "%s %s %2d %2d:%2d:%2d %5d %4d",
           temp, month, &day, &hour, &min, &sec, &offUTC, &year );
    
    // On Windows, there is _stricmp(), but on Mac it's strcasecmp().
    // So, let's make it lower case first.
    std::string month_string = month;
    std::transform(month_string.begin(), month_string.end(), month_string.begin(), ::tolower);
    
    int month_int = 0;
    
    if( month_string.compare("jan") == 0 ) {
        month_int = 1;
    }
    else if( month_string.compare("feb") == 0 ) {
        month_int = 2;
    }
    else if( month_string.compare("mar") == 0 ) {
        month_int = 3;
    }
    else if( month_string.compare("apr") == 0 ) {
        month_int = 4;
    }
    else if( month_string.compare("may") == 0 ) {
        month_int = 5;
    }
    else if( month_string.compare("jun") == 0 ) {
        month_int = 6;
    }
    else if( month_string.compare("jul") == 0 ) {
        month_int = 7;
    }
    else if( month_string.compare("aug") == 0 ) {
        month_int = 8;
    }
    else if( month_string.compare("sep") == 0 ) {
        month_int = 9;
    }
    else if( month_string.compare("oct") == 0 ) {
        month_int = 10;
    }
    else if( month_string.compare("nov") == 0 ) {
        month_int = 11;
    }
    else if( month_string.compare("dec") == 0 ) {
        month_int = 12;
    }
    
    // Now convert to standard time format, which is used by Facebook
    // 2014-06-20T06:27:00+0000
    sprintf(normalizedTime, "%4d-%02d-%02dT%02d:%02d:%02d%+05d",
            year, month_int, day, hour, min, sec, offUTC );
}

Swift language : will it be successful?

Without making Switft available on other platforms also ( whether they support Cocoa or not. ), it may not be successful.

The reason is that.. if you choose other languages, you can use them directly on many platforms ( e.g. C/C++, Ruby, Perl, PHP, Python, etc ) or with a little effort ( Objective-C ). However Swift is solely for Mac now. Who is going to choose and learn a language which can be used on only one platform?

It may be Ok not to provide Cocoa/Cocoa Touch with Swift on other platforms. Like C/C++, different parties can provide their own ‘libraries’. Or it can be even better if Apple decides to provide Cocoa/Coco Touch on other platforms along with Swift, because Cocoa programmers can use their knowledge on those frameworks to make apps on other platforms.

Actually.. if I were the lead engineer of a ‘next generation of easy to use and learn language for LLVM’, I would have chosen Ruby. Will it be hard to make Ruby get benefit from LLVM? Ruby has nice OOP support and many 3rd party libraries ready to use, like Ruby on Rails. It’s modern and has lots of positive followers.

It looks to me that Perl is kind of gaining popularity also. It’s old language, but it has been the choice of CGI / Web /Script programmers for long time due to its trust-worthy solid base and tons of libraries. So, native code-generating Perl on LLVM sounds interesting also.

Probably Perl and Ruby have their own peculiarity which prevent them from being built on top of LLVM. But I doubt if there can be any such things.

Additionally I doubt if the performance of Swift code Federighi showed is the best and optimal result or general result. Why is Obj-C slower than Swift? Is there some really special aspect that the Swift is better suited for LLVM and multicore architecture? Is there any reason Obj-C can’t be as fast as Swift?

Lots of questions in my brain… Just hope that it won’t be like Dylan.

async and await keywords with MVVM

http://msdn.microsoft.com/magazine/0513129c-db0c-4c93-a583-348431821cea

Follow

Get every new post delivered to your Inbox.

Join 50 other followers

%d bloggers like this: