51
monkcs
4y

So I have a teacher that when he use "C++" it is basically C with a .cpp file-extension and -O0 compiler flag.

Last assignment was to implement some arbitrary lengthy calculation with a tight requirement of max 1 second runtime, to force us to basically handroll C code without using std and any form of abstraction. But because the language didn’t freeze in time 1998, there is a little keyword named "constexpr" that folded all my classes, arrays, iterators, virtual methods, std::algorithms etc, into a single return statement. Thus making my code the fastest submitted.

Lesson of the story, use the language to the fullest and always turn on the damn optimizer

Ok now I’m done 😚

Comments
  • 3
    Nice!
  • 3
    No compiler optimisation is just bs. Well done. One upping the teacher is always bonus points in my book.
  • 4
    @hjk101 yeah like the “ if I turn on -O3 the code doesn’t work” argument is like, stop write undefined behavior then!
  • 4
    he knows.

    I used to tutor students and would specifically show them the long way.

    when they were done, i would show them the easy way.

    this way, they knew both and why we use the easy way.
  • 3
    I heard from other students (same course, but they started a year after me) that their new programming instructor, who's supposed to teach them the first introduction to programming, didn't even teach them that C and C++ are two different things
  • 2
    Nice story!
  • 1
    Hey i am New at this app and i have to say something on this image it is a LOL
Add Comment