Print service provided by iDogiCat: http://www.idogicat.com/
home logo





Home > IT > Programming > Other Notes

Other Notes

Java & Go with multi-threading

  • java thread consumes quite some memory: about 1MB each; while Go goroutine (Go's version of thread) consumes only about 2KB. So when there are thousands of threads, Java program may have memory issues.
  • Inter-thread communication in Java is not very easy.
  • Goroutine was built with concurrency kept in mind. But this is the only way of concurrency in Go, if it doesn't work, then you have to choose another language.
  • Java in fact has many ways of doing concurrency, not only the old thread. Such as: ExecutorService, Atomic, ConcurretHashMap, LinkedBlockingQueue, vert.x (implementing multi-reactor pattern), Clojure's core.async...
  • Things like goroutine also exist in Erlang/Elixir, which have been around for a longer time.
  • Go is a compiled language like C/C++, but its performance is only similar to (slower than) Java.
  • Go don't have many typical things in OOP, such as class, exception, inheritance, constructor, generic... This seems to make things simple, but also makes it less sophisticated.
  • Closure: can customize language features by adding or removing packages. But Go just removed some features.
  • simplicty: LISP only have following rules:
    • no syntax but only things like (+ 1 2)
    • when you have an open parenthesis, you need to close it
    • the first symbol in parenthesis is function, and it is followed by parameters.