Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’m a teaching assistant in a C++ course for second-year physics students. The goal is to teach numerical and data analysis, but the course is structured around a very object-oriented style. For example, every function is defined through inheritance:

  class BaseFunction {
  public:
    BaseFunction();
    virtual double Eval(double x) const = 0;
  };
If students want to integrate or find the roots of a function, they must first subclass it:

  class SinClass : public BaseFunction {
  private:
    double _omega, _phase;
  public:
    SinClass(double omega, double phase);
    double get_omega() const;
    double get_phase() const;
    void set_omega(double new_omega);
    void set_phase(double new_phase);
    double Eval(double x) const override {
      return sin(_omega * x + _phase);
    }
  };
Everything in the course (numerical integration, PDEs, Monte Carlo sampling, …) follows this pattern.

The professor is an excellent teacher and students love him. But other faculty worry that our students leave without any real exposure to Python, and that they keep reproducing this heavy OOP style even in situations where a simple lambda or a few lines of NumPy would be far more natural. (Lambdas are shown at the very end of the course, but mostly as a curiosity.)

That’s why I found the blog post so interesting: it shows how natural code can look in Python or Fortran. By contrast, our students’ code is weighed down by boilerplate. It makes me think that sometimes the real difficulty in teaching numerical analysis isn’t the language itself, or whether arrays start at 0 or 1, but the teaching approach that frames every problem through layers of abstraction.



> other faculty worry that our students leave without any real exposure to Python

have you seen this? https://cppyy.readthedocs.io/en/latest/


Nice, thanks!


Is the course about teaching these methods generally, or teaching to implement them in C++ in particular (maybe for e.g. ROOT)?

Using C++ as a pedagogical tool for general teaching of such methods would be quite a choice.


The course is meant to teach students how to write numerical code (integration, PDEs, Monte Carlo, …) rather than to teach OO design itself. C++ is the chosen vehicle, and the professor has a strong OOP background, so the course material ends up structured that way.

That’s why some of us wonder whether a lighter approach (lambdas, NumPy in Python, etc.) might let students focus more directly on the numerical methods without so much boilerplate.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: