Live data from Hacker News

Re: Moving from PHP to Go and Back Again

blog.breakthru.solutions

61–70 of 281 posts

Re: Re: Moving from PHP to Go and Back Again

#61
post #51

> These are hard issues to solve with PHP, so hard that Facebook hand crafted a SPECIALIZED VIRTUAL FREAKIN’ MACHINE to deal with the performance issues inherent in PHP. Does that really seem like an “easy” solution? It is worth noting that this was pre-PHP7. Post-PHP7 the out of the box performance is similar or better to what Facebook did with the HHVM.

Also, very few projects will ever end up at the scale (user base/metrics) that Facebook had.

99% of all PHP software will be fine with a quadcore server with 4GB RAM, running a LAMP stack. This can be scaled as needed (eg moving off mysql, adding a reverse proxy, real load balancing).

Re: Re: Moving from PHP to Go and Back Again

#62
post #52
post #38

I don't know Go and I didn't use PHP very much so I'm qualified to comment only on this part: > I’ve worked with RoR, and a variety of frameworks in the Node world – and I have never had a framework project where I didn’t end up fighting the very system that was supposed to make development “easy”. This is not my experience with Rails, Django and Phoenix. Actually, I was probably fighting Rails in my very first proje…

Frameworks necessarily limit what you can do. For example, the labstack echo framework in Go is one of my favorite frameworks, it does a lot of work for me. On the downside, I can't hijack HTTP connections in the router, like for example, when I want to host something under customs domains and redirect internally to a subURL. I have to hack around the framework to do that, the solution is rather ugly. But there isn't…

> For example, the labstack echo framework in Go is one of my favorite frameworks, it does a lot of work for me. On the downside, I can't hijack HTTP connections in the router,

This isn't a problem with "frameworks" but a problem with the library you specifically chose which is bad since it doesn't even fulfill your needs apparently. I wrote my own go http router, and I have no problem hijacking the connection and filter according to hosts, at all.

Re: Re: Moving from PHP to Go and Back Again

#63
post #27

Earlier quoted context omitted.

To be fair to the haters, even modern PHP can be horrible. The old nightmares are still around; we've just agreed to ignore them, and maybe deprecate a couple of the worst. (And ternary syntax is still broken, and the standard library is anything but standard.) But yes, if you're working on a modern PHP project, there's a lot to love: A solid module system, an enormous sea of high quality libraries, type checking, a…

Solid module system? It's still the same as C, which is _not_ a solid module system.

I'm assuming he meant the dependency manager, which is really nice.

https://getcomposer.org/

Re: Re: Moving from PHP to Go and Back Again

#64

Earlier quoted context omitted.

Modern PHP is very nice to work with. Ignore the haters that haven't touched the language in 10 years.

I wrote some PHP last month and I still hate it :) Though it has improved dramatically.

Did you write clean OOP code? You can still write bad code with it, no doubt about that.

Re: Re: Moving from PHP to Go and Back Again

#65
post #5
post #4

I don't know why the author bothered to even respond to that Medium article. The Medium article starts with that Go shines as a systems programming language. He lost me right there: how can a language with a garbage collector and a runtime be called a "systems programming language"?

"systems programming language" doesn't start and stop with bit twiddling one step removed from assembler. There's a huge fuzzy region between that extreme and "application programming as a semi-skilled trade", and go seems to fill certain "systems programming" needs adequately as far as that goes.

[deleted]

Re: Re: Moving from PHP to Go and Back Again

#66

At my job, before I joined, I was told we were torn between using Go and Rails and ended up with both. Now we have a Rails frontend (for web requests / authentication) and a Go backend (for business logic), which communicate over Thrift RPC. I don't think it was a very wise decision because not only are you doing things twice, you're doing it three times, because you have to serialize/deserialize to/from Thrift for e…

Have you tried thcurl or yab for debugging RPC? I’ve found that most services I consume using thrift have a yab template for easy testing and trace ids so I can follow the request- I haven’t really missed hand writing JSON curls yet.

https://github.com/yarpc/yab/blob/dev/README.md

Re: Re: Moving from PHP to Go and Back Again

#67

From My point of view. Go is a great language and this author is right when talking about using Go is better than PHP in cases like Uber or Youtube. I mean, Im not a fan of PHP, I like to use low level languages the most time but web is complicated. First of all, I don't think that not abstracting all the IO and network HTTP socketing or all this stuff 'helps' somehow developing a 'better' web app. Maybe for Uber, Yo…

I think JSP is a great contender, and I see your point about overengineering. PHP with type-checking is alright, but if I'm going to use a scripting language I'd prefer Python or Ruby.

Both ruby and python seem to encourage duck-typing. I worked with both of them in the past and that's the main reason why I always came back to PHP. I need my type declarations...

Re: Re: Moving from PHP to Go and Back Again

#68
post #54
post #49

Earlier quoted context omitted.

I think you are confusing the language runtime with the Go "runtime" package that provides an API to the Go runtime. Golang runtime is basically a program, that is running whenever your Go application is running. As a programmer, you do not have full control over the language runtime. It runs things like garbage collection, and serializes/deserializes data in the channels. True system languages like C do not have a r…

By that definition every language has a runtime (yes, including C with crt0.o). Something has to set up the stack, enter the main() function etc. So how do you differentiate a systems language runtime? One that is bundled with the OS? Or is thin enough by some arbitrary measure?

In Go you cannot fully control the runtime as a programmer- Go's GC is a complicated periodically run program with sometimes surprising behavior.

crt0.o is a very simple set of startup routines with a fixed and predictable behavior. It is typically run only once ("0" in the name is for startup), and has only a couple of assembly instructions.

Re: Re: Moving from PHP to Go and Back Again

#69
post #9
post #3

Everyone I know who uses Go complains about it. Every day you write Go code you will come across some piece of code that would be shorter with templates in C++ or using , or you could do it more simply in Python, or if you were really clever it would be a single line of Haskell. And yet we keep writing Go. By comparison, I'm a bit put off by the Rust community's evangelism, but that might just be my personal experien…

> And yet we keep writing Go. What are the alternatives if you want something with type checking? Java? No, thanks. Haskel? Where are the libraries? C/C++? I guess Typescript is the only alternative

Modern PHP is really nice to work with. I uploaded the sample code from my book on Github if you want to have a look (check inside the src directory).

https://github.com/PatrickLouys/professional-php-sample-code

Re: Re: Moving from PHP to Go and Back Again

#70
post #62
post #52

Earlier quoted context omitted.

Frameworks necessarily limit what you can do. For example, the labstack echo framework in Go is one of my favorite frameworks, it does a lot of work for me. On the downside, I can't hijack HTTP connections in the router, like for example, when I want to host something under customs domains and redirect internally to a subURL. I have to hack around the framework to do that, the solution is rather ugly. But there isn't…

> For example, the labstack echo framework in Go is one of my favorite frameworks, it does a lot of work for me. On the downside, I can't hijack HTTP connections in the router, This isn't a problem with "frameworks" but a problem with the library you specifically chose which is bad since it doesn't even fulfill your needs apparently. I wrote my own go http router, and I have no problem hijacking the connection and fi…

Writing a custom http router is kinda contra to the point of using a library, no?

I don't want to bother with writing my own router and this was one of the few times I had problems.

I think even if I wrote my own framework, I would eventually end up having to hack around it anyway when I inevitably need to do something the framework I wrote just fundamentally can't and I suggest this will be the case for your custom implementation too.

Post reply on HN