Web Noob; how hard would it be to integrate julia with HTML?

So I am not a web developer. Sometimes I do web stuff at work, and a little for fun. I was doing some thinking, and a question came to mind. Why can’t Julia be a serverside web language like PHP?

Please don’t judge the pseudocode here I just quickly scrapped it together

function do_stuff_now(x)
   out.value = x*3

<form name = "form1">
<input type = "text" name = "in"/>
<input type = "button" value = "do it" onclick="do_stuff_now(form1.out.value)"/>
<input type = "text" name = "out"/>

How much of that has to happen in the browser vs how much of that has to happen serverside? If julia were to run clientside I see that as being very browser heavy and wades into politics, but, I think it would be very possible to allow the julia to run on the server instead and get the same behaviour, but, at greater cost to the host…

Server-side: I can imagine we could sort of parse html(remove ref’s to <julia>...</julia>) , get the DOM for each page. Stand up either julia microservices via post commands, or use something like Genie to host with the code baked in. Something like a “compiled” website…

Issues here would be things like security, and also, what if you had 200_000 users all executing functions. Kind of like a reverse proxy nightmare. But maybe that’s not too different from a language like PHP?

Hoping to learn something here, color me clueless,

I would suggest you split things into three parts:

  • Do you want a templating engine that intermixes Julia and HTML?
  • Do you want to build a web service or full server using Julia?
  • Do you want a DSL to generate HTML in Julia?

There’s no reason to couple those three and they all have viable strategies in Julia, although some would be far easier than others.


I think what I am most interested in would be a templating engine that intermixes Julia and HTML. Most similar to PHP. The only way I can think of that working, would be via a DSL(parsing HTML and writing off new code) and/or having the server be almost pure Julia? Is there a smarter approach? Are there discussions about this anywhere? I am likely missing good search terminology.

Never tried myself, but maybe you can do this with Genie.jl.

1 Like

I think there’s two classes of template engines:

  • Run-time templating, which evaluates all of the Julia code in the template per-request. This is the PHP model and the default model for Jinja, which is probably a good example to follow.
  • Ahead-of-time templating, which evaluates all of the Julia code in advance. This is the logic of template engines used for rendering static websites: Jinja can be used this way and there many static site generators built on top of Jinja.

Whether you need to have the server invoke Julia really depends on whether you’re committed to run-time templating.


@jbrea - you are right the idea is similar to Genie. The difference is, the intent here is to abstract away the nuances of hosting pages, and all the Genie specific stuff. So kind of like a layer above Genie.

@johnmyleswhite - thanks for this I have some reading to do. Might come back with more questions later on in the week :).