3 ms·
There is no escape. The language thinks it knows better than you. The standard library is allowed to do things that your code isn't.
by lmm 12y ago
There is no escape. The language thinks it knows better than you. The standard library is allowed to do things that your code isn't.
- _ak 12y agoLike what? The standard library is no more special, other than where it resides in the filesystem. You can write C and assembly code as well and link it to your Go code. And I'm not talking about cgo, I mean [568][ac], the Plan 9 C compiler and assembler that come with Go.
- lmm 12y agoI was thinking most obviously of generics. The go standard library is full of generic collections, but you're not allowed to use generics in your own code.
- _ak 12y agoThat's not the standard library, though.
- claystu 12y agoIt looks like free pascal has generics: http://www.freepascal.org/docs-html/ref/refch8.html#refse46.html http://www.freepascal.org/docs-html/ref/refch8.html#refse46.... But to your larger point, doesn't any non-programmable programming language exhibit the same weakness to some extent?
- lmm 12y agoAny language will have some "magic" things that are special-cased in the compiler - things like the basic integer datatypes, or the threading primitives - and probably a few more things that are implemented as C code (though if you're lucky this can be done in a "standard" way, through the language's FFI). But most of the standard library should be implemented in the language itself (look at e.g. the Java standard library, or the Python standard library. In a more coherent language like TCL, even language constructs may be written this way - e.g. "for" or "if" can be just ordinary methods. At the other extreme, PHP has the infamous T_PAAMAYIM_NEKUDOTAYIM, because a simple-seeming piece of syntax had to be special-cased in the parser). If the standard library authors kept feeling the need to step outside the language itself, that's a bad sign - it suggests the language is poorly suited to writing libraries in. But you're right that it's a question of degree rather than a binary thing.
- pjmlp 12y ago> Like what? Maps, slices, the pre-defined functions. More powerful languages make no big distinction between user defined types and the language provided ones.
- howeman 12y agoActually, the c compiler just got deleted. https://groups.google.com/forum/#!topic/golang-codereviews/AfirOjUi6e4 https://groups.google.com/forum/#!topic/golang-codereviews/A...