
Moving from Go to PHP Again - rakibtg
https://dannyvankooten.com/from-go-back-to-php-again/
======
trixie_
Each PHP file is an endpoint. As opposed to having routers in code or client
side SPA routing.

PHP files can be deployed independently, swapped out or updated live.

No building/compiling of the php files needed.

A single layer as opposed to 'modern architecture' where there's client side
back/front end layers, api layer, logic, validator, data access, and ORM
layers.

Can extend itself as it runs. For example Wordpress, running off of php files
can download plugins to its own server (which are just more php files) to
instantly extend itself. Without restarting or redeployment. (What other web
platforms can do this?)

Intuitive, simple, powerful. Can be as easy as editing a php file in notepad
and dropping it on a ftp server. Deployed.

Amazon lambda may have more in common with PHP in terms of discreet deployable
units of functionality. What's old is new again.

Compiling/deploying an entire system to change a single endpoint feels
backwards after using PHP.

~~~
viraptor
> Each PHP file is an endpoint. As opposed to having routers in code or client
> side SPA routing.

Which becomes a security issue due to accidental endpoints or uploads becoming
endpoints. Or becomes a mess of imports. Either way, PHP frameworks often end
up with a central router anyway.

> PHP files can be deployed independently, swapped out or updated live.

Which means some people try to do that the naive way and end up breaking a few
requests that happen during the deployment.

> Can be as easy as editing a php file in notepad and dropping it on a ftp
> server.

