Writing pythonic C++

Python doesn't have a switch statement. Some people will tell you to use a chain of if ... else statements instead but this can look ugly. One elegant construct to use is a dictionary whose keys are the switch options and corresponding values are functions (lambda or otherwise) that execute appropriate actions. It's all pretty …

Advertisements

c++ dimensional analysis

One of my shaping moments in childhood was being introduced to dimensional analysis in physics class. Is there any hope of efficient dimensional analysis in a medieval language like C++?

std::optional -> Yak Shaving

All I wanted to do was use std::optional. There is a common pattern in computation where you call a function and the function can either return a value or fail. There are various patterns to handle this most of which are pretty ugly. You can use exceptions, where you raise an exception in a function …

Python vs C++: reading a binary file

While adapting some binary file parsing code from Python to C++, I was struck by 1) the supernatural shape shifting power of Python and 2) the opacity of the resulting code - which turn out to be two sides of the same coin.

Heart Stents Are Useless for Most Stable Patients.

The New York Times has published a report on a series of studies that provide good evidence to heart stents not being useful. There may be more of a place for stents in patients who are sicker, who have disease in more than one blood vessel, or who fail to respond to medical therapy. But …

“We would like to invest in your home”

Further proof that the stock market is too expensive, people have way too much cash, and our greed will doom us all, comes via a letter I received today. Paraphrased slightly, it says, "We would like to invest in your home". Basically, they want to give me cash now, like RIGHT NOW! Preferably yesterday,  in …

Aurélien Géron: Hands-On Machine Learning …

If you have an engineering mind-set and are interested in coming up to speed on contemporary (decade of 2010) machine learning practices I recommend Aurélien Géron's book "Hands-On Machine Learning with Scikit-Learn and TensorFlow". I have two other machine learning books on my shelf: Bishop's "Pattern Recognition and Machine Learning" and Hastie et al's "The Elements …