Hacker News new | past | comments | ask | show | jobs | submit login
Golang Interpreter Written in PHP (github.com/tuqqu)
176 points by hu3 46 days ago | hide | past | favorite | 74 comments



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.


In a similar spirit, I have started an experimental go to c++ compiler. But it's not in a usable state at the moment (no gc, imports management is not finished, some syntax are still not managed) and the code is probably quite bad as I'm not used to program in go. (The repo is here: https://github.com/Rokhan/gocpp if anyone interested).


I vaguely remember that the first version of the go compiler compiled into C.


I wonder how Go routines work in this?

They look to be supported:

https://github.com/tuqqu/go-php/blob/main/tests/Functional/f...


From the bottom of the README.md file:

> No support for real goroutines, go statements run sequentially


author here: yeah, as someone pointed out already, I could not find a way to make them async. PHP only has Fibers, and they are not sufficient for that.


The next project should be writing a Golang interpreter in JavaScript!


I vote for a JVM written in Perl.



lol


We need Erlang's BEAM interpreter done up in AWK


Horrors beyond comprehension.


Haskell in binary code, but by toggling those switches on the front panel of the machine.


In what a cave of nerds am I in here?! :-D


I vote for Delphi interpreter in 286 assembly.


That's perhaps trivial. There's a Go to JS compiler, and the go compiler itself is written in go.


This is an amusing companion to the PHP interpreter written in go (by Mark Karpeles of MtGox infamy)

https://github.com/MagicalTux/goro


I wonder how keep you can stack them before things start to break down


This seems actually useful since it's really doing transpiling!


I made some progress on a similar transpiler some years ago https://git.ivysaur.me/code.ivysaur.me/php2go but never really finished. I still have the use case. Do you know if there's any production quality transpiler?

Today you would probably involve an LLM somehow, but it's hard to trust the result.


> This is a toy project, not intended for production use.

Well, darn.


Won’t stop LLMs


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.



I've always wanted a Spanish DB query language. SQL is very boring. It needs some pizazz and somewhat more lyrical language than what we have.


SELECCIONA * DE CLIENTES CUANDO TELÉFONO SEA NULO


In the 70's there was a significant trend of translating programming languages to French - for example LSE, Pascal, Cobol, Algol... Didn't abide - we now take English for granted but reading code in my native is a strange sensation !


That's SQL with Spanish words. I think the parent meant something along the lines of: dame el nombre de cada cliente cuyo ciudad sea 'Granada' y que no tenga telefono. Anything more flowery will be hard to translate, though.


-- Suavemente, dame tus columnas, mi estrella


This database query language gives better results when you ask in a poetic and romantic manner.


The result might take all night, but you'll never forget it.


I do like that


User Story

As a socially inept geek, I would like to: whisper database queries to desirable persons and have a good chance of getting some.


Excel uses native language tokens everywhere.


That's one way to get ready for Age of Mythology: Retold's release.


finally


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


This is the opposite - Franken is PHP in Go. This one is Go in PHP.


But that doesn't even make any s... Oh, I misread the title then.


No worries, I got you :). Cheers and cya round


I thought "the right way" was to do everything in Rust :-)


The age of Rust is over. The time of “rewrite everything in php” has arrived.


_ ThePrimeagen entered the chat_


What is dead may never die!


My dream for Go, interpreted for fast reloads without compile for web development like e.g. PHP. Then compile for testing/unit testing/deployment.


Maybe not exactly what you meant...but you are not alone in your dream. Here's what i learned of: "Pushup - page-oriented web framework for Go" [https://pushup.adhoc.dev/]



Trying to make that work, thanks!


You might have just described dart/flutter.


Is there anything technical preventing Go from being like this? Besides the fact that nobody has put in the hard work to make it happen?

Not a leading question, I’m curious if there are any technical complications with fast-reload Go.


I've no idea, I just know dart has a built in JIT and AOT complier, and hot reload is, for me, a killer feature.


I'm an old man and the simplicity of Go is for me.


If you think Go is simple, I don't think you've done much with the language


Perhaps, but after 40+ years of coding I have seen many more complicated languages. But I did love https://100go.co/


I should rephrase. Go is simple, but it cuts corners which can really over complicate simple things that other languages would handle more elegantly. Struct tags are a perfect example of missing language features that require a weird post-processing step to get dynamic typing working.

100go.co is a great website! I referred to it a lot when learning go and It's my go to (pun unintended) for anyone learning the language


My brain read the title as "PHP interpreter written in Go" - I assume because such a thing -wouldn't- be an abomination...


I have never simultaneously seen something both so amazing and so horrible :) No but really, this is impressive.


I mean, Go is now finally suitable for web development with hot code reload?


Some people just want to watch the world burn


I wonder if you can run this in FrankenPHP.


I wonder if you can run FrankenPHP in this.


Can you compile frankenphp to run php?


Your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should.

This is awesome.


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.


If we could bring in awk somehow...


And then make it run Doom.


Each day we stray further from god's light


God's light is overrated.


1Ø GOTO DARKMODE


Ah, PHP! The grumpy old git of the programming languages (see also Jeremy Corbin and Bernie Sanders) /s


[flagged]


Online Go code checker?


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 :)


Looks like someone wanted to make a humorous comment? What a shame. As a hackernews user I MUST downvote. No humor allowed here.


Careful now someone might flag you! :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: