Live data from Hacker News

Re: Moving from PHP to Go and Back Again

blog.breakthru.solutions

211–220 of 281 posts

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

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

Object Thinking, by David West for the essential ideas and philosophy of sane OOP.

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

#212
post #189

> Would you rather? > > A – Be able to write new code 50% faster > B – Have 90% less errors in all new code you write For my employer, this is the most important question of the 3, and the answer is A every time.

50% is a big number. 6 months or 1 year. 1 year or 2 years. XD

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

#213
post #86

Earlier quoted context omitted.

I've always been really skeptical of those language performance comparisons which refer to PHP. As stated above PHP7 has similar performance when compared to HHVM which was made by Facebook. Additionally PHP has an amazing performance debugger by FB called xhprof. PHP performance could always be increased hugely by making sure is cache buckets have enough memory (opcode cache, realpath_cache_size). Secondly with any…

> If anyone's ever worked on a project where the performance problem was the language and not IO I'd be really interested in hearing about it, but in my career of making websites I've never ran into this problem yet. Our company's product is CPU bound, and our language (Python) is definitely inhibiting our ability to meet basic performance goals. I've done a few crude benchmarks and I'm confident that a rewrite in Go…

or alternatively break out the big CPU bound bits into an FFI language, i.e. C, Rust, Etc. That's why Python has these bindings. You can almost sort of do it with Go, but it's not easy, since Go has a VM as well.

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

#214
post #190

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

in latest nodejs there is no a single place to catch exceptions in promise chain, which is very inconvenient.

Not sure what you are talking about:

    Promise.resolve().then(() => Promise.resolve().then(() => {throw new Error('Problem')})).catch((e) => console.log(e.message));

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

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

> A large part of what makes me stick to Ruby over Python for example, is that I can't stand languages with significant indentation.

More like 'consistent indentation' methinks.

I still have nightmares about trying to merge some GSOC student's code from their branch to trunk where the indentation was all over the place, it was so bad that lint couldn't even figure out what the hell they were up to -- well, I think lint was crapping out on macros more than anything but still...

So...someone got to put on their resume they did a GSOC for Blender but the work they did was basically wasted since it wasn't possible to clean it up enough to merge.

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

#216
post #139

Earlier quoted context omitted.

> Secondly with any web framework your app will most likely be limited by IO (database, file lookups, networking) before it becomes limited by actual code execution performance. Latency is additive; it's a sum() operation, not a max() operation. Yes, a large fraction of most web requests get eaten by blocking on IO, but everything on top of that adds up, and small numbers add up surprisingly quickly. And the more you…

> Latency is additive; it's a sum() operation, not a max() operation. This! And you can only discard some components latency when it disappears in the deviation of another components much larger latency. In most PHP (or Ruby/Python/etc for that matter), this is not the case. They add some 10-150ms on top, and often the db calls are Performance does matter, and is hard to improve once you have many KLOC of code in a s…

> and often the db calls are Most are <10ms. Those nasty few ones with 100+ms (or sometimes 10+s!) are where the best money is spent optimizing. However good query/db schema optimization is a skill many developers do not possess... which is why a good DBA is worth his weight in gold.

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

#217

Earlier quoted context omitted.

Being skeptical is a good attitude. I'm very skeptical of this Eldorado that some posters see in PHP7. My experience is quite different. > Additionally PHP has an amazing performance debugger by FB called xhprof. xhprof is unmaintained for years. The official version does not compile with PHP7. Various forks exist, but the only stable fork has been rebranded and defaults to sending all the performance data to the bra…

> So once you add a load balancer and several PHP servers, you need to use a network mount for most of your files, which has a big impact on IO performance. That depends if you set up cachefilesd correctly. Many people think it's enough to do the NFS mount and that's it, but it's not - NFS's mount parameters have a big impact on performance, and having cachefilesd enabled can make performance go through the roof, esp…

I’ve given up on NFS entirely and just use one of the big 3 cloud file storage services.

Out of 8 downtime events, 5 were related to NFS mounts.

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

#218
post #213

Earlier quoted context omitted.

> If anyone's ever worked on a project where the performance problem was the language and not IO I'd be really interested in hearing about it, but in my career of making websites I've never ran into this problem yet. Our company's product is CPU bound, and our language (Python) is definitely inhibiting our ability to meet basic performance goals. I've done a few crude benchmarks and I'm confident that a rewrite in Go…

or alternatively break out the big CPU bound bits into an FFI language, i.e. C, Rust, Etc. That's why Python has these bindings. You can almost sort of do it with Go, but it's not easy, since Go has a VM as well.

What do you mean by VM?

I don't think there's a virtual machine in Go.

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

#219
post #79

I see no facts or genuine refutation in this article, just opinions. Therefore I can only assume that truth hurts because the article you are trying to argue with has a bunch of valid points. If you look at the history of Go you have to realize that it was created for the reason which is in the original article: to be a better C. If you come from C it is good, sure. And you can write big projects in it like in C (jus…

Okay, let's say I agree with your arguments: 1. Go "is still not as fast as Java can be" [1] 2. "Go lacks the most basic tools which any seasoned developer can expect from a language (like generics)" 3. "Go does not have a de facto build system and you can’t handle dependency management in an easy way" [2] 4. odd error handling 5. not a lot of libraries to choose from [3] 6. possibly more arguments that I missed when…

> The way you paint it, people would be stupid to use Go. However, thousands of very talented developers use Go everyday. How can you explain this disconnect?

Billions of people hold staunch religious beliefs, yet this doesn't mean they're stupid or mentally handicapped.

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

#220
post #177
post #151

Earlier quoted context omitted.

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…

> Go obviously isn't.

You can use atomics and syscalls and even assembly in Go to have complete control over the system in the same way that you can in C/C++. It's definitely not trivial to bypass Go's memory model and get raw access to memory, but you can do it if you want. I'd say that Go discourages you from doing so, just the way Rust discourages the use of unsafe memory access even though you can if you want.

Post reply on HN