News for hackers. Stuff that matters.
Re:Brython: an implementation of Python 3 running in the bro... by Tade0 on Monday July 19, 2021 @04:14PM (#27886803)
> not having for instance a SQLite natively

We had this for a brief moment in the form of Web SQL, but as a rule web standards require independent implementations to be developed, and all the implementors were using SQLite under the hood. The current alternative is IndexedDB - for better or worse.

> Is the browser environment becoming more dev-friendly with the adoption of WebAssembly?

Yes, but that doesn't have much to do with WebAssembly.

JavaScript as a language evolved, we have TypeScript with its flexible and expressive type system and bundling is becoming less of a pain with each consecutive framework re-written using ES2015 modules(and loaded via e.g. Snowpack https://www.snowpack.dev/).

WebAssembly is helpful when there's a need for some heavy lifting - e.g. in software codecs, but that's still a niche application.

Re:Brython: an implementation of Python 3 running in the bro... by peterthehacker on Monday July 19, 2021 @04:55PM (#27887155)
Technologies like TypeScript are still dependencies that require transpiling to vanilla JavaScript and add to the bundle size. While typescript is becoming more and more common (for good reason) it still is effectively a workaround that compensates for the unergonomic-ness of the browser environment. You could make the same argument for frameworks like Angular, React and Vue.

If WebAssembly replaced js, then newer, more efficient browser languages could be invented. Like a new implementation of typescript could be created that is statically compiled and more efficient. All of this transpiling from x to js and y to css would be unnecessary.

Re:Brython: an implementation of Python 3 running in the bro... by bri3d on Monday July 19, 2021 @05:24PM (#27887419)
The "y to CSS" part would still be there - even with WebAssembly, your UI options are still pretty much the DOM (great for documents and form entry, not so great for applications) or canvas (too low level and loses platform consistency, accessibility, usability, really every affordance of an operating system).
Re:Brython: an implementation of Python 3 running in the bro... by UnpossibleJim on Monday July 19, 2021 @10:51PM (#27889602)
I'm going to ask an ignorant question and I'm sorry, but couldn't you basically write an application in web assembly, using OpenGL and creating whatever UI you wanted in there, and just use CSS for the scaffold? You'd only need a mobile and desktop web app, but you'd need one anyway, right? (Note.. I'm very obviously not a web developer, so forgive my naivete).
Re:Brython: an implementation of Python 3 running in the bro... by bri3d on Tuesday July 20, 2021 @11:21AM (#27894856)
That was my second option - canvas.

WebGL is a type of HTML5 canvas context. Unfortunately, there are major drawbacks which I also outlined - it's too low level and loses platform consistency, accessibility, usability, and really every affordance of an operating system - you're starting over from scratch and loading in dependencies or writing your own implementation of some immensely challenging concepts (font rendering on its own is usually several hundred kb of code and could fill textbook upon textbook).

If you're familiar with GL UI frameworks like dear-imgui, they do all work pretty well in WebAssembly. But again, they're compromised from the start because you lose all OS consistency and accessibility. And unlike in games, where these frameworks are often employed, OS consistency isn't expected, and accessibility is sadly ignored, the experience of a cross-platform UI framework appearing in a canvas element on the web becomes jarring very quickly.

There is an alternative approach, like Google Docs employs and the sibling poster linked - combining the DOM for input elements with custom rendering. But, this is really, really complex and challenging.

Every time I develop applications for the web, I yearn for an application-focused presentation layer which provides the expected fundamentals around accessibility, OS consistency, and rendering layout while ditching the hacks-on-hypertext minefield of CSS and the DOM.

Re:Brython: an implementation of Python 3 running in the bro... by hnfong on Monday July 19, 2021 @11:21PM (#27889752)
Yes. For example: https://workspaceupdates.googleblog.com/2021/05/Google-Docs-...

But it's going to be a very "heavy" custom framework that takes time to download and load. Overkill in most cases.

Re:Brython: an implementation of Python 3 running in the bro... by UnpossibleJim on Tuesday July 20, 2021 @10:37AM (#27894277)
Ok. Makes sense. Thanks =)
Re:Brython: an implementation of Python 3 running in the bro... by peterthehacker on Monday July 19, 2021 @07:46PM (#27888575)
Good point. I was thinking of changing styles via DOM, like CSS-in-JS, but you’re right that “y to CSS” would still be there.
Re:Brython: an implementation of Python 3 running in the bro... by rpmisms on Monday July 19, 2021 @07:04PM (#27888293)
If TS is eventually added to the JS standard, I would be very happy. I've only picked it up in the past few weeks, but I'm consistently amazed at how much sense it makes
Re:Brython: an implementation of Python 3 running in the bro... by runarberg on Monday July 19, 2021 @11:49PM (#27889866)
You can actually annotate typescript types using JSDoc comments. So if you don’t like the added step of compiling your source down to JavaScript you can still write JavaScript with doc comments and then typecheck with `tsc --noEmit` which won’t run the compile step.

However I do see the appeal of the ergonomic of the TypeScript syntax. I hope TC39 will add something like optional type annotations to the spec.

Re:Brython: an implementation of Python 3 running in the bro... by rpmisms on Tuesday July 20, 2021 @03:12PM (#27897922)
It could be a feature flag, like `use strict`, but `use types` instead
Re:Brython: an implementation of Python 3 running in the bro... by runarberg on Tuesday July 20, 2021 @04:58PM (#27899238)
I’m actually hoping for something more akin to python’s optional type annotations. Where opting in is as simple as using type annotations. The runtimes (i.e browsers, nodejs, etc.) would then simply ignore them like they do with comments. But third party tools could use them to do some static analysis. Like mypy does for python (or tsc --noEmit does for javascript).
Re:Brython: an implementation of Python 3 running in the bro... by rpmisms on Tuesday July 20, 2021 @06:59PM (#27900354)
It really depends on if you want enforced typing, which is why I think a feature flag could be useful. There's room for both—explicit typing being available, and enforced types being a flag away.
Re:Brython: an implementation of Python 3 running in the bro... by julienb_sea on Monday July 19, 2021 @06:28PM (#27888018)
Transpiling is more about broad browser compatibility than anything else. In any event, even if you invented some more efficient browser language, it would likely need a universal browser-compatible compilation target anyway (like web assembly). This isn't particularly a step forwards from TS compilation to JS, and the loss of all common JS libraries would be a huge drag on adoption.
Re:Brython: an implementation of Python 3 running in the bro... by uryga on Monday July 19, 2021 @07:22PM (#27888409)
> TypeScript [...] adds to the bundle size.

tbh i haven't checked, but isn't the transpilation step for typescript just stripping out the type annotations? TSC is build-time only, so it won't factor into your bundle size, and i can't imagine the generated JS is significantly bigger than source -- if anything, it should be smaller ;p

Re:Brython: an implementation of Python 3 running in the bro... by actuallyalys on Monday July 19, 2021 @10:09PM (#27889418)
For comparison, ClojureScript, another language that compiles to JavaScript, adds to the bundle size, but in my experience, it's mostly because of the runtime (core functions and data types) because the Google Closure compiler optimizes the initial transpiled JS.

I would guess running the TypeScript output through the Google Closure compiler (or adding similar optimizations directly to the TypeScript compiler) could make TypeScript bundles comparable to JavaScript bundles or smaller. It looks like people see significant improvements running TypeScript output through Closure compared to just WebPack [0].

[0]: https://medium.com/appmonet/using-closure-compilers-advanced...

Re:Brython: an implementation of Python 3 running in the bro... by peterthehacker on Monday July 19, 2021 @07:42PM (#27888544)
It definitely adds to the bundle size, but how much it adds depends on your implementation. This discussion on the topic is pretty interesting [0]. One comment from that discussion says “it is possible to double to the size of your source code”.

[0] https://dev.to/haruanm/does-typescript-increase-the-bundle-s...