4 ms·
Last 2 years I've been using Go (instead of Python), even for webpages & apis. I'm actually considering going back to Python(for webpages and apis) because deal
by Goranek 11y ago
Last 2 years I've been using Go (instead of Python), even for webpages & apis. I'm actually considering going back to Python(for webpages and apis) because dealing with database in Go is really ugly. Currently available orms are nowhere near as useful as sqlAlchemy or django orm :(
- misiti3780 11y agoi recently starting experimenting with moving from python to go and for fun (for web development) and was surprised at the current available options for ORMs. even established frameworks like Revel seem like they are suggesting using raw sql queries still: https://revel.github.io/manual/database.html https://revel.github.io/manual/database.html this is golang's Django i believe ?
- Goranek 11y agoi'm using beego orm(can be used without using whole framework)
- misiti3780 11y agoill check it out - thanks!
- bsaul 11y agoGlad to hear i'm not alone in that case. I actually think someone should blog about this, because i've got the suspicion that the "moving to go is fantastic" feeling we get from blog posts suffers from a survivorship bias.
- jaytaylor 11y agoCheck out gorm [0] to ease your database interaction pains; it's worked out nicely for me many times. [0] https://github.com/jinzhu/gorm https://github.com/jinzhu/gorm
- sea6ear 11y agoI don't have direct experience, but quoting from this[0] seems to indicate that gorm may still have some issues compared to current standard options in the Ruby or Python ecosystems. "The ORM we ended up using for e.g. our settlement service, Gorm, is not anywhere near the level of maturity of ActiveRecord, and to get its (valuable!) feature set you have to tolerate a) throwing out most of the benefits of using a type-safe language and b) programming bugs which can cause statements which certainly look like they should generate SQL queries to just silently not generate SQL queries. In general, working with the database has been so painful in Go that I have been instead either a) hitting a REST endpoint on an internal API to have Rails do the DB access then return formatted JSON (which Go can actually consume fairly decently) or b) throwing the data at NSQ." [0] http://www.kalzumeus.com/2015/08/20/designing-and-building-stockfighter-our-programming-game/ http://www.kalzumeus.com/2015/08/20/designing-and-building-s...
- jaytaylor 11y agoOf course, maturity takes time. Go is still much newer than Python and Ruby. There's no getting around this fact.
- bsaul 11y agoI've come to think the limitations of Go orms are not due to the lack of maturity, but to inherent limitations of the language that are officialy not going to be removed anytime soon ( because they are seen as a feature by the authors). Something like linq for example seems simply impossible to code in go.
- throwaway999777 11y agoI'm sure that relying on blogs for being informed on matters like this is another kind of bias.
- alberth 11y agoORMs? Am I alone when I say that I still hand code SQL into my applications? Regardless of what web framework I'm using (e.g. Pylons/Rails/Django/etc), I still hand code SQL statement in my applications. I've had far to many times ORMs unexpectedly nuke performance and have other issues than what's it's worth gaining by using an ORM.
- Goranek 11y agowriting raw queries for crud seems like too much effort, especially when performance is not important
- deleted 11y ago[deleted]
- reinhardt 11y agoBy "hand code SQL" I hope you really mean using prepared statements of whatever language/framework you're using, not concatenating strings with input values. If not, say hello to SQLi.
- Scarbutt 11y agoand no authentication/authorization library.
- merb 11y agothat's not a real problem. only a few frameworks having a good one. In java i handwritten mine. And golang has the same good crypto tools as Java. > https://godoc.org/golang.org/x/crypto/pbkdf2 https://godoc.org/golang.org/x/crypto/pbkdf2 > https://golang.org/pkg/crypto/subtle/ https://golang.org/pkg/crypto/subtle/ And finally a Token Library: https://github.com/dgrijalva/jwt-go https://github.com/dgrijalva/jwt-go or https://github.com/dvsekhvalnov/jose2go https://github.com/dvsekhvalnov/jose2go And that's all you need to write a Authentication / Authorization Library in 100-200 lines of code. And it will mostly be more secure than most of the things you see in the open world.
- Scarbutt 11y agoI have always been scared of implementing my own and put it in production, but you motivate me to do so ;)
- gtank 11y agoCoreOS has released one: https://github.com/coreos/go-oidc https://github.com/coreos/go-oidc We're currently using it in our own OAuth/OIDC identity provider.
- grey-area 11y agoOut of curiosity, what did you most miss from those orms?
- Goranek 11y agohandling m2m is especially painful. I just hate writing same long code for fetching old members, checking if members are changed and then updating/inserting new members. Joins are also problematic (i like how beego orm is handling it, but it works only for single object and not multiple objects)
- sauere 11y agoWord! Flask and the flask-sqlalchemy extension are a dreamteam that i wouldn't want to miss anymore. Golang might perform 10x better, but i'd choose the faster development cycle and comfort of Flask at any given day.
- Goranek 11y agoI'm missing them more and more. Faster development cycle > performance for most apps.
- mrweasel 11y agoIt might be the problems I solve, or the way I think about them, but I think it's about 50/50 whether the ORM is helpful or in the way. Very often I just want the ORM to go away because I know what I'm doing and the ORM doesn't I do like sqlx, it seems to hit a balance that works for me. I get to write the SQL and structs come out.
- Goranek 11y agoI used sqlx for a while and it's definitely an improvement over std sql, but still isn't full orm.
- elithrar 11y agosqlx (https://github.com/jmoiron/sqlx https://github.com/jmoiron/sqlx) is my go-to as well. mgutz/dat (https://github.com/mgutz/dat https://github.com/mgutz/dat) and dbr (https://github.com/gocraft/dbr https://github.com/gocraft/dbr) are also more ORM-like alternatives if that's what you need—query builders with the option to use raw SQL for more complex queries. I also lean on purse (https://github.com/smotes/purse https://github.com/smotes/purse) for keeping my SQL in separate files, but I'd love to see something like Clojure's yesql. I think the likelihood of seeing an ActiveRecord-style ORM in Go is slim: ActiveRecord is a core part of Rails and can therefore make a lot of safe assumptions about its environment. Any ORM for Go can't do that to the same extent, and big Rails-style frameworks don't gain much of a following in Go.
- lbotos 11y agoHave you considered Elixir? I'm a mostly Python guy that was intrigued by Go for web but am now exploring Elixir.
- Goranek 11y agoI'm currently in a phase of life when i don't want to reinvent wheel and just focus on building stuff using tools i know (go || python).
- zem 11y agosame reason i gave up on the idea of using ocaml for crud apps, even though i love it for most other applications. it's really annoying to have to manually manipulate database rows via raw lists of strings :(
- tapirl 11y agoSince I gave up SQL databases by using NoSQL ones, ORM is not needed any more. You know, I always feel ORM is a fix to SQL.