r/Clojure • u/Trouser_Thief • Apr 21 '17
OOP Alternative to Utility Classes
http://www.yegor256.com/2014/05/05/oop-alternative-to-utility-classes.html4
u/underplank Apr 22 '17
Im unclear about this statement
Besides that, it is obvious that the second script runs in O(1) space, > while the first one executes in O(n). This is the consequence of our > procedural approach to data in the first script.
I dont understand how doing the same fundamental process could change the complexity. Somewhere in those classes you have to iterate. Could somebody explain?
1
u/pihkal Apr 23 '17
I think the author is referring to memory being O(1), not CPU. Without seeing any implementations of his proposed classes, I assume .addAll() reads in a line at a time, transforms the line, and writes it out. So it only ever needs enough memory for one line, instead of all lines at once.
Of course, there's absolutely nothing stopping you from processing it line-by-line in a procedural manner, as generations of C programmers have done. E.g.:
while((line = read_some_line(fin)) != null) { write_some_line(fout, trim(line)); }
0
u/zcaudate Apr 24 '17
This has got to be, by far, the most retarded article I have read. Love it.
1
u/zcaudate Apr 24 '17
The comment section is hilarious. The author's answer to this comment http://disq.us/p/17cjgz5 was the highlight of my day.
3
u/Trouser_Thief Apr 21 '17
Not an accidental post, nor a troll, just wondering what you folks make of this article. Would be interesting to have this guy in the same room as Rich Hickey - what happens when an unstoppable force meets an immovable object?