Posted by hadi farnoud on December 18, 2021 at 2:38pm
Drupal is awesome and I have been a user since Drupal 4
It is starting to show its age though. It's getting old tech. I can only imagine what would happen if we rewrite Drupal in Golang.
We used to use Drupal for our landing page at Kamva. Ever since we switched to Golang, it uses a lot less RAM and can handle so much more concurrent traffic. I basically use a small server now.
is this crazy idea or can it be done? I see how wordpress fell into compatibility trap and it's ancient software with lots of fundamental issues. why not do a complete rewrite?

Comments
+1
...
yes agreed
I am not for sure yet, but I think we should spend the time to do a rewrite in GO. Lets see how it does. How do we gather the the things that we have learned from drupal structure so that we can apply it to a total new language?
our own group
If there is enough interests we should create our own group here for this!
Doesn't need to be exactly
Doesn't need to be exactly the same, but can borrow a lot of ideas from drupa
Count me in.
Count me in.
Thanks,
Rahul
I just created a request for a new group.
Hopefully it will be approved soon.
Please join if you are interested.
The title is Rewrite Drupal in Golang
We should get to know each other.
I am very interested in becoming a seasoned professional quickly. There are alot of advantages of using a language like GO. Lets explore them.
You should just great a
You should just great a project on Github instead of waiting for a group to be created here.
Sign me up
I've been thinking about this for a while. Glad to hear there's other folks thinking in the same direction. Would love to contribute some time to this effort once it gets started. Golang is amazing, and a Golang front-end for Drupal would be a killer app in this space.
Also looking at vlang
I am looking at vlang too. https://vlang.io/
Not quite the following that Go has but interesting.
Also I was hoping to create a group here first so then we could pick a name and then create a domain name with that name. But drupal groups maybe isn't the best place to do that....anyhow.
Here are some interesting ideas about it
https://drupal.tv/external-video/2019-02-16/why-your-next-cms-project-sh...
Ponzu
O think Ponzu is the best suited project for this - we can just hop in and improve it with any cool drupal features we like: https://github.com/ponzu-cms/ponzu
Gobuffalo
Ponzu is dead.
Maybe check out Buffalo, which reached a 1.0 version and still has a community around it and report back?
sounds crazy!
This is an interesting question, why not nodejs or another faster language than PHP, however, I think that at least we can migrate a lot of code automatically, this task will turn into an "impossible" mission for the community, and ecosystem health can fail.
Strongly typed php and
Strongly typed php and improvements to the php binary will get you what you're after. Better usage of the database would be the biggest improvement by far though.
The future
Let's think what Drupal is best suited for. I am not a Drupal expert so please, correct me if I am wrong.
1. Drupal shines in terms of constructing a monolith website. It is very convenient to build a website with a bunch of well tested modules without spending tons of time to write your own code with bugs in it.
2. Drupal is fast only because of a caching mechanism. You just cannot use Drupal if you want to build a website where data should be updated fast and often. Basically, we can think of Drupal as a backend technology to build a static website for a cache frontend.
3. Drupal is best suited for large enterprise websites. It's learning curve is still very steep, and an average person who wants to build just a simple website just drops it in favor of any other technology.
4. Large enterprise websites are moving their development to a microservice technology. It has a bunch of benefits for such websites. Drupal cannot shine here since it is slow and still heavily depends on cache.
5. Drupal is a monolith technology and cannot be scaled horizontally. I am not speaking of database, I am speaking of Drupal itself.
6. So what we have in total: Drupal is best suited for large websites, but has a bunch of downsides for such websites, and can be dead because of that. One of the solutions I can think of - use a Drupal approach (an ability for convenient build of websites from modules with UI) with a modern technology which is sharpened especially for such a large websites, for example, Golang. However, Golang doesn't have such a large set of modules for a website builder and convenient UI, so it could be a way worth to be followed.
I think PHP is too old and
I think PHP is too old and slow for today. If anyone rewrites Drupal core in Go, it will use less memory and be an order of magnitude faster than PHP without caching.
We have rewritten from PHP to Golang with identical functionality and API. Go is so fast and efficient.
Hadi Farnoud
فروشگاه ساز | ایمیل مارکتینگ پاکت
In our measurements, The
In our measurements, The biggest performance hit always comes from database queries, not code execution. About 80% of the time for non-cached requests is generally spent doing/waiting for/parsing database queries.
Languages are often tradeoffs
Languages are often tradeoffs between low level/performance vs high level/convenience. Beyond that, languages and frameworks are highly influenced by their maintainers, ecosystem, tooling, infrastructure, and developer communities. As technology improves, these players can continue to implement best practices, and I think that determines whether a system maintains viability amongst its competitors.
PHP began on the convenience end of the spectrum, but has continued to see growth in performance as it is implementing OOP practices. Drupal and Symfony are sane frameworks for enterprise development. You get to produce things fairly quickly while getting reasonable performance and good security.
For producing static content, Drupal is a decent system. You can make the front end as performant as anything else. If you compare it to other static site generators, it's really quick and convenient to edit content. However, the admin experience is not as snappy as what we're seeing in new generation applications.
Gatsby is fast because it prefetches links and is ready to load content as soon as you click. Drupal could do something similar using ajax to reload body content, and prefetching content rendered without the surrounding blocks.
Admin pages can't be cached and a lot has to be re-rendered on the fly. One of the longest things you have to wait for is seeing a node page after saving it. This is a full entity write and render from a cold cache.
Consider the full pipeline of form validation, entity save, rendering and caching. These things could be done differently, but they make tradeoffs that improve performance on subsequent loads.
As Mikeytown2 and Martijn Houtman mention, database performance is a big bottleneck, and would be true across languages. Is PHP really the issue here, and can Go vastly improve performance? I would love to see more info and benchmarks. Let's throw rust in the mix as well. But before we move on, what about async PHP like Swoole?
OP says they got better concurrency with less RAM using Go for a landing page. If your landing page is cached and served by CDN, why does it matter what your back end produces it in? If not, why isn't your landing page cached and behind a CDN? But let's assume the question is about rewriting in Go for dynamic performance.
Drupal can support headless applications, but the back end is still PHP/MySql/jQuery. In a world of snappy React applications, can Drupal actually keep up? The Drupal UI could be improved to do more client side updates without refreshing the page. Right now that is the responsibility of themes, and making the admin UI more dynamic would take a bit of work, but it seems more feasible than rewriting Drupal in another language.
I am trying to learn more about PHP performance compared to systems, but I admittedly don't have much experience. This is my current understanding of the situation, I would love to hear any corrections or input from experienced devs on how things are moving forward.
Rewrite a feature/module not the whole codebase...
Contrary view but this has much lower scope:
...use GoLang to write PHP modules and then write minimal Drupal modules to consume the GoLang-based module.
Now, this process is barely documented for GoLang+PHP, and not at all documented for GoLang+PHP+Drupal (which would be nice to have..).
((A full rewrite is a certain way to divide efforts, and then you have users clinging to old versions due to incompatible modules. Then Drupal would suffer the exact same fates as other famous projects that did rewrites: Perl 6, Amarok Music Player, or Duke Nukem Forever. ))
That would be interesting to
That would be interesting to see. I'm not sure if this is possible, however.
if someone creates a proof of concept, that could be a great start.
Hadi Farnoud
فروشگاه ساز | ایمیل مارکتینگ پاکت
Go modules
There's known issue with stack between golang and PHP code yet https://github.com/golang/go/issues/62130
Appreciate the link. So we
Appreciate the link. So we are still a ways off then even for minimal integration. Thanks.
Can we provide a way to
So, the issue is basically a dynamic content.
How about an idea to provide a convenient way to incorporate a dynamic third-party content to a cached drupal web page? In that case we could just use a microservice written on any other language for such a dynamic content, and use drupal to build static cached pages.