Hacker News new | past | comments | ask | show | jobs | submit login
Goravel, Web framework inspired from Laravel in Golang (github.com/goravel)
38 points by sawirricardo on July 6, 2023 | hide | past | favorite | 60 comments



Laravel, the framework that made me quit PHP. Not sure the concept of "one framework doing everything" will resonate well with the wider Go community. I will keep an eye on it though.


Since this has generated quite some interest, the reasons I dislike Laravel are:

- so. many. godobjects.

- I dislike ORMs. I could not put my finger on it, while using PHP frameworks, because they were omni-present; but after using Python, Go, and C#, I found it to be easier for me to just avoid the overhead of an ORM.

- Terrible structure. Sorting classes by type is something I have experienced to be generally less helpful than sorting by "topic" (not a native speaker, so this might not be the correct word for it. I recently heard it compared to collecting cars, then disassembling them and sorting by tires, steering wheels, seats, and so on)

- Too much magic™. I understand that many like this about it, but I found it harder to understand what exactly the program is doing.

It's not a lot, but after literally years of PHP and having these paper cuts almost weekly, I was at one point fed up. I first switched to CodeIgniter, which I found more pleasant, but still not even comparable to the comfort that cherry-picking components gets you (yes, you can by using composer, but most people I have spoken to discouraged that in favour of Laravel's built-in fun).


I agree Laravel is a bit too much magic, but I’ve found Eloquent to be a top notch ORM. It hasn’t really failed me in any way, so I’d be interested to hear what you specifically disliked about it.


While I enjoyed my (small) foray into the world of Laravel, I'm happy to see something other than unabashed praise for Laravel here on HN.

A technical decision should be done by weighting it's pros and cons, not just by looking at the pros.

Agree on the 'Sorting classes by types', it's something I've always found surprising too, and love the car-collection metaphor.


> Laravel, the framework that made me quit PHP.

I would be interested to hear more.


Not OP. While I didn't quite PHP. I just don't work with Laravel.

A lot of good points are written down here: https://old.reddit.com/r/PHP/comments/131t2k1/laravel_consid...

In short, it just doesn't use good programming principles. It's not just easy to write code with bad principles, it's everywhere in the tutorials.

There's of course Laravel apps out there that do have good programming principles. It's very much possible to write good code with Laravel. It's just less common.


I think the reddit post missed the point multiple times. Laravel does not use the best principles everywhere, yes. Taylor Otwell is a (very) strange person, yes. But "Laravel should be considered harmful for the PHP community" is just wrong.

Laravel was the first framework, that "just worked" and had everything, you need to make your first steps in a web application. Nowadays, people write PHP components that are usable in Laravel and that means a lot of code out there is compatible to a lot of other code. That alone did a lot to the PHP community. 2010 or so, the PHP landscape was much more scattered and things didn't look good.

Since then a lot happened and Laravel carries old stuff with it, and I'm very happy about that! I'd hate to be forced to do big refactoring work on every update of the framework. As strange as some decisions in Laravel are, they try new things, and they also try to stay compatible to the old stuff. Between Laravel 5.5 (released 2017) and 10 there were not much breaking changes. For a framework, this is a big plus.


"Laravel was the first framework, that 'just worked' and had everything" - well, there was Symfony before. And CakePHP, and Yii (which was also considered as quite easy to learn), and much more. Laravel may did a few things "better", especially for junior devs, but it's not the first.


Laravel didn't have all this on day one, but having docs and supported configurations for something like queue processing. IIRC, there were community plugins for CakePHP for queue processing, but it wasn't something the core framework embraced and supported out of the box. I don't think Laravel had this until their v4.

