Skip to content

Instantly share code, notes, and snippets.

View rayshih's full-sized avatar

Ray Shih rayshih

View GitHub Profile
@rayshih
rayshih / FPNineNine.kt
Last active April 6, 2018 23:13 — forked from chartsai/NineNine.kt
FP NineNine
package ninenine
// ----- Data -----
sealed class NineNine
data class Item(val x: Int, val y: Int): NineNine()
data class Col(
val x: Int,
val n: Int
): NineNine() {
val items =

我就直接回在下面了

回應 https://gist.github.com/rayshih/4144d6b8bc045fc26daf8887bd0cb4e2


我一直覺得你的發言和其他人沒有交集,但想不通到底哪裡出了問題。但看了這段程式之後,我覺得有點懂了。原文的程式不容易看 timestamp(加上 1th 2th 3th 讓我豆頁痛),所以我稍微改寫如下。

import asyncio

Re: asyncio 好寫嗎?

首先,其實還滿開心有機會可以做個小小辯論的啦。我的回應如下

這把好幾個主題混在一起了,需要一個一個看。

1. Async Program 好寫嗎?

不好寫。東西好不好寫的意思,代表它和 programmer 的內在思考模式符合程度。Async program 不符合人類習慣思維,所以才會被說一開始的學習 overhead 很高,寫起來容易卡。尤其如果同步與異步 paradigms 並立(例如 Python),就更容易在切換的時候出問題。

@rayshih
rayshih / promises.js
Last active September 5, 2016 07:57 — forked from christianalfoni/promises.js
A comparison of promises and signals
// ----- start of "extracted functions" ------
const toggleLoggedActivity = (data) => {
const selectedActivity = getActivity(activities, data.activityKey);
const selectedActivitySubCategory = getSubCategory(activities, data.activityKey);
const transactionCallback = toggleLoggedActivity(data, activities, selectedActivity, selectedActivitySubCategory);
const loggedProfileRef = firebase.database()
.ref(`loggedActivities/${data.datetime}/${data.profileUid}`);
return utils.getValue(loggedProfileRef)