diff options
Diffstat (limited to 'comp/lucas-standen-NEA/writeup/coverpage.ms')
-rw-r--r-- | comp/lucas-standen-NEA/writeup/coverpage.ms | 154 |
1 files changed, 93 insertions, 61 deletions
diff --git a/comp/lucas-standen-NEA/writeup/coverpage.ms b/comp/lucas-standen-NEA/writeup/coverpage.ms index e62d80d..2aced24 100644 --- a/comp/lucas-standen-NEA/writeup/coverpage.ms +++ b/comp/lucas-standen-NEA/writeup/coverpage.ms @@ -10,15 +10,17 @@ Analysis .NH 2 The current problem .PP -For general small and simple projects, I write in C. However this leads to hours of debugging due to segfaults, and memory leaks. -Due to the languages manual memory management the programmer is required to know so much information about the hardware they write for, -and the second anything goes wrong, it is vague on how to fix things. +For general small and simple projects, I write in C. However this leads to hours of debugging due to +segfaults, and memory leaks. Due to the languages manual memory management the programmer is +required to know so much information about the hardware they write for, and the second anything goes +wrong, it is vague on how to fix things. .B "I need a language that stops me from shooting myself in the foot" -C has been standard for many decades now and its age is showing, it lacks many modern features like OOP, or higher level functional abstractions, that have become common -in modern years due to there helpfulness. This is not to fault C's achievements either, the language is my personal choice for most projects for a reason, -it's fast and powerful; any solution I make should not cut that away. +C has been standard for many decades now and its age is showing, it lacks many modern features like +OOP, or higher level functional abstractions, that have become common in modern years due to there +helpfulness. This is not to fault C's achievements either, the language is my personal choice for +most projects for a reason, it's fast and powerful; any solution I make should not cut that away. .NH 2 A solution @@ -26,22 +28,25 @@ A solution .BI "Zippy LANG" A next generation language, for general use. Designed for keeping code simple, neat and readable. -It will be similar to functional languages, known for there strict ability to keep code safe and practical. -The language should be interpreted like python, perl and lisp, to allow for easy debugging tools. +It will be similar to functional languages, known for there strict ability to keep code safe and +practical. The language should be interpreted like python, perl and lisp, to allow for easy +debugging tools. The goal of Zippy is to make codding easier, while remaining fast, with a interpreter writen in C. .NH 2 Clients .PP -In a project of this nature, the Client is every programmer alive; which is a pretty large scope. To narrow this down as much as possible, I will interview a small handful -of people throughout the project, of different skill levels. +In a project of this nature, the Client is every programmer alive; which is a pretty large scope. +To narrow this down as much as possible, I will interview a small handful of people throughout the +project, of different skill levels. .NH 3 Client 1, Amy C .PP -My first client is a friend of mine, Amy C, she is a confident programmer who has completed many complicated projects. I am choosing her as a client as she can give me -technical feed back on my project and its function/utility. +My first client is a friend of mine, Amy C, she is a confident programmer who has completed many +complicated projects. I am choosing her as a client as she can give me technical feed back on my +project and its function/utility. .NH 3 Client 2, a technical user, but not a programmer .PP @@ -53,54 +58,61 @@ some stuff about how the normie finds the completed project. .NH 3 Client 4, myself .PP -I've wanted to take out a project like this for a long long time, and this is the perfect opportunity to do so, I will be assessing myself along the way of this, -building the project to my personal specification. +I've wanted to take out a project like this for a long long time, and this is the perfect +opportunity to do so, I will be assessing myself along the way of this, building the project to my +personal specification. .NH 2 Examples of similar projects .PP -As Zippy will be interpreted, I should compare it to other such languages; trying to compare it to C++/rust/go, isn't helpful as they are so very different in the way they -function. +As Zippy will be interpreted, I should compare it to other such languages; trying to compare it to +C++/rust/go, isn't helpful as they are so very different in the way they function. -Zippy is by far not the first language, and I'm only one person, so I can't expect to beat others in everything. +Zippy is by far not the first language, and I'm only one person, so I can't expect to beat others in +everything. Below are a few languages that zippy should be compared to throught developemen: .NH 3 Python .PP -Python is a high level OOP language that was designed in 1991. It was made to make programming easy while still being able to use some of C's functions. -Although it has become standard for many use cases, it is slow and inefficient, and very bloated. +Python is a high level OOP language that was designed in 1991. It was made to make programming easy +while still being able to use some of C's functions. Although it has become standard for many use +cases, it is slow and inefficient, and very bloated. https://www.python.org/ -Zippy should take pythons high level abstractions, as they make programing very easy and it should try and take notes from its libaries as they are mostly well writen, -and well documented. +Zippy should take pythons high level abstractions, as they make programing very easy and it should +try and take notes from its libaries as they are mostly well writen, and well documented. .NH 3 Lisp .PP -Lisp is the second ever programming language, developed at MiT, it is the first functional language, creating many common features like higher order functions, recursion, -and garbage collection. It is generally not used anymore as it feels old compared to other functional languages, like ocaml or haskell. +Lisp is the second ever programming language, developed at MiT, it is the first functional language, +creating many common features like higher order functions, recursion, and garbage collection. It is +generally not used anymore as it feels old compared to other functional languages, like ocaml or haskell. https://lisp-lang.org/ -Zippy should try to take alot from the syntax of lisp, () make it easy to see what parts of code will effect what, and make things easy to parse. +Zippy should try to take alot from the syntax of lisp, () make it easy to see what parts of code +will effect what, and make things easy to parse. .NH 3 Perl .PP -Perl is scripting language designed for use in linux, when bash is too slow, or not suited for the job. -Perl is often described as the glue of the universe (see xkcd https://3d.xkcd.com/224/). Its syntax is quite strange however and it is slow. -Making it poorly suited towards general use. +Perl is scripting language designed for use in linux, when bash is too slow, or not suited for the +job. Perl is often described as the glue of the universe (see xkcd https://3d.xkcd.com/224/). +Its syntax is quite strange however and it is slow. Making it poorly suited towards general use. https://www.perl.org/ -Zippy should take from perls minimalisum, it is a small language that is of a similar size to bash or zsh, while feeling closer to python. If zippy can achieve a -similar small size, while remaining powerful I will be pleased +Zippy should take from perls minimalisum, it is a small language that is of a similar size to bash +or zsh, while feeling closer to python. If zippy can achieve a similar small size, while remaining +powerful I will be happy. .NH 2 Questionnaires .PP -It is important to get feedback from end users, so I will take multiple questionnaires throughout the project. I will then use them to slightly edit the requirements of my -project this should make the final outcome more helpful and what people want. +It is important to get feedback from end users, so I will take multiple questionnaires throughout +the project. I will then use them to slightly edit the requirements of my project this should make +the final outcome more helpful and what people want. In the section bellow you will find questionnaires from the analyses stage of my project. .NH 3 @@ -115,11 +127,14 @@ Speed, readability, debugging ease and disk space efficiency. .NH 4 What tools are important for a language to have? (eg: pkg-manager, IDE integration) .PP -IDE integration (things like tab complete and debugging tools), a package manager, and the ability to interact with the user through the command line easily. +IDE integration (things like tab complete and debugging tools), a package manager, and the ability +to interact with the user through the command line easily. .NH 4 -What features do you like from other languages (eg: C's advanced memory management, haskell's terse syntax) +What features do you like from other languages (eg: C's advanced memory management, haskell's terse +syntax) .PP -The ability to pass the memory reference of an object or function and a collection of built-in or standard functions like "print", "split", or "sort". +The ability to pass the memory reference of an object or function and a collection of built-in or +standard functions like "print", "split", or "sort". .NH 4 What do you want to program in this language (eg: websites, low level systems) .PP @@ -143,24 +158,27 @@ I try to use as little languages in a project as possible, so likely not in an e .NH 4 Do you care for low level control, or would you prefer high level abstractions? .PP -I think low-level control is very important, but high-level abstractions are convenient, so a good balance between the two is best. +I think low-level control is very important, but high-level abstractions are convenient, so a good +balance between the two is best. .NH 4 -Would you be happy to develop libraries for things that aren't already implemented (eg: an SQL library) +Would you be happy to develop libraries for things that aren't already implemented +(eg: an SQL library) .PP Potentially if it is simple enough to implement new things. .NH 3 Notes from questionnaire 1 .PP -Some of the key things that I'm taking away from this first questionnaire, are my client/users initial needs and use cases. -I think it's clear my language can be of assistance to my client, Zippy will be a good language for web back ends and small command line tools, which my client expressed +Some of the key things that I'm taking away from this first questionnaire, are my client/users +initial needs and use cases. I think it's clear my language can be of assistance to my client, Zippy +will be a good language for web back ends and small command line tools, which my client expressed interested in. -I find the fact my client is worried by executable size interesting, however I doubt it will be an issue; a ballooning code-base is unlikely as only one person -is writing the project. +I find the fact my client is worried by executable size interesting, however I doubt it will be an +issue; a ballooning code-base is unlikely as only one person is writing the project. -I am also taking on the fact that my client wants good command line tools, so a pkg-manager and bundler should be a priority, perhaps they could be written in Zippy after -the interpreter is done. +I am also taking on the fact that my client wants good command line tools, so a pkg-manager and +bundler should be a priority, perhaps they could be written in Zippy after the interpreter is done. .NH 3 The first elements of the project @@ -181,17 +199,20 @@ Ensure the language is well supported with tools like a pkg-manager. .NH 2 Abstract data structures and there implementations .PP -In larger projects, when a programmer needs a data structure that the language they are writing in doesn't provide, they will need to make their own. +In larger projects, when a programmer needs a data structure that the language they are writing in +doesn't provide, they will need to make their own. Bellow are a few examples of these data structures that C doesn't already provide. .NH 3 Linked lists .PP -this is an alternative implementation of a list, where you store some data, and the memory address to the next node. Then you can move through the list by reading the data -then reading the data of the next node, and then repeating until the 'next' part of the node is empty. +this is an alternative implementation of a list, where you store some data, and the memory address +to the next node. Then you can move through the list by reading the data then reading the data of +the next node, and then repeating until the 'next' part of the node is empty. -In C this is easy to implement as you can find a memory address very easily with '&' to find where a bit of data is stored. I will need to use a 'struct', which is a bit like -a class in C (however you can't attach a function to it). A simple implementation looks like this: +In C this is easy to implement as you can find a memory address very easily with '&' to find where +a bit of data is stored. I will need to use a 'struct', which is a bit like a class in C (however +you can't attach a function to it). A simple implementation looks like this: typedef struct ll { @@ -201,15 +222,19 @@ typedef struct ll { } ll; -The pro's of a linked list are the fact that they can have data appended to the start or end easily by changing the root node, or the next node. +The pro's of a linked list are the fact that they can have data appended to the start or end easily +by changing the root node, or the next node. -Linked lists have a few downsides, for example you can't move through them backwards, and unless you store it on its own, you cant find the length of it in a fast way. +Linked lists have a few downsides, for example you can't move through them backwards, and unless you +store it on its own, you cant find the length of it in a fast way. -In my project I would like to use linked list in the AST (see later sections for info), and to store lists in the language. +In my project I would like to use linked list in the AST (see later sections for info), and to store +lists in the language. .NH 3 Dictionaries .PP -A dictionary is a simple data structure that just stores, a bit of data, and a number or string to identify it. +A dictionary is a simple data structure that just stores, a bit of data, and a number or string to +identify it. A dictionary like a linked list can be implemented with a struct in c like so: typedef struct dict { @@ -220,7 +245,8 @@ typedef struct dict { } dict; -In my project I think I could use a linked list represent a zippy variable and an ID that i can use to identify it, this could make execution faster as i can compare ID's +In my project I think I could use a linked list represent a zippy variable and an ID that i can use +to identify it, this could make execution faster as i can compare ID's rather than string values .NH 2 @@ -228,10 +254,12 @@ Prototyping hard features .NH 3 Abstract Syntax Trees (AST) theory .PP -In a programming language many abstract data types will be used to allow the code to execute, however I think the hardest part of this is an abstract syntax tree. -This is a data structure that holds the code in an ordered form that can be analysed and executed in a simple way. It is a tree structure, with the top node being a root -and all lower nodes being things needed to calculate the root. It can be used not only for code but also for mathematical expressions. I think the easiest way to show it -is via a mathematical example +In a programming language many abstract data types will be used to allow the code to execute, +however I think the hardest part of this is an abstract syntax tree. This is a data structure that +holds the code in an ordered form that can be analysed and executed in a simple way. It is a tree +structure, with the top node being a root and all lower nodes being things needed to calculate the +root. It can be used not only for code but also for mathematical expressions. I think the easiest +way to show it is via a mathematical example Take the follow expression for example: @@ -239,7 +267,8 @@ Take the follow expression for example: We know that this is equal to -49 -However for a computer this is far harder to understand. This is because it has no understanding of order of operation +However for a computer this is far harder to understand. This is because it has no understanding of +order of operation To solve this we use an AST (abstract syntax tree) @@ -250,15 +279,18 @@ We can represent the steps as a tree like so: .PSPIC ast.ps .PP -As you can see, you need to evaluate the expression in the most brackets first, then the next, and so on, working you way up +As you can see, you need to evaluate the expression in the most brackets first, then the next, and +so on, working you way up -You can evaluate code in a similar way, treating each operation (such as +-*/) as functions, doing the most deeply nested function first, then working up. -Each expression can be represented in this tree, then to show a whole program you can create a list of trees +You can evaluate code in a similar way, treating each operation (such as +-*/) as functions, doing +the most deeply nested function first, then working up. Each expression can be represented in this +tree, then to show a whole program you can create a list of trees .NH 3 Implementing AST's .PP -As a prototype i will make a program that can take mathematical expressions and evaluate them, and allowing for functions (in the form f(x)). +As a prototype i will make a program that can take mathematical expressions and evaluate them, and +allowing for functions (in the form f(x)). It will do this via AST's This prototype takes 173 lines of code, it takes a string as a cmd line argument then converts it |