Comments

Okay what are comments? Its sure that they are not what we post and like on social networks. Its also not what we “comment” about someone’s opinion or attitude or so… In the real programming-life they are not even comments!



What is this “comment” thing anyway?

Good question! Well, in programming comments are what we use to explain how our code works. Comments are some texts you write inside your code so when someone is reading the code, the code be easy to understand. Look at this code for example:


[ #i / 2 - 8 , r ] [ #j / 2 - 4 , d ]
[ 3 , rp ] d [ 3 , l ] p rp rr p d p
[ 2 , lp ] d p [ 3 , rp ] d [ 4 , l ]
[ 7 , rp ] d [ 6 , lp ] d p [ 3 , rp ]
d ll p


What it is and what it does are two really hard problems to solve. So what it is? Actually, it is the code for the Arendelle’s Logo “Birdy”. But it’s really hard to read, right? That’s why we use comments! Arendelle has two kinds of comments. They are the only thing Arendelle uses from another language. Arendelle uses the C style comments. First is what we call in Arendelle slash-slash comment. An slash-slash comment starts with two slashes “slash-slash!” like this:


// comment 


What ever that is in the right side of the slashes till the end of the line will be ignored by Arendelle. So if you write a code like this:


// rp 


You will only see one dot, not two dots because Arendelle ignores what’s after the slashes and it reads the code like this:

p

No more // rp - We use slash-slash comments for one-line comments which we use to explain what’s happening in the next line. Look at this code for example:


// This line goes to #x = 4 and #y = 4: 
   [ 5 , rd ] 

// This line paints the dot with #x , #y of 4: 
   p


Now let’s see how the Birdy’s code will look like if we add comments:


// First Spacings 
   [ #i / 2 - 8 , r ] 
   [ #j / 2 - 4 , d ] 

// Line 1 
   [ 3 , rp ] 

// Line 2 
   d [ 3 , l ] prprrp

// Line 3 
   dp [ 2 , lp ] 

// Line 4 
   dp [ 3 , rp ] 

// Line 5 
   d [ 4 , l ] [ 7 , rp ] 

// Line 6 
   d [ 6 , lp ] 

// Line 7 
   dp [ 3 , rp ] 

// Line 8 
   dllp


You see how more clear is the code when you add comments to it? You now can see that as Birdy has 8 rows of dots you can divide the code to 8 lines and then simply write each line and name it. Now if you want to edit line 6 you know where you have to edit.



Multi Line Comment

In the C way, We have this other comment which people know it as “Multi Line Comment” and in Arendelle we call it slash-star comment. This comment starts with a /* ( slash-star ) and ends with a */ ( star-slash ) what ever you write between two these two /* and */ elements will be easily ignored. so the code like this:


/* [ 10 , r ] */ rp


Will result two connected dots, not two dots with 11 dots distance because what Arendelle see is this:

prp

Nothing more. However there is a common culture about using slash-star comments in the multi line star which is this: When you write a multi line comment. You may write it like this:

/* line 1
line 2
line 3 */

But as you see it’s really ugly! That’s why developers use this style for a multi line comment:


/*
 *   line 1
 *   line 2
 *   line 3
 */
 


Remember to keep asterisks in a line. So as you see this kind of comments are very pretty in multi line. So look at this example:


/*
 *  Copyright 2014 Pouya Kary k@arendelle.org 
 *  This sketch generates a a simple star for you
 */
 


NOTE : Many people like me prefers to use only slash-slash comments. So it’s obvious that you can use them to also write multi line comments line this:


// Copyright 2014 Pouya Kary k@arendelle.org 
// This sketch generates a a simple star for you 




In almost any programming system we write one or a few lines of comment in the start of our app. Explaining the copyright. We also name the developer and we share our emails so if someone wanted to report a problem, or share a bugfix, or a code patch to use find us easily. For example this is a starting comment in Apple’s Swift Language:


// Copyright year firstName lastName 
// one line that explains the code 


As you see it’s a very good starting comment. It says what is the copyright, when the last edit was and what file and project this code is.

In Arendelle we have our own way. This is the template of our starting:


// Copyright year firstName lastName 
// one line that explains the code 


For example:


// Copyright 2014 Pouya Kary k@arendelle.org 
// Birdy - Arendelle’s Logo 


Okay. Let’s look at a real Arendelle app’s code:


// Copyright 2014 Pouya Kary k@arendelle.org 
// Birdy - Arendelle’s cute logo! 

// First Spacings 
   [ #i / 2 - 8 , r ] 
   [ #j / 2 - 4 , d ] 

// Line 1 
   [ 3 , rp ] 

// Line 2 
   d  [ 3 , l ]  prprrp

// Line 3 
   dp  [ 2 , lp ] 

// Line 4 
   dp [ 3 , rp ] 

// Line 5 
   d [ 4 , l ] [ 7 , rp ] 

// Line 6 
   d  [ 6 , lp ] 

// Line 7 
   dp [ 3 , rp ] 

// Line 8 
   dllp


So the code that you’re looking at is the original code for Arendelle’s cute bird! You now can write the original Arendelle’s logo from scratch!