Any suggestions for a source to better understand JS syntax that applies to PB? Is syntax even the right word to describe the “rules”, such as what goes inside curly brackets and what goes outside? For instance, If I want to use an if/else conditional, as an absolute beginner all I can do is copy the form from someone else. While that strategy works, it’s an incredibly slow and ineffective to way to actually understand the underlying rules. I’ve dug into some JS tutorials but then I encounter lots of rules that don’t apply to PB, and I can’t always tell the difference. I understand that this forum is focused, appropriately, on coding for LEDs, but I just haven’t found an appropriate source elsewhere to learn some foundational basics.
I’m in a very similar position, so me answering this is a little “blind leading the blind”, but I think I have a pretty good idea of the place you’re currently at. I had never used JavaScript before the PB outside of copy-pasting some code for web stuff. Luckily my only other programming experience was half a class in C, which is relatively similar in syntax, and doesn’t have a lot of the extra features that Javascript has but PB doesn’t. It’s also definitely a lot harder reading the PB docs without a javascript background, since things are often referred to in a way that expects that familiarity.
I think it’s worth looking at C syntax, and maybe even watching some of the harvard CS50 course where syntax is a focus, like the first one on C: CS50 2021 in HDR - Lecture 1 - C - YouTube. The videos are long, but the newer ones have good timestamps at the bottom so you can look for relevant sections. If you really want to dive in, the assignments are challenging and relatively fun, but I’m guessing you’d more like to get to a point quickly where you can stop thinking about syntax and work on a pattern, rather than actually feel like you’re “taking a class”, so just watching certain parts, maybe following along in an IDE (personally I have to at least write it out once to have a chance of remembering it), is probably enough.
It can also be helpful to write code in an IDE like VSC that, when your cursor is on a bracket, highlights the corresponding opening or closing bracket like this:
which makes it harder to get lost in the sauce.
I’m not 100% sure that the PB doesn’t do that since I’m at work and can’t check mine, but I’m pretty sure it does not.
Yes, any simple JavaScript tutorial will help you with basic syntax/usage.
Just keep in mind it’s NOT quite JS, it’s just close enough to ES6 to be compatible.
The upcoming lessons 2, (and likely 3,etc) will cover a lot of the similarities and difference. It’s half written, but still not quite ready to tackle it, this winter’s been rough on me.
I appreciate the suggestions; I’ll check it out. I was looking for a good IDE (code editor?) the other day and couldn’t find one with helpful features like pointing out bracket pairs. I’ve not seen PB do that, but that would be cool. I’ll take another look and I’ll check out VSC. Cheers
@Booli Check out my recommended subset of the Codecademy course on JavaScript:
One other thing: I ended up learning a bit when I set off to create the unit test suite, which aims to use every language feature once. Looking through it, you’d at least have one point of reference for how every language feature is expected to be used.
Hey, thanks for the info about where to bone up on JS, and especially, what we can ignore. For someone new to coding, new to JS, and trying to figure out what applies to PB it has been rather opaque. You just threw a bunch of light on the subject and you’ve answered my question of a few days ago.