Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Vanadium posted:

if you want a non-js-based bytecode, why arent you just shipping java applets

not invented here! :mad:

Adbot
ADBOT LOVES YOU

Max Facetime
Apr 18, 2009

prisoner of waffles posted:

If that's the problem, why is this bizarro AST-building exercise the solution?

it’s like step 1 of the solution. when you have a lot of existing JavaScript code and you are deploying your code to browser, you have to make use of the js runtime environment

step 1 is to reduce the amount of JavaScript source code that you are shipping to the minimum amount possible

step 2 is to realize there’s a huge amount of JavaScript ast still being used and working to reduce it. this is straightforward if you’re already using WebAssembly for generating the ast. you are structuring your ast into snippets which are like higher level APIs defined in terms of the js runtime. you are also talking with the browser vendors to make sure these snippets get optimized to match the speed of native function calls in C

step 3 is to consolidate the remaining JavaScript source code and infrastructure for generation of the JavaScript ast, and based on these standardize JavaScript Runtimes for the Web. JavaScript itself becomes just another of these runtimes

step 4 is web developers of today lamenting how in their youth we used angular libraries to react to functional programming and we drat well liked it. both ways

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Vanadium posted:

if you want a non-js-based bytecode, why arent you just shipping java applets

because no one wants to click through 10 security and deprecation dialogs just to use your site

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Max Facetime posted:

step 2 is to realize there’s a huge amount of JavaScript ast still being used and working to reduce it. this is straightforward if you’re already using WebAssembly for generating the ast. you are structuring your ast into snippets which are like higher level APIs defined in terms of the js runtime. you are also talking with the browser vendors to make sure these snippets get optimized to match the speed of native function calls in C

i still think you have no idea what an ast is.

Max Facetime posted:

step 3 is to consolidate the remaining JavaScript source code and infrastructure for generation of the JavaScript ast, and based on these standardize JavaScript Runtimes for the Web. JavaScript itself becomes just another of these runtimes

what on earth are you talking about

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
let me make it very clear for you what this proposal is.

today's compiler: text javascript -> in-memory ast -> bytecode codegen -> (hot path) jit native optimization -> (hot path) jit optimization path
binary ast compiler: serialized binast -> in-memory ast -> bytecode codegen -> (hot path) jit native codegen -> (hot path) jit optimization path

you might notice the only thing that changes is the "text javascript -> in-memory ast". parsing is a non-trivial amount of initial execution latency. if we could somehow do codegen directly from "ast snippets" that would be as fast as function calls, we would, but the other passes are there for a reason and post-ast.

that's also a rough flow of v8 which i know is missing a ton. other engines may differ.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

eschaton posted:

sorry, I don’t pay all that much attention to what new ways web “developers” are coming up with to gently caress users

but looking at the “binary encoding” description it looks like a reasonable transliteration of WebAssembly to a linkable bytecode format so one can write a VM to directly execute it

now they need to entirely divorce it from all of JavaScript and HTML

did you type this response in ms word or something because it has that dumb smart quote thing

perhaps you would enjoy my article on webassembly which hopefully gives an approachable understanding of WebAssembly and also started the current discussion

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
nah, I’m good, I work on real software not web pages

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Suspicious Dish posted:

let me make it very clear for you what this proposal is.

today's compiler: text javascript -> in-memory ast -> bytecode codegen -> (hot path) jit native optimization -> (hot path) jit optimization path
binary ast compiler: serialized binast -> in-memory ast -> bytecode codegen -> (hot path) jit native codegen -> (hot path) jit optimization path

so bytecode codegen happens on a build server somewhere and the bytecode packages are downloaded to the client system, right?

because if so congratulations JavaScript you invented Java applets but even shittier

and if not lol that’s even worse

just build real native applications using real languages people and let Brendan Eich’s abomination die in peace

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

they're not bytecode

they're a serialized AST

cinci zoo sniper
Mar 15, 2013




im slowly turning javascript over this debate

Dylan16807
May 12, 2010

eschaton posted:

so bytecode codegen happens on a build server somewhere and the bytecode packages are downloaded to the client system, right?

because if so congratulations JavaScript you invented Java applets but even shittier

and if not lol that’s even worse

just build real native applications using real languages people and let Brendan Eich’s abomination die in peace

there are so many differences between Javascript and Java applets

whether it's delivered as minified source or bytecode is one of the least important

it only affects loading time, and this is a situation where JavaScript loses

Max Facetime
Apr 18, 2009

Suspicious Dish posted:

let me make it very clear for you what this proposal is.

today's compiler: text javascript -> in-memory ast -> bytecode codegen -> (hot path) jit native optimization -> (hot path) jit optimization path
binary ast compiler: serialized binast -> in-memory ast -> bytecode codegen -> (hot path) jit native codegen -> (hot path) jit optimization path

you might notice the only thing that changes is the "text javascript -> in-memory ast". parsing is a non-trivial amount of initial execution latency. if we could somehow do codegen directly from "ast snippets" that would be as fast as function calls, we would, but the other passes are there for a reason and post-ast.

