Live data from Hacker News

Goro – An implementation of PHP written in Go

github.com

71–80 of 135 posts

Re: Goro – An implementation of PHP written in Go

#71
post #36
post #19

A perfect example of error handling in go in the wild: https://github.com/MagicalTux/goro/blob/3cb3dfe0eef910c03e41... More php interpreters is of course nice.

I don't understand. I have a C background. What is wrong with that?

In many languages invented since c that have errors as values, you can use something akin to a specialized monad to sequence things which may fail together.

For example, in rust you could use:

    let res1 = w.Write(...)?;
    let res2 = w.Write(res1)?;
In haskell, you can use do notation or monad binding to do a similar thing.

Of course C doesn't have a good type system that allows this sort of thing; it was created before such type systems were well known.

I would expect any modern language to at least recognize that there are good ways to sequence and compose types.

Re: Goro – An implementation of PHP written in Go

#72
post #56

Earlier quoted context omitted.

Facebook forked PHP to make Hack to try and make PHP usable. Yahoo is yahoo. Wikipedia wouldn't have the resources to change anything. Google has a wiki page for their developers telling them to never ever use PHP for any google project.

Those facebook improvements made there way back into the core. Google might be able to move quicker if they allowed php. Facebook killed them in social. The type of products google can offer is limited by this decision.

HHVM can't make its way entirely back to core, and is in fact completely separating from PHP entirely now[1]. If I recall correctly, while PHP7 implemented better op-caching, it has _not_ implemented JIT compilation yet.

1. https://hhvm.com/blog/2017/09/18/the-future-of-hhvm.html

Re: Goro – An implementation of PHP written in Go

#73
post #62

Earlier quoted context omitted.

Yeah buddy. https://servo.org/ Also there is already amazing work for Rust and WASM https://rustwasm.github.io/book/

Servo uses spidermonkey

Oh, I see. Thanks. I assumed the JS engine was written in Rust!

Re: Goro – An implementation of PHP written in Go

#74
post #40

Earlier quoted context omitted.

I don't see what it fixes. You're just replacing an interpreter and in all likelihood bundling a web server. PHP 7 is a pretty solid language. I don't like WordPress at all, but there's so much cruft, legacy nonsense and plugin garbage that you won't win that battle.

well obviously we won't win the performance battle, and it may be impossible to protect the database and user data, but sandboxed execution with a virtual filesystem could protect the overall system, keep it from joining botnets and sending spam, etc.

Ok, but think about how many other ways you could fix that by wrapping battle tested interpreters.

Re: Goro – An implementation of PHP written in Go

#75
post #68
post #60

Earlier quoted context omitted.

And so it's clear to others, this probably the worst possible way for a language to go about implementing error handling (maybe aside from just not having any mechanism outright and terminating). But alas, those are the choices that the Go language made.

Is it really though? I've tried out Exceptions in most languages and Go's error handling stuck out to me as the first one that is clear what it does, which of course is the mantra of the language.

Exceptions are a strawman.

Compare it to another modern language such as rust. Go does not have a stdlib mechanism for converting error types into each other (akin to rust's Into), it doesn't have the idea of mapping values together (akin to rust's carrier operator which is basically like monad do syntax), it doesn't have a way to create a list of errors by default (akin to 'cause' in rust), it doesn't have a way to generate concrete error types for your functions (like the 'failures' or 'error-chain' libraries in rust, which can't be written in go due to a lack of macros and generics and sum types).

It doesn't have a way to match on all possible concrete error values (akin to 'match' in rust or other sum-type things) or to do thing slike '.and_then' or '.map_err' or so on.

Go's error handling is downright insulting in a language that wasn't built at the same time as c.

Re: Goro – An implementation of PHP written in Go

#76
post #42
post #36

Earlier quoted context omitted.

I don't understand. I have a C background. What is wrong with that?

Probably the repetition of if err != nil {} You get used to that pretty quickly in Go, but it still looks messy to a lot of people.

The alternative is just as bad, a multi block try and catch mess that is in Java!

Re: Goro – An implementation of PHP written in Go

#77
post #45

Earlier quoted context omitted.

While true, there is still a tremendous amount of the web that is powered by php and not using WordPress or Magento. Facebook, Yahoo, Wikipedia, even Google.

Facebook forked PHP to make Hack to try and make PHP usable. Yahoo is yahoo. Wikipedia wouldn't have the resources to change anything. Google has a wiki page for their developers telling them to never ever use PHP for any google project.

> Google has a wiki page for their developers telling them to never ever use PHP for any google project.

I didn't know that, but it makes sense - the things that PHP's good for (getting a web-based service backed by some sort of datastore up and ready to receive requests) are not the things that Google (on the whole) cares about.

Google instead cares that the thing can be improved and maintained by your colleagues, few of whom know PHP.

Re: Goro – An implementation of PHP written in Go

#78
post #52
post #22

One of the most "hip to hate" languages implemented in one of the most "hip to love" languages...

I thought Go was a hip to hate language also. Seems to get a bunch of grief about "missing" things. I quite like it but haven't used much beyond toy projects.

Well, the difference is that the hate is coming from different directions. PHP is hated by nearly everyone except pure pragmatist. Go is hated by somewhat experienced programmers which find the absence of certain features inconvenient.

That said, I like them both somehow. PHP was the first programming language I learned beyond simple hello-world like programs (today, I use it mostly for prototypes only) and Go is my language of choice for performance-intensive tools.

In the end, I have not met any language yet, you can not hate. Smalltalk is beautiful, but can't do arithmetics properly (e.g., `1 + 2 * 3` == 9). Lisp lets you write correct programs, but breaks your parenthesis key. C++ can be fast, but actually doing it is hard and have you ever solved one of those template-error riddles?

Re: Goro – An implementation of PHP written in Go

#79
post #72
post #56

Earlier quoted context omitted.

Those facebook improvements made there way back into the core. Google might be able to move quicker if they allowed php. Facebook killed them in social. The type of products google can offer is limited by this decision.

HHVM can't make its way entirely back to core, and is in fact completely separating from PHP entirely now[1]. If I recall correctly, while PHP7 implemented better op-caching, it has _not_ implemented JIT compilation yet. 1. https://hhvm.com/blog/2017/09/18/the-future-of-hhvm.html

It hasn't - a JIT compiler (if it comes) will come in PHP 8.

Re: Goro – An implementation of PHP written in Go

#80
post #15

> PHP is a nice language but is having trouble keeping up with modern languages It's only "having trouble" because it can't change its API from month to month to match whatever's in vogue. A majority of the web still runs on some variant of PHP, and that guarantees that it's not dying anytime soon. More broadly, it seems the author wants to create a version of PHP that's not focussed on web requests, which is sort of…

> a version of PHP that's not focussed on web requests, which is sort of the entire point of PHP.

But even for web requests it's terrible. Or at least, it was, last time I used it years ago. Couldn't really do any long-running tasks in response to an HTTP request, or load a single data set into memory to share among all the HTTP requests over the lifetime of the server. (Maybe you could, but I couldn't figure out how.)

I'm quite happy that I haven't touched PHP in years. As fun/cool as this project is, there's nothing I miss from PHP that isn't present -- or even better -- in Go.

Post reply on HN