deprecation of C++ style for loop and its replacements are…

New Features in Swift 2.2

Swift… 이거 참..
Telestream에서 일을 한 이래, 제대로 Objective-C/Cocoa에서 새로 나오는 것을 시도하거나, 심지어 Swift를 공부할 짬이 없었다. C#/.NET이나 C++도 마찬가지…
이전 회사들에선 퇴근하고서도 당연히 했고, 회사 내에서도 할 일 다하고, 추가로 더 알아보곤 했는데, 도대체 이 회사에선…
Cocoa에 대해서 알고 있던 것도 까먹고. 그래서들 미국 애들이 이런 회사에 지원을 안하나보다.

아무튼 투덜대는 것은 이만하고..
난  Swift가 도대체 마음에 들지 않는다.
Swift가 후져서가 아니라, 이건 순전히 마케팅에 의한 것이란 생각이 들기 때문이다.
GNU의 Objective-C 컴파일러를 들춰본 사람들은 얼마나 간략하게 Objective-C가 만들어져 있는지 안다. C++쪽은 별 이상한 짓을 해서라도 기능을 추가하는데, 굳이 몇가지 Objective-C의 단점을 들춰서 그걸 Swift를 합리화하는 건 뭐하지 않나? 문제가 있으면 고치면 되지 않나?

더군다나 Swift는 헷갈리는 면이 많다. 새로 언어를 배우는 어린 학생들이야 모르겠지만, 내겐 이 Swift는 어떤 면에선 Pascal, 어디선 C, 어디선 Perl 같은 느낌이 든다. Python을 하는 사람들은 Python 같은 부분도 있다고 한다.
일단 모드가 Pascal 모드로 바뀌면 Pascal 다워야 하고, C로 바뀌면 C 다워야 한다. 그래야 기억하기도 좋고 그렇지. 이건 순전히 잡탕같은 느낌이어서, 간만에 Swift 문서를 읽어서 익혀 두어도 나중에 기억이 잘 안난다. 왜? 파스칼 같으면 쭉 파스칼 같아야 하는데, 어느 순간 Perl 같다거나 그런식이기 때문이다.

그리고 2.2에서 새로 나온 문법을 보자.
다음의 코드를 보자

for var i = 0; i < 10; i++ {
    print(i)
}

이걸 이제 없애고 다음과 같이 바꾼다 한다.

for i in 0 .. < 10 {
    print(i)
}

이까진 좋다. Fast Enumeration 스타일이니까.

근데, 다음을 보자.

for i in (1...10).reverse() {
    print(i)
}

for i in 0.stride(to: 10, by: 2) {
    print(i)
}

저거 그냥 (10…1)로 못 만드나? 물론 reverse()도 지원하면서?
뭐 첫번재 예는 그렇다치자.
두번재 예..

저거.. 영어가 모국어인 사람은 0.stride(to..)가 와 닿을지 몰라도, 외국인들에겐 그렇지 않다. stride의 뜻이 그다지 강하게 다가오지 않기 때문이다.
단어의 뜻을 아는 것과, 그것이 얼마나 강하게 다가오느냐는 다른 문제이다.
stride?
Apple의 사전 앱에서 뜻을 보자.
1. 성큼 성큼 걷기. 활보
2. 한걸음, 한달음.

아.. 안다가온다.
이런게 낫지 않나?

for i in 0.increment(to: 10, by: 2) {
    print(i)
}

for i in 0.increment(to: 10, by: -2) {
    print(i)
}

두번째 것은 다음과 같은 동일 표현을 가질 수 있겠다.

for i in 10.decrement(to: 0, by: 2) {
    print(i)
}

Swift는 컴퓨터 언어에서의 cultural difference와 사람이 쓰는 언어에서의 cultural difference를 고려하지 않고 디자인되는 느낌이다.
이건 문제다. 그리고 내가 Swift를 좋아하지 않는 문제 중의 하나이다.

Dialogue’s Guiding Principles, or a Healthy Hatred of OOP two chain links

Dialogue’s Guiding Principles, or a Healthy Hatred of OOP two chain links

Well, it will be interesting to read the post.
However, I found out that problems among US programmers in terms of C++ is that they follow C++ techniques or new syntax etc, which are just supplemental rather than keeping philosophy of OOP and meta-programming.
Syntax-sugar is good. But problems of C++ is that ( don’t misunderstand that. As you can see I’m a long-time C++ programmer and I liked its initial paradigm a lot. ) a lot of features have been added to C++ for the sake of convenience ( with difficulty of using it ) or more power. People, who just judge others’ knowledge on C++ just by asking terminology and features, thus missing core values, love to use any new features.
Knowing such things are good and beneficial, but not always.
I’ve worked on pSosystem at Samsung and other systems where the greatest and the latest C++ features were omitted intentionally for the purpose of the system or unintentionally (just old C++ compiler). If people just stick to the greatest and latest feature and when exposed to such system, they are embarrassed often.
So, I’m always in the attitude of choosing common ground, which maximizes compatibility of source code and your knowledge compatibility.

Anyway, folks. Knowing more terminology and new features will make look more knowledgeable person especially here in the US due to its culture, but actually it’s not. What is more important is to know why you need to use this or that, philosophy behind of a language you choose, etc.

Here I see Objective-C code which is not written by people who understand Objective-C philosophy. They argue that they know, but if you see such code, ou will be able to see that they don’t understand the philosophy.
They oppose Objective-C or any other language without understanding their philosophy. Criticism can be good only and only if people criticize after understanding philosophy or background history on why this language/system is designed as such.