that's also a rough flow of v8 which i know is missing a ton. other engines may differ.

okay, look, you seem like a reasonably smart person, so let me just float something by you real quick-like, right? okay, so, what if, and please bear with me here but, what if, instead of “serialized binast -> in-memory ast”, you instead did “WebAssembly code+data -> in-memory ast”? I know, I know, that’s completely crazy and something only a very, very stupid person would actually even think about doing, but you could, theoretically, do that, right?

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

Max Facetime posted:

okay, look, you seem like a reasonably smart person, so let me just float something by you real quick-like, right? okay, so, what if, and please bear with me here but, what if, instead of “serialized binast -> in-memory ast”, you instead did “WebAssembly code+data -> in-memory ast”? I know, I know, that’s completely crazy and something only a very, very stupid person would actually even think about doing, but you could, theoretically, do that, right?

what is the advantage that this provides

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



idgi

just define a vm with memory/register layout, calling convention, etc + a set of function headers for browser/dom hooks

then whoever can make an app to compile 10 print "penus"; goto 10 and make it work

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Max Facetime posted:

okay, look, you seem like a reasonably smart person, so let me just float something by you real quick-like, right? okay, so, what if, and please bear with me here but, what if, instead of “serialized binast -> in-memory ast”, you instead did “WebAssembly code+data -> in-memory ast”? I know, I know, that’s completely crazy and something only a very, very stupid person would actually even think about doing, but you could, theoretically, do that, right?

1. parsing needs to be secure and you don't want your parsing code to be attacker-provided. like, webassembly doesn't let you poke into browser internals or anything like that.
2. obviously, in-memory ast is going to differ between js engines, meaning you'd have to have some standard which would be parsed into the actual in-memory ast used by the js engine. so it's actually "WebAssembly code+data -> in-memory standardized binast -> in-memory engine-specific ast" and still would have a parsing/validation step.
3. if you have a way of instantiating binast, as the proposal suggests, you can already do "WebAssembly code+data -> serialized binast -> in-memory ast".
4. why would you do this

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
then they wouldn’t be able to even pretend it’s JavaScript any more which might make some web “developers” sad despite making the world overall better

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.
sorry m8 still sounds like a half-baked solution in search of a problem

prisoner of waffles posted:

PL thread: WASM binary AST *airhorn* faaaaaaart

Soricidus
Oct 21, 2010
freedom-hating statist shill
wasm is a really bad control layout

Notorious b.s.d.
Jan 25, 2003

by Reene

carry on then posted:

because no one wants to click through 10 security and deprecation dialogs just to use your site

the original intended role for java applets was what sun demoed in their "hotjava" browser

with a single jvm that ran all applets in isolated app domains, applets were low-overhead. you could run 100+ applets on a single page. use applets as a substitute for animated gifs. it all worked smoothly

