• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

Compile Errors != Linker Errors, BTW why do I get Linker errors?

Software Maintenance is not a top priority in CS education. This is what can happen when you jump head-first into a software project. Happens a lot.


“A Big Ball of Mud is a haphazardly structured, sprawling, sloppy, duct-tape-and-baling-wire, spaghetti-code jungle. These systems show unmistakable signs of unregulated growth, and repeated, expedient repair. Information is shared promiscuously among distant elements of the system, often to the point where nearly all the important information becomes global or duplicated. The overall structure of the system may never have been well defined. If it was, it may have eroded beyond recognition. Programmers with a shred of architectural sensibility shun these quagmires. Only those who are unconcerned about architecture, and, perhaps, are comfortable with the inertia of the day-to-day chore of patching the holes in these failing dikes, are content to work on such systems.”
 
How to avoid output disappearing in Visual Studio

1. Select project properties
2. go Linker/System
3. Set property Subsystem to value /SUBSYSTEM:Console

4. Save

Arrivederci no system("pause") :)
 
Quiz: how to make loops but exclude one index. Which one do you prefer?

C++:
void TestLoops()
{
    std::vector<double> v(20);
    std::iota(std::begin(v), std::end(v), 0.0);

    std::size_t i = 10;

    // I, stops at i
    for (std::size_t j = 0; j < v.size() && i != j; ++j)
    {
        std::cout << j << ",";
    }
    std::cout << '\n';

    // II
    std::cout << '\n';
    for (std::size_t j = 0; j < v.size(); ++j)
    {
        if (j != i)
        {
            std::cout << j << ",";
        }
    }
    std::cout << '\n';

    // III
    for (std::size_t j = 0; j < i; ++j)
    {
        std::cout << j << ",";
    }
    for (std::size_t j = i+1; j < v.size(); ++j)
    {
        std::cout << j << ",";
    }

}
 
Quiz: how to make loops but exclude one index. Which one do you prefer?

C++:
void TestLoops()
{
    std::vector<double> v(20);
    std::iota(std::begin(v), std::end(v), 0.0);

    std::size_t i = 10;

    // I, stops at i
    for (std::size_t j = 0; j < v.size() && i != j; ++j)
    {
        std::cout << j << ",";
    }
    std::cout << '\n';

    // II
    std::cout << '\n';
    for (std::size_t j = 0; j < v.size(); ++j)
    {
        if (j != i)
        {
            std::cout << j << ",";
        }
    }
    std::cout << '\n';

    // III
    for (std::size_t j = 0; j < i; ++j)
    {
        std::cout << j << ",";
    }
    for (std::size_t j = i+1; j < v.size(); ++j)
    {
        std::cout << j << ",";
    }
}
what about break & continue?
 
A general remark that causes issues and leads to somewhat (and long) trial-and-error debugging sessions:
  1. Distinguishing between compiler and linking errors; knowing what they are, what causes them and how to resolve them.
  2. Seeing a compiler as a series of steps to translate Hello.cpp to Hello.exe
  3. Really reading error messages and go to step 1.
  4. When debugging, reduce the scope (e.g. 1st test w/o ExcelDriver). Solving 2 problems simultaneously is not a good idea.
  5. Take an analytical approach.
In one of my early modules I explain the compilation process.
 
Quiz:
Doing a small least-squares linear regression and my first output was wrong. Sometimes it is due to lack of good code inspection and not the math which is impeccable :) Can you spot my stoopid mistake?

C++:
std::vector<double> MyGradient(const std::vector<double>& theta)
    { // Gradient function in ML minimax solvers

// line y = a + bx

        std::vector<double> result(2); // dF/da, dF/db

        double a = theta[0]; double b = theta[1];
        double xj, fj;
        double dfda = 0.0;
        double dfdb = 0.0;

        for (std::size_t j = 0; j < x.size(); ++j)
        {
            xj = x[j];
            fj = y[j] - a - b * xj;

            dfda += fj;
            dfdb += xj * fj;
        }

        result[0] = -2.0*dfda;
        result[0] = -2.0*dfdb;

        return result;
    }
 
Last edited:
Question:
Someone told me that Mac machines don't support VS2019 C++.

AFAIR it does. Has something changed?
 
Facebook and Microsoft join up with Visual Studio

https://developers.facebook.com/blog/post/2019/11/19/facebook-microsoft-partnering-remote-development/

For example, when it comes to code, Facebook is a polyglot. Code is written in Python, C++, Java and in some of our own created languages like Flow, Hack and Reason. Extensions exist to support these languages, which include syntax highlighting, formatters, linters, etc. Flow, for example, has had a Facebook-developed public Visual Studio Code extension since 2015. With Facebook’s internal move to Visual Studio Code, Flow has been in active development, through areas like Language Service Protocol (LSP) improvements, to better ensure the language works great with Visual Studio Code.
 
Back
Top