I am a TA in a robotics class at my school, the majority of the class uses V5 blocks and I am interested in how the “when started” block works. When you have multiple of them does it split them off into separate threads/tasks or does the code still remain linear? I also have the same question about the custom blocks and the “broadcast message” and “when message received” blocks. My assumption is the “when started” blocks are their own threads along with the “broadcast” and “receive” blocks while the custom blocks are linear. I am just guessing though as I don’t have much experience with V5 blocks and have never actually tested it, if I am wrong about the way they work it would be great to know so I can help people with their problems better!
I used VEXCode blocks to create two When Started events and a custom HelloWorld event.
If you click on the Code Viewer (<>) button it shows the following image. There are three methods.
HelloWorld is an event, the second WhenStarted is in a separate thread (task), and the first WhenStarted is in the main thread. Both threads can call (broadcast) the HelloWorld event.
If the students are ready for threading, they are ready to move away from blocks, IMNSHO. Move away from blocks and then to threading.
Just because something can be done doesn’t mean it should be done.
It was more of a question for me, the students are doing it without understanding what multithreading is. I just want to make sure that’s actually what adding multiple when started blocks is doing. Right now it is a very big leap from blocks to c++ or python for them. I think it would be great if they could but it’s pretty early on for them to do that.
Ah okay so adding multiple when started blocks does break off into multiple threads along with the broadcast block when called. Presumably the custom blocks are just a way to neaten up code and still remain linear correct?
Yet another reason, IMNSHO, why doing anything beyond the most simple program in a graphical programming language is fraught. Don’t underestimate your students or succumb to the fallacy that pretty graphics make programming concepts “easier”. I’ll pull the “back in my day”, I learned programming with Logo probably before I was 10.
Blocks programming’s biggest role is to entice students into believing that coding is achievable. Once a student believes she can program, she should be transitioned immediately away from blocks and into a text-based language. Even better if the student never encounters Blocks programming.
Yeah I totally get that, I really dislike block coding, it is nice for getting into coding but beyond that, it’s not good for much. I don’t underestimate that the students could make the swap to text code but it’s not really my call to make, I am just a TA so it would be up to my teacher to change the way he teaches robotics. Like I said the students aren’t really doing it with the intent of multithreading, it’s just something they are doing and expecting it to have that result, I just wanted to make sure what they are expecting to have happen ends up happening.
I can’t completely agree with this. When I am helping teams troubleshoot code at competitions, a big contributor to the issues is multithreading/tasks and conflicts between them. They are difficult for students to troubleshoot because they don’t fully understand the implications and it is very hard for them to see and understand the issues in their code.
The visual nature of blocks can be very useful. When I explain the conflicts in their code, students learning these concepts on block code can often see them much more clearly, because we can see these threads side by side and discuss what is happening.
That is not to say that I think blocks is “better” than text, but I think for understanding concepts before applying them badly in text-based languages, it can be a very useful tool.
Visual Basic would like to have a word