My experiences with cake and zend back ... 10-12+ years ago... things 'worked' mostly, but there was often a lot of "you can do it any way you want", and often minimal examples for the cases I was trying to achieve. Testing... as much as it was there, my experiences trying to get decent testing never seemed to work very well; Laravel's testing experience felt better out of the box. Testing traits like 'useDatabaseTransaction' to rollback the db after each test seemed both useful and novel - I don't remember seeing things like that in Cake (at least not early on - haven't checked recently).

FWIW, I use Laravel a lot these days, but wasn't terribly 'trusting' of it early on. Started seeing it in what I guess were its 3.x days; then saw 4.x - big changes, and what seemed like a moderate amount of BC breakage, then again from 4-5. Around 5.x, it seemed to adopt a bit more of an incremental approach to changes, and I started using it more day to day in the 5 series.


I tried CakePHP at the time and it was awful, like many other PHP frameworks of the time (remember joomla?). Frameworks were either "what the framework provides is easy, but don't dare to do anything that the framework is not made for" or "just do what you want, we provide almost no help, just figure it out by yourself". And all of them were slooooooow. It wasn't possible to answer a web request in under 50 milliseconds with any PHP framework in 2008.

Laravel was awful when everyone else were awful. But around Laravel 5.5 (and PHP 7) it was complete enough, documented enough and fast enough, that you could just start building stuff with it without having to think about it. Is Laravel the best Framework out there? Not at all! But is also not considered harmful, far from it.


I thought Sensio labs and PHP-FIG made lots of efforts to have compatible code...


They did, and the outcome of that is a couple generations tools/libraries that have more standard compatibility 'by default'. That has enabled another generation of frameworks (Laravel probably the largest of those) that can take a 'mix and match' approach, using 'best of breed' bits from the community as well as their own ideas and philosophies.


Also not OP, but the linked reddit post sums up one of the major reasons I had to get out of PHP several years ago. Everything is/was moving to Laravel in PHP land. I got tired of dealing with highly coupled, non-unit testable code that seemed to go out of it's way to ignore SOLID principles.

God help us if it this project becomes the normal way of writing http go servers applications. Maybe at that point it's time to become an embedded rust programmer or a monk.


People like you, not meant personally, are the reason I abandoned PHP. Too much dogma. Too much nonsensical paradigms without considering pragma.

Who gives a shit about SOLID or OO.

I used to love PHP for its simplicity. That was before zealots of your type flooded the ecosystem.

You wanted to apply what they taught you in uni, which was Java, to PHP. PHP was fine before. I earned good money with it and had fun doing so. Then 2010 the next generation of clueless devs enters the scene, polluting it with their nonsense.

Very much what's happening in Go right now with the cloud microservices fetish.

Can't you booksmart idiots STFU for once and let people do the pragmatic and sensible approach?

Fucking Hipsters


> Who gives a shit about SOLID or OO.

The people who care about and are tasked with maintaining a large long running code base.

> You wanted to apply what they taught you in uni, which was Java, to PHP.

Nope, that came after my time.

> Can't you booksmart idiots STFU for once and let people do the pragmatic and sensible approach? I earned good money with it and had fun doing so. Then 2010 the next generation of clueless devs enters the scene, polluting it with their nonsense.

Those OO & OOP principles are the pragmatic and sensible approach learned after cleaning up after "hipster" web "artisans". If we're going to throw around claims without knowing anything about the other person; you sound like the kind of dev who writes some code that works on the happy path, but is completely unmaintainable and non-extensible.

(But I know nothing about you, so I really have NFI, just like you have NFI about me and what I do)


When I studied computer science, I promised myself to never touch PHP again.

But PHP has more to give than just as a birthing ground for teenage programmers.

When I many years later accepted a PHP job as a senior developer, PHP provided a consistent experience of "bad practice everywhere", a fractal of cringe I couldn't ironically reproduce. Working with this for a year taught me a lot about how to deal with critical legacy software beyond repair and being responsible with what you've got.

I think there is no better way to get your hands consistently dirty than with PHP.

Coincidence: I do embedded Rust, and my wife is a buddhist monk. ;-)


