This ends the Requirements Analysis and Specification chapter. The next chapter investigates the various tools available for implementing the system and chooses the best ones for the task.
Chapter 4
Tools and Technologies
4.1 Programming Languages
There are various languages available that could be used to implement the current analysis system. Here is a discussion of some of those languages, leading to a decision on which should be used.
4.1.1 C
Advantages
C has a simple, small core language with extra functionality being provided by a large range of libraries which include maths and file handling functions [36].
This allows programmers new to the language to quickly become proficient in the basics, while the more complicated routines are readily available when needed.
The language the supports procedural programming paradigm [36] which lends itself to modular design. While C does not force modular design upon the pro-grammer, good programmers can use the language to create a cohesive modular structure. The modules are usually separate files which can be compiled sepa-rately. This would be useful for this system since it has been designed as a set of modules with specific functionality.
C is extremely flexible and allows the programmer to have low level control over the computer. As such, the programmer has full control of memory allocation and pointers to create program solutions which are tailored to the problem. The low level nature of the language also results in the language being fast in its
execution. This is a feature which would be welcomed for this system as there are parts of it which need to run as fast as possible.
Through the use of special keywords, C allows the programmer to create new data types to suit the needs of the program solution. This is particularly advantageous for this project as some unique data structures will be needed to store the data for the objects in the system such as nodes, branches etc.
The Lyric Physical Design Framework is programmed largely in C. If this system is also programmed in C, it would be easy to integrate it into Lyric which is an obvious advantage. Furthermore, the author has extensive experience of using C which would mean implementing the system in this language would be easier.
Disadvantages
One disadvantage of C is that memory allocation has to be done explicitly by the programmer. This can lead to errors when memory is not allocated properly.
Allocated memory is also not initialised automatically [36] and so this too has to be done by the programmer to avoid getting bizarre values when trying to access data structures. If C is used, these disadvantages mean that the author will have to be particularly vigilant when allocating the memory for the data structures which will doubtlessly be needed.
C is not a strongly typed language. This means that the compiler will often not complain when a variable is declared as one type and then used to store a value of a different type. Therefore, if using this language, the author will have to be careful when writing the program to ensure variables are used as declared to avoid getting any unusual behaviour.
C has some idiosyncracies in its syntax which can catch the programmer out and cause unexpected behaviour in the program. A well known example of this is accidentally using if (x = 0) instead of if (x == 0). The former will set x to be zero rather than testing if x is equal to zero. This will usually cause the program to run differently than expected, but it will not be picked up by the compiler.
Other such syntax issues include the ”dangling else” and loops that only iterate over the first line if a block if the curly braces are forgotten. These issues mean the programmer has to be very careful when writing a program to ensure the code will perform exactly as they are expecting.
The disadvantages above can mean debugging C code can be problematic which means the author will need good debugging skills.
C also has no automatic garbage collection which means the programmer has to explicitly free all allocated memory.
4.1.2 C++
Advantages
Since C++ is derived from C, it inherits many of the advantages of C such as support for procedural programming, the ability to create bespoke data structures and its general flexibility.
C++ supports object-oriented programming [35]. This allows programs to be organised as a collection of classes and objects, which, enthusiasts claim, makes programming large systems easier. If the circuit analysis system had been de-signed with object oriented programming in mind, this would be an advantageous feature. However, the author is more comfortable with the procedural paradigm which is why the system has been designed in a modular fashion instead.
Despite the extra functionality included into the language to support object ori-ented programming, C++ remains a fast language which is an advantage for the iterative circuit analysis tool which relies on speed.
The majority of Pulsic’s source code is written in C, while a good portion is written in C++. This means that if the system was written in C++, it would be easily integrated into the Pulsic software.
The author has little experience with C++, but the fact that it is a derivation of C and that the author has a lot of experience using C, learning C++ should not present too much of a challenge.
Disadvantages
Since C++ is derived from C, it inherits many of the disadvantages of that language too, such as the idiosyncracies of the syntax and the lack of garbage collection.
While the core of the C++ language is small like C, there are many libraries that deal with the additions for objected oriented programming which can make it seem like a large and complicated language [35]. If programmers try to use all of the functionality at their disposal, then it can be a difficult language to master. The additional functionality can also make C++ a slower language than C. Furthermore, while the standard library has been developed by many users over the years to become useful and reliable, many other libraries have not. This can cause problems when trying to develop programs that utilise these libraries.
The C++ language contains constructors and destructors that are supposed to
help with memory allocation. In reality however, they can often hide a lack of deallocation of memory which then leads to memory leakage.
The error messages produced by a C++ compiler are notorious for being ex-tremely complicated and difficult to understand. This will mean choosing C++
to implement this system will require a lot of effort when it comes to debugging the program.
4.1.3 Java
Advantages
Java’s syntax is heavily derived from that of C/C++ [40] and so it should look familiar and be easy to learn for those programmers who have experience with either of those languages. The author has had some experience with Java, which is an advantage should Java be chosen as the language to be used to implement the circuit analysis system.
Java hides the details of the machine from the programmer. For instance, the programmer does not have to worry about pointers or explicit memory alloca-tion. Java has automatic garbage collection [40], so implementing the system in this language would mean the author would not have to worry about explicitly freeing the memory used by any data structures. These features should make implementing the system easier.
Since it is compiled to bytecode which can run on any machine with a Java Virtual Machine (JVM), Java is an extremely portable language [6]. This is an advantage for this project since the circuit analysis system has to be able to run on a variety of different machines and operating systems. Simply by installing a JVM on each of the platforms, the program would be able to run without any changes to it.
Disadvantages
Java is a pure object oriented language [40]. This means the design of the system would have to be changed to be organised in terms of classes and objects rather than the modular design it currently has, if Java is to be used. The author is also more comfortable with the procedural programming style rather than the object oriented approach.
The inclusion of features such as an automatic garbage collector and the fact it is an interpreted language means that Java is generally recognised as being a fairly
slow language [6]. This is a disadvantage because, as discussed previously, speed is important in certain parts of the system.
As Java hides away the complexities of the underlying machine away from the programmer, the language may be considered to be less flexible than C/C++.
There may be occasions when implementing the system where having tight control over the machine may be beneficial, but this is something which Java will not be able to allow.
As a company Pulsic does most of its programming in C or C++. This means that it will be more difficult to integrate a system programmed in Java into Pulsic’s software than if the system were programmed in either C or C++.
4.1.4 Python
Python is an object oriented language that is good for graphical user interface programming. This is because of its Tkinter package which is a thin object oriented layer on top of Tcl/Tk - a graphical user interface toolkit [41]. As such, Python is the language that Pulsic use to implement all their GUIs.
Pulsic also have a customised set of GUI widgets known as pwidgets. pwidgets are created simply by putting a ’wrapper’ around the normal Tcl/Tk widget set to give the widgets a look and feel that make them unique to Pulsic.
Since the circuit analysis system will be integrated into Lyric and will use the same GUI, this project will use Python for any additions that need to be made to the interface. This is the obvious choice so that there wont be any need to integrate a foreign programming language into the GUI software. Furthermore, its imperative that any additions to the GUI retain the same look and feel as the rest of it. Therefore it is necessary that the added widgets are created from the pwidgets widget set, which means using Python.
4.1.5 Conclusion
Having considered the pros and cons of the major languages available for imple-menting the circuit analysis system, the decision has been made to use C. This is because the author has extensive knowledge of the language which should reduce implementation time and also the majority of the Lyric source code is written in C which should mean integrating the two systems should be an easier task.
Furthermore, C is a fast language which will help enable the system to meet its performance requirements, and the language supports the procedural
program-ming paradigm which is the author’s preferred programprogram-ming style.
As for implementing the graphical user interface of the system, the only option really is to use Python since it will enable an easy integration into Lyric and also maintain Lyric’s look and feel.