java was embedded into the browser itself, not a plugin. there was no reason hotjava could not have been extended to allow direct java access to the dom, for example. (except the dom didn't exist yet!)

we very nearly lived in a world where java was the default language of the web. oops.

mystes
May 31, 2006

Notorious b.s.d. posted:

the original intended role for java applets was what sun demoed in their "hotjava" browser... it all worked smoothly
I'm sure the idea was "smooth" but I seem to recall the actual browser crashing constantly. Like worse than early milestone releases of Mozilla.

skimothy milkerson
Nov 19, 2006

Soricidus posted:

and then throw it away completely and just use the jvm or .net clr like grownups

thats our shaggar! :razz:

Notorious b.s.d.
Jan 25, 2003

by Reene

mystes posted:

I'm sure the idea was "smooth" but I seem to recall the actual browser crashing constantly. Like worse than early milestone releases of Mozilla.

nah it was perfectly stable

not the best html renderer, though. it really was only a proof of concept, not a fully fledged replacement for netscape 3.0 (the cutting edge browser of its day)

mystes
May 31, 2006

I think I actually just tried the alpha version now that I think about it. I didn't realize they kept developing it for so long.

Gul Banana
Nov 28, 2003

necrotic posted:

WebAssembly is very small subset of javascript, not just "a different format".

web assembly isn't, but a javascript binary AST would be. that's why i'm saying WASM doesn't seem relevant

mystes
May 31, 2006

Gul Banana posted:

web assembly isn't, but a javascript binary AST would be. that's why i'm saying WASM doesn't seem relevant
It's not relevant because it's not JavaScript? Isn't that the whole reason people are interested in it?

Max Facetime
Apr 18, 2009

Suspicious Dish posted:

1. parsing needs to be secure and you don't want your parsing code to be attacker-provided. like, webassembly doesn't let you poke into browser internals or anything like that.

sure, I haven’t suggested it should

Suspicious Dish posted:

2. obviously, in-memory ast is going to differ between js engines, meaning you'd have to have some standard which would be parsed into the actual in-memory ast used by the js engine. so it's actually "WebAssembly code+data -> in-memory standardized binast -> in-memory engine-specific ast" and still would have a parsing/validation step.

your conclusion doesn’t follow from your premise, not even if you use the word “obviously”

what you’re suggesting is the same as saying “we could do less parsing when manipulating the DOM if instead of sending Strings to .innerHtml we could send arrays of bytes to a new .innerBinHTML api”

I mean, technically you would, but is that really the best api you can come up with?

Suspicious Dish posted:

3. if you have a way of instantiating binast, as the proposal suggests, you can already do "WebAssembly code+data -> serialized binast -> in-memory ast".

but that’s a garbage api and nobody cares about yet another file format

so I guess chrome has already implemented it and there’s gonna be a polyfill for IE6 on MDN next week

Suspicious Dish posted:

4. why would you do this

obviously the cure for too much parsing is more parsing
   /
:ironicat:

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Max Facetime posted:

what you’re suggesting is the same as saying “we could do less parsing when manipulating the DOM if instead of sending Strings to .innerHtml we could send arrays of bytes to a new .innerBinHTML api”

I mean, technically you would, but is that really the best api you can come up with?

this is a reasonable analogy. i want to remind you that engineering is about tradeoffs. what's the advantage of using the DOM API rather than an innerBinHTML?

* well, one is that the the DOM is expected to change a lot, it's designed as a living object model. doing a full serialize/unserialize pass might be expensive. a living object model lets us do transformations on that tree a lot better.

* DOM nodes can contain any attribute, so a loose k/v dictionary is required in the mapping anyway.

* modifications of serialized data is actually destructive. I can't easily replace a DOM node in the middle and have its siblings unchanged. part of this is because the DOM has "hidden state" not serialized: the user's cursor position, selected text, scroll position -- I cannot, currently with innerHTML, assign those fields.

the same doesn't apply to JS AST.

* JS AST is designed for parse-once, not modification. the most you can possibly come up with is combining snippets of already-constructed ASTS, but we already have a method for composition: the function.

* AST nodes themselves have a formalized set of fields, meaning you can have an easier time parsing since you just have an ordered collection of fields.

* JS AST doesn't need to be living, in fact, it's more likely it will be thrown away after parse. there's also no analogous model to what happens if I change that AST after the fact, like if I modify DOM in-place.


addendum: frameworks like React limit the dynamic nature of the DOM API anyway, preferring a more functional model. that they're implemented on top of DOM API rather than innerHTML is because of limitations in innerHTML, and they might honestly be better served by an API that lets them make atomic modifications to the tree, rather than treating it as a collection of objects. perhaps we will see an innerBinHTML in the future.

one downside of the "living objects" model is that it's too easy to accidentally fall off a performance cliff with things like relayouts

Max Facetime posted:

obviously the cure for too much parsing is more parsing
   /
:ironicat:

i hope you can agree that parsing JSON is different than parsing C++ is different than parsing fixed-length binary messages. the complexity of parsing differs heavily and in fact we have very formalized theory that gives us an understanding of the complexity to parse something.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
all JavaScript parsing should be done on the developer’s build server to produce a linked binary artifact; what’s sent to the client should be bytecode rather than a “serialized AST” unless you want to stretch the definition of the latter past the breaking point

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
what advantages does a bytecode give you?

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
it can be designed for direct execution (emulation), code generation (JIT or AOT), or both, more straightforwardly than an AST

really I don’t understand why the gently caress anyone would want to send an AST instead of a compiled product

why is LLVM bitcode not just an AST? why did Sun create the JVM an MS the .NET runtime instead of just serializing ASTs? why did Smalltalk use a bytecode interpreter? why did Scheme-48 compile to bytecode instead of using an interpreter (since Scheme pretty much is an AST when represented as cons cells)?

either there’s some advantage to sending an AST instead of a compiled bytecode that nothing else has seen or maybe it’s actually not that great an idea

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
Oh are we already to the point of killing the hackable web so that another inner platform can take hold?

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
the real question here is how does wasm make browsers a more compelling and effective platform for the most important class of users

by which i obviously mean advertisers

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
how does wasm help companies ram ads straight up everyone's orifices every time they visit a web page ever

can the new dom apis be designed in such a way that they "accidentally" make content blockers impractical or impossible to implement perhaps

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
i propose a native advertisment api, coupled with drm, that's injected straight into the video signal.

Soricidus
Oct 21, 2010
freedom-hating statist shill
say “mcdonalds” to load next post

comedyblissoption
Mar 15, 2006

Internet Janitor posted:

how does wasm help companies ram ads straight up everyone's orifices every time they visit a web page ever

can the new dom apis be designed in such a way that they "accidentally" make content blockers impractical or impossible to implement perhaps
capitalism was a mistake

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
you don’t need to run code to format the information presented on a web page, so browsers don’t actually need the ability to download and run code

even for input validation you could just provide a predicate/expression language where validation predicates with well defined semantics can be attached to input fields, just like styles can be attached to presentation, and not have to worry about arbitrary code execution

Soricidus
Oct 21, 2010
freedom-hating statist shill
no you see there are very good reasons why I need to implement my own email address validation instead of just having it built into the browser

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

Maybe, maybe not, but the genie's out of the bottle.

Adbot
ADBOT LOVES YOU

HoboMan
Nov 4, 2010

seems bad, op

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply