it makes great sense for network with concurrency, not so with real time or low resource devices to me.
it makes great sense for network with concurrency, not so with real time or low resource devices to me.
Defer helps but some true lexical scoping might be nicer.
I thought JacaScript doesn’t have destructors (in the memory/resource management sense) or finalizers…
WebSocket's destructor: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/c...
HTTP server's destructor: https://nodejs.org/api/http.html#serverclosecallback
Etc etc etc.
You're right that JS/C/Go don't have language features called destructors, but they have a whole bunch of types with ad-hoc destructor functions which you have to remember to call if you want to avoid leaking resources.
Writing and reading simple Go libraries is a breeze. I’ve written tiny libraries that fit in one file. You can read it linearly, starting at the top and following the logical progression of type declarations, functions, globals, etc.
Whereas with an identical Java library, a reader would be presented with several small files and have no idea where to start reading.
public class Wrapper {
public static class C1 { }
public static class C2 { }
}
//other module:
var x = new Wrapper.C1();The Go style just lets your code live together for easy reading, no problem. You can comfortably fit all of this into one file: a one-function interface, a couple of small functions that take the interface as a parameter, and two implementations of the interface.
Compare this to 3 or 4 tiny Java files. You’d have to guess which one to click on first.
Not sure about any objective metric on the other languages, though. Tried to look at ANTLR grammar files for each, but grammar is only one part -- language semantics are not included. (E.g. Rust's grammar is slightly smaller than Java's, yet I don't think many would argue that it is the easier one). JavaScript, while easy on the surface, can actually be quite complex/has many non-idiomatic concepts, e.g. `this` handling, property flags, etc. Python has similar "rabbit holes".