Live data from Hacker News

Back-end languages are coming to the front-end

github.com

311–320 of 328 posts

Re: Back-end languages are coming to the front-end

#311
I'd love to see this approach make more headway in the Django community. Based on the last DjangoCon it seems like the community is coalescing around HTMX.

This tool does play very nicely with Django's templating engine; you can just have HTMX re-render a particular template block on the server, and send down that updated block. The migration path is quite clean; you just wrap your "HTMX-updated" template block in a `hx-post` div.

Having not gone too deep on HTMX, I'm interested in folks' thoughts on where it's lacking vs. LiveView and Hotwire. One area I can see is performance; Elixir is going to be faster than Django, and so if you're trying to handle high session counts over websockets. But the impression I get is that HTMX is a bit more light-weight, so I'm wondering if there's usecases that can't be met with it vs. LiveView.

Other Django libraries that haven't quite seen as much uptake:

We have https://github.com/edelvalle/reactor, and a port of Hotwire: https://github.com/hotwire-django but both of these don't seem to have much adoption (yet!).

Re: Back-end languages are coming to the front-end

#312
post #284
post #245

Earlier quoted context omitted.

I'm legitimately curious what that person expects out of documentation. MDN has basically everything you could want. Simple explanation, examples in an an editor that can be played with and executed, argument names and explanations, browser compatibility, etc etc etc Compared to the amount of languages where their documentation is a table auto-generated from code, it's everything I could dream of!

MDN documentation and Sqlite documentation stand out to me as some of the best around. The Cloudflare how-tos would be up there, if you stretch the definition of documentation

Tailwind CSS also has super nice documentation. Really quick omnisearch, and covers basically everything in-depth with good examples, and what CSS is generated from each class.

Re: Back-end languages are coming to the front-end

#313

I'm surprised this wasn't about WASM. Either way, I'm receptive to the "LiveView" model, but until such a time a server can deliver both HTML and server driven native UI for mobile interchangeably, I prefer the RPC approach. I don't want to develop: 1. Both an API for mobile and LiveView for web. OR 2. Create my own server driven UI paradigm for mobile. I find maintaining one architectural pattern simpler. I do want…

I am currently developing sites with Django and DRF, where the client requests what format it wants and the server sends it in the format of the clients choice- a browser would request HTML, in which case the server sends HTML- using htmx. A mobile app might request JSON, or XML or CSV or any other supported format. No need to develop a separate API for web and mobile- its all the same API. DRF makes it very easy. No…

Your app can certainly request whatever data in whatever format from whatever server it wants. Making substantial changes to the app's functionality using this channel is disallowed.

Re: Back-end languages are coming to the front-end

#314
post #245

Earlier quoted context omitted.

I'm legitimately curious what that person expects out of documentation. MDN has basically everything you could want. Simple explanation, examples in an an editor that can be played with and executed, argument names and explanations, browser compatibility, etc etc etc Compared to the amount of languages where their documentation is a table auto-generated from code, it's everything I could dream of!

> I'm legitimately curious what that person expects out of documentation. MDN has basically everything you could want. w3schools style "Let me walk you through every step of the process" probably. It has it's place, I know I've found it useful in the past, but definitely not a place you want to stay in very long.

Maybe, but I think MDN would be even more helpful for beginners. Compare the documentation for JavaScript's Math.pow() on each:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

https://www.w3schools.com/jsref/jsref_pow.asp

W3 doesn't have much in terms of English explanation, has less examples, and their playground forwards you to another page as opposed to MDN where it's embedded.

Re: Back-end languages are coming to the front-end

#315

Earlier quoted context omitted.

> I realized just how disconnected JavaScript developers—yes, the "big boys" are especially off in CS la-la land—were from web development fundamentals. HTTP distilled down to its absolute essence is brilliant, but for some reason gets absolutely ignored in the JS world. Can you please elaborate what these areas of disconnect are? I looked at Joystick documentation hoping to find more of your thoughts this topic, but…

I've tried writing a response to you a few times but realizing how complex it is—the real answer to your question is worthy of a long blog post. The core problem is the blurring of the lines between a framework and the underlying technologies of the web (HTML, CSS, and JavaScript). To me, it seemed like a lot of unnecessary complexity was being added just to achieve the common goal of rendering some HTML, styling it…

For those looking for the elaboration on the above, I've written one here: https://cheatcode.co/meta/the-joystick-story-how-what-and-wh...

Re: Back-end languages are coming to the front-end

#316
post #203
post #71

I remember JSF (Java Server Faces) and GWT (Google Web Toolkit). Both burned in flames. JSF: main idea is to abstract away boundary between server and client. Turns out -- you really want to know where that thing is running -- on the server or on the client. So it turned into a fight against that main idea of JSF. GWT: main idea is to forget JavaScript/DOM and write pure Java. Turns out -- you really need to know Jav…

Also Vaadin which sort of combines two approaches and these days even allows you to go Java-only or Javascript-only. The company is still alive and well so I assume it's popular for internal enterprise apps.

Vaadin does a good job, but if you adopt it as for your product, the problem is finding people who know how to use it.

Re: Back-end languages are coming to the front-end

#317
post #280
post #232

Earlier quoted context omitted.

