Is PureScript incompatible with MPA (i.e. usual websites)?

I know title is little baity but hear me out. This is my cry of the soul because things are bad, for reasons I’d have assumed of me doing something wrong, weren’t it for the fact that no one experienced say anything useful on the matter.

I’m not really a web-dev, I’m more of a low-level guy, though with very broad experience (web-dev unrelated). Just so happened I’m doing web-devel ATM.

One thing I can see is that SPA is typically a poor design, because user typically wouldn’t want to wait for megabytes of data just to view the front page. Most popular websites out there are MPAs, except perhaps web-apps, like draw.io. It makes sense for WEB-programming to be MPA first, and SPA be a second-class citizen. I recall this seems to be the case with PHP.

PureScript tutorials seem to be SPA-first: you create a index.js, and it contains whole world (I disregard here those that do a npm run … to start a browser, because it’s clearly debug-only. In production you’d have js or ideally html files to be fetched by the backend).

And somehow I ended up pioneering the technology that should’ve always existed! I was the first person in the recorded history to ask such basic question as “how to produce multiple outputs/pages with PureScript”. You can look up my answer there for details, but in short: PureScript support for this is basically non-existent: being done via bundle-module it depends on some hacks and requires writing a build system around build system!

Per my understanding the post was read by more than one actually experienced person, and no other commentary or answers were posted. Furthermore, my “heavy-lifting” answer got a downvote, whereas the dude’s answer that ain’t worth a cent (which is just “try using bundle-module”, doesn’t work as is as you can see by my ignored comments under, and should’ve been just a comment) somehow got an upvote, both done judging by the delay by different people. That confuses me even further. Did I do something wrong, was there a better way…? No one has commented anything :man_shrugging: The question per se was also downvoted (someone upvoted it later), despite being so important for the ecosystem.

Two weeks ago story continued with this post: I’m trying to add a JS lib and FFI is not working for me. Discussion got kinda offtopic there, but the results as of writing the words are in the first 2 comments: “Use relative paths” — “Oh, yeah, it works…! Well, not really: works for bundle-app, doesn’t for bundle-module”.

bundle-module treats JS code as ESM format, and from research I done it seems to totally make sense (i.e. it’s exactly the format that should be used). However, ESM format is very limited, meaning that you can’t FFI a random JS lib this way. But you need FFI!

I haven’t really dug into the lower-level to see if it’s possible to come up with some crazy trick. But offhand this really seem to be a fundamental incompatibility with bundle-module. And it is the 2nd serious problem for such simple basic usecase that most websites out there adhere to!

So what gives, is PureScript really just incompatbile with MPA and people are just being people, being evasive and rude? Or is there still some sacred knowledge, some dark mysterious hidden wisdom, inaccessible to uninitiated, prohibited to look upon by bystanders…?

At the moment, I think the answer is No.

Purescript is, at least at my skill level, a single page app only language. If you want that to change, you should look into helping out. Maybe figure out how to change that. I know that one prolific member of the community went over to another ecosystem. So, I can’t imagine that they have all that much help right now. I wish I could help but I wouldn’t even know where to start. I’m content to work around that limitation while I get a Deku app going.

1 Like

No problem producing the same kind of SPA/MAP with Purescript as with Typescript, workflow is primarily the same if to use the same tools (bundlers vite.js/webpack/etc). Purescript doesn’t support async imports for lazy loading by itself, but is quite easy to accomplish using js FFI modules.

1 Like

Sorry, but this reads very vague. I know very little about Typescript (except that it’s a lang with static typing worse than Python’s, ironically). I described 2 huge problems, and the 1st one may be the lack of tooling support on the PureScript side. But the second one (discussed in a separate thread) so far seems fundamentally incompatible with MPA.

I would say that PureScript is incompatible with MPA (or anything else) no more than JavaScript is.

1 Like