Live data from Hacker News

Moving from Go to PHP Again

dannyvankooten.com

231–240 of 371 posts

Re: Moving from Go to PHP Again

#231
post #13

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 Wordpres…

> 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…

If "people use it wrong" was a good excuse not to use a language, I can say that every language I've worked with is bad.

Re: Moving from Go to PHP Again

#232

Earlier quoted context omitted.

What's a good IDE for Go? Something that's snappy and fast, no Java dinosaurs please

I mean GoLand is pretty good, but I do also like IntelliJ, so YMMV if you don't like the JetBrains products. And it isn't free. VSCode is also really good for Go, I was surprised. There are plugins that massively help with testing, syntax checking, error handling, etc. I think it actually catches more issues than GoLand!

I've tried VSCode but it seems to require you to install Go... It can't even find the declaration of a variable or the definition of a function without Go, while Sublime can.

Re: Moving from Go to PHP Again

#233
post #128

Earlier quoted context omitted.

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 favor…

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…

I find waitgroups to be similar to condvars

Re: Moving from Go to PHP Again

#234
post #68

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.

> 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, everyo…

> 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?

Re: Moving from Go to PHP Again

#235

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.”

why would I need 18600 req/s ?

If you're at that scale then probably symfony isn't for you.

Re: Moving from Go to PHP Again

#236

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

What are the differences between the both of them?

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.

Re: Moving from Go to PHP Again

#237

Earlier quoted context omitted.

This sounds a lot like JavaScript

Gotchas in Javascript are syntactic/semantic, because there's no standard library worth its name bundled with it. PHP's gotchas are syntactic/semantic but mostly on its huge standard library, which is an haphazard collection of functions from sending emails to parsing ID3 tags from MP3 files. EDIT: JS, as the legend says, was written in 10 days, while PHP grew without much long term vision for years.

I think the parent poster was talking about both being messy in the past, but recently having a major version upgrade that deprecated old features. PHP 7 could be compared to ES6 (as well as ES5's strict mode)

Re: Moving from Go to PHP Again

#238
post #13

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 Wordpres…

As other commenters point out, most PHP written today goes through a framework that negates most of these points (single entry point, modern architecture, code is precompiles/cached and optimised, simple and intuitive goes through the window)

On the more general point, I am not sure scripting languages lend themselves better to lamdbas, as dependencies are usually external to the system. For instance PHP often relies on system json/xml libraries. Database access also needs to be precompiled and installed on the system, as would be crypto or internalionalization routines.

Compared to that, I'd expect compiled runtimes can have one single "fat" binary that has most of the risky dependencies and only rely on the bare minimum provided by the system.

Re: Moving from Go to PHP Again

#239
post #187

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 ? I…

You might want to check out gearmand and/or any of it's spiritual successors.

Re: Moving from Go to PHP Again

#240
post #128

Earlier quoted context omitted.

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 favor…

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…

> 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.

Post reply on HN