Skip to content

Commit 08aca49

Browse files
committed
reorganizing the principles of code chapter and adding more information.
1 parent 7ff5e7c commit 08aca49

File tree

7 files changed

+59
-36
lines changed

7 files changed

+59
-36
lines changed

SUMMARY.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* [Introduction](chapters/introduction.md)
55
* [A Personal Note](chapters/getting_started.md)
66
* [Principles of Code](chapters/principles_of_code/principles_of_code.md)
7-
* [Hindsight](chapters/principles_of_code/hindsight.md)
87
* [Choosing A Language](chapters/principles_of_code/choosing_a_language/choosing_a_language.md)
9-
* [FORTRAN](chapters/principles_of_code/choosing_a_language/FORTRAN.md)
10-
* [Building Blocks](chapters/principles_of_code/building_blocks.md)
8+
* [Compiled Languages](chapters/principles_of_code/choosing_a_language/compiled/compiled.md)
9+
* [FORTRAN](chapters/principles_of_code/choosing_a_language/compiled/FORTRAN.md)
10+
* [Building Blocks](chapters/principles_of_code/building_blocks/building_blocks.md)
1111
* [Code Quality](chapters/principles_of_code/code_quality.md)
1212
* [Mathematical Background](chapters/mathematical_background/mathematical_background.md)
1313
* [Taylor Series](chapters/mathematical_background/taylor_series.md)

chapters/principles_of_code/building_blocks.md renamed to chapters/principles_of_code/building_blocks/building_blocks.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
## Building blocks
2-
3-
INCOMPLETE!
1+
## Building Blocks
42

53
When it comes to programming, there are certain features that will be used again and again, so it's a good idea to mention how they work and where they are used.
64

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
## Choosing a Language
22

3-
I have a perfectly healthy habit of personifying things. I figure a good way to properly distinguish each language from each other is to list the common ones here with a small description about their typical uses.
3+
I'm not going to beat around the bush here. Every single time I try something new, I fail at it. Programming was no exception. By the time I started to learn programming, I knew how to use a terminal decently well, but that was it. I remember googling, "What is the best programming language." The response was (of course) mixed. Many experts said Python was the way to go when learning programming because it was easy to use and used professionally in many areas of computer science and scientific research. Others said to go for Java, which was the most common language to learn for computer science students and thus had a large and rich archive of text to learn from. Still others said to go for C++ or FORTRAN. I was inundated with new information, and I felt like I was drowning in it.
44

5-
**These will be updated. Feel free to let me know your favorite language and why!**
5+
As a fledgling programmer, the problem for me was deciding which language was right for the projects I wanted to do. In my head, I still wanted to be an author, so I wanted to make something creative, and because my entire group of friends was into gaming at the time, I wanted a language that I could make games with. This radically changed my google search to "What language is best for making games?" It was still a bad search. Apparently, almost any language can be used to make games. Who would have guessed?
66

7-
#### C/C++
7+
So there I was, struggling to figure out what to do and where to go. I decided to do what any teenage boy would do in that situation: go to the bookstore and see what books were actually available for purchase at the time. Now, I think the first book I picked up really describes the desperate pit I had dug for myself. It was a book on how to make websites in HTML. Yup. I will refrain from commenting on that book for now because a much more important decision was ahead of me. There before me was an aisle with all the key players I had heard about online: C, C++, C#, Java, Python, Ruby, and so on. They were there just waiting to be chosen. I knew my time had come. I needed to make a decision then and there!
88

9-
#### Python
9+
At the time, I knew the choice didn't really matter. I knew that no matter which language I learned first, most ideas would transfer from language to language. At the same time, the thought of making an uninformed decision terrified me, so I sat there in the bookstore for hours, just staring and thinking to myself. At some point, a store employee walked by and I asked if he knew anything about programming. He said he did, so I asked the only question that popped into my head at the time, "What's the difference between C, C++, and C#?"
1010

11-
#### Julia
11+
The employee said that C# was the newest of the three languages, but that all three were used regularly and if I wanted to learn programming, any would do. Like the experts online, he then suggested python because it was easy for beginners and I was clearly a novice. I thanked him for his time and began thumbing through the book on C#. I remember thinking, *C must be the original language. C+ must be the next generation, followed by C++, then C+++, and then they stylistically changed C++++ to C# by placing the 4 plusses in a pound sign. I guess this means that C will be a little too outdated, but C# might be a little too new. I'll go with C++.*
1212

