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
Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Yeah, you have to read the docs before you can just start throwing them into your code all willy-nilly.

AFAIK, there's no hidden gotcha's. I'ts just that you have to use them like the docs tell you to use them.

Of course, you wouldn't think that if you just saw the syntax because, for better or worse, they look like regular ole' functions that you can just slap into your code wherever.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

That reminds me of something I came across yesterday.

https://wattenberger.com/blog/react-hooks

It's a good article, but really I just thought the UI she has for code diffs is neat. Particularly when you hover the mouse over the...lines(?)...between the code blocks on each side showing the diffs.

tankadillo
Aug 15, 2006

99% of hooks gotchas are prevented by just using the ESLint plugin with rules for them. Create-React-App is even configured to fail to build if they raise any errors.

The Fool
Oct 16, 2003


Thermopyle posted:

It's a good article, but really I just thought the UI she has for code diffs is neat. Particularly when you hover the mouse over the...lines(?)...between the code blocks on each side showing the diffs.

That does look super cool and the best that I can tell is that she is using prism+d3 to do it. Would have never occurred to me.

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop

MrMoo posted:

Does anyone know how to properly implement a texture atlas in modern THREE.js that uses geometry based UVs instead of hacking offset/repeat in the texture and cloning it's UUID? The latter now results in multiple texture uploads to the GPU.

I'm after a Sprite and PlaneGeometry based Mesh detail for a texture atlas and anything to do with UVs is confusing the hell out of me. I can see THREE.js examples for Minecraft have a texture atlas for BoxGeometry but that doesn't easily translate.

I've managed various messed up results, didn't save the really odd ones with trippy random dots and odd angles.






demo

It's supposed to look like this:



I don't know anything about texture altases or the fancy uses of texture buffers that are common, but don't these screenshots just make it look like a much simpler issue of common mistakes when plugging in the numbers for texture coordinates? Such as U and V being swapped or the wrong sign?

MrMoo
Sep 14, 2000

I fixed it by manually testing every combination of {0, 1} UV values, :lol: It ended up with some unused values, or at least with no effect on the output. I guess the vertex order used within THREEjs for a PlaneGeometry doesn’t match what anyone else normally uses.

WebGL is still making GBS threads it’s pants on performance though. At least the Chromium Team are pushing through daily updates for OffscreenCanvas. Performance in a WebWorker is more reliable.

I’m down to 10 GL calls a frame, I’ve been reading on how to get this down to 1, but that looks a bit tedious, grouping the meshes by material. Some of the THREEjs demos on their home page I assume do this to achieve the low GL call rate. FYI: you can debug the JavaScript and view renderer.info.render to see basic GL API stats.

MrMoo fucked around with this message at 14:45 on Oct 1, 2019

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.

The Fool posted:

That does look super cool and the best that I can tell is that she is using prism+d3 to do it. Would have never occurred to me.

she's got perfectly good source maps being served up, you can go and look at it.

as an enthusiast of web technology, I really don't love JSXing all the things. the individual blog posts are React components and... I mean, it's very very nice and it works pretty darn well but...

Ola
Jul 19, 2004

prisoner of waffles posted:

she's got perfectly good source maps being served up, you can go and look at it.

as an enthusiast of web technology, I really don't love JSXing all the things. the individual blog posts are React components and... I mean, it's very very nice and it works pretty darn well but...

Agree with this. It works very well, but it's not ... nice.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Ola posted:

Agree with this. It works very well, but it's not ... nice.

Wait, you say you agree, and then say its not nice, but the person you're quoting said it's very, very nice!


But anyway...

prisoner of waffles posted:

she's got perfectly good source maps being served up, you can go and look at it.

as an enthusiast of web technology, I really don't love JSXing all the things. the individual blog posts are React components and... I mean, it's very very nice and it works pretty darn well but...

How would you do it?

Ola
Jul 19, 2004

Thermopyle posted:

Wait, you say you agree, and then say its not nice, but the person you're quoting said it's very, very nice!



Seems there was a state lost in some reducer there.

e: To be serious, React works drat well when you use it, but I don't like how it is to read and work with. It just seems so far removed from what is actually taking place in the browser window.

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.
the end result is nice, but the guts are rather opaque. I'm not saying that the finished result isn't nice, but that I don't care for the implementation technology.

why?
1. transpilation makes things opaque. she didn't have to serve up source maps and the input source and many (especially many companies) don't.
2. transpilation steps make it harder to reproduce a workflow and/or keep a workflow working.
3. JSX, aka "might as well be everything in JS", means that certain types of basically static information (styling, document structure) get stuck in the middle of a general purpose scripting language. usually when there's a functional division of concerns and appropriate languages per concern it's best to use the weakest language that fulfills your needs for each concern, lest The Script Get Complicated And Hairy.

I know that this is not a novel take or especially insightful.

Suspicious Dish
Sep 24, 2011

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

MrMoo posted:

I fixed it by manually testing every combination of {0, 1} UV values, :lol: It ended up with some unused values, or at least with no effect on the output. I guess the vertex order used within THREEjs for a PlaneGeometry doesn’t match what anyone else normally uses.

WebGL is still making GBS threads it’s pants on performance though. At least the Chromium Team are pushing through daily updates for OffscreenCanvas. Performance in a WebWorker is more reliable.

I’m down to 10 GL calls a frame, I’ve been reading on how to get this down to 1, but that looks a bit tedious, grouping the meshes by material. Some of the THREEjs demos on their home page I assume do this to achieve the low GL call rate. FYI: you can debug the JavaScript and view renderer.info.render to see basic GL API stats.

You should be able to do more than 10 GL calls a frame -- I can push up to around 5000 draw calls a frame at 60fps, so something sounds very off to me. Are you on SwiftShader or something?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

prisoner of waffles posted:

the end result is nice, but the guts are rather opaque. I'm not saying that the finished result isn't nice, but that I don't care for the implementation technology.

why?
1. transpilation makes things opaque. she didn't have to serve up source maps and the input source and many (especially many companies) don't.
2. transpilation steps make it harder to reproduce a workflow and/or keep a workflow working.
3. JSX, aka "might as well be everything in JS", means that certain types of basically static information (styling, document structure) get stuck in the middle of a general purpose scripting language. usually when there's a functional division of concerns and appropriate languages per concern it's best to use the weakest language that fulfills your needs for each concern, lest The Script Get Complicated And Hairy.

I know that this is not a novel take or especially insightful.

Oh, ok. I thought you were specifically calling out using React components or JSX, but I think I now understand that your critique is the same whether it's React/Angular/Vue/whatever.

(FWIW, I don't exactly disagree or agree, but I see where you're coming from now.)

Roadie
Jun 30, 2013

prisoner of waffles posted:

3. JSX, aka "might as well be everything in JS", means that certain types of basically static information (styling, document structure) get stuck in the middle of a general purpose scripting language. usually when there's a functional division of concerns and appropriate languages per concern it's best to use the weakest language that fulfills your needs for each concern, lest The Script Get Complicated And Hairy.

