Griesemer" <[email protected]> To: "Rob 'Commander' Pike" <[email protected]>, [email protected] Subject: prog lang discussion ... *** General: Starting point: C, fix some obvious flaws, remove crud, add a few missing features - no includes, instead: import - no macros (do we need something instead?) - ideally only one file instead of a .h and .c file, module interface should be extracted automatically - statements: like in C, though should fix 'switch' statement - expressions: like in C, though with caveats (do we need ',' expressions?) - essentially strongly typed, but probably w/ support for runtime types - want arrays with bounds checking on always (except perhaps in 'unsafe mode'-see section on GC) - mechanism to hook up GC (I think that most code can live w/ GC, but for a true systems programming language there should be mode w/ full control over memory allocation) - support for interfaces (differentiate between concrete, or implementation types, and abstract, or interface types) - support for nested and anonymous functions/closures (don't pay if not used) - a simple compiler should be able to generate decent code - the various language mechanisms should result in predictable code ...
• No more shared DB — distributed transactions? • Testing becomes really hard • Require dev/ops culture: devs deploy & operate their work • Job (service) scheduling — manually works, for a while...
like Finagle for Go • Adapters, bindings, etc. to common infrastructure components • Play nice in your existing, heterogeneous infrastructure • Structure to tame the beast of incidental complexity
Finagle (Scala) — original inspiration, lower-level than Go kit • Spring Boot (Java) — similar abstractions, far more magical • Tokio (Rust) — explicitly a clone of Finagle, lower-level than Go kit
{ case "/sum": var req struct { A int `json:"a"` B int `json:"b"` } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return }
error) Concat(ctx context.Context, a, b string) (string, error) } type basicService struct{} func (s basicService) Sum(_ context.Context, a, b int) (int, error) { if a == 0 && b == 0 { return 0, ErrTwoZeroes } if (b > 0 && a > (intMax-b)) || (b < 0 && a < (intMin-b)) { return 0, ErrIntOverflow } return a + b, nil }
next Service } func NewLoggingMiddleware(logger log.Logger) Middleware { return func(next Service) Service { return loggingMiddleware{logger, next} } } func (mw loggingMiddleware) Sum(ctx context.Context, a, b int) (v int, err error) { defer func() { mw.logger.Log("method", "Sum", "a", a, "b", b, "v", v, "err", err) }() return mw.next.Sum(ctx, a, b) } // Concat is the same