Actuarial Outpost
 
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Software & Technology
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions

DW Simpson
Actuarial Jobs

Visit our site for the most up to date jobs for actuaries.

Actuarial Salary Surveys
Property & Casualty, Health, Life, Pension and Non-Tradtional Jobs.

Actuarial Meeting Schedule
Browse this year's meetings and which recruiters will attend.

Contact DW Simpson
Have a question?
Let's talk.
You'll be glad you did.


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-02-2015, 10:31 AM
actuary21c actuary21c is offline
Member
 
Join Date: Sep 2009
Location: UK
Studying for double bass & jazz piano
Posts: 1,786
Default Towards the next improvement in programming languages

I have programmed (so far) in Basic, Fortran, Visual Basic, C, C++, perl, php, VB.net, C#, F#, html and javascript. I've also dabbled a tiny bit in Scratch (for raspberry pi) and python.

My favourite of all the above is C# because of its object oriented nature and the richness of the .net framework and the ability to restrict scope of variables to just the part of the code they are needed (via the use of { } within a function).

However, there are 2 parts of C# that I don't like:
  1. (this is a problem with the .net framework, not C# per se): terrible error messages from Microsoft. (eg "the system cannot find the file specified", "the dictionary already contains the key specified" "Index out of range". In each case, the error message needs to be specific, ie say WHAT the specified file/key/index was.)
  2. Inability to create class properties at runtime. This would be very useful eg in creating charts where the names of the series are set by the user at run time. (There are workarounds, and there is an ExpandoObject class in System.Dynamic, but that doesn't work very well with web apps, which is what I prefer to write these days).

Other developers on the AO: what is your preferred language for writing in, and how would you like to see it improved? What would your ideal language look like?
__________________
Spoiler:

Quote:
Originally Posted by Brock View Post
a21c is one of the better posters on the AO. That's not saying he's good.

UK software developer, actuary, musician, atheist. All posts in a personal capacity (unless explicitly stated otherwise in the post).

Last edited by actuary21c; 07-02-2015 at 10:31 AM.. Reason: added F# and php
Reply With Quote
  #2  
Old 07-03-2015, 09:17 PM
AndrewC's Avatar
AndrewC AndrewC is offline
Member
 
Join Date: Aug 2010
Posts: 946
Default

What I would like to see is easier implementation of GPGPU. I think actuarial modelling can have a great benefit of using GPGPU. However, it is still not simple to use in most programming languages. So far, I think MATLAB is doing some works to simplify GPGPU. Any idea on other programming languages?
__________________
AC.
Reply With Quote
  #3  
Old 07-05-2015, 10:55 PM
actuary21c actuary21c is offline
Member
 
Join Date: Sep 2009
Location: UK
Studying for double bass & jazz piano
Posts: 1,786
Default

Quote:
Originally Posted by AndrewC View Post
What I would like to see is easier implementation of GPGPU. I think actuarial modelling can have a great benefit of using GPGPU. However, it is still not simple to use in most programming languages. So far, I think MATLAB is doing some works to simplify GPGPU. Any idea on other programming languages?
I haven't used GPU (Graphical Processing Units) in calculations, I'm afraid. (So far I've taken the view that cloud computing / parallel processing should enable the speed improvements I want, but maybe you have other advantages in mind? Have you seen http://www.marriottsinclair.com/ by the way? They claim to make heavy use of GPU.)
__________________
Spoiler:

Quote:
Originally Posted by Brock View Post
a21c is one of the better posters on the AO. That's not saying he's good.

UK software developer, actuary, musician, atheist. All posts in a personal capacity (unless explicitly stated otherwise in the post).
Reply With Quote
  #4  
Old 07-09-2015, 10:29 AM
actuary21c actuary21c is offline
Member
 
Join Date: Sep 2009
Location: UK
Studying for double bass & jazz piano
Posts: 1,786
Default Anyone care to sing the praises of Java, or Python, or Ruby?

I have little experience of any of the above (in fact none of Java [NB I mean Java, not Javascript]). Does anyone out there really love any of these, and if so why?
__________________
Spoiler:

Quote:
Originally Posted by Brock View Post
a21c is one of the better posters on the AO. That's not saying he's good.

UK software developer, actuary, musician, atheist. All posts in a personal capacity (unless explicitly stated otherwise in the post).
Reply With Quote
  #5  
Old 07-09-2015, 09:05 PM
Bill Rudolph Bill Rudolph is offline
Member
 
Join Date: Jan 2005
Posts: 42
Default

1. "what is your preferred language for writing in" C++
2. "how would you like to see it improved?" concepts
3. "What would your ideal language look like?" I have no idea.
Reply With Quote
  #6  
Old 07-26-2015, 11:46 PM
actuary21c actuary21c is offline
Member
 
Join Date: Sep 2009
Location: UK
Studying for double bass & jazz piano
Posts: 1,786
Default

Quote:
Originally Posted by Bill Rudolph View Post
1. "what is your preferred language for writing in" C++
2. "how would you like to see it improved?" concepts
3. "What would your ideal language look like?" I have no idea.
Hi Bill Rudolph

Have you used C#? If so, I'd be interested in your views on the following, given that you prefer C++.

I used C++ until C# came along. I prefer C# to C++ because:
- there is no need to have separate header and body files (.h and .cpp files in c++ always seemed to me like unnecessary duplication)
- it used to be (maybe this has improved) that you had to have separate files for each class in c++. So with say 50 classes (very common in my experience) that meant 100 files (again the doubling from .h and .cpp files), whereas you can put as many classes as you want into a c# .cs file
- c++ may be a tiny bit faster (typically 5% from what I've read) but that extra performance is not worth it compared to the advantages above which make writing code so much easier, and in any case, code optimisation is usually best done by finding the bottleneck and optimising that (in c++ if really needed)

in your reply to 2 above, please would you expand a bit on what you mean by "concepts"?

Thanks
__________________
Spoiler:

Quote:
Originally Posted by Brock View Post
a21c is one of the better posters on the AO. That's not saying he's good.

UK software developer, actuary, musician, atheist. All posts in a personal capacity (unless explicitly stated otherwise in the post).
Reply With Quote
  #7  
Old 07-27-2015, 02:41 PM
pragmatist pragmatist is offline
Member
CAS Non-Actuary
 
Join Date: Jan 2014
Posts: 173
Default

Quote:
Originally Posted by actuary21c View Post
Hi Bill Rudolph
I used C++ until C# came along. I prefer C# to C++ because:
- there is no need to have separate header and body files (.h and .cpp files in c++ always seemed to me like unnecessary duplication)
- it used to be (maybe this has improved) that you had to have separate files for each class in c++. So with say 50 classes (very common in my experience) that meant 100 files (again the doubling from .h and .cpp files), whereas you can put as many classes as you want into a c# .cs file
It's not that you have to; it's just how teachers/books want you to organize your program. In fact, you could have everything (declarations and code) in the cpp file as long as you meet compiler's requirements. To me, declaring structures in the .h files is annoying; it's like having to use book B every time you want to see the index of book A.
Reply With Quote
  #8  
Old 07-27-2015, 04:42 PM
actuary21c actuary21c is offline
Member
 
Join Date: Sep 2009
Location: UK
Studying for double bass & jazz piano
Posts: 1,786
Default

Quote:
Originally Posted by pragmatist View Post
It's not that you have to; it's just how teachers/books want you to organize your program. In fact, you could have everything (declarations and code) in the cpp file as long as you meet compiler's requirements. To me, declaring structures in the .h files is annoying; it's like having to use book B every time you want to see the index of book A.
Agreed, and you get the usual hassles of duplication (every time you want to change the signature of a class method/function, you've got to do in two places etc).
__________________
Spoiler:

Quote:
Originally Posted by Brock View Post
a21c is one of the better posters on the AO. That's not saying he's good.

UK software developer, actuary, musician, atheist. All posts in a personal capacity (unless explicitly stated otherwise in the post).
Reply With Quote
  #9  
Old 07-27-2015, 10:11 PM
Bill Rudolph Bill Rudolph is offline
Member
 
Join Date: Jan 2005
Posts: 42
Default

"Have you used C#?" No.

Separate header and source files are not needed. I normally start with one main.cpp "Hello World" file and then go from there. As the code grows, though, and the file gets bigger it is more difficult to manage. It is also possible that the file grows so big that the compiler can not handle the size of a particular translation unit. When I first started programming C++ that happened to one of my programs. It was template heavy with a lot of skulduggery. The compiler crashed. I sent an e-mail to the compiler writer asking him what had happened. He wrote back suggesting that I split the program into multiple source files. I did and the problem was resolved. I also re-read chapter 9 "Source Files and Programs" of Stroustrup's TCPL book that explained all this. That was a particularly difficult section of the book to understand.

You wrote "it used to be...that you had to have separate files for each class.... So with 50 classes...that meant 100 files (again the doubling from .h and .cpp files) ...." I guess this suggests that there was one header for each source file. I do not understand.

Let me describe to you a little of how I am coding a program. The program currently has 9 source files and 60+ header files. The header files are nested (e.g., I have an #include matrix.hpp line in the iterative_inverse_matrix.hpp header). The nesting can be deep.

The header matrix.hpp (1156 lines of code) contains vector and matrix classes, and some accompanying functions.
Reply With Quote
  #10  
Old 07-27-2015, 10:17 PM
Bill Rudolph Bill Rudolph is offline
Member
 
Join Date: Jan 2005
Posts: 42
Default

Here is some code that is similar to what would be found in matrix.hpp.

#ifndef MATRIX_HPP
#define MATRIX_HPP

namespace bonkers {

template<class Q0,class Q1>
class Matrix<numeric_tag,checked<nope>,Q0,Q1>:public Matrix<simple_tag,checked<nope>,Q0,Q1> {

using ELEMENT_TYPE=Q0;
using INPUT_TYPE=Q1;

using BASE=Matrix<simple_tag,checked<nope>,ELEMENT_TYPE, INPUT_TYPE>;

public:

const ELEMENT_TYPE& operator()(const INPUT_TYPE& t1,const INPUT_TYPE& t2) const
{
//no check that this is out of bounds...

return BASE::operator()(t1,t2);
}

};

template<class Q0,class Q1>
class Matrix<numeric_tag,checked<yep>,Q0,Q1>:public Matrix<simple_tag,checked<nope>,Q0,Q1> {

using ELEMENT_TYPE=Q0;
using INPUT_TYPE=Q1;

using BASE=Matrix<simple_tag,checked<nope>,ELEMENT_TYPE, INPUT_TYPE>;

public:

const ELEMENT_TYPE& operator()(const INPUT_TYPE& t1,const INPUT_TYPE& t2) const
{
if(outside_constraints(t1,t2))
throw some_class();

return BASE::operator()(t1,t2);
}

};

}

#endif

Of course, this is not complete. The matrix classes are partial specializations of another matrix class. They are also children which inherit some member functions from the parent. numeric_tag, simple_tag, yep, and nope are classes without much import. checked is a template class.

Why would I need more than one matrix class? I might need a matrix class for more than one program. I could access the checked matrix class in one program and the unchecked matrix class in another. Alternatively, I could access both of the matrix classes in one program. I might have that program do some simple arithmetic operations that require the checked matrix. On the other hand, I might have an iterative inverse matrix algorithm that does not need a check on individual elements but rather on the whole matrix. By not having to check each element, the time the algorithm takes processing a matrix is significantly decreased.

Last edited by Bill Rudolph; 07-27-2015 at 10:52 PM..
Reply With Quote
Reply

Tags
.net, csharp, languages, programming, python

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 03:36 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.46451 seconds with 9 queries