News for hackers. Stuff that matters.
Re:C++ still isn't cutting it by zabzonk on Sunday October 18, 2020 @12:19PM (#24818928)
You can try, but it would likely be at least 10x the length of the C++ (or rust) program.
Re:C++ still isn't cutting it by saagarjha on Sunday October 18, 2020 @01:26PM (#24819483)
Maybe 5x, with most of that increase being a handrolled associative array.
Re:C++ still isn't cutting it by zabzonk on Sunday October 18, 2020 @01:41PM (#24819632)
You also need at least dynamic string of some sort. Actually, I would estimate 20x - I was being kind with 10x. But feel free to prove me wrong.
Re:C++ still isn't cutting it by saagarjha on Sunday October 18, 2020 @05:50PM (#24821390)
So it turns out that factor is just over 2.5x: https://gist.github.com/saagarjha/00faa1963023206a8ccd987798.... You can split hairs about it being POSIX and inefficient or not checking all the errors, but it works and isn't really all that massive.
Re:C++ still isn't cutting it by tptacek on Sunday October 18, 2020 @03:23PM (#24820376)
Why do you need a dynamic string of any sort for this problem?

(I think you estimated badly, for what it's worth.)

Re:C++ still isn't cutting it by saagarjha on Sunday October 18, 2020 @05:08PM (#24821146)
You'd need it to read words, unless you're using a libc function that does the allocation for you. (Not that you actually need a full string, realloc works just fine for the code I'm writing.)
Re:C++ still isn't cutting it by tptacek on Sunday October 18, 2020 @05:30PM (#24821266)
Yeah, I just used strdup and strsep, like a C programmer. You don't need a dynamic string to count words.

:P