OldHellaGnarGnar2

OldHellaGnarGnar2 t1_iyf5swx wrote

I'm not sure if I missed your link about breaks earlier, or if it was edited in, but I just now saw it, and it's super helpful. Our robot programs technically use "JMP LBL", not GOTO, but I basically took them as the same thing in terms of function. So it already has labels for each section if I were to restructure it to use nested loops and whatnot.

All of your comments have been super helpful. I've been wanting to learn more programming for a while, but wasn't sure what concepts or practices I'm not even aware of, and this gives me a lot to think about. I recently got the "Automate the Boring Stuff with Python" book, to use as a starting point, but am still kinda learning the syntax and python-equivalent commands of what I already know in Matlab of Fanuc TP, and haven't really gotten to stuff about code structures or paradigms, etc

2

OldHellaGnarGnar2 t1_iyeh3yo wrote

Ahh, ok that makes a lot of sense. So, rather than doing a one-to-one translation, figure out how I can take advantage of python's capabilities vs whatever language I'm trying to convert code from.

Secondary question:

Is your comment related at all to programming paradigms? Like, I think all the code I know how to write would be considered "functional" (I didn't learn anything about paradigms in school), so after seeing some discussion on paradigms and watching some videos, I'm trying to understand "when would I use object-oriented" or another paradigm. So maybe if I learned to write in a different paradigm, it could be a better fit than what I'd be able to write in functional?

2

OldHellaGnarGnar2 t1_iycyqk2 wrote

Good advice!

>If they don't have any bugs to fix or features to add, this obviously doesn't help you much!

But that's the issue I think I'll have if I try to push it. Our robots generally just work as-is, and most of what we have to add is parameterized, so we're mostly filling in variables and not actually writing code. Actually writing new code for bug fixes or new functionality is pretty rare (I think I'm the only one that's learned how to do it since our division implemented robots).

About a year ago (first time I actually wrote new functionality for them), my boss and I had to convince management I was capable of adding in a new safety feature that got brought up as something we should do.

2

OldHellaGnarGnar2 t1_iycf6rr wrote

>If you can get paid for it, definitely.

>If you plan to flip a switch and go from 0 to 100 on the job you're setting yourself up for a forever project and ultimately failure

If I were to refactor the code, I'm not sure it would ever actually be implemented. The robots have been working correctly for a few years, so I doubt management would want to "fix" what isn't broken, and potentially mess what has already been working.

If I did this, I think it would purely be an exercise for me to get better at coding. After a couple years at this job, it turns out I like writing code more than almost anything else, but that's a really small part of my current job - so my goal would be more of "get better at programming and/or learn a new language, so I can be more employable in positions that are more programming-focused"

7

OldHellaGnarGnar2 t1_iyce8wd wrote

Thanks for the feedback! I've never heard of refactoring, but I guess that's exactly what I was trying to describe.

>In a professional setting you're also unlikely to see a company trying to do a 1:1 re-write of an existing product.

True, however my goal with trying to write it in another language wouldn't be for actual implementation; it would be to try to start learning a new language. I only really know Matlab and Fanuc TP (the robot language I was talking about). I'd like to learn a more widely used language so I can potentially open doors to more types of jobs than I'd currently be qualified for.

4

OldHellaGnarGnar2 t1_iyb9od3 wrote

This is the first explanation I've read about this topic that made me understand it.

The robots we have at work had their code written by an integration company we use. The first 1-2 hundred lines of each program is "where to go next", with a bunch of

>if (all these conditions match) GOTO {section that handles whatever is supposed to happen next}

It's always a huge pain whenever I'm writing new code to add or improve functionality, and trying to check that I didn't introduce any new possible states where it can't figure out where to go - because I have to jump from line 50 to 400 to 30 to 670 to 30 to 900 etc.

Having the function directly follow the "if" condition seems like it would make more sense.

Question for you: if I want to improve my coding skills (because I only took one class in school, and have just picked other stuff up as I go), would it be a good exercise to re-write all their code using the structure you've outlined? And/or if I'm trying to learn another language like python specifically, see if I can re-write it in that, so I can learn that syntax & commands at the same time?

42