Which causes
[https://stackoverflow.com/search?q=headers+already+sent+bom&...](https://stackoverflow.com/search?q=headers+already+sent+bom&mixed=1)
because people don't realise they had an invisible character before all the
code.

I really don't think any of those are a good thing.

~~~
trixie_
You can create a mess of code, open security holes, and/or be hit with
‘gotchas’ in any web framework. PHP is much less complex than most.

~~~
viraptor
These are things very specific to PHP. Yes, there are language-specific
gotchas in many environments. But I'm criticising specific things that do
exist and that I've seen causing issues in real deployments. Things that make
PHP accessible make it also an excellent footgun.

~~~
furicane
So.. what you're trying to highlight is that a language is supposed to make up
for the incompetence of the person using it?

~~~
coldtea
Of course. That's the only reason to invent languages: to take care of stuff
people are not good taking care of, and move the work to the computer,
allowing us to work on the level that we're good at taking care of.

Else we'd all be using assembly.

There's absolutely no pride or glory in doing things nicely and securely that
the computer could have automated in the first place.

Anything the language allows that it could refuse while allowing devs to
express the same features, and that results in bugs is a mistake in the
language (e.g. the sorry state of strings in C).

~~~
kristopolous
Incompetent people will create incompetent things regardless of the tool.
Simpler tools lead to simpler messes while complicated tools lead to
complicated messes.

I've seen an attitude that people think they can inoculate themselves from
inept programming by using obtuse frameworks as if martin-fowler-speak acts as
a drill sergeant making disciplined coders out of the herd.

But after 20 years of bouncing around startups I've never seen the intended
results actually happen a single time. Not even close. Not once. Never.

Instead it leads to larger, less maintainable, more convoluted messes that
have to be trashed quicker. Giant ceremonial cargo cult style monstrosities
with huge circuitous logic - 4, 5, maybe 6 layers, a router calling a
controller, calling a service, calling a provider, calling an event model,
which runs a single if statement ... as if that's how we protect ourselves
against incompetence.

These approaches just lead to wasteful projects where they end up rewriting
the whole thing in whatever the framework/language de jour is instead of
writing easily maintainable, quickly understandable code that's designed to
work for the next 10 years. I've talked to many programmers who are
_embarrassed_ by the language they are using ... wtf is that?! They've turned
programming into fast fashion.

Then people like to ask what someone's _favorite_ language is, usually when
they first meet them, as a social cue, as if we are a bunch of highschool kids
following pop music. I mean what on earth... we're supposed to building the
future here, not running around like a bunch of spastic fanboys from platform
to platform, just to mess everything up all over again in bold new ways using
slightly different syntax.

The best thing to do is give people the least _abstract_ thing with the fewest
conformity requirements ... essentially make it open ended and then the messes
are easier to spot and easier to fix. You won't get 4 folders with 26 files
handling simple tasks like uploading images to an S3 bucket (saw this huge
mess just last week and guess what?! It's broken. I know, surprising right?)

Anyway, new shiny fancy tools with GoF buzzwords won't ever fix incompetence,
it'll only make it worse.

~~~
coldtea
> _Incompetent people will create incompetent things regardless of the tool_

Which is neither here nor there.

For one, it ignores the pragmatic issue, that very competent people (the very
people that built the foundations we all work on even) will still make lots of
mistakes, even trivial ones, but with severe consequences (e.g. buffer
overflows) when the languages don't prevent them.

If only it was just "incompetent people" that made mistakes...

> _But after 20 years of bouncing around startups I 've never seen the
> intended results actually happen a single time. Not even close. Not once.
> Never._

You weren't looking hard enough. Every day millions of programmers don't make
"buffer overflow" errors for example, that otherwise they'd have made, because
they work in languages that don't allow them.

And they'd have made those mistakes regardless of their programming chops. The
best programmers, people that run circles around you and me, still make those
mistakes.

~~~
kristopolous
Those mistakes aren't easy to spot or easy to fix.

It's about giving code sunlight so that action at a distance and other kinds
of magic don't hide errors making them harder to find, get in your way of
fixing them, making reproducibility a mess and confirmation simply guesswork.

Its the restrictive design trend of crippling languages which needlessly
prevents the sunlight effect from happening along with "information hiding
principle" gone completely amuck with the information successfully hidden in
dozens of innocently named files with listeners, observers, watchers, triggers
and who knows what else being mysteriously called based on reflective
programming so not even grep will help you.

Static code analysis and seamless navigation is totally a thing of the past.

Instead, the errors will have the stack of the error handler and that's it.
The debugger is useless because stepping through the code is 98% scaffolding.

All these fancy tools bludgeoning any introspection or diagnostic system so
the only remaining workable debug system is printing debug variables and
rerunning the code like I'm programming on a TI-81 (only that had debug and
release run modes...features I can usually only dream of these days)
_Progress! Welcome to 2019!_

It's crazy. This isn't how maintainable code is written

~~~
svsucculents
You are speaking to the inmates writing the asylum. Give it up. This is the
4chan of the enlightened.

~~~
kristopolous
The amateur-to-expert ratio of any topic is directly proportional to its
popularity. It's why popular things are polluted with well-intentioned bogus
information.

------
tptacek
For the kinds of applications people tend to build in PHP, PHP is probably a
better choice than Go. I'd still do Django or Rails before PHP, but Go just
isn't designed to make serverside-rendered database-backed websites especially
pleasant to write.

~~~
diamondo25
Rest API? Sure. Building webpages? I dont think it was made for that...
Although Go templates can work, its still not as flexible as you might want it
to be.

~~~
nkozyra
It's pretty flexible in my opinion. And you can substitute go templates for
another template library if you like.

Granted, we're talking about largely server side generated web pages and,
haha, who does THAT still in 2019 : hangs head in shame :

~~~
52-6F-62
It's true. I don't often do so at work anymore, either—except for utility
pages.

But I _am_ rewriting my personal site/blog in Go as a trial run/learning
process. I've been critical of Go in the past so I thought I'd give it a...
_go_.

So far I don't mind the experience. No server framework, either. The standard
library is actually pretty good, at least for something simple like that.

The only [external] dependency I'm pulling in so far is `blackfriday` for
parsing Markdown files (the posts) upon request— I'm much too lazy to write a
Markdown parser myself for this purpose.

It's not finished yet, but it's on its way—
[https://github.com/robertfairley/rf-19-go](https://github.com/robertfairley/rf-19-go)

------
joaodlf
I love Go, for many situations, but definitely not for a typical user facing
website.

The community seems bent on the whole "all you need is net/http", but that
just isn't practical in modern web development. People like ORMs, easy to
handle html forms, security as a default, easy session/cookie handling etc. In
the end, web developers want ease of life.

Go is a great language for many things, but if it's going to take on the web
at large (outside of HTTP APIs), the community needs to grow out of this
"net/http or nothing" approach.

There is some hope, some frameworks like
[https://gobuffalo.io/en](https://gobuffalo.io/en) are showing up, but the Go
ecosystem is dying for a Rails/Django solution.

~~~
jimmy1
> but that just isn't practical in modern web development

People always use this modern term as if it implies something significantly
different or more "advanced". The web hasn't changed much. It's still data
over tcp sockets to a contained runtime -- a web browser.

> People like ORMs

People in my experience are starting to dislike ORMs. If you have done this
for long enough, you realize they are great for getting off the ground, but
they inevitably get in your way, and start generating some really bad queries
which you have to start one by one replacing with raw SQL statements, at which
point you might have well started with raw SQL.

Having come from Rails, and PHP frameworks like Symphony and Laravel at my
company, using Go I feel almost like I am more intimate with my code. I
understand it better, the dependency chain only ever goes one or at most two
levels deep. I will admit the the templating and routing is more "batteries
included" in these frameworks, but the other parts that I have control of that
I consider much more important (such as how my data actually gets stored and
other network calls I have to make), I would much rather do those in Go than
in PHP

~~~
davidsawyer
Speaking as someone who moved from a company that heavily leaned on an ORM to
a company that is using jOOQ (a thin Java wrapper around SQL) for everything,
not being able to use an ORM is pretty painful.

I greatly miss the nice, clean ORM experience. It's so much better for
developer efficiency.

------
pasta
I agree with the author. Symfony 4 is the best PHP framework at the moment.

Trying both Laravel and Symfony I think there is no need for Laravel
(anymore). Laravel just has too much magic that will bite you later on.

The only thing you should skip in both frameworks are 'annotations'. But this
is easy to do.

~~~
Double_a_92
> Laravel just has too much magic that will bite you later on.

Especially when that is not explained in the docs or just in a very vague
way...

I tried improving the docs by pointing out where magic (e.g. fix naming
conventions) is needed and where not, but the mantainer just turned that into
vague mush again (after he had even agreed to the changes).

Also if you need any more details that are not in the docs, everyone points
you to _paid_ video courses that assume you have a Mac...

That honestly leaves me with a bad taste im my mouth after trying laravel :/

~~~
tomschlick
> Also if you need any more details that are not in the docs, everyone points
> you to paid video courses that assume you have a Mac...

I assume you're referring to laracasts.com... what does having a mac have to
do with the videos there?

~~~
Double_a_92
When I watched it 2-3 years ago most of the tooling that they set up was OSX
specific. Nothing tragic, but still.

------
perlgeek
Wait what, two complete rewrites of their complete website in 2 or 3 years?

If you have that much time to spend on rewrites, I really envy you :-)

------
013a
Go really just isn't designed for the same kind of service that PHP is
normally used for. Its best at small API services (and, tangentially, its also
pretty great at CLI tools).

> They were a little surprised to hear our stack involved Golang and some flat
> out told us they’d prefer PHP, because that’s what most of our products rely
> upon.

I believe this is the real reason why, and everything else above it is
pointless technical justification for a sound business decision. I also
believe there's an unvoiced, even more powerful reason, in "I already know PHP
and don't want to learn a whole new thing."

These are both sound reasons. The technical justifications are not.

Choosing Go for something like this was a bad decision. But choosing PHP is
only slightly better. Opting for Django, Rails, or Phoenix would have better
technical justification, but technical justification is rarely the real reason
why we make decisions like these.

~~~
exceptione
You are comparing frameworks with a language here.

I think that if they choose to use a high-quality, modern php framework like
Symfony, the technical decision would still make sense in the context of the
alternatives you mentioned.

~~~
013a
That comparison is intentional, for one reason: Go doesn't have any
"frameworks", let alone frameworks that are remotely comparable to the
productivity offered by Symfony, Django, or Phoenix. The language actively
opposes the development of tools like these. At best, we've got libraries that
wrap net/http, io/ioutil, etc and moderately increase developer productivity,
but there's nothing holistic and opinionated. The closest you can get is
something like gRPC, but its not even the whole story, and it also relies on
codegen so that's a disqualification in my book.

This isn't just technical; its baked deep into the culture of Go. And that's
fine. Its designed for something different.

------
leetbulb
Oh man, yes! Doctrine and especially Symfony's Form component absolutely
spoiled me.

Check out Sylius for a really solid Symfony based application:
[https://sylius.com/](https://sylius.com/)

------
Xeronate
Why do so many companies keep moving to go? I tried to like it, but it was
just so painful to write.

~~~
12298765
I'm curious, what is painful about it?

I came to Go from mainly C++, Java, and Python background, and I feel like
it's the best of all 3 (to me). It's compiled and really fast (like C++), it
has a great set of libraries and community interaction/support (like Java),
and it has simple syntax that is clear and quick to understand (like Python).

It's not a perfect language (nothing can ever be), but it's become my favorite
to use for back-end web services and even taken over some of my scripting
workflow.

I can see it being painful if you're trying to render websites server-side
though. That's a bit outside of what it's made for

~~~
hazz99
Personally, I find the concurrency support quite lacking. Compared to
Java/Javascript/Python/etc, it's great, but nothing compared to languages like
Ada or Elixir.

I wish we could use more than channels - for me, I often feel like I'm
shoehorning them in because there's no support for protected objects (native
queues, conditional variables etc).

Perhaps I'm just using them wrong. Sometimes I have to use locks, and I don't
think we should be forced to use locks in 2019. We've had better solutions
since the 80s.

~~~
grumpydba
> Sometimes I have to use locks, and I don't think we should be forced to use
> locks in 2019. We've had better solutions since the 80s.

Absolutely not. Locks/spinlocks are found in pretty much every significantly
parallel software project. It is pretty arrogant to criticize almost all
software architectures on earth.

~~~
hazz99
> It is pretty arrogant to criticize almost all software architectures on
> earth.

Almost all software is programmed with modern languages, which all (imo) have
extremely lackluster support for concurrency. It's not a symptom of the
programmers, but the tools they work with. Who uses Ada these days?

Locks should only be used when other protection mechanisms are too slow.

Semantically, the critical region protected by a lock is _not_ connected to
the lock in any way. This can make debugging races super difficult, and you
have to rely on everyone to lock everything at the right point.

Juggling multiple locks in complex concurrent processes is difficult, and
prone to bugs.

I struggle to think of where a lock is required, barring the extremely
hyperoptimised hot paths within operating systems, or similar applications.

------
waibelp
Symfony 4 is much more lightweight than previous versions. If you create a new
symfony 4 project with composer you just get an empty project with just a hand
full of dependencies. First time I tried out the v4 (coming from 2.x & 3.x) I
thought that the installation did not work properly because stuff like twig
(for templating) and other things were missing.

The whole integration in composer with the symfony flex component makes
developing even easier than before:
[https://symfony.com/doc/current/setup/flex.html](https://symfony.com/doc/current/setup/flex.html)

------
gigatexal
Um...

“Just for fun, I compared apples and oranges again by benchmarking the login
page (which doesn't hit any database) for both application versions using
Siege.

The Symfony application (PHP 7.3, OPcache enabled, optimized autoloader)
handles about 1470 req/s. The Go application (compiled using Go v1.11)
averages about 18600 req/s.”

~~~
gigatexal
I’d say that’s apples v apples.

~~~
lixtra
Yes, but you’re more interested in fruit salad vs. fruit salad. Maybe they
actually never have to handle more than a dozen logins. But they have to
change the templates relatively frequently:

> it’s more maintainable for us to do it in PHP right now

------
_the_inflator
Can relate, after 7+ years I am again using WordPress and PHP again. I am
impressed by PHP 7.

~~~
ehnto
Hm, I hate to be on the bandwagon, but why WordPress? One of the things that
has made PHP become what it is today is a focus on good software engineering
and the introduction of language features that are required by that. WordPress
did not keep up on the engineering front and there are so many amazing options
out there now for well written, well engineered platforms. Even in pre-built
blog platforms.

You're not alone mind you, most of the new platforms are not very popular just
because of how embedded WordPress is in its ecosystem. It just surprises me
that both WordPress never moved on and that the PHP developer community never
chose something different when it was clear WordPress had no intention of
moving to more modern practices.

~~~
vvpan
I am completely out of the loop here. All I know is that I really disliked
Wordpress and really-really disliked Drupal back in the day. Can you mention
some of the better alternatives? Once in a while a PHP CMS is what I gotta
deal with and I dread it, because of the said systems.

~~~
pasta
As a developer use ProcessWire instead of all the others.

Imho the best CMS for PHP.

~~~
progx
Thats the problem when you view with the eyes of a developer and not with the
eyes of a user.

~~~
pasta
I don't understand. My customers are super happy with ProcessWire.

Have you ever tried it?

------
moreentropy
He's comparing a language (w/ extensive standard library) with a web
application framework.

~~~
k__
It's hard not to.

Comparing Go ans PHP a few years ago would mean to compare Go and PHP/Apache
or PHP/Nginx, because PHP could not run its own server.

It's like comparing Git and Subversion, where you have to explain concepts
like staging.

Or IntelliJ and Eclipse, where you have to explain workspaces.

------
throw2016
PHP is the same but with speed improvements in 7. But even without that the
sheer number of high traffic sites built on PHP and proven scalability cannot
be ignored or its ease of use and setup.

All talk of accessibility and ease for new users often comes off as posturing
by some tech folks who then proceed to rubbish any efforts at achieving it and
the compromises involved. It fits in nicely with the 'contempt culture'
recently covered here.

The growing problem for the technical community and new users is the marketing
by other languages, frameworks and those vested in these ecosystems which
means using forums like this to belittle, rubbish and exaggerate any perceived
fault in everything else. PHP's contemporaries like Python, Ruby, Javascript
have their many downsides too but these efforts create false binary
narratives. This is not a good basis for technical decisions or informed
discussion.

------
iamleppert
An entire business that resolves around a nag box? Wow!

------
no_gravity
It's interesting that he names Symfony 4 as one of the main reasons he uses
PHP again after he already used PHP with Laravel.

I have a lot of discussions with friends in the startup scene about the topic
of Laravel vs Symfony. So far it's a head to head race.

I have yet to find a good 'Laravel vs Symfony' comparison page. Yes, there are
tons of 'SEO optimized articles' with this title. But I find them all rather
uninformative and often even totally wrong and unfair.

The page I would love to see would have the same project coded twice. Once
with each framework. And then display each file on the left for Laravel and
the corresponding file on the right for Symfony.

~~~
pasta
Those SEO pages are horrible. I had the same problem.

But there are multiple reasons I choose Symfony 4 over Laravel.

And if you want a code comparison then this small example:

Laravel:

    
    
      class User
      {
      }
    

Symfony:

    
    
      class User
      {
        private $id;
        private $name;
    
        public function getId():?int
        {
           return $this->id;
        }
    
        public function setName(string $name): self
        {
          $this->name = $name;
    
          return $this;
        }
    
        public function getName():?string
        {
           return $this->name;
        }   
      }
    

Laravel looks a lot easier and quicker. And it is. But good luck next month
when you can't remember what properties User has. Your IDE can't autocomplete
it. And also good luck working with a team. Your team members have to look up
the database model for the User to see what properties are available.

And this is happening in Laravel all the time. Very quick, very easy, a lot of
magic but it will bite you in the end.

~~~
honopu
I don't use laravel anymore, but I had a live template that would generate
getters and setters that wrote to set_attribute. As long as you maintained the
convention of doing this, you could use autocomplete with getters and setters
to accomplish this.

You could also hint these with / __@var * / there are ways around it but yes
it isn't ideal. I really liked doctrine, perhaps I was using it wrong, but
having everything in annotations was pretty nice since migrations etc could
run off of it.

With doctrine I ran into issues with performance, which you can alleviate with
extra lazy etc, it also hydrated what appeared to be massive objects, which
you had to use a custom debugger because print_r'ing one with the recursive
references etc caused some crazy issues. I have since moved on from PHP, but
if the project calls for it, I have no problem using laravel. While not ideal,
it sure is productive to build an API in. I wrote a project in lumen, which
is/was a subset of laravel built for APIs, and that was okay to work in. No
clue if it still exists.

------
tak2siva
Golang is not a silver bullet. No programming language is.

------
ggregoire
Any idea why PHP has such a bad reputation compared to other interpreted and
dynamically-typed languages such as Python?

~~~
acomjean
Its a quirky little language and the early versions weren't great. The
language can be inconsistent in places, and embedding php in the html made for
a rapid though sometimes trying experience. Its keeps backward compatibility
which keeps those quirks in there. (though with new 7 series php versions
older stuff is starting to break.)

Someone wrote an article with a title like "php a language with terrible
design" that got traction.

I like the language and with the right framework and templating engine its a
pleasure. (I'm moving code from silex to symfony).

I've been to a fair number php meetups and frankly people there seem to be end
result focused not so concerned with the language. Frankly I think PHP doesn't
have as strong a fan club as ruby/python, which are decent languages but they
too come with their own quirks.

~~~
gnarcoregrizz
"and embedding php in the html made for a rapid though sometimes trying
experience."

Funny, that is React/JSX's biggest sell

~~~
nprateem
React can't execute arbitrary database queries.

~~~
Aeolun
I’m sure you can use the all JS mysql client to connect directly from your
client app to your database.

~~~
nprateem
Well yes if you're stupid enough to directly expose your DB to the world then
it's technically possible, but barring such idiocy there's arguably more risk
of a DB hack through PHP than client side JS in most architectures.

~~~
mixedCase
React can do SSR. You can use JSX on the backend for rendering pages just like
on PHP.

------
proyb2
> Honestly, Go is great. Its simplicity is refreshing and its performance
> unmatched. I would still pick it if we need a small API or something that
> requires high throughput.

I wonder which part is performance unmatched?

My opinion would be Crystal language for its simplicity and higher throughput
but unmatched performance is behind Rust and C.

~~~
pjmlp
Not sure about the OP, but for many Go is the only compiled language they ever
used, so they get to attribute features to Go that aren't that unique of it.

~~~
sacado2
> for many Go is the only compiled language they ever used

That, or it can be read as "in the family of web-friendly languages". The only
other "fast" language widely used for the web is Java.

~~~
grumpydba
And java is a memory hog quite painful to deploy and tune.

~~~
sacado2
Yes, launching a new server/executable in java is a PITA dur to the JVM warmup
(at least it was a few years ago, don't know whether they improved that point
or not).

~~~
grumpydba
Don't forget that you also have to install and update the JVM. We admins don't
like that.

~~~
pjmlp
Only those that don't know how to bundle the JVM with the application or make
use of a commercial AOT compiler to native code.

~~~
grumpydba
You prove my point, it requires specific knowledge full of gotchas.

~~~
pjmlp
As team lead I consider having the interest to master the tooling part of the
job requirements and respective evaluation, not specific knowledge full of
gothas.

------
crimsonalucard
I'm finding that although golang offers type safety it introduces a new kind
of error class to applications typically not encountered in web apps of the
python/php/ruby/node class.

Deadlocks and race conditions.

For node, the entire app is a single thread so this just doesn't happen. For
python/php/ruby concurrency is abstracted away and handled above the framework
layer so the programmer never has to deal with it. You can launch threads in a
route handler for these languages but it's not often done and you have nothing
like a context object that is basically this abstraction leak that explicitly
forces the programmer to constantly be aware of concurrency issues.

------
ryanmccullagh
What IDE do people use for PHP these days? Editing PHP in a standard text
editor is a pain because most don't supporet "Go to definition", or "Find all
refernences" (Two killer features of Visual Studio)

~~~
ok_coo
Most of my work on a daily basis is PHP (Laravel) and I use Visual Studio Code
as my main driver.

It's pretty good with Python too, which we have a little bit of (mostly Flask
apps).

~~~
davidsawyer
Do you have any good extension recommendations for VS Cocde as it relates to
PHP development?

~~~
vaggal
For code copletion I use PHP Intellisense but it still doesn't support
multiple root folders in the same workspace. For debugging PHP Debug. vscode-
php-cs-fixer and vscode-phpstan have helped a lot. In addition I use PHP
Namespace Resolver and PHP DocBlocker. Lastly, PHP Getters & Setters may be
useful.

------
EZ-E
Question : modern PHP is great for websites, but what are the solutions when
you need to make some async work ? For example if I need to make few third
party API calls in parallel ? With Laravel I resorted to using queues which
feels like more complicated than it had to be (each worker takes up quite a
bit of memory). Eventually I switched to SQS + Lambda + node.js. Is there any
mature way to do async work in PHP ? In Node.js for example, it's quite
trivial and powerful with promises and async/await

~~~
no_gravity
One easy way to do multiple http requests in parallel are the curl_muli
functions:

[http://php.net/manual/en/function.curl-multi-
init.php](http://php.net/manual/en/function.curl-multi-init.php)

~~~
EZ-E
Thanks, that's one solution if making multiple calls is needed. That was
mostly an example though, for example if I wanted to run 3 functions in
parallel, I don't find any "easy" and elegant way. Some libraries exist like
amp, but it seems a bit heavy handed as the language itself doesn't have great
tools for it [https://github.com/amphp/amp](https://github.com/amphp/amp)

~~~
no_gravity
Why do you want to run 3 functions in parallel?

~~~
EZ-E
It's an example. For example if each of these functions takes about 0.2
seconds to finish, it might make sense to run them in parallel

------
tmaly
Internally, I think PHP is great for prototyping. I have written systems in Go
and PHP, and I think each has their strengths.

I like the batteries included standard library and single binary deployment of
Go.

PHP, like others have said, gives you a single endpoint and you can make rapid
changes. Its ideal for internal web apps that do not require insane
performance.

------
thrownaway954
In all seriousness... doees PHP have C# envy? With all of the stuff that has
been put into PHP7 (like typed returns and typed arguments) and stuff being
proposed (like annotations), PHP isn't that far off from being a interpreted
brother of C#.

~~~
romanovcode
All OOP languages have C# envy, they just don't want to admit it.

------
luord
Now that's pragmatism that's rare to see, specially here in HN.

------
bsaul
Honest question : is there any technical reason that prevents a go web
framework to replicate the functionalities of symfony / doctrine ?

~~~
atsjie
No.

And there alternatives. The best known is probably Revel:
[https://revel.github.io](https://revel.github.io)

For a doctrine (ORM) alternative you have for example
[https://github.com/jinzhu/gorm](https://github.com/jinzhu/gorm)

The point about Go; using those types of tools is generally frowned upon in
the community. It's overkill for most (micro)services.

But few gophers build a full-stack website in a single application.

I'm a gopher; I wouldn't want to use Revel or Gorm. I feel I'd be using the
wrong tool for the job. I'd more likely use Django or Symfony when I'd need to
build a full-stack SSR.

If a backend API is used by different clients (mobile apps, SPA, servers, ...)
using a full-stack SSR framework like Symfony or Django doesn't make much
sense anymore. You wouldn't use 90% of the framework's features. It feels like
bloat.

But many websites don't need to serve different clients.

The author's decision to go from Golang to PHP makes perfect sense if he's
building SSR websites.

~~~
Oras
Gorm is not bad but I don't think it is an alternative. To start with, the
association requires some extra work to save/update which you have to do
manually. In doctrine, this is done already. Documentation, maturity, and
community behind doctrine are a lot better.

~~~
atsjie
Funny this, +/\- 6 years ago when I last worked with Doctrine I had the same
feeling about Doctrine itself. I thought it was a poor replacement compared to
Hibernate / JPA.

I'm getting old ;)

Obviously things will have matured since then.

Doctrine implements the Unit of Work pattern. From what you're saying GORM is
more like an Active Record ORM.

You're right, that wouldn't make it a good direct alternative.

------
argd678
Is there any way to test php code the same way a compile phase does in other
languages to catch obvious mistakes from hitting your users?

~~~
lukifer
It's obviously not as comprehensive as compiled or strictly-typed languages,
but you can use "php -l" as a linter to catch obvious parsing/syntax bugs. I
use this script to check our whole codebase before deployment:

> find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v "No syntax
> errors detected"

------
ilovecaching
Why not try out Hack? It's kind of a cross between PHP and Go. Hack has a real
type system, and HHVM is incredibly fast.

~~~
kijin
Perhaps because they don't want to incur technical debt to a language/runtime
that could change at the whim of one company that probably doesn't have other
companies' best interests in mind?

The speed advantage of HHVM has also been largely erased. Some high-profile
PHP sites migrated to HHVM before and up to ~2015, but I haven't heard of a
single site doing that since PHP 7.0 came out.

~~~
ilovecaching
> Perhaps because they don't want to incur technical debt to a
> language/runtime that could change at the whim of one company that probably
> doesn't have other companies' best interests in mind?

How is Go any different?

~~~
kijin
Go has been well received outside of Google. Wikipedia even has a list of
companies known to use Go. I'm not sure how up to date it is, but the list
includes Cloudflare and Netflix. At least some of them might have the oomph to
fork, take over, or otherwise influence Go if Google ever dropped the ball.

Meanwhile, I can't think of any major online service that relies on Hack apart
from Facebook and its subsidiaries.

~~~
pushtheenvelope
Slack does.

But I agree with the original point about not fully relying on the whims of a
major corporate promoter. Priorities can change within, without clear
visibility on the outside.

------
kenzieL
I stopped working with PHP about 4 years ago and I can't say I miss it. I
moved to Python and never looked back.

------
lazyant
Seems like he didn't go from Go to PHP but from Go to a PHP framework that
does a lot of things for him.

------
abbiya
Would you choose golang if we have a framework like symfony in Go?

------
aboutruby
Seems like he should try Rails (from which Symfony was inspired) and that is
much better suited for building web apps that Go

~~~
thekingofh
What are the differences between the both of them?

~~~
aboutruby
I only tried Symfony 1.4 and 2.0. And I'm doing Rails from 2.3 to 5.2.

I could go on a very long discussion about why I prefer Rails but at the end
of day it's just up to you to compare.

When I started Rails I was building an app with Symfony, took me a week to get
it to a good state and it was extra frustrating (I had been doing PHP for 5
years).

I started Rails, learned Ruby on Wikipedia and just general googling and got
the same app in a few hours.

------
Bucephalus355
[deleted]

~~~
shittyadmin
To be clear, this just means that PHP has libsodium as an official language
extension. Most modern languages have better package management than PHP and
make pulling it in as a library trivial.

This has nothing to do with homomorphic encryption, unless I'm missing
something.

~~~
00deadbeef

      composer require some/library
    

That's PHP's package management. What's so non-trivial about that?

~~~
spdionis
And, as a bonus feature, composer install won't automatically update your lock
file!!

Unlike some other package managers...

------
the_other_guy
Golang is awesome once you submit and accept its intentionally mediocre design
as a work of mysteriously genius simplicity. I did that myself and now I love
it.

------
sandreas
Well comparing Go and PHP is kind of difficult, because they are targeting
completely different goals.

After some years of development, both languages have evolved a lot and they
both can be used for many other things, that they haven't been designed for.

PHP was a dynamically typed scripting language to build personal homepages
(Personal Home Page Tools). Today it is an object oriented, type hinted
language that supports functional and object oriented programming, many
database management systems and has a package manager (composer). I really
like PHP (see
[https://github.com/sandreas/m4b-tool](https://github.com/sandreas/m4b-tool)
for a proof), but some concerns about PHP have always been (and still are):

\- backwards compatibility reaching too far

\- way too big standard library (see levenshtein function)

\- the "callable" concept - call_user_func_array([$obj, "method"])

\- mixing up too many concepts (OOP, Traits, Functional style)

\- the type system (which is getting better with php 7)

\- unpredictable statements - empty($x), comparisons (== vs ===) and the
"mixed" type

\- the "array" type being array and dictionary and...

\- the $ used for variable declaration

\- $this-> is still needed for calling object methods

\- "." for concatenation and "\" for namespace separation

Another bad thing about PHP is, that on most web servers it is meant to be
stateless, which means that you are in trouble using technologies like
websockets.

Some of these things unfortunately mean that PHP often is much slower than it
could be - and this is where "go" can be a successor. Performance. If you
really need FAST web apps and performance is the goal, go can be a nice
choice. But for getting things done in a not too complex web page, i would
always choose php.

~~~
ddtaylor
> \- the "callable" concept - call_user_func_array(["object", "method"])

For at nearly 10 years now PHP has had support for lambdas, meaning for most
uses `$foo()` can be used instead and with the inclusion of the spread
operator it's seldom used.

~~~
sandreas
With the "callable" concept i meant, that many things are seen as callable:

[$obj, "methodName"] => callable for $obj->methodName()

"str_replace" => callable for function "str_replace"

["ClassName", "staticMethod"] => callable for ClassName::staticMethod()

"ClassName::staticMethod" => callable for ClassName::staticMethod()

function() {} => callable for a lambda

I would prefer a "ClassMethod" and a "Function" type, instead of using
strings.

$x = phpinfo; $x();

$y = $obj->method; $y();

But i don't think, this is possible, because PHP supports global constants and
function names cannot be distinguished from constants, especially because PHP
is not case sensitive regarding functions and classnames.

But I see, that my karma has decreased with this post, so it seems, that not
many are in my opinion...

