Skip to content
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

Open
greggman opened this issue Jan 18, 2021 · 6 comments
Open

Update the code to 2021 practices? #11

greggman opened this issue Jan 18, 2021 · 6 comments

Comments

@greggman
Copy link

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

@esangel
Copy link
Owner

esangel commented Jan 18, 2021 via email

@greggman
Copy link
Author

greggman commented Jan 19, 2021

Note that most of your suggestions require ES6.

FYI, only 2 of my suggestions (import, no var) needs es6. All the rest are normal stuff from years ago

@esangel
Copy link
Owner

esangel commented Jan 19, 2021 via email

@greggman
Copy link
Author

greggman commented Jan 19, 2021

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 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

@esangel
Copy link
Owner

esangel commented Jan 19, 2021 via email

@greggman
Copy link
Author

I have no idea where the students are getting the materials. They just show up on stackoverflow.
You're right they might be getting old materials from somewhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants