-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the code to 2021 practices? #11
Comments
Gregg,
Thanks for your input. I’m agreement in principle with almost all your examples. Let me address the issues in dealing with them in the context of my and Dave Shreiner’s textbooks.
The largest part of our audience and the ones we write for are students in computer science and engineering programs. Almost none of these programs use the JavaScript API in any of their core courses. Although I personally am troubled by this reality, the problem for us is when students get to a course on computer graphics, the majority of them have never programmed with JS. Because the instructors’ goal is teaching computer graphics using OpenGL/WebGL and not creating experts in JS, we decided to stick with a very simple subset of JS, even if it meant our code is often not very efficient or JS-like or up to the present versions of JS.
Note that most of your suggestions require ES6. When we discussed our plans for the 8th Edition of Interactive Computer Graphics (Pearson Education) which came out last year, we decided to move to WebGL 2.0 but, given the background of our readers, we decided to stick with ES5. If there is a 9th Edition, we’ll almost definitely move to at least ES6. For now, we can do two things. We can clean up the existing code on our website, which will still be ES5. We can also create ES6 versions of the present examples and put them on our website. The latter will take a little while.
Ed
…_______________________
Ed Angel
Founding Director, Art, Research, Technology and Science Laboratory (ARTS Lab)
Professor Emeritus of Computer Science, University of New Mexico
1017 Sierra Pinon
Santa Fe, NM 87501
505-984-0136 (home) [email protected] <mailto:[email protected]>
505-453-4944 (cell) http://www.cs.unm.edu/~angel <http://www.cs.unm.edu/~angel>
On Jan 17, 2021, at 9:23 PM, Greggman ***@***.***> wrote:
Would you consider a series of PRs that update the code to slightly more modern practices? Some are minor, some less so.
Examples might include
Remove all uses of var for let and const
var is basically considered bad practice at this point
no need for `type="text/javascript"
this is not needed for script tags
stop using window.onload
Just move your script tags to the bottom or use defer
consider using es6 modules for loading scripts
use requestAnimationFrame instead of requestAnimFrame
There's no need for the polyfill in 2021
put the shaders in multiline template strings
They've been in every browser since 2010 or earlier
get rid of "Oops, your browser doesn't support canvas"
There are no browser that don't support canvas in 2021
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#11>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB33BFZGCEIS4Y2XTCA2C23S2OZV3ANCNFSM4WGWKQIQ>.
|
FYI, only 2 of my suggestions (import, no var) needs es6. All the rest are normal stuff from years ago |
True. I should have been more careful to note the version of ES5.
The main issue in updating the examples to use let and const is the change in scoping rules.
Ed
…_______________________
Ed Angel
Founding Director, Art, Research, Technology and Science Laboratory (ARTS Lab)
Professor Emeritus of Computer Science, University of New Mexico
1017 Sierra Pinon
Santa Fe, NM 87501
505-984-0136 (home) [email protected] <mailto:[email protected]>
505-453-4944 (cell) http://www.cs.unm.edu/~angel <http://www.cs.unm.edu/~angel>
On Jan 19, 2021, at 4:51 AM, Greggman ***@***.***> wrote:
Note that most of your suggestions require ES6.
FYI, only 1 of my suggestions (import) needs es6. All the rest are normal stuff from years ago
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#11 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB33BF64PYZVIR5GQV63UPLS2VW3PANCNFSM4WGWKQIQ>.
|
I hope this isn't too pushy, But, for example, searching and replacing That seems like a minor change? Similar, searching and replacing The Maybe there is other work todo but at a glance those seem like 5 minute changes that have some positive benefits though maybe minor. Anyway, I'll shut up now. I'm just the guy that answers your student's questions on stack overflow every few months when a new batch comes through :P |
Where are the students looking at the examples? Are they using interactivecomputergraphics,com and the code for the most recent edition (8E)? I removed all the references to requestAnimFrame quite a while ago. We’ve had a lot of trouble with illegal copies of older editions on the internet. One of the consequences is that students who use them are using legacy versions of the code. I’ll check to see if I missed one or two. As for the others, I agree and will do.
Ed
…_______________________
Ed Angel
Founding Director, Art, Research, Technology and Science Laboratory (ARTS Lab)
Professor Emeritus of Computer Science, University of New Mexico
1017 Sierra Pinon
Santa Fe, NM 87501
505-984-0136 (home) [email protected] <mailto:[email protected]>
505-453-4944 (cell) http://www.cs.unm.edu/~angel <http://www.cs.unm.edu/~angel>
On Jan 19, 2021, at 9:56 AM, Greggman ***@***.***> wrote:
let and const would be a big change, I agree
I hope this isn't too pushy, But, for example, searching and replacing requestAnimFrame with requestAnimationFrame is a small change and would stop teaching students about some non-existent function outside the class.
That seems like a minor change?
Similar, searching and replacing type="text/javascript" with nothing is a minor change that stops repeating outdated practices.
The Oops just removes clutter and is also outdated
Maybe there is other work today but at a glance those seem like 5 minute changes that have some positive benefits though maybe minor.
Anyway, I'll shut up now. I'm just the guy that answers your student's questions on stack overflow every few months when a new batch comes through :P
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#11 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB33BF5DDTBZCWJBUFXEVO3S2W2UPANCNFSM4WGWKQIQ>.
|
I have no idea where the students are getting the materials. They just show up on stackoverflow. |
Would you consider a series of PRs that update the code to slightly more modern practices? Some are minor, some less so.
Examples might include
Remove all uses of
var
forlet
andconst
var
is basically considered bad practice at this pointno need for `type="text/javascript"
this is not needed for script tags
stop using
window.onload
Just move your script tags to the bottom or use
defer
consider using es6 modules for loading scripts
use
requestAnimationFrame
instead ofrequestAnimFrame
There's no need for the polyfill in 2021
put the shaders in multiline template strings
They've been in every browser since 2010 or earlier
get rid of "Oops, your browser doesn't support canvas"
There are no browser that don't support canvas in 2021
The text was updated successfully, but these errors were encountered: