Live data from Hacker News

Pushup: a new compiler for making web apps in Go

github.com

51–60 of 121 posts

Re: Pushup: a new compiler for making web apps in Go

#51

Pushup creator here. We're interested in feedback on the design. Pushup introduces a new lightweight template syntax that mixes Go code and HTML in the same page; pages are then compiled down to pure Go, relying on the net/http package. Pushup uses file-based routing, so adding a page adds a route to your app. The template language has an "inline partials" feature to make it easier support for modern hypermedia libra…

This looks really good. I like the compilation to a single binary. I'm already using Htmx with Flask for routing/templating. File based routing with a page as the unit of functionality sit well with me. The use of caret to denote Go code is quite clean, but given well formed HTML, could the parser detect anything not inside HTML tags as Go code and thus remove the need for a caret outside of HTML. I will be trying th…

Love this idea. And I’ve been looking for something exactly like Pushup. Really excited to try it out.

Re: Pushup: a new compiler for making web apps in Go

#52

Earlier quoted context omitted.

One counterpoint is React is doing gangbusters right now and uses the JSX syntax extension to embed HTML directly into JavaScript or TypeScript. To my money, the main issues with PHP had little to do with template embedding and everything to do with Perl being a messy language for writing correct code (coupled with too many people in the era underestimating the importance of "correctness" for HTML rendering when the…

Are you equating PHP and Perl? If so, that's incorrect - the relationship between the two is just one of influence, PHP has some influences from Perl (but also tons from C, C++, and Java).

To be fair, you haven't exactly augmented the single-element list [Perl] with a host of languages that I'd consider improvements on writing correct code. ;)

Java, yes, mostly.

Re: Pushup: a new compiler for making web apps in Go

#53
post #26
post #9

Earlier quoted context omitted.

I’m Finnish. The caret is not always easy to type in my experience on international keyboards. Not sure what the added value is of creating yet another convention here, as there are so many already with each new templating language.

Oh yes it's pretty hard to type on a German keyboard as well. In most editors you will need two keystrokes.

But don't you need 4 keystrokes for the common alternative, {} enclosed template expressions? Same as french, nordic, and probably lots of other european intl layouts.

(Or even better against the {{ }} ones requiring 6)

Re: Pushup: a new compiler for making web apps in Go

#55
post #6

It's a nice idea. I'm going to dig a little deeper in the design and developer experience choices. That being said, I am a little curious -- what is the intended use case here? The reason I am asking is because I've been doing lots of web-development, with Go as a primary backend lang, for the last 9 years but never have I seriously felt the need to do serve the UI from Go. I guess there is some advantage reducing n…

The imagined use-case for Pushup is the same niche that Rails, Django, and Flask apps occupy, which is a wide range but broadly I would describe as page-oriented, HTML-first, server-side frontends. I started Pushup because I asked myself, I like programming in Go and think (like you) it's great for web backends - but what is holding it back from being a great full-stack web dev language or environment? net/http is a…

First off @paulsmith, thanks for creating Pushup! I've been meaning to learn Go, and in particular in web context...and I've always been a fan of the "mildly dynamic" approach to web sites, web apps. So, I will certainly dive in. Secondly, thank you for sharing that article that inspired you. I kept nodding along so much while reading that article, it was like i was a bobblehead! I don't code much over the last decade or more, but when i do (for web anyway), i almost always employ php in the "mildly dynamic" method...Because its easy and solves needs that come up. Thanks again!!

Re: Pushup: a new compiler for making web apps in Go

#56

This looks really promising — at first blush, I like this a lot more than normal Go templating! That said: maybe it's just my bias as someone who primarily works with React, but I'm wondering why not just mimic JSX, which has been incredibly successful and has millions of people who already understand it. The big missing piece to me here is composability. How can I encapsulate reusable bits of markup, styles and pres…

> why not just mimic JSX

Definitely considered that. Might be worth revisiting.

> The big missing piece to me here is composability

You zeroed in on the right things ;^) I have a draft note to myself about pages-as-components. I have some ideas (basically, mimic ASP.net Razor components at the moment). Having a compiler with full control of the page makes this easier to figure out.

> without having to backtrack, since that last period is ambiguous in this grammar.

It doesn't backtrack, it just looksahead at the next token: https://github.com/adhocteam/pushup/blob/main/main.go#L3692

Re: Pushup: a new compiler for making web apps in Go

#57
post #41

Earlier quoted context omitted.

same in french. it's a dead key on our keyboard, so it's basically two keystrokes instead of one to type it. to be fair most special characters are behind AltGr on azerty, soooo...

Interestingly, there's no such problem on Cyrillic keyboards despite being a totally different alphabet. We only need to switch the current layout to English which is what we do all the time anyway.

Not despite, because. You need to switch to type in any other alphabet, so you switch to English. German, French keyboards work perfectly well for English, it’s just that the symbols are not as easy to reach.

Personally, I use and love EurKEY [0] as I rarely type in German anyway and rather optimize for coding.

[0]: https://eurkey.steffen.bruentjen.eu/

Re: Pushup: a new compiler for making web apps in Go

#58

So basically PHP, but in Go? I love Go, but I honestly hope this doesn't become as widespread as PHP. There is a reason why we switched away from template-based frontends (à la PHP). On the other side, it's also true that some frontend frameworks are partially moving back to SSR...

One counterpoint is React is doing gangbusters right now and uses the JSX syntax extension to embed HTML directly into JavaScript or TypeScript. To my money, the main issues with PHP had little to do with template embedding and everything to do with Perl being a messy language for writing correct code (coupled with too many people in the era underestimating the importance of "correctness" for HTML rendering when the…

There's a difference though. JSX embeds html into strings while the way Php intermingles html and code uses global buffers. That makes composition more complicated since you have to deal with nested buffers, flushing, cleaning, etc. I really prefer the way JSX does it over Php's.

Re: Pushup: a new compiler for making web apps in Go

#60
post #27

Pushup creator here. We're interested in feedback on the design. Pushup introduces a new lightweight template syntax that mixes Go code and HTML in the same page; pages are then compiled down to pure Go, relying on the net/http package. Pushup uses file-based routing, so adding a page adds a route to your app. The template language has an "inline partials" feature to make it easier support for modern hypermedia libra…

"Pushup uses file-based routing, so adding a page adds a route to your app." Make sure to have a clean way of escaping that and having some richer concept of how to route. This was the original way routing worked, back in the ASP (not ASP.net, the predecessor), CGI, original PHP days. We moved away from it for good reasons. It works well early but has scaling problems over time. I'm not saying don't have it as a defa…

> If you throw away the ability to have middleware on specific routes you've really caused a big problem. The Go ecosystem is fairly dependent on that.

Agreed! Pushup pages compile down to structs that implement http.ServeHTTP. And an entire Pushup app is just a http.ServeMux too. So it should be trivial to insert middleware (although there isn't Pushup syntax for that yet), and/or embed a Pushup app in a larger Go app (this is quite possible today).

Post reply on HN