Reading: Week 50, Dec 11 - Dec 17

At a glance

  • You are interested in popular science and general knowledge: [2] and [9] are for you.
  • You are an iOS developer: [4], [5], [6] and [11] are worth a look.
  • Finally, the book in [8] is awesome!

Dec 17, 2017

[11] Friday Q&A 2017-12-08: Type Erasure in Swift #ios #protocols #generic #type-safety - This post discussed several approaches towards type-easure. The underlying functions approach is the same as what I blogged a while ago in Swift: Generic protocol (p.1).

  • We can recognize the noticeable presence of Bridge design pattern here because it is compatibility that motivates type erasure.

  • This article published recently also mentions type erasure, and a few more problems when working with associate types: Patterns for Working With Associated Types. A nice-to-read!

[10] An Interactive Introduction To Quantum Computing Part 2 #quantum-computing - I’m not from Physics background but I cannot resist my curiosity to get to know this trendy term. The article gave me a rough sense of how quantum search totally defeats the conventional one. Anw, need more exposure!

[9] What if everyone jumped at once? #science - Rất thích cách đặt vấn đề của Vsauce. Có những câu hỏi tương tự, chẳng hạn như giả sử bất thình lình Trái Đất ngừng quay thì chuyện gì xảy ra? Những câu này làm mình nhớ đến những thí nghiệm tưởng tượng của Einstein.

Dec 16, 2017

[8] Diary of a Wimpy Kid (Diary of a Wimpy Kid, Book 1) #books #reading - This book is increadibly fantastic. The story was written in a very distinctively witty manner. I really love the way the author portraited the Greg-Rowley friendship and how Greg learned from his hard lessons. Also, the differences in how children and parents normally conceive were described so vividly, which brought me lots of laugh… I’m gonna grab other books of the series :).

[7] FluidDATA #podcasts #tools - Podcast lovers will be definitely into FluidDATA. The wonderful power of this site is that you can search podcasts based on your interests. This feature also provides you relevant sources whose contents meet your creteria.

Dec 15, 2017

[6] Swift Analytics: Comparing structs, enums and protocols #ios #analytics - Well, the original post by John has drawn lots of attention from the community. The way developers use to handle analytics diverges. Chris’s post gives a fair comparison between the approaches mentioned. In short, each has both benefits and drawbacks. It’s up to your needs to pick the most suitable implementation. Personally, I prefer Dave’s approach.

Dec 14, 2017

[5] SourceKit and You #ios #talk - Đây là một bài nói, chứ hỏk phải bài đọc. Tóm lại bài nói là, SourceKit cho phép mình làm việc với language syntax, và giải quyết nhiều vấn đề thú vị như code analysis, code generation, code refactoring

  • Đã nghe nói về SourceKit và cũng thử qua các thư viện nổi tiếng xây dựng trên cái này như SwiftLint, Sourcery trong mấy cái projects thử nghiệm. Về cảm nhận cá nhân thì mình thấy SwiftLint cực kỳ hiệu quả. Nếu coding style là quan trọng đối với team thì nó hoàn toàn đáng thời gian để tích hợp. Mình nhớ lần đầu gắn thử vào project trên công ty (code base hơi lớn), mặc dù đã disable các rules, và chỉ enable 1 vài rules thôi mà số lượng warnings/errors bay nhảy lên 3 con số (999+). Lý tưởng nhất là tích hợp lúc đầu. Còn không thì chia theo pha mà tích hợp (mỗi pha enable 1 số rules tuỳ theo mức độ nghiêm trọng, và mức độ vi phạm của project hiện tại). Đây là cách làm trong đầu mình, chứ project trên công ty vẫn chưa có dấu chân của swiftlint đâu :)).

  • Sẵn tiện nhắc về code analysis, mình có một trải nghiệm cũng thú vị. Project mình tham gia lúc ấy khá đặc thù về mặt code base. Đó là một dòng các apps mà tụi chúng share gần hết 80% các features, (20% còn lại ngốn mất 80% thời gian và công sức của team đó LOL (jk)). Sau một thời gian quan sát, tôi thấy có nhiều classes/structs/enums mới ra đời, nhưng na na với những app khác. Đây hẳn là code smell - tôi nghĩ.

    • Vì muốn đánh giá được mức độ phức tạp của project hiện tại, xem thử coi mức độ giãn nở của project ra sao theo thời gian, tôi quyết định viết 1 cái script rú-bì (ruby), xài chủ yếu là regex và đọc ghi file là chủ yếu (code chuối lắm =]]). Nó cho mình xem overview của project theo 1 vài thông số như: số lượng classes/structs/enums/protocols, trong đó có bao nhiêu thằng được xài chung, có bao nhiêu thằng chỉ xài ở 1 vài apps. Đại ý là vậy, sau này dự sẽ thêm tiêu chí khác vào.
    • Tuy nhiên, vì dùng regex chứ không xài mấy cái hào nhoáng như SourceKit, có khá nhiều trường hợp biên phải xử lý, ví dụ như nested classes/structs/enums, comments, typealias. Cũng vì xử lý nhiều vậy nên thòi gian chạy không được nhanh lắm. Cực khổ vậy đó, nên mới cần ba cái frameworks này chớ :D.
    • Đánh giá chung thì cái script tôi viết ra không đủ để phục vụ nhu cầu tương lai. Nhưng tôi không hối hận khi dành cuối tuần ngồi code thay vì đi chơi. Đơn giản vì cái mình viết ra giúp cho mình có 1 cái nhìn tổng quan, giúp đưa ra chẩn đoán sơ bộ về một đối tượng nào đó. Bước đầu tiên trong giải quyết vấn đề là nhận diện vấn đề! Ngoài ra, nó còn đem lại lợi ích về mặt học tập :).

Dec 13, 2017

[4] Friday Q&A 2017-10-27: Locks, Thread Safety, and Swift: 2017 Edition #ios #concurrency - Now I understand the name of os_unfair_lock. Lock fairness means that different threads could have some chances to acquire the lock. Otherwise, there could happend the situation in which a thread holds the lock (many times) for a long time. This lock, which is available since ios 10, is the replacement of OSSpinlock, to avoid thread priority issue.

  • The high performance of os_unfair_lock comes from the fact it constantly check if the lock has been released or not.

  • The author pointed out that DispatchQueue seems to be the right choice among those mentioned. I also run a benchmark and this is the result: NSLock ~< pthread_mutex_t < DispatchQueue ~< DispatchSemaphore < os_unfair_lock

[3] Meet the man behind the most important tool in data science #data-sience #story

Dec 11, 2017

[2] Can you solve the egg drop riddle? - Yossi Elran #ted #riddle - Interesting riddle. Definitely worth a share.

[1] Doing Data Science at Twitter #data-science - The author mentioned two types of data scientists. One is particularly strong in statistics, other highly excels at programming skills.

  • Really enjoy Dan’s comparison =]]

“Big data is like teenage sex: everyone talks about it, nobody really knows how to do it, everyone thinks everyone else is doing it, so everyone claims they are doing it” — Dan Ariely

comments powered by Disqus