Counterpoint here: using separate CSS and tag definitions for components (whether it's React or whatever else) loving sucks because CSS is awful.

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.
i am semi-unqualified to speak and a semi-hypocrite here because 1. i've never had to do real heavy lifting in CSS 2. I actually liked using google closure compiler (via plovr) 3. next time I get a chance to do a hobby project I'm probably going to use typescript (one hypocrisy strike against me for transpilation) and native web components (actually consonant with the previously-expressed values).

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Typescript is good for client side, since you still have to compile that either way, and Typescript's is the best compiler I've used. Unless you're using Typescript and Babel in which case you're just another one of those people that thinks it's totally ok to use every single toolset at the same time.

The Fool
Oct 16, 2003


Babel is kind of a requirement to do typescript and react.

MrMoo
Sep 14, 2000

The Fool posted:

Babel is kind of a requirement to do typescript and react.

That doesn’t make sense, Babel is a subset of TypeScript functionality. How else would it work? You compile TypeScript/ES9 or whatever to ES6 then transpile to ES5 in Babel?

The Fool
Oct 16, 2003


MrMoo posted:

That doesn’t make sense, Babel is a subset of TypeScript functionality. How else would it work? You compile TypeScript/ES9 or whatever to ES6 then transpile to ES5 in Babel?

It's entirely possible that I am missing something or things have changed since I did this, but as of a year ago when I was first looking at typescript, literally every write-up I could find had you using webpack+babel to get react+typescript up and running.

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop
I don't use a compiler for client side stuff

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



The Fool posted:

It's entirely possible that I am missing something or things have changed since I did this, but as of a year ago when I was first looking at typescript, literally every write-up I could find had you using webpack+babel to get react+typescript up and running.

Looking at http://www.typescriptlang.org/docs/handbook/react-&-webpack.html, it sure looks like tsc can handle JSX now, which surprises me, too.

e: no, I didn't look hard enough before I posted - webpack-cli brings Babel in

Munkeymon fucked around with this message at 17:03 on Oct 3, 2019

Roadie
Jun 30, 2013
The reason to use Babel with Typescript is so that your code doesn't explode in browsers as soon as you want to use a library exclusively written in ES6/ES7/whatever.

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop
Does Typescript preclude you from taking advantage of ES6 features? Holy poo poo

necrotic
Aug 2, 2005
I owe my brother big time for this!
No, browsers can though.

Roadie
Jun 30, 2013

Dumb Lowtax posted:

Does Typescript preclude you from taking advantage of ES6 features? Holy poo poo

No, but it doesn't compile non-Typescript things.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Roadie posted:

No, but it doesn't compile non-Typescript things.

Last I checked TS is a strict superset of JS, so it'll handle any valid JS, but not React's JSX. Or were you thinking of, I dunno, CoffeeScript?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dumb Lowtax posted:

Does Typescript preclude you from taking advantage of ES6 features? Holy poo poo


Munkeymon posted:

Last I checked TS is a strict superset of JS, so it'll handle any valid JS, but not React's JSX. Or were you thinking of, I dunno, CoffeeScript?


Not all browsers support all ES6+ features.

TS doesn't handle transpiling such features, babel does.

When they hit approved status there's a few ES2019 proposals I'm using ASAP.

Pipeline operator and optional chaining are high on my list of features that will greatly improve my day to day developer life and Typescript won't help at all during the probably years long wait between the features being accepted and browsers actually implementing said features.

edit: Oh BTW, typescript does compile React JSX without the need for babel.

Thermopyle fucked around with this message at 20:45 on Oct 3, 2019

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop
I hate the idea of needing compilation and source maps just to use the built-in official syntax of JavaScript. ES6 stuff is more readable and has been the standard since 2015, so why can't whichever browsers that are so far behind get forced into niche usage territory at this point? Sounds better than adding a whole extra layer of abstraction in code execution, just to be inclusive toward those users. What's the most major ES6 feature that's still unsupported on a very commonly used browser?

skul-gun
Dec 24, 2001
I got this account for Xmas.

Dumb Lowtax posted:

ES6 stuff is more readable and has been the standard since 2015, so why can't whichever browsers that are so far behind get forced into niche usage territory at this point? Sounds better than adding a whole extra layer of abstraction in code execution, just to be inclusive toward those users.

Force how? The passage of time will take care of it eventually but browser compat is a business decision (assuming a commercial project here).

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dumb Lowtax posted:

I hate the idea of needing compilation and source maps just to use the built-in official syntax of JavaScript. ES6 stuff is more readable and has been the standard since 2015, so why can't whichever browsers that are so far behind get forced into niche usage territory at this point? Sounds better than adding a whole extra layer of abstraction in code execution, just to be inclusive toward those users. What's the most major ES6 feature that's still unsupported on a very commonly used browser?

Safari on iOS doesn't support default parameters. :/

But whatever we decide is the most major feature not widely supported is just going to be a snapshot in time as of right now. Browsers always lag behind the ES standard. When every browser in use supports every ES2016 feature, we're going to be moaning about there not being widespread support for whatever ES2017 feature.

Unless you're willing to be hamstrung by the whims of the browser powers that be, just throw Babel or whatever into your build process and don't worry about it again.

Unfortunately, language features are not actually decided by the ES committees, they're decided by a bunch of different browser companies and they're always changing what they make available and each is making different decisions at different times about what is available.


Like, I want to use the ES2019 proposal for optional chaining.

JavaScript code:
const  secondaryEmail = user?.profile?.emailAddresses?.secondaryEmail;
That's some hot poo poo right there. I could enable it right now with Babel if I wanted to. Generally, I try to avoid enabling proposal features and wait until they've been approved...but this is tempting.

Thermopyle fucked around with this message at 21:52 on Oct 3, 2019

MrMoo
Sep 14, 2000

Thermopyle posted:

TS doesn't handle transpiling such features, babel does.

Technically Babel doesn’t either, they just ship a pack of polyfills. You can use those with ES5 targeted TypeScript output.

I use Babel and TypeScript for different projects, certainly not together as a pipeline.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

MrMoo posted:

Technically Babel doesn’t either, they just ship a pack of polyfills.

I don't think this is right. How would they polyfill arrow functions?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Thermopyle posted:

Not all browsers support all ES6+ features.

TS doesn't handle transpiling such features, babel does.

When they hit approved status there's a few ES2019 proposals I'm using ASAP.

Pipeline operator and optional chaining are high on my list of features that will greatly improve my day to day developer life and Typescript won't help at all during the probably years long wait between the features being accepted and browsers actually implementing said features.

edit: Oh BTW, typescript does compile React JSX without the need for babel.

Isn't transpiling down to legacy browser speak what --target is for?

And, yeah, while I was looking up target, I found the JSX option. Thinkin' MrMoo was right on this one and TSC has come a long way since I last used it.

e: well poo poo :v:

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Munkeymon posted:

Isn't transpiling down to legacy browser speak what --target is for?

And, yeah, while I was looking up target, I found the JSX option. Thinkin' MrMoo was right on this one and TSC has come a long way since I last used it.

e: well poo poo :v:

I guess I should make the same disclaimer you have...I don't often revisit my project config boilerplate (it just works, I'm afraid to touch it!) so I can't say for sure what TSC does right now. So, take all of what I say with that in mind.

Anyway, the "problem" with target in the past, in this context, is two-fold. (neither of which are show-stoppers). One, it just lets you target a JS version rather than JS features*. Like, if you target ES2016, you're going to end up with code using default parameters that work everywhere except mobile safari. (if you just say gently caress it and select ES3 as your target, you end up with sub-optimal performance in different scenarios) With babel you can select the actual browsers you're targeting. Secondly, it doesn't support all ES6+ features for transpilation.

If you're using TS, you already have a build step and there's really no reason to avoid adding Babel.

If you're using Babel, try TS...types are cool and good.

If you're using neither, you're in a netherworld of features that may or may not be supported by the browsers people are using.

* You can do something like this in package.json...

JavaScript code:
{"browserslist": "cover 99.5% in US"}
// or
{"browserslist": "last 2 Chrome versions"}
// or a bunch of other selectors
{target

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
TypeScript is cool & good except for when its compiler output goes completely off the tits.

http://www.typescriptlang.org/play/...ggxQwIjJicm44kA

this only happens when using babel, because it uses the "isolatedModules" flag or some weird bullshit like that, which means that multi-file compilation isn't allowed, so it has to fall back to normal, non-const enums, which means weird poo poo happens

https://github.com/babel/babel/issues/8741

Roadie
Jun 30, 2013

MrMoo posted:

Technically Babel doesn’t either, they just ship a pack of polyfills. You can use those with ES5 targeted TypeScript output.

I use Babel and TypeScript for different projects, certainly not together as a pipeline.

You've confused Babel and core-js. core-js is a bunch of polyfills, Babel is a generic engine for translating syntax and preprocessing code.

MrMoo
Sep 14, 2000

Babel-polyfill is a package in NPM for general ES6 polyfills for ES5, “Babel” itself is the transpiler.

You should realize webdev is a dump and the same name is used all over the place.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

MrMoo posted:

Babel-polyfill is a package in NPM for general ES6 polyfills for ES5, “Babel” itself is the transpiler.

You should realize webdev is a dump and the same name is used all over the place.

I'm sure I'm missing something, but I'm not sure how your point is related to the point that Roadie is making.

Anyway, just to be clear, this makes it sound like they're unrelated packages that they just happen to use the same name.

babel-polyfill is the official polyfill that Babel provided pre version 7.4.

Now babel just directly includes corejs.

MrMoo
Sep 14, 2000

I is dumb, no problem. I'm not a webdev so I only pick up changes from this thread.

It looks like Babel supports TypeScript now? Just to be even more confusing, and an odd situation.

https://babeljs.io/docs/en/next/babel-preset-typescript.html

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Yeah. It'll convert TS files to JS and do all the other stuff Babel does.

Of course, it doesn't do type-checking so you still have to have tsc as part of your build process.

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