<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Programming | Remotely Actuarial</title><link>https://www.remotely-actuarial.com/tags/programming/</link><atom:link href="https://www.remotely-actuarial.com/tags/programming/index.xml" rel="self" type="application/rss+xml"/><description>Programming</description><generator>HugoBlox Kit (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Wed, 09 Sep 2020 00:00:00 +0000</lastBuildDate><image><url>https://www.remotely-actuarial.com/media/icon_hu_da05098ef60dc2e7.png</url><title>Programming</title><link>https://www.remotely-actuarial.com/tags/programming/</link></image><item><title>Rust for Domain Experts</title><link>https://www.remotely-actuarial.com/blog/rust-vs-python/</link><pubDate>Wed, 09 Sep 2020 00:00:00 +0000</pubDate><guid>https://www.remotely-actuarial.com/blog/rust-vs-python/</guid><description>&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Over the past few years I have been writing more and more Rust code. I have been using Python for many years, it&amp;rsquo;s a
great language, and I am very productive in it. However, I have come to the conclusion that Rust is a really strong
candidate for domain experts to learn. By domain expert I mean someone who does not have a formal computer science
background. I&amp;rsquo;m in this category, my domain being Actuarial Modeling. I will refer to Actuaries below, but you can
insert your domain if you are in the same boat as I believe the arguments apply across domains.&lt;/p&gt;
&lt;h2 id="but-isnt-python-good-enough"&gt;But isn&amp;rsquo;t Python good enough?&lt;/h2&gt;
&lt;p&gt;Python is a fantastic tool and language. I feel I owe a lot to Python and the community that supports it. In my
initial years working as an Actuary I was always drawn to the more technical roles, especially with regard to
technology. For any new Actuary without any knowledge of programming or computer science this meant bending Microsoft
Excel to do things it was never designed to do.&lt;/p&gt;
&lt;p&gt;I then started to work on a product then embedded Python, I had the Python interpreter and standard library at
my finger-tips. This was an amazing period of exploration. It was like a whole new world opened up for me. I
started to realize the power of a &amp;ldquo;proper&amp;rdquo; programming language. Over the next few years I became quite proficient in
Python and I loved the power that came with it. I felt I was able to hack on anything I wanted, and it was quite
addicting. Sometimes I would solve certain problems in a certain way just to use feature X or challenge myself. I have
come a long way in my Python journey and over time I invested in learning to fill in the holes in my skills with
regard to software development.&lt;/p&gt;
&lt;p&gt;Python can be used to build larger software systems that need to be performant, i.e. Actuarial Modeling, but as with
most things in life you are making a trade off. Python is &lt;em&gt;too easy&lt;/em&gt; in some sense. People copy and paste code that
uses (insert-new-machine-learning-framework) and just go from there. In reality, it takes an investment in the basics
of software development to really &lt;em&gt;learn&lt;/em&gt; it correctly, or more accurately learn how to manage it correctly. When I
write large systems in Python now it feels a little like taking out a loan. I can have that instant satisfaction of
building something fast, but I know that I&amp;rsquo;m going to have to pay for it down the line in the form of maintenance.&lt;/p&gt;
&lt;p&gt;Another drawback is when you hit the performance barrier in Python. All the high performance libraries in Python are
written in C/C++ but every so often your problem does not fit into the paradigm that these libraries use (typically
array processing). At this point you&amp;rsquo;re out of luck, you can invest in numba, Cython, etc. but they bring their own
complexity and trade-offs.&lt;/p&gt;
&lt;h2 id="rust-is-too-hard-for-actuaries-to-learn"&gt;Rust is too hard for Actuaries to learn&lt;/h2&gt;
&lt;p&gt;There is no denying that Rust is more difficult to learn than Python, but let&amp;rsquo;s not sell the Actuarial profession short
here. Actuaries spend years studying complex topics, it&amp;rsquo;s well within their reach to learn Rust. In general, I don&amp;rsquo;t
feel that Actuaries embrace programming as much as they should. Quants embrace programming and go head first into C++
of all things, I would love to have Actuaries take this approach also, i.e. the mind-set not C++&amp;hellip;&lt;/p&gt;
&lt;p&gt;I prefer to look at Rust as enforcing standards, i.e. quality at the source. Yes, you will get frustrated but once it
complies generally it works. Also, once it complies there are whole classes of bugs that are ruled out, the kinds of
bugs that you always remember to write tests for in Python, right? Rust is blazing fast and complies to a single binary
meaning that deployment is simple. Hand over the .exe and it runs, no more serving as the Python install help desk
within your team.&lt;/p&gt;
&lt;p&gt;The biggest win for Rust though is that in return for the upfront investment you create systems that are far more robust
and easier to maintain. When you build a large system in Python it&amp;rsquo;s easy to build because you have the whole system in
your mind while you are working on it. However, coming back to said system years later and making changes can be
difficult especially if others have been developing it since then. The Rust compiler is the ultimate code reviewer
ensuring that everyone is keeping up their standards.&lt;/p&gt;
&lt;h2 id="a-short-note-on-c"&gt;A short note on C++&lt;/h2&gt;
&lt;p&gt;Yes - this actually &lt;strong&gt;is&lt;/strong&gt; too hard to learn for Actuaries (in general). In order to learn C++ you really need to
immerse yourself in it. There is no other way, the language is too big (something I hope does not happen Rust). You
have to learn the concepts encoded in the Rust borrow checker as &lt;em&gt;good coding practice&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id="where-do-i-sign-up"&gt;Where do I sign-up?&lt;/h2&gt;
&lt;p&gt;After all this would I recommend using Rust today, yes I would. However, it will still feel like you are an &amp;ldquo;early
adopter&amp;rdquo; the point of this post is that I see it being a far more attractive option in Actuarial Modeling in the future.
Like all software, great abstractions can reduce the barrier to entry and increase productivity. At the moment, you
kind of need to &amp;ldquo;roll your own&amp;rdquo; for a lot of things. I think that once some foundational Actuarial Modeling libraries
are in place Rust will be a great option for Actuaries and Actuarial Modeling in particular. My involvement in the
Apache Arrow project has been motivated with this goal in mind. More to come on that&amp;hellip;. I hope :)&lt;/p&gt;</description></item></channel></rss>