cat "hey dog!" cat "i have a small go module. can you help me convert it to c++?" dog "sure! the modern cpp version will be so simple that your primitive go version will be a rube goldberg machine in comparison." cat "great, let me show you my go code." edit 1000 0 0 "package intreader\n\nimport \"myorg/filemod\"\n\ntype IntReader struct {\n file filemod.File\n}\n\nfunc New(file myorgmod.File) *IntReader {\n return &IntReader{file: file}\n}\nfunc NewFromPath(filename string) (*IntReader, error) {\n f, err := filemod.Open(filename)\n if err != nil {\n return nil, err\n }\n return &IntReader{file: f}, nil\n}\nfunc (r *IntReader) Close() {\n r.file.Close()\n}\nfunc (r *IntReader) Next() (int, bool) {\n // implementation omitted.\n}\n" cat "this is my go code. nice, eh?" pause 1000 dog "it's nice code like how a septic tank is a nice jacuzzi." cat "let me create my IntReader struct now." edit 300 0 456 "" edit 200 0 0 "struct IntReader {\n}\n" dog "hippie time is over." dog "use a class instead like professional programmers." edit 100 0 6 "class" cat "done." dog "don't forget the semicolon." edit 10 19 0 ";" cat "done. go was quite smart about this though." dog "go thinks it is better than you and inserts the semicolons automatically." dog "c++ isn't pretentious to the point that it writes the code instead of you." cat "oh, very noble." cat "now is my new class object oriented?" dog "if you live in the eighties then yeah." dog "put it into unambiguous namespaces." edit 10 0 0 "\n" edit 2000 0 0 "namespace myorg {\nnamespace intutils {" edit 2000 60 0 "} // namespace intutils\n} // namespace myorg\n" cat "done." cat "now is my class declaration modern enough?" dog "if you hate the users of your class then yes." dog "you are missing header guards." cat "my bad, i shouldn't have asked." edit 10 0 0 "\n" edit 2000 0 0 "#ifndef _MYORG_INTUTILS_INTREADER_H_\n#define _MYORG_INTUTILS_INTREADER_H_" edit 1000 181 0 "#endif // _MYORG_INTUTILS_INTREADER_H_\n" cat "done." cat "i am having doubts about this assignment. all this weird decoration was just 2 lines in go." cat "anyway, let me just add the file member just like what i had in go." edit 1000 130 0 "\n File file_;" cat "oh wait, i'm missing the namespace." edit 1000 133 0 "core::fileutils::" cat "oh, this doesn't work, file_ has to be a pointer because File is an abstract class." edit 100 155 0 "*" cat "there." dog "i wrote a more robust class while flushing my morning fecal matter down the toilet." dog "but okay, go on." cat "now i just need to create the constructors and for Close i'll have a destructor instead." edit 2000 130 0 "\n IntReader(core::fileutils::File *file) : file_(file) {}" edit 2000 188 0 "\n IntReader(std::string filename)\n : file_(core::fileutils::Open(filename)) {}" cat "and now the destructor." edit 2000 272 0 "\n ~IntReader() { delete file_; }" cat "there, i'm getting a hang of it. i'll be a c++ master in no time." dog "it's like a preschooler thinking of being a michelin 3-star chef after she finished preparing her first nutella bread." dog "i don't even know where to start." cat "shut up." dog "you need to open up visibility for the new functions." edit 1000 130 0 "\n public:" edit 1000 314 0 "\n\n private:" cat "this was much simpler in go but done." dog "you need to pass string by reference for efficiency." edit 1000 222 0 "&" dog "oh, i meant const reference, of course." edit 1000 210 0 "const " cat "this is so dumb. so much fluff for a simple string passing. how can people remain sane using this? done." dog "manual pointer management is error prone." dog "you should use a unique pointer for storing that pointer." dog "that also asserts that this class owns the pointer." cat "horserubbish! who the hell cares about this? can't the computer deal with this instead?" edit 1000 335 0 "std::unique_ptr<" edit 100 372 2 "> " cat "whatever, done." cat "ah, crap, i need to update the constructor now." edit 1000 152 0 "std::unique_ptr<" edit 1000 189 2 "> " cat "this wasteproduct is making my lines way too long. how is this legible?" edit 1000 196 0 "\n " cat "it's still not compiling." dog "you need to move the pointer." cat "what the bollocks is this excrement?" edit 1000 211 4 "std::move(file)" cat "done." dog "beautiful." dog "now you can remove the destructor." cat "beautiful my ass." edit 1000 322 33 "" cat "but at least it's one line less, done." cat "my Next function returns two values. can i even express that in this pile of turd?" dog "of course you can." dog "use a pair for that." cat "ugh." edit 1000 321 0 "\n std::pair Next() { ... }" dog "don't put the implementation right into the header." dog "that makes the compilation much slower." dog "put it into the source file." cat "what in the heaven was i doing if not editing a source file?" edit 1000 351 8 ";" cat "you know what?" cat "i'll ship this is as is." cat "one more word from your hole and i'll throw this laptop out the window." dog "but we haven't even talked about exception safety." pause 2000 pause 1000