Many of my programming jobs in PHP had me working with people that were super anal about "good coding practices". Especially the Symfony guys seem to try to be the new ultra-corporate Java. So I don't think it a issue with the language but more that you didn't find your people. (Personally, I actual like working with legacy crap. It's easy money and reminds me of the past when things were simpler.)

I feel most of the PHP community is pretty mature these days. More pragmatic than Rust, sure but that is a good point in my book. Though I am glad you found your enlightenment.


Symfony was the worst. Holy shit dude. I still have to deal with a legacy Symfony project, which needs to be rewritten because of their... I don't even know what to call it.

That stof guy was one of the worst. Inconsistencies, incompatibility. But the dogma was strong.

Indeed they wanted to be the Java of PHP. And so inefficient. Imagine duplicating all variables of a request context for dogmas sake. So you can later do Request->getVar() from their own copy. It shows a basic not understanding of the language.


> I don't think it a issue with the language but more that you didn't find your people

I can be more specific: I'm identifying problems with the language ecosystem.

I deliberately didn't shit on the people involved; I'll definitely ride the #not-all-php-programmers (I've met some great ones), but it takes a broken mind to accept a toolchain this historically fallible as something with which you'd want to recreate the Java ecosystem. ;-)

Have you tried Java?

It's definitely a better Java than PHP!


"bad practise everywhere" - you could say that for C++, Python and many more programming languages, too. If we're honest - most of the code out there is poorly written. PHP - nowadays - doesn't prevent developers in following good practises.


What would you like to do with PHP/Laravel that isn't unit testable? Laravel is, from my experience, written in a way that specifically makes testing of most things very easy.


Yeah, I'd like to know, too. I've done laravel + TDD for almost a decade and I can't think of anything you can't test or mock. Emails, Queues, Guzzle requests, AWS SDK, events, grammers, sessions, etc.. You name it, I've probably done extreme TDD to it.


It seems like they thought a lot about making sure everything could be mocked and tested: https://www.goravel.dev/digging-deeper/mock.html


Also interested in hearing more - first person i've heard say they do not like Laravel...


Poke around a bit more; you'll find plenty of people don't care for it.


Overly pedantic programmers always have trouble conforming to a framework where compromises are made in ways they can't get behind. For every one of these, there a thousands of programmers who are very successful with the same framework.


care to elaborate? interested to hear more about your use case back then


Overly pedantic programmers always have trouble conforming to a framework where compromises are made in ways they can't get behind. For every one of these, there a thousands of programmers who are very successful with the same framework.


Goravel. Sounds like Azog or Borgs brother in the Hobbit movies.

You can almost hear one of these dudes say it.

https://m.youtube.com/watch?v=njUa_1FY8rA&pp=ygUPVGhlIGhvYmJ...

Goooravell...


I'd start with double-checking permission for using Laravel logo :)


This framework reminds me of Bud[1], which is also inspired by Laravel.

[1] https://github.com/livebud/bud


It's there a "default" web framework for Go which most of people use?


AFAIK, no. There are some helper frameworks [1], but none of them is dominant. Two possible reasons: it's quite easy to write a (web) service with the library functions (it even includes a gzip stream), and it's practically impossible to write an ORM framework like you have in Java and Python, so the Go frameworks I've seen are basically a bunch of helper functions.

[1] https://github.com/avelino/awesome-go#web-frameworks


> impossible to write an ORM framework like you have in Java and Python

genuinely interested in knowing why it is so. I quite like Go, but I also like Django, so I would like to know why a Django-like ORM would not be feasible.


I thoroughly dislike Django.

But if you look at how it works in Python, it's by taking over class definitions in such a way that a field can be both a description of the field and an actual value. That doesn't work in Go (explicit casting the fields at every place you use them could work, but is prone to errors). It "cleverly" overrules operators to turn something like the Python expression `age > 50` into the sql string `age > 50`. Can't be done in Go, unless you define functions for all operators and find a way to reflect on the field name and the current context (`gt("age", 50)`). That's a lot of work to turn one string into the same one. URLs can't be linked to a class by simply importing a file; you'd need to add quite a bit of scaffolding (a factory for each class with a common interface, I guess?). And there are other parts that rely on annotation and whatever that simply can't be ported to Go, so you'd have to turn them into function calls. And Django doesn't give you more than a glorified POST form app out of the box anyway. You have to add more views and serializers to turn it into a modern backend, so why not skip that and use libraries that implement the functionality you do need.

Ok, my dislike shines through, but the gist is that Go doesn't let other code take over the interpretation of the meaning of expressions and statements and inject things into classes like Python does. It all has to be done explicitly. So django-like functionality for Go would have to look very different.


> why not skip that and use libraries that implement the functionality you do need.

I was just asking specifically about the ORM part. The subject of "use an opinionated framework vs. tie specialized libraries together" is a complete different debate.

But about this matter: I quite like to assemble libraries when I'm solo on a personal project. But that's definitely not something I want in a team. That's pretty much why we go with Django and not Flask or any of the "lightweight", "micro" framework things that are everywhere. "Just bring whatever ORM you want", "Use whatever template engine you like", etc. But that's a lot of decision making and integration with no added value for us. The fact that Go has such a comprehensive standard library is a good thing, but probably not enough because, like you wrote:

> you'd need to add quite a bit of scaffolding

(Which obviously contradicts the idea that Django brings just a glorified POST form app to the table)

As to why I'm interested in Go: faster execution, less memory, easier deployment... but as a small shop, team productivity still comes first.


I meant: you'd need quite a bit of scaffolding to imitate django's way of importing urls. If you're happy writing them as function calls, and/or manually importing them, it can be quite straight-forward.

But Go doesn't have one framework that pretends to do it all. And IMO, django just pretends. Want to turn your GET/POST-based views into JSON/REST-like endpoints? Add a library, and two extra modules per data type. Want to do something slightly more complicated with the database? Be prepared to write a bunch of code, or look for a library that understands tree/graph-structures. Want to integrate Angular or React? Add another library or two. File conversion? Charting? Monitoring? Repeated tasks? Packing static files? Moving images into the right place for deployment? You get the picture.

You may have to good reasons to pick django for your team, but it sounds a bit like you're outsourcing the architecture, hoping that django suffices and the community can support you. But if you understand the needs of your (web) service, flask or basic 'requests' or fastapi are not such bad starts. Once you're at that point, Go's web frameworks can look quite similar, so I'd recommend that if you ever take that step.


I have written about this some time ago here: https://andrewpillar.com/programming/2019/07/13/orms-and-que...

The main reason, in my opinion, comes down to how Go as a language was designed. I have written some follow up posts to that, specifically this one: https://andrewpillar.com/programming/2022/10/24/a-simple-cru... wherein I explore creating an ORM-like library via generics in Go, this may be of interest to you if you want a better understanding of how some of these things would work in Go.


Not "default(s)", but gin and fiber come to mind regarding popularity.


I also find myself reaching these!


Yes, and it’s called net/http.


No default. There is Buffalo which is modeled after Rails, haven't used it in anger though.

https://gobuffalo.io


My intuition is that Golang people dislike frameworks.


So they roll their own stuff each time they do a web app?


Composition is king.

The standard library defines some decent interfaces already around HTTP handling and SQL calls. Most libraries are built to integrate with them. Then interfaces like io.Reader and io.Writer mean you can pretty much use anything to read requests and write responses.

This means that usually you're composing libraries and some application code together, rather than building everything on top of some jack of all trades framework. You get to choose the best tool for each job.


> Then interfaces like io.Reader and io.Writer mean you can pretty much use anything to read requests and write responses.

Yeah, that’s not the hard part at all. What about routing, converting from/to json/params/cookies safely, sessions, authz/n..


I'm a fan of gin over the builtins but:

> What about routing, converting from/to json/params/cookies safely All supported out of the box with the standard library. It's also table stakes, and not the hard part.

> sessions, authz/n

This is where you need to step out of the standard


A lot of go apps bolt together libraries yeah.


From what I've seen yes. So in practice every go app is a custom & unique framework. Same problem as react. This was also the norm in php until laravel got popular a few years ago.

IMO it's a rough way to make a web page but people keep doing it so it must have some advantages.


Not a go dev but I have dabbled. I get the impression that the sweet spot for go is not in building standard crud web apps but for specialised network services and tooling. For those reasons big heavy frameworks don’t seem popular.


Yes and that's frustrating


It’s not that we roll all our own stuff it’s just that most of us avoid opinionated frameworks. Example I’d wager most go backends are using gorm or sqlx because rolling your own orm would be insane for most


I would recommend to look at Iris-go


I would recommend avoiding iris-go, the author has a bad history of rewriting the git history, and using code without attribution, see this for more: http://www.florinpatan.ro/2016/10/why-you-should-not-use-iri...


Downvoted because that guy steals other people's code without their permission.


Yeah, Go is not a great language for frameworks as it usually works until it absolutely doesn't and then you have to rip that out.


That's not a problem with Go, it's a problem with frameworks: they give you some abstractions, e.g. the Laravel query builder, but they don't cover all the use cases, so you quickly find yourself using "raw" queries anyway.

There are some well-established web frameworks for Go (e.g. https://github.com/gin-gonic/gin), but they are controversial too, as most Go developers seem to prefer libraries (that your code calls) instead of frameworks (that call your code and impose their structure upon it). So I don't think just cramming a framework from a completely different language into Go will fly...


Please, no. While you can write really clean code in modern PHP, Laravel is a collection of anti-pattern. PHP has a bad reputation because in the past it was hard to implement clean code because of inconsistencies and lacking language features. PHPs reputation should improve, but Laravel is working against it. Please don't bring Laravel to Go.


Can you give a concrete example of what you mean by “Laravel is a collection of anti-pattern?” I would really love to understand what you are referring to.


There was a reddit link posted under another thread, which had a very extensive list.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: