Live data from Hacker News

Re: Moving from PHP to Go and Back Again

blog.breakthru.solutions

171–180 of 281 posts

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

#171

Earlier quoted context omitted.

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

For most setups at most ISPs, PHP servers are zero setup, self contained systems which, without any setup from the client (the user, you), comes back after reboot with no issues. It has also been the case for 15+ years so it's quite something you can actually trust to happen. This is not so for Go or Node for most hosters out-of-the-box. Sure in the HN echo chamber, every hoster offers this maybe, but there are liter…

So this is about the technical decisions made by small businesses, and how those decisions impact engineers?

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

#172
Some background. I actually wrote a semi-popular book on PHP (published by a major publisher) and have contributed to the core project. And I have spoken at many PHP conferences. Perhaps tellingly, PHP is rarely my first choice anymore. Which I think it a great language (contrary to many opinions) I just find other languages a better choice.

Today my language usage looks like this:

- Web services / APIs: Node.js [1]

- Front-ends that require easily modifiable templates and quick command line scripts: PHP [2]

- When I need speed and low latency for a network connected app: Go [3]

- When I need speed on an app that requires no network: C

[1] The promise chain asynchronous nature of Node.js makes it great for web services in my opinion. And the ability to easily have global variables that persist across connections for things like caching and pooling is a huge plus over PHP.

[2] PHP is very good at spitting out HTML and making web service requests, the performance is acceptable in most cases, and it is really easy for most people to edit, even people without a CS background. Likewise, for quick command like scripts PHP is unbeatable in my opinion. The tools it provides out of the box means most common command line tasks can be done 100% with the standard library. No package manager required. Though if you need to add packages PHP is pretty good about that now. Incidentally the fact the standard lib does so much is also one of PHP weaknesses. The standard library is a mess of inconsistently named functions and classes that grew organically over 20 years.

[3] I've saturated my loopback network interface on a non-trivial app on my Macbook Pro using Go. PHP and node don't even come remotely close.

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

#173
post #109

Earlier quoted context omitted.

Many people were taught OOP the UML and Java way†, to which the concept of prototype-based inheritance is completely alien, while composition is not even on their radar. † Although they have their fair share of issues, this is not a jab at UML nor Java themselves, but the way things have been taught, terribly, for so many.

What would you consider solid references to learn sane OOP? I have a vague working model of object orientation but a lot of the finer details go straight over my head.

[deleted]

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

#174

Not strictly about Go, but how is it supposed to impress that 'big company X' uses language Y (in this case the author uses Uber as if that's some kind of + for Go); I would be far more interested in the language + framework used to solve what level of complexity and scale problem with how many servers + people. If you can build & run something with less people and servers than your competitor and which makes you mak…

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 expect something like AWS and GCE to already have our to be building a solution to handle the go scenario efficiently for you.

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

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

> 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 actually does use semicolons and the formatting has been forced onto users to allow easier automatic insertion of them. They were going to get removed but in the end it was easier just enforcing a format.

https://golang.org/doc/effective_go.html#semicolons

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

#176
post #109

Earlier quoted context omitted.

Many people were taught OOP the UML and Java way†, to which the concept of prototype-based inheritance is completely alien, while composition is not even on their radar. † Although they have their fair share of issues, this is not a jab at UML nor Java themselves, but the way things have been taught, terribly, for so many.

What would you consider solid references to learn sane OOP? I have a vague working model of object orientation but a lot of the finer details go straight over my head.

While Lisp is usually associated with FP practices, the CLOS (Common Lisp Object System) really helped me with getting OOP to click as a concept. Part of it is that, CLOS is just Lisp, so all of the concepts of OO programming are there with none of the syntax generally added in other OO languages. Also, the method/function names clearly name all the concepts instead of using opaque notation: SLOT-VALUE instead of dot, arrow, or double-colon notation, DEFCLASS does what it says on the tin instead of the vaguer "class ClassName { }" of C++/Java/etc. I feel like this makes it clearer what is happening. A good overview of CLOS is chapters 16 and 17 of /Practical Common Lisp/ (http://www.gigamonkeys.com/book/)

I've heard other people speak similarly of learning Perl's MOOSE after already being familiar with non-OO Perl. This probably is no coincidence since MOOSE is heavily inspired by CLOS.

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

#177
post #151
post #136

Earlier quoted context omitted.

> You are only happy if you look for a better C which most people aren't. I'd argue Rust is the "better" C. Go is a "simpler" C, at the expense of expressiveness, features, speed (only noticable in very low level usecases) and applicability for certain domains (Go is primarily for networked apps). In the same way Java wanted to be a simpler C++ (which came with it's own drawbacks). And for me Go is more of a competit…

To me, Rust is like C++, Go is like C. Rust loves zero cost abstractions, and isn't afraid to be complicated. It gives the programmer as much power as possible. Go is simple and actually very fast. The garbage collector is probably the biggest hurdle for performance and it's still best in class. Definitely higher level than C, but not enormously so.

> Rust loves zero cost abstractions

C was also king of the zero cost abstractions.

> and isn't afraid to be complicated.

C sure is not afraid to be complicated. But at the time it was huge simplification. I'd say Rust's complexity is not there for it's own merit, but has huge advantages (though not that visible in a very small project).

> It gives the programmer as much power as possible.

C, C++, Rust are all in that corner.

Go obviously isn't.

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

#178
post #103
post #82

Earlier quoted context omitted.

If you look for an oop or fp language you are also out of luck. You are only happy if you look for a better C which most people aren't.

That is basically Go’s niche, the revival of Limbo, compiled instead of using the Dis VM. Which took C’s place for user space applications on Inferno, the last Plan 9 iteration.

Inferno was sold to Vita Nuova Holdings Ltd in March 2000. Other licensed versions exist, I was working on one until 2007.

Plan9 3rd edition was released June 7, 2000

Plan9 4th edition was released in 2002

This version went into continuous improvement mode, the latest commit in the tree was Apr 29 2017

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

#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 code to look nicer and more separated).

Thank God I can do a lot of my work in Python and don't have to care about these things though. Would've been great if Go too borrowed the "indentation for code structure" amazing idea from Python ;)

I mean, really, even Lisps never put their parens at the beginning of otherwise empty lines...

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

#180
post #144

Earlier quoted context omitted.

The relevance is that a compiler running in 90's hardware is able to beat Go's compilation speeds of 2017. That same compiler has evolved through the years. If you want the 2017 version of it, it is called Delphi. Beats Go in language features and compilation speed. Go's compilation speed only surprises those developers that never used anything else beyond C and C++.

>The relevance is that a compiler running in 90's hardware is able to beat Go's compilation speeds of 2017 And beat 99% of other compilers today, meaning that overall compiler complexity has grown. >If you want the 2017 version of it, it is called Delphi. Ok, this is something actually relevant. >Go's compilation speed only surprises those developers that never used anything else beyond C and C++. For me (tm), Go com…

> And beat 99% of other compilers today, meaning that overall compiler complexity has grown.

Which ones?

> For me (tm), Go compilation speed has compared equal or favorably against C, C++, Java, C#, Rust at least.

Since when does Go compile faster than Java and C#?

When I hit Ctrl+S my binary is already on the disk, thanks to incremental compiler integration on the IDE.

I have a full blown WPF application with multiple plugins, including data visualization, talking to Oracle and Postgres, total compilation time after check out 12s.

Eiffel, D, Nim, Jai are other fast compilation examples.

Post reply on HN