6 ms·
Macaron: a high productive and modular web framework in Go
- virmundi 9y agoI quickly looked this over. Does Golang have some hidden ORM like feature that makes complex persistence easy? I spent the last three months working on a storage mechanism that controls all of CRUD at the document level across what is essentially Google Groups (each op is allowed to multiple groups). This is where web work is complex.
- kornish 9y ago> Does Golang have some hidden ... feature No.
- yehohanan7 9y agohaha
- bsaul 9y agoCame here to say the same thing. Go won't enter "crud webapp" market until they have a better story on relational db interactions. I'm afraid this is way beyond the current possibilities of the language as it offer barely any meta-programming technics, on purpose.
- kaio 9y agoDid you had a look at sqlx? [1] Granted, it won't generate the queries for you - but parsing into structs works 95% of time without additional mapping for me. Coming from other languages I also found the amount of necessary typing a bit disturbing first. But then you can actually read code instead of orm framework documentation, issue trackers and workarounds. [1] http://jmoiron.github.io/sqlx/ http://jmoiron.github.io/sqlx/
- bsaul 9y agosqlx didn't work in my case last time i tried (don't remember why exactly), but it's still far from any standard like sqlalchemy (python), hibernate (java) , active records (ruby),entity framework (.net), doctrine (php) or bookshelf (js). Writing every select for every entity, with all the variations depending on whether you want to inner join with 1-n relationships (and which ones) is really tedious when you've got 30 entities in your model.
- weberc2 9y agoWe use SQLalchemy at work and I would rather write queries by hand. A lot of that is because the documentation is a huge pain, but also because the object composition isn't intuitive. I've built a profile query builder in Go and it was pretty straight forward; I'm confident I could build an ORM in a couple of weeks.
- bsaul 9y agosqlalchemy ( which i used and liked a lot) has multiple layers. query builder is the bottom one, but the most "challenging" one for go is probably the orm with things lazy loading and its parametrization ( such as eager loading of relationships). keeping it all type safe ( not having the user cast interface{} to struct everywhere) and performant would be a challenge.
- weberc2 9y agoI'm not sure exactly what you mean about parameterization, but I suspect in general my notion of what an ORM is differs from yours (in particular, I don't assume lazy loading). Maybe what I'm thinking isn't appropriately called "ORM" (maybe "type relational mapping" is more appropriate?). At any rate, I don't think type safety should be a challenge (somehow a mapping must be generated for each type, just like SQLAlchemy--in Go this can be either explicit or inferred once via reflection or code generation) and I don't think performance would be more a challenge in Go than any other language (the trick to ORM performance is in building efficient SQL queries, not in reflection or type asserts).
- simplehuman 9y agoWhat about https://github.com/go-xorm/xorm https://github.com/go-xorm/xorm ?
- bsaul 9y agoThanks for the link, i didn't know about it. From what i see from the documentation (which looks pretty sparse) it doesn't implement lazy loading or any kind of mapping between SQL relation (1-n , n-n) to and from the go structs, so i guess it's pretty far from any of today's standard.
- ptman 9y agoI've used https://github.com/jinzhu/gorm https://github.com/jinzhu/gorm with Go, and it's ok. Sometimes I just use https://github.com/Masterminds/squirrel https://github.com/Masterminds/squirrel or https://github.com/elgris/sqrl https://github.com/elgris/sqrl with database/sql or https://github.com/jmoiron/sqlx https://github.com/jmoiron/sqlx
- peterkieltyka 9y agocheck out https://github.com/upper/db https://github.com/upper/db as well while you evaluate the various projects
- Thaxll 9y agoNone of the company I worked for had any ORM like in place and they were all doing crud app.
- bsaul 9y agoi've seen companies forbid the use of ORMs by fear that developpers will abuse lazy loading and collapse the db instead of using inner joins ( which any decent orm is able to do btw). It could make sense in some context, and i'm pretty sure that any sufficiently advanced service has so many custom and optimized queries that an ORM doesn't make a difference. however IMHO, ORMs do play a very important role in the beginning of the project when prototyping screens and apis, and when rapid iteration is important. It isn't a coincidence that RoR advertized active record as much, that symfony use doctrine in all tutorials, and that java , .net and node.js frameworks all include an ORM component.
- jalfresi 9y agoThere is no ORM like feature anywhere that makes complex persistence easy.
- jalfresi 9y agoSorry if that was a snarky reply. I have a deep hatred of ORMs. In the past I've had great success with XO, which will generate Go code from an existing DB Schema: https://github.com/knq/xo https://github.com/knq/xo It's really very good!
- Cthulhu_ 9y agoI'm no expert, but I think for ORM like you're referring to, the language would need features like generics, which Go doesn't have and may never have. At best there would be a code generator which would allow you to write your stuff in a higher-level language which would generate compilable and efficient Go code in turn.
- charlesetc 9y agoCode generation is one way to get around generics. Go also stores all the type data at runtime so you can inspect the arguments passed to any function, which gives the same kind of generic behavior in any dynamically typed language. So you definitely could implement an ORM in go without code generation - it's almost certainly been done.
- swah 9y agoI'm learning Django after playing with Go and webapps just to see how much easier can some things be...
- ddorian43 9y agoAre they easier on django compared to go+framework ?
- ruleabidinguser 9y agoDjangos ORM is really really good. Plus it's integration with RabbitMQ through Celery, and so on. Django is kind of the golden standard of web frameworks. (Not having tried rails)
- swah 9y agoGolang is quite strict about unused variables and imports (the last one is fixed by an external tool). This IMO makes it a little bit rigid for prototyping web apps.
- ahacker15 9y agoTake a look at Gorm: http://jinzhu.me/gorm/ http://jinzhu.me/gorm/
- deleted 9y ago[deleted]
- heavenlyhash 9y agoI've been experimenting with a library called `refmt` which does the Object Mapping part, but explicitly not the Relational part. It's still experimental, but you might like it, and test coverage is shaping up nicely. The idea is by focusing completely on making Object Mapping consistent and powerfully customizable, and then composing that with either serialization formats or relational storage, we'll get good things. Right now we seem to be at and awkward hump of complexity where every new DB binding ends up implementing their own object mapping, increasing everyone's complexity, overhead, and decreasing reusability of code; refmt will hopefully represent a break from that. https://github.com/polydawn/refmt https://github.com/polydawn/refmt
- jdc0589 9y agoobject mapping is the most important part of the ORM experience in my opinion. Writing DB queries isn't hard or even annoying, manually doing model binding constantly is frickin infuriating.
- deleted 9y ago[deleted]
- cgdub 9y agoDoes this have hot reloading?
- jrs95 9y agoI read this as Macron at first lol
- simplehuman 9y agoMacaron is awesome. It's used in Gogs and Gitea
- whoiskevin 9y agoStarting to feel like Go is suffering from a glut of web frameworks.
- yehohanan7 9y agoThere are a lot of web developers (aka full stack developers) out there!
- timtosi 9y agoCan we stop this language to become the next JS ?
- brightball 9y agoIt happens anytime a language has the web tooling built in so a framework largely becomes arranging parts to your preference and naming it. See PHP and JavaScript. The languages that don't have all the web stuff built in tend to have a single dominant framework.
- 0xCMP 9y agoThis framework has been around forever and not really. Most people use the standard library unless they need better routing than the standard library provides. There are actually very few web frameworks that provide much other than a router in Go. Most of the frameworks are actually just packages that can be used for all sorts of things. e.g. Beego by astaxie
- whoiskevin 9y agoWell I wasn't commenting on age of particular projects. I had not heard of Beego so now I still feel there is a bit of over growth. Leads to confusion over what to use when you do want better routing which I think is pretty much every project. Perhaps routing will continue to improve in the standard library such that it does not feel like I need to pick a package or roll my own.
- camus2 9y agoIt's a simple http router, it just filter requests and assign them to an handler, it's hardly a framework like Symfony, Laravel, Django, Rails or Spring. People need to stop calling http routers "frameworks". People are going to write code for multiple reason. You can't complain about people writing opensource code, you're not forced to use it.
- deleted 9y ago[deleted]
- 0xCMP 9y agoDeveloped by a very smart, nice guy who used this to make Gogs among other things. I've been using Gogs for almost 2.5 years now and I've had zero downtime or issues. It's reliability and efficiently is one of the reasons I began very strongly learning and using Golang more. A Django project can't use less than 100mb of memory because of Python. Gogs is a full github clone which uses 5-10mb on average. When you're trying to run something self-hosted it's super valuable that you don't need a huge server(i.e. $$$) just to make it responsive which helps make self-hosting make sense economically.