{"id":10697,"date":"2015-02-03T15:34:04","date_gmt":"2015-02-03T20:34:04","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=10697"},"modified":"2015-02-03T15:34:04","modified_gmt":"2015-02-03T20:34:04","slug":"what-color-is-your-function","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/02\/03\/what-color-is-your-function\/","title":{"rendered":"What Color Is Your Function?"},"content":{"rendered":"<p><a href=\"http:\/\/journal.stuffwithstuff.com\/2015\/02\/01\/what-color-is-your-function\/\">Bob Nystrom<\/a> (via <a href=\"https:\/\/twitter.com\/rsanchezsaez\/status\/562589422592737280\">Marco Arment<\/a>):<\/p>\n<blockquote cite=\"http:\/\/journal.stuffwithstuff.com\/2015\/02\/01\/what-color-is-your-function\/\"><p>But if you have threads (green- or OS-level), you don&rsquo;t need to do that. You\ncan just suspend the entire thread and hop straight back to the OS or event\nloop <em>without having to return from all of those functions<\/em>.<\/p>\n<p>Go is the language that does this most beautifully in my opinion. As soon as\nyou do any IO operation, it just parks that goroutine and resumes any other\nones that aren&rsquo;t blocked on IO.<\/p>\n<p>If you look at the IO operations in the standard library, they seem\nsynchronous. In other words, they just do work and then return a result when\nthey are done. But it&rsquo;s not that they&rsquo;re synchronous in the sense that it would\nmean in JavaScript. Other Go code can run while one of these operations is\npending. It&rsquo;s that Go has <em>eliminated the distinction between synchronous and\nasynchronous code<\/em>.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Bob Nystrom (via Marco Arment): But if you have threads (green- or OS-level), you don&rsquo;t need to do that. You can just suspend the entire thread and hop straight back to the OS or event loop without having to return from all of those functions. Go is the language that does this most beautifully in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[351,800,846,346,1136,71],"class_list":["post-10697","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-c-sharp","tag-concurrency","tag-go-language","tag-javascript","tag-node-js","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=10697"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10697\/revisions"}],"predecessor-version":[{"id":10698,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10697\/revisions\/10698"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=10697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=10697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=10697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}