I don't buy that. If you squint a bit, Lua and Javascript are basically the same language. Lua shares many of javascript's peculiarities and warts (strings you can do arithmetic on, all numbers are doubles (originally), arrays are objects are hashtables of sorts, global scope by default etc). Now it's of course true that Lua is less of a mess than javascript, but a) the complexity explosion of javascript postdates V8…

No offence, but have you written any compilers or interpreters? The points that you discuss (all numbers are doubles, strings have arithmetic methods) may be performance concerns for application developers , but they have very little to do with the optimisations you can make as a compiler/interpreter writer. The only one that's somewhat relevant is 'global scope by default', but this doesn't touch the surface of the…

> No offence, but have you written any compilers or interpreters?

I have, but nothing sophisticated.

> The points that you discuss [...] may be performance concerns for application developers [...] but they have very little to do with the optimisations you can make as a compiler/interpreter writer. [...] The only one that's somewhat relevant is 'global scope by default'

I didn't mean to imply that these where the three common traits that make both Javascript and Lua particularly hard to optimize, I just picked them as examples for how Javascript and Lua are closer to each other than most other dynamic languages.

But let's dig in a bit on your claim that things like all numbers being doubles or having a array cum map cum record type has very little to do with the optimizations you can make as a compiler/interpreter writer, because it sure seems to me that LuaJIT and V8 do a bunch of optimizations around these things. Both have dual number representations under the hood and will try to avoid representing numbers that remain in the domain of 32 bit integers as double values internally when that gives performance gains. The logic for figuring out if that's the case doesn't seem to be super-straightforward or target architecture independent from looking at the comments in https://github.com/LuaDist/luajit/blob/master/src/lj_opt_nar...>.

LuaJIT furthermore uses NaN tagging (as do some JS engines, although not V8), which looks less attractive to me as a representation strategy if your numbers are not all/mostly notional doubles (as is indeed the case in newer version of Lua where 64bit integers are the dominant number type). Do you disagree?

Also, as far as the super-flexible lua tables are concerned, I'm pretty sure LuaJIT goes through some amount of trouble to specialize various common use cases of tables, e.g. as arrays without holes, and surprise, so does V8 (https://v8.dev/blog/fast-properties#elements-or-array-indexe...). I don't think you'd find something equivalent in a high performance scheme implementation.

> but this doesn't touch the surface of the issues that make JS hard to optimise, such as the fact that your, say, memoisation of an object property or method may be broken by an `eval` call of an arbitrary runtime value somewhere else in the code (which, due to asynchronicity, could take place at more or less any time from the point of view of your given 'peephole').

Eval belongs to a core set of features that basically all popular dynamic languages share that presents headaches for high performance implementations. How is Javascript's eval particularly problematic in this regard, and specifically much more so than Lua's loadstring/load?

More generally what do you think makes (pre-ES6) javascript significantly harder to optimize than lua 5.0?

Re: Back-end languages are coming to the front-end

#318

Earlier quoted context omitted.

> 2) If there's a form input at each step, the server needs to store that info and be aware that the user has an incomplete checkout. Now the user is at step=2 and presses the back button, or clicks on the step=1 link. In that case, the server should know the information stored in the point no. 2 above, and return an HTML form with the data pre-filled based on the last state. The problem is that when you press back b…

I see... What about using hx-trigger="load" for the form? Maybe that makes the browser reload it even after hitting the back button? (Sorry I can't check this right now, just a random idea). Edit: I quickly tried it (mixing hx-from="#some-other-element" and hx-trigger="revealed", and it seems to be doing the request, but I haven't looked a lot.

Ok, so turns out default chrome/firefox on windows/android were not issuing the history refresh request on back button click. Turns out you need to add some additional config to make that happen. It's now working, and it's excellent.

Set htmx to not cache prior pages by setting `htmx.config.historyCacheSize = 0` in window.onload.

Also set the http caching header `cache-control: no-cache`

Re: Back-end languages are coming to the front-end

#319
post #272

Earlier quoted context omitted.

Isn't front end software almost defined by latency sensitivity, though? It seems that after logical correctness, there's nothing more important for user experience than bounded and low latency.

FE can tolerate 10-20 ms of timer slosh, unlike e.g. audio synthesis.

120Hz+ screens are becoming common place. For the first time in decades, this guidance is no longer true -- it's reasonable to design for a frame or so of fixed latency, but to avoid jitter the latency should really be bounded within 8 ms these days.

Re: Back-end languages are coming to the front-end

#320
post #226

Earlier quoted context omitted.

Not really... Groovy was never really in the building and is just awful. Scala is like a reimagining of the building that happened to find the old foundation useful. Clojure is like a skybridge from the Lisp skyscraper across the way. Kotlin is the only JVM language that's gained traction while aiming to be Java but better, the rest just happen to use the JVM, but calling them "evolutions" of Java would be deeply mis…

It gained traction on Android thanks to Google pushing it over their creptic Java implementation, while pretending anything beyond Java 8 never happened. It will follow the path of every other JVM guest language. I will care when the JVM gets a single line of Kotlin commit. Google should just buy JetBrains and rename ART into KVM.

This is being too charitable to Java imo, after all we had stuff like Retrolambda at the time.

Kotlin exists because Java moved like molasses for years

If Java had moved like C# it'd be a much nicer language today, and Kotlin wouldn't be needed.

Even comparing Kotlin 1.0 to today's Java nearly 6 years later would favor Kotlin for ergonomics with stdlib, nullability, reified generics, and syntax

Post reply on HN