5 ms·
The actual reason is that the language lacks the meta-programming facilities required for creating effective ORMs and certain frameworks. (Whether this is a goo
by eternalban 7y ago
The actual reason is that the language lacks the meta-programming facilities required for creating effective ORMs and certain frameworks. (Whether this is a good thing or a bad thing is a subjective matter.)
- sedeki 7y agoExactly. There's not much choice. The best approximations are considered hacks.
- tombert 7y agoWait, is that true? I thought that the Java packages like Hibernate were just using method attributes and reflection...doesn't Go have the ability to add attributes to structs and a working reflection library?
- zaphar 7y agoThey use generics pretty heavily too so it's not only reflection. Generics allow them to do a typesafe interface for the developer to use as well as making less work for the reflection code to do.
- eternalban 7y agoAnd annotations and classloaders. Haven't looked at Hibernate in years ("10 years" to be exact /g) but it is possible that it also requires Java and JVM's instrumentation facilities. So certain kind of software magic can't be done with Go. Options in Go for effective ORM require source level processing.
- kissgyorgy 7y agoYes, Go has a reflection package, but it's terrible. Nowhere near has the power compared to Python's metaprogramming capabilities.
- excursionist 7y agoGo has reflection, but it doesn't have annotations or generics. Annotations are key for libraries such as hibernate.
- noisem4ker 7y agoAren't `tags` akin to annotations?
- excursionist 7y agoNo, Go tags are like metadata which can be accessed through reflection at runtime. Java annotations allow you to actually generate code during the build phase.
- EdwardDiego 7y agoI've encountered a bunch of code generation in client-go - I'm not very good at Go, so not sure what the term for the code generation directives in comments is, if there is one.
- badrequest 7y agosqlx (1) is probably the closest thing to a tradition ORM that operates this way ^1: https://github.com/jmoiron/sqlx https://github.com/jmoiron/sqlx
- skybrian 7y agoI'm not sure that's really a showstopper if you really want to do it? Code generation is powerful and it can be done outside the language.