Young Writers Society



Sunny and the Syntax Errors of Doom: Chapter 6.2

by Spearmint


As soon as Sunny stepped into the factory building, she was hit by a wave of sound. Various machines were whirring and pounding away, and workers in colorful suits of armor were rushing around, shouting things like, "Error on line C!" or "Someone check on the paint machines!"

Sunny couldn't help but be energized by the hustle and bustle of the factory. She turned to the unnamed person excitedly and asked, "So, where to first?"

The person stood taller in their neon orange armor and declared, "We'll start with the chainmail. Follow me!"

Sunny and Robert trailed after the guide, weaving around assembly lines and ducking past busy workers. Soon enough, they arrived at a row of machines. Metal wire was being fed in through one end, and circular links were released from the other end. Sunny tried to peek through the openings in the machines to see if she could figure out how they worked.

The person in orange armor chuckled and said, "No need to look inside the machines! Luckily, all of us gate-watchers carry around informational diagrams, just in case a curious Javalandian wants to learn more about our work." They produced a laminated paper seemingly out of thin air and handed it to Sunny.

Well, that's convenient, Sunny thought.

On the paper was a sketch of a machine. Wire came in from the left side and looked to be wrapped around a thicker bar inside the machine. Then the resulting coil was cut into links by a blade on the right side of the machine. Sunny nudged Robert excitedly and pointed at the diagram. The robot shrugged.

"As you can see here, as long as the wire keeps coming in, the machine has to wrap it into coils and then make links. We can use a while loop for that!" The person's armor clanked as they raised two fingers into the air. "So, there are two main types of loops we use here in Javaland. For loops are for when we need to do something a certain number of times. While loops are for when we want to do something until a condition is met."

The gate-watcher pointed to the diagram. "In this case, a while loop would work better because we want the machine to keep working until the factory closes. We don't know how many links the machine will be able to make exactly, so a for loop wouldn't work.

"As for the condition, it could be time. The machine will keep working until the end of the day." The armored person took out a marker and scribbled some lines of code on the laminated paper.

while (!endOfDay) {

}

"And while the condition in the parentheses is true, whatever's inside the curly braces will keep executing."

while (!endOfDay) {

  wrap wire around bar;

  cut off a link;

}

Sunny couldn't see the person's face through the helmet, but she imagined they'd be grinning proudly. "Thanks for the explanation," she started, "but what does the exclamation point mean? It doesn't seem like it's supposed to mean either enthusiasm or factorial…"

"Oh! Well, in coding, the exclamation point is called ‘not,' and it reverses the value of the boolean after it. So, !true is false, and !false is true." The gate-watcher pointed at the diagram. "Here, !endOfDay basically means ‘not end of the day,' so the loop runs while it isn't the end of the day. Does that make sense?"

Sunny nodded thoughtfully. "Yeah. So while it isn't the end of the day, the machine keeps wrapping the wire and cutting off links?"

"Exactly!" Sunny could hear a smile in the person's voice. "Now then, check out the chainmail assembling machines over here."

Sunny and Robert moved to another row of machines. Sunny oohed and ahhed as they took individual links and pieced them together into chainmail.

"In this case, we know exactly how many links we want in a row. So, we can use a for loop! Assuming the number of links in a row is 50, we can write a for loop like this."

for (int i = 0; i < 50; i++) {

  add link to row;

}

"Just like ‘while,' ‘for' is a keyword. It signals that we'll be using a for loop. But the integer ‘i' could be named anything else, like ‘a' or even a word or phrase, like ‘javaIsAwesome'!

"Now, let's look at each of the parts of this loop. int i = 0 initializes the variable i and says that it'll start at 0. Then we have the condition, i < 50. This means that the loop will continue while i is less than 50. Finally, the i++ is the increment. i++ is a shorthand for i = i + 1, and it means that each time the code inside the loop runs, i will be increased by 1."

Sunny blinked for a few moments. "Ohhkay?"

"Hm. Maybe a simpler example would help."

for (int i = 0; i < 5; i++) {

  System.out.println(i);

}

0

1

2

3

4

"This for loop would print the integers 0 through 4 inclusive. Try stepping through the loop– tracing each of its iterations– to see why!"

Sunny frowned. "Okay, so I get the initialization part. At the beginning, i equals 0, so the integer 0 is printed. And then… there was something about… increasing by one?"

"Yep! Each time the part inside the loop runs, i will be incremented by one. So the second time it runs, 1 will be printed, then 2, and so on. After 4 is printed, i is increased by 1 again, but 5 is not less than 5, so the loop ends without printing 5."

"Right." Sunny took a moment to wrap her head around that. "Is it possible to increment i by more than one at a time?"

"Definitely! You could do i += 2, or i += 100, or even i -= 1, which is the same thing as i-- and would count down instead of up."

"Got it." Sunny whipped out her notebook and tried to scribble down everything she'd learned before she forgot. When she finished, she looked up at the gate-watcher again. "Is that all?"

The orange armor clanked again as the person let out a belly laugh. "Oh, those are just the absolute basics! There are so many other things you can do with loops. You could use logical operators like ‘not,' ‘and,' and ‘or' to customize while loops, or use nested for loops… And of course, don't forget to watch out for infinite loops!"

Sunny's head started spinning. "A-alright…"

"But we don't usually teach casual visitors all of that." The person tapped the diagram. "Even just knowing the basics is useful!"

"Okay. Thank you!"

"Now then, I could show you both around the rest of the factory–"

"Apologies, but I think we've spent enough time here already," Robert interrupted. "Your lesson on loops was much appreciated– I wouldn't have had the patience to teach Sunny myself– but we really should be getting to the Array Train."

Sunny pouted for a moment, then nodded reluctantly. "We should." She smiled at the gate-watcher. "Thank you for the diagram and the lesson, and I hope you can get your name soon!"

"Me too," the person agreed. "Well then, goodbye, and feel free to visit anytime!"

With that, they escorted Sunny and Robert out of the building and to the exit of the factories, then returned to their gate watching duty.


Note: You are not logged in, but you can still leave a comment or review. Before it shows up, a moderator will need to approve your comment (this is only a safeguard against spambots). Leave your email if you would like to be notified when your message is approved.







Is this a review?


  

Comments



User avatar
3779 Reviews


Points: 4173
Reviews: 3779

Donate
Sun Jan 29, 2023 4:01 am
Snoink wrote a review...



As soon as Sunny stepped into the factory building, she was hit by a wave of sound. Various machines were whirring and pounding away, and workers in colorful suits of armor were rushing around, shouting things like, "Error on line C!" or "Someone check on the paint machines!"


LOL. Though, having toured several engineering factories as a college student, I have to admit... I am wondering why are they wearing suits of armor as PPE? Like... will we get to see this PPE in action??? That might be neat...

Okay, so the loop tutorial was actually good, which is good because usually loops are... impossible to teach, haha. Though, I think you rush the end, which makes me wonder if this is going to come up later and Sunny might mess up on a loop thing??

I do think that the coding, now that it's getting a lot more complicated, ought to be set apart somehow. You used to make images for it, which actually might be nice. Either that or use the YWS [ code ] function to help you out.

Now that they left the person, I think it's a bit weird that the person was never named, either by their algorithm or... Sunny. I am sort of surprised that Sunny, being that eternally cheerful and helpful person, wouldn't offer her naming services to the poor nameless man.

So... I guess we're going on a train next??? DUN DUN DUNNNNN.




User avatar
436 Reviews


Points: 20490
Reviews: 436

Donate
Mon Dec 19, 2022 2:18 pm
View Likes
Liminality wrote a review...



Hi there mint!

First Impressions

This was a cute little chapter! I liked finding out about the loops, especially with how you’ve characterized them as being like chainmail. I definitely relate to Sunny being confused about the ‘for’ loops and things like increments. I’m very much a coding beginner and still struggle with those things xD The loop factories are a nice and new sort of environment, busier and more task-focused than the previous ones – and I like that variety in an adventure story. It’s also still in line with the coding theme overall c:

Characters

Sunny couldn't help but be energized by the hustle and bustle of the factory.
Sunny comes across as being more extroverted than Robert, which is a classic contrast for hero + sidekick :] though I noticed that dialogue-wise, Robert was quiet in this part, even more than usual. I think he only had one or two lines? Maybe it’s just because the focus here is the guide’s explanation on loops.
The person stood taller in their neon orange armor and declared, "We'll start with the chainmail. Follow me!"

I forgot if I mentioned this in my last review, but the guide does stand out with how enthusiastic about their job they are! I’d imagine in the real world people in factories are usually more subdued, so this is noticeable to me. Maybe coding factories in Javalandia are just more fun than real factories?