So far, my experience here in the US is that when interviewers were too picky and just judges people by asking if the interviewee knows(memorizes) one thing, I usually found out that their source code were dirty and messy in every angle.
If an interviewee is not a liar or a salesperson who wants to sell himself rather than an engineer, they tend to memorize terminology etc. But if they are engineers, they know but at the moment of being asked, they may not answer the interviewers question. It’s not because they don’t know about the answer, but they can guess something else.

For example, I’ve been asked like “implement this thing using STL.”
Well, I use Win32 collection APIs, Cocoa/Core Foundation collection APIs and also STL. Also I use boost. They are similar. If you happen to use Win32 collection API for the week when you are interviewed, you can temporarily forget STL. But if you look up document, you can quickly write in STL. Then doesn’t he know the STL?

Here in the US, although they say they are Objective-C programmer, they write in C++ and STL mostly. So, they can remember STL syntax.

I’m different. When I implement Win32 code, I stick to Win32 stuffs mostly. When I implement Cocoa/Core foundation code, I stick to them.
If I need to implement something common code, which I may need to use on Window / Mac / iOS/ Unix, I write with pure C/C++/STL. Then, I can temporarily forget one syntax. But does it mean that I don’t know about it?

I’m versatile person. However, the way US people interview others are not like that and they stick to one thing and say they are “the other” programmer.

Another example is … I’m asked how to implement XOR in C++ while being asked about bit-wise operations. So, I told him it’s ^ operator.
He said “No.”
Actually in the conversation, he jumped from logical operation and bit-wise operation. So, I wonder why he said “No.”
Well, what he wanted “DeMorgan’s law” to express logical XOR.
Damn.. then he must be clear on that.
In Korea, DeMorgan’s law is taught in middle school. Everybody knows DeMorgan’s law. Well, actually what is taught here in the US are mostly taught in middle school or high school like calculus, probability etc. Well. some are taught in here too in high school. But compared to the level of things taught in Korea, well here.. I understand why Obama mentioned education in Korea, although I oppose to his intention.
Anyway, then he treated me like a person who doesn’t know C++.

What the..

LLVM based just-in-time compiler for C++

http://www.jyt.io/

Raw Key Code for Function Keys

I figure out key codes for function keys from F1 to F12 on Mac.

  • F1 : 122
  • F2 : 120
  • F3 : 99
  • F4: 118
  • F5: 96
  • F6: 97
  • F7: 98
  • F8: 100
  • F9: 101
  • F10: 109
  • F11: 103
  • F12: 111

They are not related to ASCII table at all.
Code marked as ‘solution’ or ‘answer’ here doesn’t care of them. They are all converted to a printable characters, ^P. So, a table created with the method in the StackOverflow can’t differentiate each of the function keys. So, if you want to differentiate them, customize value saved there using the table above.

It turned out that the database solution, 4D, also had such values for the function keys.
So, it says that the values above is not only specific to my keyboard, Logitech  K760.

(It’s surprising that 4D is still alive.)

parent selector in Chrome as of today

parent selector in CSS is said to be included in new CSS draft as has() class. A stack overflow comment mentions about it.

Also, on this blog, the author says a reverse selector or parent selector is available with IE and WebKit-based browsers. Chrome was a WebKit-based until Google exited from the WebKit herd. However, in many document, Chrome is mentioned as WebKit-based and there are still lots of WebKit-ness there.
However, as of today, on my Chrome browser on Windows, this parent selector, <, is not available.The version of Chrome browser on my machine is Version 47.0.2526.106 m.

 

 

Way to figure out if a target memory is good to read/write?

Hmmm… IsBad*Ptr() functions are deprecated in Win32 API! Ok.. but what if you need it? Actually there is no reliable way to figure out if a pointer is valid or not. If you suffer such problem, it should be fixed at the caller side or the side where it prepared the pointer.

But.. what if you really need it even though you sufficiently considered that?
What if some external code gives you a bad pointer?

Here is a good blog post, “There is no point improving the implementation of a bad idea.”

There is a simple drop-in replacement and it’s.. reasonable.

Windows 10 can be run on Raspberry Pi!

This is great movement by MS.

Unix programming on this kind of one board PC is interesting enough to people like me, but for most of people, if things can be developed as Windows app, it can attract more audience!

Now, because MS Windows has a build for ARM, they finally allowed to run Windows 10 on Raspberry Pi AND you can develop app with Visual Studio!

It’s great!!!!

it can be also great ‘learning’ kit for Windows device developers.
Well, I know, I know. There is no good reference book for developing Windows device drivers. MS’s own one is too old, and some info there can’t be even applied.
However, at work, your managers can be people who don’t major in Engineering or Computer Science. So, they would think like “This is S/W program, and you are a S/W engineer. Why can’t you implement it?”
it’s not usual case S/W developers put their hands on device drivers. It’s usually done by people who major in EE, not CS or CSE.
(Well, nowadays, even CSE folks can do it, because embedded programming was now included in their curriculum.)
Also, device driver development requires information about target H/w. For example, when you want to write your own mouse driver for some logitech mouse, You may not be able to get information about the target device. there are some common interface, but may not.
(Think of web cams, for which standard was not fully prepared or even though there was standard, it was difficult to get informaiton on it. – remember MACAM? )
Also, a person who never developed device driver don’t know what information he needs.

But anyway, with this kind of device, at least people can try and play. Well.. yes. You can also study such stuff with normal PC box, but Raspberry Pi would encourage you to do so more because it would not have device drivers you want use with the raspberry pi. :)

Follow

Get every new post delivered to your Inbox.

Join 42 other followers

%d bloggers like this: