Coroutines or async/await is not a new concept as it was named in 1958 by Melvin Conway. Coroutines had support in languages such as Simula(1962), Smalltalk(1972) and Modula-2(1978) but I think one can argue that coroutines came into mainstream with C# 5(2012) when Microsoft added async/await to C#.
A thread can only execute a single subroutine at a time as a subroutine starts and then runs to completion. In a server environment subroutines can be problematic as in order to service connections concurrently we would usually would start a thread per connection, this was the idiom a few years ago. A thread depending on the operating system and settings needs about 1 MiB of user stack space meaning 1,024 threads needs 1 GiB of for just user stack space. In addition there's the cost of kernel stack space, book-keeping and scheduling of threads. This drives cost of VM/hardwa
This document has been modified from its [original format][m1], which was written by Ning Shang (geek@cerias.net). It has been updated and reformatted into a [Markdown][m2] document by [Woody Gilk][m3] and [republished][m4].
When working with a remote git repository which is hosted on a third-party storage server, data confidentiality sometimes becomes
#!/usr/bin/env python | |
# by djazz, using various bits of code found over the web | |
# works with both python2 and python3 | |
# requires: python-alsaaudio, python-numpy, python-smbus, piglow | |
# install piglow: curl get.pimoroni.com/piglow | bash | |
# usage: | |
# this script accepts raw audio in this format: S16LE 44100 kHz Mono | |
# script-that-outputs-audio | python piglow_fft.py |
open System.Collections.Generic | |
open Microsoft.FSharp.Collections | |
[<RequireQualifiedAccess>] | |
module Folds = | |
// These are the fast implementations we actually want to use |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import Control.Monad.Reader | |
hello :: Reader String String | |
hello = do | |
name <- ask | |
return ("hello, " ++ name ++ "!") | |
bye :: Reader String String | |
bye = do | |
name <- ask |
data IOAction a = Return a | |
| Put String (IOAction a) | |
| Get (String -> IOAction a) | |
get = Get Return | |
put s = Put s (Return ()) | |
seqio :: IOAction a -> (a -> IOAction b) -> IOAction b | |
seqio (Return a) f = f a | |
seqio (Put s io) f = Put s (seqio io f) |