Going Markdown for book notes

2016-12-02 00:00:00 +0000

So for a long time I have been trying out different ways to take notes for my books and writing character sheets. However no tool I have found actually does exactly what I want. The tools where either too complex or relied to heavily on muse interaction or the internet. The latter is a problem as I have a tendency to disable the internet when I write, to minimise the possible distractions during my process.

So what options do I have then. Well I have a text processing program such as Microsoft Word or LibreOffice Writer, or a note taking program such as OneNote. But and thing all these have in common is that they are uselessly heavy and have a strange workflow in my opinion. This is not saying that they are not excellent applications. So where should I then turn? Well Emacs of course it is my favourite editor and it can actually do a lot of the things I want, with a mode called Org or Organisation mode. But at the moment I do not have the time to learn a new mode (Christmas holly day is coming)… So what to do? Well it turns out that Org mode likes Markdown and so do I. Therefore I will start using it for my notes.

But why do I choose Markdown and not ReStructuredText (rst)? Well first of there is not a big difference and I just prefer the syntax of Markdown. However it is also to streamline the amount of formats I use and as I am already using Markdown for this blog, README files, university notes and so on. It just makes sense to go Markdown.

So now you know why, but what does this mean? It means that I will come with some blog post about how to use Markdown in Emacs, how to convert it pdf’s and latex and a few other things.

-Lars Nielsen

Status - A couple of updates

2016-10-24 00:00:00 +0000

So as you might have noticed, the blog is in scrambles. There are a couple of reasons for this which I will cover in this blog post. I will also cover why I have not be blogging, but also what topic I will blog about in the near future and also a bit about what is going on in my life.

So let us get started

Scrambles and why

If you have followed this blog for a while you will noticed, that I have changed back to a more standard Jekyll theme (if you know Jekyll). This change was committed and worked as it should. However, I wrongly executed a commit all script in the blog root and by such a lot of draft post was published which I was working on. Therefore the blog is currently in scrambles, and it will take me a bit of time to edit and sort out the problems.

Why I have not been blogging and what to come

When I started at my Masters degree back in September, at lot of things change. Firstly the project group which I have been a part of for the past two and half years, split into atoms and I had to find a new group. Luckily I found that during the summer break, but it still have taken some adjustments and by such I have spend a lot of time on that.

Secondly, due to a (sorry Professor) hopeless course and style of lecturing, I have had to study an entire course based only on literature, instead of lectures and literature. Which is a completely new concept to me and it has consumed a lot of time.

Finally, due to different aspirations I have had during the summer break and start of the semester. I have been completed stressed out, all at my own account and fault. However, it have had me lash out at friends and comrades, resulting in me having to patch up a lot of things.

Those three factors have done such that I have been completely drained of energy and times. Hopefully I will become better at controlling myself and spend time on project I 100 percent care for and find less stressful.

What is going on with my life

I am still attending Aalborg University, just as a master student instead of a bachelor. I have also both chosen a topic and found a project for my 9th semester project and master thesis. Which I will begin in about a year. However, at the moment I am not at liberty to name the subject of either project nor thesis. I will state that it is about performance benchmarking and parallel programming. I have also found a supervisor to each project, again not at liberty to say who (yet). I will though state that the both will be done in collaboration with a company (guess which) and I might need a co-supervisor from another department at the university.

Topics to come

Here I will write a few topics I am going to write blog post about in the coming months

  • Going Markdown
  • Functional programming, why its a curse and a blessing
  • Emacs, a welcome home
  • Archetypes - A “class” of characters in my books universe
  • The war and the fall that followed - Prelude to my book (a very shorted version of the back storry)
  • Why I continue with Mac
  • Goodbye Manjaro, hello again Fedora
  • MacBrew - A new open source project
  • irisPause - The saga continues
  • More book stuff

Best Regards,


Why using immutable restriction in programming is good

2016-09-18 00:00:00 +0000

I have developed software libraries for some years now and part of that have been learning to designing API’s for idiots. What I mean with that is; People with gladly use a software library without reading the full documentation for it, and then when do something which the API was never intend for. They complain that it is not acting as it is supposed to. One of the things I have experienced are people whom either expect and object to change or not change if it is parsed to a function or procedure. Therefore if either happens, they think the library is broken and needs to be fixed. This often happens when a user have not read the documentation for a function they are using. I found that a way to actually avoid this is by applying a restriction on the input given to a function. This is the restriction of saying this will not change or this is constant. Effectively making a object immutable, for a given function or and entire application.

So what does this mean? Well before we get started let me explain the concept of constant. I will base this in C++ but it can be applied in C#, Java and such, but it might need the application of other keywords. For instance in C# it is sealed and readonly. Now back to C++, in C++ we have two usages of constant I will explain but both using the keyword ‘const’. One is the application of making a variable immutable by applying the const keyword when we declare the variable.

const int x = 10;

Let us break down, we have a integer x, x is 10 and it is constant 10. What this means is that x will ALWAYS be 10 and it cannot be changed. Therefore if yourself or another developer uses x, you can always be certain that it is 10. This is very neat as there will be no confusion, when testing and function and its results. It also ensures that there are no discussion when you have to determine the value of variable.

The second usage of ´const´ is function based immutability. Just to emphasis I will show a function signature;

float avg(const int[] data, const int size);

What we have is the function signature for method calculating the average of integer values in an array. As you can see, I have applied the ‘const’ keyword to both data and size. This is to tell the user of the function that in the function ´avg´ we will never change either data nor size. Emphasising to the user that if he/she uses this function, the content of data and size will not change and are in good hands.

There is a third option of using const in C++, but I have never actively used it myself, but it is used to explicitly tell that a function cannot change member variables of a class and are only applicable when doing object oriented programming

To Emacs or to Atom

2016-08-26 00:00:00 +0000

So I will start at university again next week and by such my summer is over and so it is time for me to decide between Emacs and Atom.

First I would like to remind you why I decided to try out other editors. I started trying others editors due to RSI problems and I suspect one of the reasons for my RSI issues was Emacs and it strange key bindings. This let to that I wanted to try out other editors.

I started out with trying out both Spacemacs and Atom. Where I found Spacemacs impossible to setup at least for me and therefore I ended to only focused on Atom. Which I have already written a blog post about this topic, so see that please.

So what is the result and why is the result as is? Well I have actually decided on something I usually do not do. I have decided to continue to use both Atom and Emacs.

I normally never use two tools for the same thing, but I simply do not think I have spend enough time with Atom yet to dismiss, but I still prefer Emacs (surprise). But do really like Atom, and would like to get to know it even more. Because I think with a couple of months additional usage of Atom, it might actually become my preferred editor (if I can get the damn British dictionary to work).

That is actually basically that. The only difference I will be using Atom only at work and for my study development work. While I will continue using Emacs for writing my documents and books.

-Lars Nielsen

My take on Template Programming in C++

2016-08-05 00:00:00 +0000

So lately I have been doing a lot of C++ programming with heavy usage of template programming, which is a type of meta/generic programming. Which have inspired this blog post. Now I am not an expert at all, that would take years and this is not a guide to template programming. This is my take on the advantages and disadvantages.

So let us get started, what does template programming enable you to do? Well it enables you to make your code dynamic, in the sense that types are first determined at compile time, and not while you are coding. This means that we can create methods which can take different kind of types, depending on how it is invoked.

template<typename Type>
class vector
    vector(uint32_t size);

    void push_back(Type item);
    Type pop();
    uint32_t m_size;

Let us continue based on the code example above, just so we have some common ground. We have a template of the following structure template<typename Type>, this is a type template which allow a type to be “dynamic” until compile time, where the type will be set in stone, and then type checking is performed. This type for of template allows us to create a vector like auto x = vector<int>(); or auto y = vector<double>();.

We are also able to create templates of variadic length, and based on a pre set type. But as this is not a guide, we will not dwell on this. But if you are into C++ programming take a look at here: cppreference:Template . Bonus info cppreference.com is an awesome reference database for C++ and I use it often.

So what is the advantages and disadvantages with using templates? Well like all generic programming, it often lessens the amount of code you actually have to write. For example can these methods using polymorphism

int add(int x, int y);
double add(double x, double y);
float add(float x, float y);
int add(int x, float y);

Be replace with a single method utilizing templates:

template<typename TypeOne, typename TypeTwo>
TypeOne add(TypeOne x, TypeTwo y)

But is this a good idea, to replace a set of type specific functions with a single template function? In my opinion both yes and no. No because if you are a newcomer to software development, you need to understand different concepts such as polymorphism and type compatibility, writing functions with specified types seems to be a good way to learn both in my opinion. Therefore I suggest newcomers to actually write out the code, you can always learn tricks for writing less code. But it is also a good idea, for the experienced developer it can be quite the advantage to write lesser code and by such become a more efficient and accomplished programmer.

However in addition to lessen the amount of code, it can also make it hard to get and overview of a codebase. If you as a developer is not familiar with template, heck not only templates, generic programming in general it can be really hard to get an overview over codebase using generic programming. Some would argue that if code is hard to write, it should be hard to read. I would argue that if code is hard to read, you as a developer wrote it wrong.

Another disadvantages with template programming is the header only approach. The functions I have written above, cannot be defined in a .cpp file, why I am not completely certain about, but it is annoying. But why it is annoying, well it is because it increase compile time. The smallest change in the code of a header file can/will result in a recompilation of an entire project. Which can take a lot of time if you are working on a very large project.

So is template programming a go or a no-go? Well after working with it, everyday for a week I can say that I love it, and would not be without it. I would like to recommend template programming for non-novice C++ developers.

-Lars Nielsen

subscribe via RSS