Comments (9)
I can definitely see what you mean. During the porting proces in the past months I've made an effort to not only do a verbatim translation from Java to JavaScript, but also utilise the power of JS where it made improvements to both performance and readability. I've also removed or changed things that just don't make much sense in JavaScript or are remnants of old versions of Processing (for example: smooth();
is completely unnecessary since that's on by default since at least Processing 2). In JavaScript it's a lot easier to do OOP. Instead of having a dozen of arrays of the same length where the index has to be kept in sync, you can make an Array of objects that does the same thing with comparatively better performance, shorter overal size of the sketch and beter readability.
from code-package-p5.js.
So basically what I'm saying is that we should find a good middle ground.
from code-package-p5.js.
You're right, we should find a compromise. I'd opt for keeping the Circle object but replacing forEach()
, circles.some()
and circles.find()
with simple for-loops. I know, it breaks the heart of a real javascript programmer, but from my experience even a simple for-loop is hard enough to understand for beginners.
from code-package-p5.js.
I completely agree. I will make the appropriate changes to P_2_2_5_01
and P_2_2_5_02
ASAP. Also will look into changing this the new sketches I designed.
from code-package-p5.js.
@bohnacker @Niels-NTG - do you think we should convert then all the forEach
loops into for
loops for the other sketches as well? I think I use forEach quite often...
from code-package-p5.js.
forEach
is for iterating data, normal for
loops are for iterating a range of numbers. I use forEach
all the time whenever I write JavaScript. But this style where you pass functions isn't common in other mainstream programming languages, meaning that's not directly transferrable to another language. Also you have the complexity of scoping this
, of which the working should not be in the scope of the book. To keep it simple for the reader, I'm in favour for picking a single style we use all throughout the book. And that's is probably a plain old for
loop.
from code-package-p5.js.
I wouldn't mind if there are some forEach
s remaining in the examples. It's especially ok for all _02, _03, ... sketches. We explain the _01 sketches in the book, so these should be quite readable and understandable for beginners.
from code-package-p5.js.
@Niels-NTG Did you already change something on this sketch? If not, I will just go on with that...
from code-package-p5.js.
@bohnacker I haven't had time for it yet. Go ahead.
from code-package-p5.js.
Related Issues (20)
- P_4_2_1_02 needs to be synchronised with P_4_2_1_01
- P_4_2_2_02 needs to be synchronised with P_4_2_2_01
- Readme: Add Acknowledgments and Contributors Link HOT 6
- P_4_3_1_02 needs to be synchronised with P_4_3_1_01
- P_4_3_3_02 needs to be synchronised with P_4_3_3_01
- loadImage() pushed to array fails in Firefox HOT 2
- Performance slowdown since p5js v0.5.14 HOT 13
- Cross check data/README.md HOT 2
- index.html (sketch list)
- Code-Package-p5.js for p5js-web-editor HOT 39
- FYI / Please check for 1.0 release
- Readme: improve local webserver and setup instructions HOT 2
- Maintenance + updating to more recent p5.js version HOT 10
- gd not defined in P_1_2_2_01 HOT 2
- Question about uploading to p5.js editor HOT 7
- Blocked by CORS HOT 3
- Bug in P_1_2_1_01 HOT 2
- Erratum: mouseX and mouseY p. 46 and 47
- 404 link on generative-gestaltung.de HOT 4
- Unable to launch HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from code-package-p5.js.