Descriptions

Something I kind of find myself wishing for as I read this story is more ‘material’ to chew on and ponder. I think so far the story has been kind of literal and direct, which makes sense for something that’s supposed to be middle-grade genre fiction (I think you mentioned it’s for middle grade readers in your #shoutoutyourproject ? Correct me if I’m wrong!)– but still, since this part has that mystery of the name-related error lingering over it, it would be nice to have more descriptions of stuff going wrong so the reader can guess what the error is. (Like I enjoyed guessing what was wrong with the variapets several chapters ago c:) For example, is being nameless affecting the guide’s appearance in some way? Do some of the workers look worried? Are they whispering?

As a side note, I feel some of the descriptions of characters’ gestures are a bit repetitive here. I think I’ve totally done that before myself when writing long novels, so it’s to be expected for an LMS project ^^’ so I don’t think you need to worry about it at the moment! Could be something to keep an eye out for in revisions.

Plot

Plot-wise I think the main thing that happened here was Sunny learnt about loops. It’s a practical piece of knowledge, which makes me think she’s going to have to program something with a loop in it to resolve her next obstacle (such as fixing whatever error is keeping the names from being given out). I still don’t quite understand what an array is in code myself, so I feel I can’t make a prediction about the Array Train, but I don’t think Sunny and Robert are just going to ride out from the factories smoothly at this point. <.<
The line about knowing the basics being helpful especially makes me think she’s going to need that knowledge sometime soon.

Overall

This was a nice mini ‘training montage’, and it definitely makes me feel like I understand the concept of a loop a little better as well :D I like Sunny’s enthusiasm as usual, and I’m eager to see what happens next.

Hope this helps and let me know if you’d like more feedback!
-Lim




Spearmint says...


Thank you for the wonderful review, Lim!! ^-^
it would be nice to have more descriptions of stuff going wrong so the reader can guess what the error is.

Ah, that makes sense! Yeah, I'll try to add more foreshadowing and descriptions in revisions. :]
As a side note, I feel some of the descriptions of characters%u2019 gestures are a bit repetitive here.

Ooops. >.> *jots down a reminder to change them up* xD
This was a nice mini %u2018training montage%u2019, and it definitely makes me feel like I understand the concept of a loop a little better as well :D

:D
Thanks again for the helpful observations, and have an excellent day/night! <3



User avatar
3850 Reviews


Points: 210016
Reviews: 3850

Donate
Tue Dec 06, 2022 8:58 am
View Likes
KateHardy wrote a review...



Good Morning/Afternoon/Evening/Night(whichever one it is in your part of the world),

Hi! I'm here to leave a quick review!!

First Impression: Okayy well this little tour of the Loop factory ended up being a bit shorter than I thought it would be and Sunny did not get armor or a sword but I do love the bits we did get to see. As usual the way this is all being built up just works so well together.

Anyway let's get right to it,

As soon as Sunny stepped into the factory building, she was hit by a wave of sound. Various machines were whirring and pounding away, and workers in colorful suits of armor were rushing around, shouting things like, "Error on line C!" or "Someone check on the paint machines!"

Sunny couldn't help but be energized by the hustle and bustle of the factory. She turned to the unnamed person excitedly and asked, "So, where to first?"

The person stood taller in their neon orange armor and declared, "We'll start with the chainmail. Follow me!"


Well that seems like a pretty standard sounding factory from the start of this little tour. Besides of course the errors being yelled out instead of broken machines here and there. Well let's see what more this tour can reveal to us here.

Sunny and Robert trailed after the guide, weaving around assembly lines and ducking past busy workers. Soon enough, they arrived at a row of machines. Metal wire was being fed in through one end, and circular links were released from the other end. Sunny tried to peek through the openings in the machines to see if she could figure out how they worked.

The person in orange armor chuckled and said, "No need to look inside the machines! Luckily, all of us gate-watchers carry around informational diagrams, just in case a curious Javalandian wants to learn more about our work." They produced a laminated paper seemingly out of thin air and handed it to Sunny.

Well, that's convenient, Sunny thought.


That is certainly quite convenient and pretty handy as far as being able to quickly explain something like this to someone is concerned. I do have to say though, this now leaves me wondering the reason behind the guards in the first place. Is it some sort of leftover response to the war mentioned earlier where they've got this place being protected against such issues coming up in the future? I'm just thinking out loud a bit here because it seems like there's not really any need to protect against Javalandians.

"As you can see here, as long as the wire keeps coming in, the machine has to wrap it into coils and then make links. We can use a while loop for that!" The person's armor clanked as they raised two fingers into the air. "So, there are two main types of loops we use here in Javaland. For loops are for when we need to do something a certain number of times. While loops are for when we want to do something until a condition is met."

The gate-watcher pointed to the diagram. "In this case, a while loop would work better because we want the machine to keep working until the factory closes. We don't know how many links the machine will be able to make exactly, so a for loop wouldn't work.


Oooh these are some really good examples right there for explaining those loop types. This book could honestly also work as a bit of a beginner's guide to code in addition to the whole fantasy quest part of things. Ahh, I wish our textbooks were written in this style xD. Definitely would cause a lot less falling asleep on the job.

"Oh! Well, in coding, the exclamation point is called ‘not,' and it reverses the value of the boolean after it. So, !true is false, and !false is true." The gate-watcher pointed at the diagram. "Here, !endOfDay basically means ‘not end of the day,' so the loop runs while it isn't the end of the day. Does that make sense?"

Sunny nodded thoughtfully. "Yeah. So while it isn't the end of the day, the machine keeps wrapping the wire and cutting off links?"


Sunny is catching on quickly there. Also love that she mentions factorials in addition to just the excitement situation. Its not often concepts from Maths like that end up in stories so I am definitely cheering at that.

Sunny blinked for a few moments. "Ohhkay?"

"Hm. Maybe a simpler example would help."


Well I definitely relate to Sunny there, that was quite a lot to be dumped out there all at once. I'm debating between that being fitting given the acknowledgment that happened here and it still being just a little bit too much information for that moment but I am leaning more towards it being fine given the purpose it serves here.

"Got it." Sunny whipped out her notebook and tried to scribble down everything she'd learned before she forgot. When she finished, she looked up at the gate-watcher again. "Is that all?"

The orange armor clanked again as the person let out a belly laugh. "Oh, those are just the absolute basics! There are so many other things you can do with loops. You could use logical operators like ‘not,' ‘and,' and ‘or' to customize while loops, or use nested for loops… And of course, don't forget to watch out for infinite loops!"

Sunny's head started spinning. "A-alright…"


Poor Sunny is going to end up doing a lot more homework before this quest is done by the looks of it. On the bright side she's at least going to end up with a lot of useful information here.

"Now then, I could show you both around the rest of the factory–"

"Apologies, but I think we've spent enough time here already," Robert interrupted. "Your lesson on loops was much appreciated– I wouldn't have had the patience to teach Sunny myself– but we really should be getting to the Array Train."

Sunny pouted for a moment, then nodded reluctantly. "We should." She smiled at the gate-watcher. "Thank you for the diagram and the lesson, and I hope you can get your name soon!"

"Me too," the person agreed. "Well then, goodbye, and feel free to visit anytime!"

With that, they escorted Sunny and Robert out of the building and to the exit of the factories, then returned to their gate watching duty.


Well that was an interesting end there. The more we don't get to see what this factory does, the more suspicious I become of it ahhh. Am I just being far too paranoid here or is there more to this xD? Either way I suppose it does make sense that they shouldn't waste much longer if they want to go to the mountain as soon as possible. The lesson on loops did seem like what Sunny was meant to be learning from this place anyway.

Aaaaand that's it for this one.

Overall: Overall we're jumping through these pretty fast here. NOw I'm even more paranoid that the Array Train is going to end up being where things end up a little derailed (couldn't resist sorry) and I'm going to be left with a cliffhanger xD Hopping onto that last bit now.

As always remember to take what you think was helpful and forget the rest.

Stay Safe
Harry




Spearmint says...


This book could honestly also work as a bit of a beginner's guide to code in addition to the whole fantasy quest part of things.

Yep, that's my hope! :]]
Am I just being far too paranoid here or is there more to this xD?

You're being an appropriately suspicious reader. xD I think it's just that I'm reluctant to make Sunny and Robert suffer... i know, am i really a writer?? xD
NOw I'm even more paranoid that the Array Train is going to end up being where things end up a little derailed (couldn't resist sorry)

Lol, I love puns! And I suspect so... although nothing too bad... probably... >.>



KateHardy says...


xD suffering is difficult to do....until you start...




cron
uwu
— soundofmind