This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
JJRcop's profile picture

Are coroutines discouraged?

Started by JJRcop, 30 November 2012 - 04:02 PM
JJRcop #1
Posted 30 November 2012 - 05:02 PM
I have not seen one program use coroutines yet. And the only one I have seen use parallel (which uses coroutines) is the bios.

Are using multiple threads discouraged?
Lyqyd #2
Posted 30 November 2012 - 05:08 PM
Here's one example, off the top of my head. Programs use coroutines all the time, usually unnecessarily. They are useful, when used correctly. Just make sure to know when to use them and when not to!
JJRcop #3
Posted 30 November 2012 - 05:14 PM
Well, why do most people use hacks when they could easily use coroutines? Does using it make computercraft unstable/interrupt the flow? Are there limits to how many threads can be running in computercraft?
Lyqyd #4
Posted 30 November 2012 - 05:15 PM
What hacks do you refer to? No. I believe so.
JJRcop #5
Posted 30 November 2012 - 05:18 PM
The hacks. I have seen people instead of using coroutines, do three tasks in a chronological order, when they easily could get it done much quicker with 3 coroutines.
PixelToast #6
Posted 30 November 2012 - 05:20 PM
The hacks. I have seen people instead of using coroutines, do three tasks in a chronological order, when they easily could get it done much quicker with 3 coroutines.
coroutines arent multithreading, they are resumed in an order
there is no significant performance improvements when using them, they are just an awesome way to control the flow of your code :3

like how i made a manufactoid api that runs a peice of code over a multiple number of cycles
allowing for easier programming :3
Cranium #7
Posted 30 November 2012 - 06:32 PM
The only reason I don't use coroutines is because I have no idea how to use them. Scary new things scare me :(/>
KaoS #8
Posted 02 December 2012 - 08:12 PM
I think coroutines are amazing, they are so useful it's scary (well mainly for hacking I must admit :D/> ) I use them all the time, it would benefit you a lot to learn them Cranium
Kingdaro #9
Posted 02 December 2012 - 08:21 PM
The only reason I don't use coroutines is because I have no idea how to use them. Scary new things scare me :(/>/>
This.

The parallel API is there so I just use it because I don't feel like reinventing the wheel and it makes my code not look like a massive unorganized ascii vomit.
KaoS #10
Posted 02 December 2012 - 09:06 PM
The only reason I don't use coroutines is because I have no idea how to use them. Scary new things scare me :(/>/>
This.

The parallel API is there so I just use it because I don't feel like reinventing the wheel and it makes my code not look like a massive unorganized ascii vomit.

hahaha. I prefer to use the normal base interface as it can be used for more than just running in parallel, it doesn't really make your code look that bad
ekzane #11
Posted 07 December 2012 - 11:05 AM
The hacks. I have seen people instead of using coroutines, do three tasks in a chronological order, when they easily could get it done much quicker with 3 coroutines.
coroutines arent multithreading, they are resumed in an order
there is no significant performance improvements when using them, they are just an awesome way to control the flow of your code :3

true.

@Topic
Coroutines are useful if you want to let your program run and still use your shell.

I use it for my file server running in the background and receiving file requests or uploads. But I still want to use my shell while my program runs.