Live data from Hacker News

Re: Moving from PHP to Go and Back Again

blog.breakthru.solutions

201–210 of 281 posts

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

#201

Earlier quoted context omitted.

How is restarting a go-based server harder than restarting a PHP-based server?

You'll need the go process to complete all ongoing requests before restarting it. Whether that be RPC, HTTP, WS, etc. And this is behind a load balancer, so did you just go offline, or are you doing this one at a time? With PHP, you don't have to restart php-fpm or modapache. Just git-pull or FTP the new files in and the next HTTP request will automatically user the new version. Zero downtime. Honestly though, I expe…

This would be easily achievable by having 2 processes: one, which accepts the socket connections and relays them to the subprocess which does the actual work. New subprocesses could be started any time for updates, without killing existing connections. All new connections would be handled by the new subprocess.

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

#202
post #146
post #143

Earlier quoted context omitted.

... curly brackets on new lines do work perfectly fine in case you're writing code on your own. As soon as you start working in a team and each team member starts to use their own formatting, it becomes super messy and unreadable. Either you inforce a clear style guide which leaves you to explain the team why your style is the best, or you leave this task to the language itself and never ever have to start arguing ab…

But why should Go enforce it on behalf of everybody? A parser option to not automatically insert semicolons would be all I need, but no. To me, even with super short lines, braces at the end of the line are messy, and consistently messy is still messy. > Either you inforce a clear style guide which leaves you to explain the team why your style is the best, or you leave this task to the language itself Which then leav…

Official response: https://www.youtube.com/watch?v=PAAkCSZUG1c&t=8m43s

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

#203

Earlier quoted context omitted.

Why do you say that? I love both Perl and Rust, yet the latter doesn't feel very perlish to me.

Seems it’s optimized for developer enjoyment and is a big language that allows for terse expression, as well as a few ways to achieve the same thing.

Any measure by which Rust allows for “terse expression” has to be horribly broken. (And I don't even dislike Rust.)

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

#204
post #179
post #127

I know this is about the weakest critique possible, but currently using Go, I know my next project won't be in it, simply for the impossibility to put an opening curly brace on its own line. Other languages that don't require semicolons at the end of a line have it, and even if they didn't, I'd rather have to put semicolons manually.. Go is "opinionated" I guess, but so am I. Whatever their target audience is, I'm no…

> impossibility to put an opening curly brace on its own line I sincerely wish all languages with braces would have this feature! Even Javascript devs practically standardized in always putting braces at the end of the line. I prefer working with code that mixes tabs and spaces than with the old-ancient style of spoiling a nice and clean empty line with a brace (yeah, you can just leave a line empty if you want your…

That Go uses curly braces instead of significant whitespace was a conscious decision. I think it was Rob Pike who talked about how he got bitten by a subtle bug in Python due to overlooked incorrect indentation. Curly braces also make it easier to paste code into the correct scope.

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

#205
post #201

Earlier quoted context omitted.

You'll need the go process to complete all ongoing requests before restarting it. Whether that be RPC, HTTP, WS, etc. And this is behind a load balancer, so did you just go offline, or are you doing this one at a time? With PHP, you don't have to restart php-fpm or modapache. Just git-pull or FTP the new files in and the next HTTP request will automatically user the new version. Zero downtime. Honestly though, I expe…

This would be easily achievable by having 2 processes: one, which accepts the socket connections and relays them to the subprocess which does the actual work. New subprocesses could be started any time for updates, without killing existing connections. All new connections would be handled by the new subprocess.

So, basically what you get for free in erlang and PHP, but not in golang?

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

#206
post #84
post #80

Earlier quoted context omitted.

Since Xerox PARC, UK Royal Navy, DEC, HP Labs, ETHZ, Microsoft Research have implemented full stack OSes in GC enabled systems programming languages. At ETHZ Oberon workstations were used during a couple of years by several users across the department. Most of those attempts failed due to losing the political and financial wars of bringing them into the wider market, not because of lack of features.

very interesting. I would have thought that any practical kernel written in a language with a GC would either have unpredictable slowdowns or be exceedingly complex.

I don't think that is a necessity. You can write Go code which doesn't heap-allocate at all - the Go GC is written this way in Go. In any case, you would have very little heap allocations in the kernel space and the GC should be well integrated with the kernel operations.

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

#207
post #148
post #143

Earlier quoted context omitted.

... curly brackets on new lines do work perfectly fine in case you're writing code on your own. As soon as you start working in a team and each team member starts to use their own formatting, it becomes super messy and unreadable. Either you inforce a clear style guide which leaves you to explain the team why your style is the best, or you leave this task to the language itself and never ever have to start arguing ab…

But when the language/tooling enforces it, you've made language choice a proxy for style choice. A large part of what makes me stick to Ruby over Python for example, is that I can't stand languages with significant indentation. It may seem minor, but it isn't to me, to the extent where I avoid Python whenever I can. When your language enforces formatting like that, people will choose or choose away the language over…

Go enforces a style because all code, written across different teams and organisations, should look the same so anybody can pick up anybody else’s code and read it with ease. There are no differing styles in different libraries. It’s very harmonic.

What I can’t stand in other languages is the Laisser-faire attitude regarding styles. Some people put whitespace here, some there, some put the curly brace here, some there. How about some consistency across all codedbases?

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

#208
> I have never had a framework project where I didn’t end up fighting the very system that was supposed to make development “easy”.

Not always, but often, I find this attitude in developers who either refuse to read documentation, or just entrenched in their ways and too stubborn to try it someone else's way.

Is every project you're starting really so cutting edge that the problems others have solved and come to a consensus on don't apply to you? Perhaps, but maybe you should also be taking a look in the mirror and making an honest assessment on just how difficult you are to work with.

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

#209
post #201

Earlier quoted context omitted.

This would be easily achievable by having 2 processes: one, which accepts the socket connections and relays them to the subprocess which does the actual work. New subprocesses could be started any time for updates, without killing existing connections. All new connections would be handled by the new subprocess.

So, basically what you get for free in erlang and PHP, but not in golang?

Right, as Go is compiled into a static executable, you can't do code updates on the fly that easy. A small price to pay in a production environment. On the other side, you do have all compiler checks run while building.

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

#210
I recently used Python for a project and was again reminded why PHP is still the king of smallish web sites. With PHP I could rent a cheap service to host a few sites, no problem, take FTP and just upload scripts. That was possible 15+ years ago and still works today.

With Python - not so much. Sure, I can rent a whole VPS but I don't want to do server administration. And there are some options for hosting Django / Flask apps, but not many. Is it any wonder people still use PHP? I have used it for a long time and I hate the language - but it is hands down the best solution for small web pages where hosting is concerned.

EDIT: thank you for the downvotes. It was nice having a constructive conversation. But then again, I knew in advance it is unpopular to mention on HN that PHP, MongoDB and similar technologies have their use cases.

Post reply on HN