Split and join is worse because it allocates N junk strings, all of which have to be fully copied only to be copied again and then thrown away. This is the same problem as the "Array.push() is 945x faster than Array.concat()" post from last week: https://news.ycombinator.com/item?id=19991339
As I commented on the other post, all programmers really should spend some time learning how memory, pointers, data structures, heap vs stack, etc. work. Even if you aren't writing C++ at your day job, that stuff matters.
As I commented on the other post, all programmers really should spend some time learning how memory, pointers, data structures, heap vs stack, etc. work. Even if you aren't writing C++ at your day job, that stuff matters.