13-
#### Fortran
13+
I was proud of my deductive reasoning, but before continuing, I would like to point out that this logic was completely flawed. There was never a C+ or a C+++ (so far as I'm aware). The fact is that I didn't know any better. My hope is that many people had similar experiences when they started programming, otherwise I am going to be really embarrassed when people start reading this book.
1414

15-
#### CUDA
15+
Suffice it to say that I learned a good deal of C++, which was a good choice in the end. It is one of the languages I use most frequently nowadays (alongside Python, CUDA, Julia, and FORTRAN), and is an essential tool in my belt. That said, I primarily do computational physics. Everyone will need a different set of tools to attack different problems.
1616

17-
#### Java
17+
So. Let's address the issue of choosing a language.
1818

19-
#### Haskell
19+
As mentioned, this text does everything it can to be *language agnostic,* so the language will not matter too much when trying to learn the algorithms, themselves; however, it will matter when you try to implement them on your own. It would also be nice to formally distinguish what makes certain languages worth studying and using.
2020

21+
For now, let's briefly list all the languages we will eventually cover in the archive:
22+
23+
### Compiled
24+
1. FORTRAN
25+
2. C / C++
26+
3. CUDA
27+
4. Java
28+
29+
### Interpreted
30+
1. Python
31+
2. Julia (half interpreted, to be discussed)
32+
33+
We will obviously add more languages with time. This is simply a quick list. Please let me know which languages you want to cover and I'll add them here!
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Compiled Languages
2+
3+
Programming is hard because we need to write instructions for our computer. The computer then reads this set of instructions and executes them accordingly. That's the story, at least. In principle, there is more to it: *compilation*. Compilation is the act of translating what we write into something the computer can read. This is done with a *compiler*.
4+
5+
In this section, we will talk about all the compiled languages and discuss how to deal with different compilers and compiling options.

chapters/principles_of_code/hindsight.md

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
11
# The Principles of Code
22

3-
This chapter will be updated as the book progresses and is currently incomplete! Sorry about that!
3+
At least to me, programming is a form of creative expression. Sure, programming is difficult. It's difficult in the same way that art, music, or writing is difficult: you know exactly what you want to create, but it takes time to learn how to create it. As I mentioned previously, for a significant portion of my life, I wanted to be an author, so I spent hours and hours every day writing fantasy novels. The more I wrote, the better I got at writing, but when I went back to read the initial chapters of my books, I was frankly revolted at how poor my writing was. By the time I finished revising those chapters and writing more on the side, I felt that the second half of the story was in need of revision too. In the end, I wrote and re-wrote and re-wrote again until I was sick of the story altogether, so I wrote something else. Same characters, different story. It was a vicious cycle that ultimately lead to failure on my part to publish anything.
4+
5+
Here's that cycle again in code:
6+
7+
```
8+
type Human
9+
ability::Int64
10+
standard::Int64
11+
end
12+
13+
function create_something(me::Human)
14+
while (me.ability < me.standard)
15+
me.ability += 1
16+
me.standard += 1
17+
println("I am not good enough. Continuing...")
18+
end
19+
end
20+
21+
create_something(Human(0,1))
22+
```
23+
24+
I am sure this has a name, but I like to call it the *perfectionist's loop*. It's obviously endless and the only way out is by forcing the code to terminate early with `ctrl+c`. Any artist knows this problem. At first, the act of creation is fun, but after a few iterations, it becomes frustrating. Soon, you are curled into a ball in the corner of a room with a paintbrush in your hand and a myriad of colors splattered all over you and the immediate area. In front of you lay the remains of your art, toppled to the ground. It happens. It will probably happen when you learn programming. When it happens, there is only one thing to do: *keep iterating through the loop!*
25+
26+
The moment you press `ctrl_c` is the moment you stop improving. Don't stop improving. Don't lower your standards. If you ever need motivation to continue, look at who you were a few months ago. You should be "better" than that person. If not, figure out what's holding you back and keep iterating through the loop!
27+
28+
The problem is that when it comes to programming, there are a bunch of technical problems that crop up and prevent us from improving. This chapter is specifically written to help you make decisions and improve your ability to program. We'll start with choosing a language -- a question that kept me from even starting programming to begin with. Then we'll move on to programming building blocks and important data structures to remember. The idea is that we'll link to the building block sections when necessary throughout the book. This section will probably be the section that changes the most frequently as the archive evolves. after all, the more algorithms we cover, the more building blocks will be necessary to write them.
29+
30+
As always, let me know if there's anything that is unclear or you think needs to be fixed! Thanks for reading and good luck!

0 commit comments

Comments
 (0)