August 24th, 2024

Golang Interpreter Written in PHP

Go-PHP is a Golang interpreter for PHP, allowing Go code execution within PHP. It is a work in progress, not for production, with sequential execution and examples available in the repository.

Read original articleLink Icon
CuriosityAmusementSkepticism
Golang Interpreter Written in PHP

Go-PHP is a Golang interpreter designed to run within a PHP environment, enabling the execution of Go code alongside PHP. The project includes an example demonstrating how to define a Go struct and function, and execute it within PHP. The provided example code illustrates the creation of a `person` struct and a function to instantiate it, followed by a print statement to greet the user. Users can run the examples by navigating to the examples directory and executing the PHP script. The project is currently a work in progress and is not intended for production use. Users can find implemented features in the tests directory. To set up the project, dependencies can be installed using Composer, and tests can be run with a make command. However, it is important to note that the interpreter does not support real goroutines, meaning that Go statements execute sequentially rather than concurrently. For further information, users can visit the project's GitHub repository.

- Go-PHP allows execution of Go code in a PHP environment.

- The project is a work in progress and not for production use.

- Users can run examples by executing PHP scripts in the examples directory.

- The interpreter does not support real goroutines; execution is sequential.

- Development instructions include installing dependencies and running tests with make commands.

AI: What people are saying
The comments on the Go-PHP interpreter reveal a mix of amusement and skepticism about the project.
  • Many commenters find the idea of combining Go and PHP to be both intriguing and absurd.
  • Some mention existing alternatives like FrankenPHP, which offers more comprehensive solutions.
  • There are discussions about the potential for web development with Go, emphasizing the desire for features like hot code reloading.
  • Several comments reflect on the philosophical implications of such projects, questioning whether they should exist at all.
  • Overall, the project is seen as a playful experiment rather than a serious production tool.
Link Icon 24 comments
By @AdamJacobMuller - about 2 months
As someone who knows both languages intimately (written more code in both of those languages than any others), I can't think of any two (non-toy) languages which are more diametrically opposed.

This is deeply cursed and I love it.

By @laidoffamazon - about 2 months
This is an amusing companion to the PHP interpreter written in go (by Mark Karpeles of MtGox infamy)

https://github.com/MagicalTux/goro

By @slashdave - about 2 months
> This is a toy project, not intended for production use.

Well, darn.

By @remoquete - about 2 months
This is the kind of "why not" projects that one could use Copilot for!

Sorry, I'm heading to my workstation to ask Copilot to help me build a new JVM language using ancient Greek reserved words.

By @dominick-cc - about 2 months
finally
By @JoosToopit - about 2 months
But there is frankenPHP [1] already. And it's not just an interpreter, it's a complete app server with Caddy web server underneath.

[1] - https://frankenphp.dev

By @yas_hmaheshwari - about 2 months
I thought "the right way" was to do everything in Rust :-)
By @KingOfCoders - about 2 months
My dream for Go, interpreted for fast reloads without compile for web development like e.g. PHP. Then compile for testing/unit testing/deployment.
By @wavemode - about 2 months
My brain read the title as "PHP interpreter written in Go" - I assume because such a thing -wouldn't- be an abomination...
By @rzz3 - about 2 months
I have never simultaneously seen something both so amazing and so horrible :) No but really, this is impressive.
By @nasretdinov - about 2 months
I mean, Go is now finally suitable for web development with hot code reload?
By @DannyBee - about 2 months
Some people just want to watch the world burn
By @ndegruchy - about 2 months
I wonder if you can run this in FrankenPHP.
By @withinboredom - about 2 months
Can you compile frankenphp to run php?
By @tombert - about 2 months
Your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should.

This is awesome.

By @xyst - about 2 months
This is one of those “your scientists were preoccupied with whether they could, they didn’t stop to think whether they should” type projects.

This is something you add to a project to obscure some sploit.

By @shaftoe444 - about 2 months
If we could bring in awk somehow...
By @antonvs - about 2 months
Each day we stray further from god's light
By @surfingdino - about 2 months
Ah, PHP! The grumpy old git of the programming languages (see also Jeremy Corbin and Bernie Sanders) /s
By @minkles - about 2 months
locating spoons to scoop own eyes out with

Edit: this project is the sort of thing I'd do if I had the time to :)