Python 的原生 multithreading 支援

Simon Willison 這邊看到的:「Real Multithreading is Coming to Python - Learn How You Can Use It Now」,他引用的原文在「Real Multithreading is Coming to Python - Learn How You Can Use It Now」這邊,在講 Python 3.12 將會有原生 multithreading 支援。

Python 裡知名的 GIL 問題將會用 Per-Interpreter GIL 的技術來解決,把 GIL 的 global-based 改寫變成 thread-based:

With introduction of "Per-Interpreter GIL", individual Python interpreters don't share the same GIL anymore. This level of isolation allows each of these sub-interpreters to run really concurrently.

這算是基礎建設,之後應該會有蠻長的陣痛期要轉換,尤其是各個其他程式語言寫的 library 要考慮到 thread-safe 的問題。

話說回來,PHP 就沒繼續討論過 threading 這個問題了,大家還是繼續用 process 架構在搞 XD

Microsoft 推出的 React Native for Windows + Mac

看到「React Native for Windows + Mac」這個,微軟推出了自己的 porting,以桌面環境的 Windows 與 macOS 為主,另外因為 Windows 10 的關係,也順便把平板與 Xbox 拉進來:

React Native for Windows + Mac brings React Native support for the Windows 10 SDK as well as the MacOS 10.12 SDK. With this, you can use Javascript to build native Windows apps for all devices supported by Windows 10 including PCs, tablets, 2-in-1s, Xbox, Mixed reality devices, etc., as well as the MacOS desktop and laptop ecosystems.

macOS 的 10.12 是 macOS Sierra,已經是 unsupported 的版本 (到 2019 年九月),所以目前蘋果官方有支援的作業系統都有在這包的範圍內。

Windows 10 SDK 的部份就不知道現在還有在支援的 Windows 8.1 能不能裝了。(看「Windows 10 SDK」這頁有列出 Win32 程式可以,但就不知道這次這包是不是用 UWP 技術...)

本來 javascript 開發 desktop 程式比較常見的是 GitHub 放出來的 Electron,現在等於是微軟多提供了一個選項讓...

Facebook 推出了 Hermes,為了 React Native 而生的 JS Engine

Facebook 提供了一個對 React Native 最佳化的 JS engine:「Hermes: An open source JavaScript engine optimized for mobile apps, starting with React Native」。

裡面有提到兩個比較重要的的部份是 No JIT 與 Garbage collector strategy,針對行動裝置的特性而設計:避免 JIT 產生的 overhead,以及降低記憶體使用量。

官方給的改善主要也都是偏這兩塊:

不過沒有提到 CPU usage 會上升多少,只是帶過去:

Notably, our primary metrics are relatively insensitive to the engine’s CPU usage when executing JavaScript code.

對於 Facebook 也許是可以接受的數量,但對於其他人就沒概念了... 要入坑的人自己衡量這部份的風險 XD

將 Sketch 輸出成 iOS/Android 的程式碼

Supernova 是前陣子看到的工具,目前是 public beta,將 Sketch 的設計直接轉成 iOS/Android 的程式碼,減少每次手動調整的痛:「Introducing Supernova」。

目前只支援 iOS/Android,但之後有打算要支援 React Native。(參考「Import & Export」這邊的說明)

五月時寫到的「透過 NN (類神經網路) 訓練好的系統,直接把圖片轉成程式碼」這篇是直接從圖片轉成程式碼,也是想做類似的事情。但 Supernova 因為有 Sketch 內的資訊,轉換的準確度會高不少...

Android NDK 宣佈向 Clang 靠攏...

Hacker News Daily 上看到 Android NDK 宣佈向 Clang 靠過去的消息:「Changelog for NDK Build 2490520」。

Android NDK 做為效能的加速手段而使用到 C 或是 C++,所以會使用對應的 compiler suite:

The NDK is a toolset that allows you to implement parts of your app using native-code languages such as C and C++. Typically, good use cases for the NDK are CPU-intensive applications such as game engines, signal processing, and physics simulation.

而粗體的兩段則說明了遷移:

PSA: Everyone should be switching to Clang.

以及:

GCC in the NDK is now deprecated.

微軟的 CodePush

看到微軟推出的 CodePush,針對 CordovaReact Native 類透過 WebView 跑的程式提出的方案。原因是 Apple 的 App Store 審核都要很久,透過 CodePush 可以直接更新程式:

CodePush is a cloud service that enables Cordova and React Native developers to deploy mobile app updates directly to their users’ devices. It works by acting as a central repository that developers can publish certain updates to (e.g. JS, HTML, CSS and image changes), and that apps can query for updates from (using our provided client SDKs). This allows you to have a more deterministic and direct engagement model with your end-users, while addressing bugs and/or adding small features that don’t require you to re-build a binary and/or re-distribute it through any public app stores.

FAQ 文件裡提到了這點:(Frequently Asked Questions · CodePush)

Does the Apple App Store allow developers to perform these types of updates?

According to section 3.3.2 of Apple’s developer agreement, as long as you are using the CodePush service to release bug fixes and improvements/features that maintain the app’s original/presented purpose (i.e. don’t CodePush a calculator into a first-person shooter), then you will be fine, and your users will be happy. In order to provide a tangible example, our team published a (pretty cheesy!) CodePush-ified game to the Google Play Store and Apple App Store, and had no problems getting it through the review process.

Because Cordova apps are executed within a WebView, and React Native apps are executed within JavaScriptCore, from a technology perspective, these runtimes are unique in their ability to leverage dynamic code downloads according to the aforementioned Apple developer agreement.

同樣的想法如果真的可行,應該會有其他更開放的 open source 方案可以用 (而非綁定性的服務,而是可以掛到自己的 CDN 上下載更新),先觀察一陣子...

判斷是否為付費文章的瀏覽器套件

AdDetector 是個 ChromeFirefox 的套件,可以在頁面上顯示這篇文章是不是付費文章:

AdDetector reveals articles with corporate sponsors.

會在最上面出現紅底的警告說明:

這個套件之所以未被發展出來,主要是因為付費內容即使被標注,也都是很不明顯的標注。這個套件的目的就是希望讓標注更清楚。

Google Chrome 上使用 Native Client (NaCl) 執行 Vim...

Twitter 上看到有人講:「Vim console application running using NativeClient」,實際跑起來長這樣:

只是跑起來測試,因為平常用的平台 (UbuntuMac OS X) 都有原生的 Vim 可以用...

這算是 Native Client 的火力展示嗎?

NaCl (Native Client) 總算要支援 ARM 了...

OSnews 上看到 NaCl 要支援 ARM 了,在這之前的版本都只能跑在 x86 family 上面:「Native client now supports ARM」。

另外在 The Chromium Blog 上也提到這件事情:「Native Client support on ARM」。

下一個預定要完成的計畫是 Portable Native Client (PNaCl),希望用 LLVM 一統江湖... XD