3 Ways To Make C++ Easy For Data Scientists
21/30

3 Ways To Make C++ Easy For Data Scientists

What if C++ could be easy?

As data scientist and roboticist I've often opted for a python implementation when it was available. My reasoning - I would be more productive as a developer in python, and if speed was important I could invest time later in C++. A recent project involving a complex system in C++ has changed my mind.

Here are 3 ways modern C++ can make development much faster:

Use auto to infer simple types

C++ has automatic type inference for simple types.

This kind of type inference is not as flexible as duck typing in python, but it can take some of the tedious work out of building types.

All you have to do is use the auto keyword in place of the type.

Use new for-loop syntax

Python has a great for loop syntax.

C++ now has a similar for loop syntax that allows iterating through a standard container without needing to worry about iterators or de-referencing pointers. You can combine it with the auto keyword for very simple for loops that look like this:

for (auto a : container_variable) { }

Use CMake to download dependencies

Managing code dependencies is hard.

CMake is the industry standard way of building C++ solutions, but managing packaging used to involve cloning source code and managing it yourself. CMake has a feature FetchContent, that can be used to download a CMake project from github and load it into your CMakeLists file.

This allows your builds to be easy and reproducible.

Kim Nielsen

Team lead for Process Optimization support

3 年

Not sure if it is a matter of avoidance. The two languages are basically different. I am convinced an understand and experience of C++ will ease the learning process with Python, but it is not an absolute requirement.

Ashkan Rafiee

Advanced Analytics | Artificial Intelligence | Operations Research | Energy System Modelling

3 年

How about just using Julia?

要查看或添加评论,请登录

社区洞察

其他会员也浏览了