4 ms·
C doesn't have generics, and is certainly a systems language. I don't think you have a strong point here. Systems != embedded.
by nteon 11y ago
C doesn't have generics, and is certainly a systems language. I don't think you have a strong point here. Systems != embedded.
- masklinn 11y ago> C doesn't have generics, and is certainly a systems language. C doesn't have a mandatory runtime, ubiquitous dynamic dispatch or a GC, and it lets developers decide whether to stack or heap allocate. cmrdporcupine also isn't talking about generics, they're replying to the assertion that > Go is not -- from a practical point of view -- a static language
- bryanlarsen 11y agoC programmers use void pointers for generics. :)
- cmrdporcupine 11y agoAnd so, basically, does Go.
- kyrra 11y agoExcept there is a fairly large difference with interface{}, in that it is typed. interface{} is more like Object in java than void* from C. If you incorrectly cast an interface{} to a type it's not, it will be a runtime error. Details: http://research.swtch.com/interfaces http://research.swtch.com/interfaces
- fizzbatter 11y ago> If you incorrectly cast an interface{} to a type it's not, it will be a runtime error. Sidenote, you may or may not have meant a panic - so i just want to clarify. Casting an interface to a type incorrectly will not cause a panic/crash, assuming you use the proper syntax. // Will panic foo := myInterface.(BadType) // Will not panic foo, ok := myInterface.(BadType) In the latter, you simply check if `ok` is true or not. If not, the interface value does not implement the given type/interface.
- 4ad 11y agoGo doesn't have casts. It has conversions and type assertions. This is a type assertion.
- TheDong 11y agoC has generics as of C11 via '_Generic'. Google can tell you more, and here's a blogpost with examples: http://abissell.com/2014/01/16/c11s-_generic-keyword-macro-applications-and-performance-impacts/ http://abissell.com/2014/01/16/c11s-_generic-keyword-macro-a...
- klodolph 11y agoWell, yes, kind of. It's not something you would really use a lot. It doesn't help you with generic types, but only with generic functions. Since it only makes sense when coupled with macros, it really only helps with functions that are written out but accessible by the same name. For example, selecting sinf() or sin(), or writing a max() function.