▲ 433 ▼ Who cares about time complexity (lemmy.world) submitted 1 year ago by qaz@lemmy.world to c/programmer_humor@programming.dev 51 comments fedilink hide all child comments
[–] douglasg14b@lemmy.world 67 points 1 year ago (11 children) Still linear time at least, could always be much MUCH worse permalink fedilink source hideshow 11 child comments replies: [–] dfyx@lemmy.helios42.de 43 points 1 year ago (2 children) There could be a hidden quadratic cost because the string needs to be reallocated and copied multiple times. permalink fedilink source parent hideshow 2 child comments replies: [–] Jerkface@lemmy.world 42 points 1 year ago Not if I don't see it. permalink fedilink source parent [–] kogasa@programming.dev 5 points 1 year ago Not quadratic in the length of the input. Assuming replace is linear this is also linear permalink fedilink source parent [–] lugal@lemmy.dbzer0.com 16 points 1 year ago (7 children) True. Lost opportunity to blow things up with useless recursivity permalink fedilink source parent hideshow 7 child comments replies: [–] bleistift2@sopuli.xyz 16 points 1 year ago (6 children) The word you’re looking for is recursion (see recursion). permalink fedilink source parent hideshow 6 child comments replies: [–] lugal@lemmy.dbzer0.com 5 points 1 year ago Thanks. I knew something was off permalink fedilink source parent [–] Gonzako@lemmy.world 6 points 1 year ago (4 children) Nah, I'd like to un-see recursion. It was way overblown on uni, I barely ever use it. permalink fedilink source parent hideshow 4 child comments replies: [–] Cethin@lemmy.zip 10 points 1 year ago (3 children) Recursion is amazing for a small selection of problems. Most of the time you don't need, or want, it. When it is useful though, it tends to be really useful. I don't understand people's issue with it. I always found it easy. Maybe that's why I feel this way. Maybe if you find it challenging you want to avoid it, even when it's a good solution. permalink fedilink source parent hideshow 3 child comments replies: [–] Ephera@lemmy.ml 4 points 1 year ago (1 child) I think, their point (and also my experience) is that you get taught about it in university a lot more than about simple loops, so it feels more important even though you rarely use it in reality. Same thing goes for linked lists and inheritance... permalink fedilink source parent hideshow 1 child comment replies: [–] embed_me@programming.dev 2 points 1 year ago Linked lists are encountered somewhat frequently in low level systems programming. permalink fedilink source parent [–] kamstrup@programming.dev 1 point 1 year ago Most devs I know like recursion. Trouble is that many popular languages don't support tail recursion, but throw a stackoverflow error after a few thousand levels. So you have to keep track of max recursion depth manually, and it starts to look like a complicated solution permalink fedilink source parent
[–] dfyx@lemmy.helios42.de 43 points 1 year ago (2 children) There could be a hidden quadratic cost because the string needs to be reallocated and copied multiple times. permalink fedilink source parent hideshow 2 child comments replies: [–] Jerkface@lemmy.world 42 points 1 year ago Not if I don't see it. permalink fedilink source parent [–] kogasa@programming.dev 5 points 1 year ago Not quadratic in the length of the input. Assuming replace is linear this is also linear permalink fedilink source parent
[–] Jerkface@lemmy.world 42 points 1 year ago Not if I don't see it. permalink fedilink source parent
[–] kogasa@programming.dev 5 points 1 year ago Not quadratic in the length of the input. Assuming replace is linear this is also linear permalink fedilink source parent
[–] lugal@lemmy.dbzer0.com 16 points 1 year ago (7 children) True. Lost opportunity to blow things up with useless recursivity permalink fedilink source parent hideshow 7 child comments replies: [–] bleistift2@sopuli.xyz 16 points 1 year ago (6 children) The word you’re looking for is recursion (see recursion). permalink fedilink source parent hideshow 6 child comments replies: [–] lugal@lemmy.dbzer0.com 5 points 1 year ago Thanks. I knew something was off permalink fedilink source parent [–] Gonzako@lemmy.world 6 points 1 year ago (4 children) Nah, I'd like to un-see recursion. It was way overblown on uni, I barely ever use it. permalink fedilink source parent hideshow 4 child comments replies: [–] Cethin@lemmy.zip 10 points 1 year ago (3 children) Recursion is amazing for a small selection of problems. Most of the time you don't need, or want, it. When it is useful though, it tends to be really useful. I don't understand people's issue with it. I always found it easy. Maybe that's why I feel this way. Maybe if you find it challenging you want to avoid it, even when it's a good solution. permalink fedilink source parent hideshow 3 child comments replies: [–] Ephera@lemmy.ml 4 points 1 year ago (1 child) I think, their point (and also my experience) is that you get taught about it in university a lot more than about simple loops, so it feels more important even though you rarely use it in reality. Same thing goes for linked lists and inheritance... permalink fedilink source parent hideshow 1 child comment replies: [–] embed_me@programming.dev 2 points 1 year ago Linked lists are encountered somewhat frequently in low level systems programming. permalink fedilink source parent [–] kamstrup@programming.dev 1 point 1 year ago Most devs I know like recursion. Trouble is that many popular languages don't support tail recursion, but throw a stackoverflow error after a few thousand levels. So you have to keep track of max recursion depth manually, and it starts to look like a complicated solution permalink fedilink source parent
[–] bleistift2@sopuli.xyz 16 points 1 year ago (6 children) The word you’re looking for is recursion (see recursion). permalink fedilink source parent hideshow 6 child comments replies: [–] lugal@lemmy.dbzer0.com 5 points 1 year ago Thanks. I knew something was off permalink fedilink source parent [–] Gonzako@lemmy.world 6 points 1 year ago (4 children) Nah, I'd like to un-see recursion. It was way overblown on uni, I barely ever use it. permalink fedilink source parent hideshow 4 child comments replies: [–] Cethin@lemmy.zip 10 points 1 year ago (3 children) Recursion is amazing for a small selection of problems. Most of the time you don't need, or want, it. When it is useful though, it tends to be really useful. I don't understand people's issue with it. I always found it easy. Maybe that's why I feel this way. Maybe if you find it challenging you want to avoid it, even when it's a good solution. permalink fedilink source parent hideshow 3 child comments replies: [–] Ephera@lemmy.ml 4 points 1 year ago (1 child) I think, their point (and also my experience) is that you get taught about it in university a lot more than about simple loops, so it feels more important even though you rarely use it in reality. Same thing goes for linked lists and inheritance... permalink fedilink source parent hideshow 1 child comment replies: [–] embed_me@programming.dev 2 points 1 year ago Linked lists are encountered somewhat frequently in low level systems programming. permalink fedilink source parent [–] kamstrup@programming.dev 1 point 1 year ago Most devs I know like recursion. Trouble is that many popular languages don't support tail recursion, but throw a stackoverflow error after a few thousand levels. So you have to keep track of max recursion depth manually, and it starts to look like a complicated solution permalink fedilink source parent
[–] lugal@lemmy.dbzer0.com 5 points 1 year ago Thanks. I knew something was off permalink fedilink source parent
[–] Gonzako@lemmy.world 6 points 1 year ago (4 children) Nah, I'd like to un-see recursion. It was way overblown on uni, I barely ever use it. permalink fedilink source parent hideshow 4 child comments replies: [–] Cethin@lemmy.zip 10 points 1 year ago (3 children) Recursion is amazing for a small selection of problems. Most of the time you don't need, or want, it. When it is useful though, it tends to be really useful. I don't understand people's issue with it. I always found it easy. Maybe that's why I feel this way. Maybe if you find it challenging you want to avoid it, even when it's a good solution. permalink fedilink source parent hideshow 3 child comments replies: [–] Ephera@lemmy.ml 4 points 1 year ago (1 child) I think, their point (and also my experience) is that you get taught about it in university a lot more than about simple loops, so it feels more important even though you rarely use it in reality. Same thing goes for linked lists and inheritance... permalink fedilink source parent hideshow 1 child comment replies: [–] embed_me@programming.dev 2 points 1 year ago Linked lists are encountered somewhat frequently in low level systems programming. permalink fedilink source parent [–] kamstrup@programming.dev 1 point 1 year ago Most devs I know like recursion. Trouble is that many popular languages don't support tail recursion, but throw a stackoverflow error after a few thousand levels. So you have to keep track of max recursion depth manually, and it starts to look like a complicated solution permalink fedilink source parent
[–] Cethin@lemmy.zip 10 points 1 year ago (3 children) Recursion is amazing for a small selection of problems. Most of the time you don't need, or want, it. When it is useful though, it tends to be really useful. I don't understand people's issue with it. I always found it easy. Maybe that's why I feel this way. Maybe if you find it challenging you want to avoid it, even when it's a good solution. permalink fedilink source parent hideshow 3 child comments replies: [–] Ephera@lemmy.ml 4 points 1 year ago (1 child) I think, their point (and also my experience) is that you get taught about it in university a lot more than about simple loops, so it feels more important even though you rarely use it in reality. Same thing goes for linked lists and inheritance... permalink fedilink source parent hideshow 1 child comment replies: [–] embed_me@programming.dev 2 points 1 year ago Linked lists are encountered somewhat frequently in low level systems programming. permalink fedilink source parent [–] kamstrup@programming.dev 1 point 1 year ago Most devs I know like recursion. Trouble is that many popular languages don't support tail recursion, but throw a stackoverflow error after a few thousand levels. So you have to keep track of max recursion depth manually, and it starts to look like a complicated solution permalink fedilink source parent
[–] Ephera@lemmy.ml 4 points 1 year ago (1 child) I think, their point (and also my experience) is that you get taught about it in university a lot more than about simple loops, so it feels more important even though you rarely use it in reality. Same thing goes for linked lists and inheritance... permalink fedilink source parent hideshow 1 child comment replies: [–] embed_me@programming.dev 2 points 1 year ago Linked lists are encountered somewhat frequently in low level systems programming. permalink fedilink source parent
[–] embed_me@programming.dev 2 points 1 year ago Linked lists are encountered somewhat frequently in low level systems programming. permalink fedilink source parent
[–] kamstrup@programming.dev 1 point 1 year ago Most devs I know like recursion. Trouble is that many popular languages don't support tail recursion, but throw a stackoverflow error after a few thousand levels. So you have to keep track of max recursion depth manually, and it starts to look like a complicated solution permalink fedilink source parent