MD Document, Python and C++ Style Script

Multiple Graphs

The following code is for modelling of two graphs. The code on the left is Mat Deck code while the code on the right is the Python code needed for the same two graphs.

matdeck graph code
python graph code

This code is used to generate these two graphs. The first graphs are  from the MatDeck code and the second graphs are from the Python code.

matdeck graph example
python graph example

In MatDeck graph properties can easily be changed by going onto the Graph properties GUI seen below. Every aspect of a MatDeck graph can be changed here to allow for a personalized experience.

graph properties

As we can clearly see, the MatDeck code requires less than a third of the Python code to produce an interchangeable result. The Python code also needs the matplotlib to be downloaded whereas no additional downloads are required for the MatDeck code. The Python graph is created independently from the MD documents. A MatDeck graph can be created in a MD document or separately. Since the Matdeck code uses a MatDeck GUI graph, Colour, Numeration, Fonts, type of graphs and several other features can be changed.

matdeck graph example

python graph example

The graph on the left hand side can also be produced by the first piece of MatDeck code. To generate the graph on the right hand side a different Python code would be needed. This following code would’ve be used to plot the Python graph on the left.

python graph code

Compared to the MatDeck code used for the graph, nearly three times as many lines of code are needed. The MatDeck code was also simply re-used to create this graph, whereas new Python code was needed for it. This especially applies to creating two separate graphs on a single output as we can see in the code below.

python graph code
matdeck graphs

TCP and IP Channels

The following code is for a TCP/IP Sender. This sends the variable (data) through the channel to the receiver. At the end of this code the Sender closes the channel. The variable data can be changed into anything.

As we can see, only eight lines of written code was used in this script and three of those were variable declarations. This shows how little MatDeck code is needed for such a core program.

This code is for the TCP/IP Receiver that is used in parallel with the TCP/IP Sender above to create a full program. As we can see the following program connects to the channel created by the TCP/IP Sender and reads the variable written (data) and then closes the channel. It then outputs the variable receive through the channel under a new name (echo.)

matdeck tcp ip code
python tcp ip code

This time only seven lines of written code are needed and two of the lines are for declaring variable chr and echo. This emphasises how little code is needed for such as widely used program as TCP/IP.

The TCP/IP Sender and Receiver combine to output the variable below. This code was also written in two separate documents to mimic a real TCP/IP protocol.

echo = 10

This file contains a similar amount of code. However, Python uses outside libraries that needed to be downloaded separately and more advanced python that only a skilled programmer would know. The code below is a TCP/IP server created in python code via a MatDeck script. The server below, opens a server socket, receives a message through it decodes it the turns the message into uppercase before encoding it and sending it back to the client. It then closes the socket.

The client code below uses the socket created by the server code above and encodes the string variable called sentence and sends it via the socket created. The variable, modified sentence, then receives the encoded and changed data from the server.

matdeck client code
python client code

Before closing the socket with the server the client prints “From Server” and the decoded variable. The Server and Client codes above produce the following output when used in conjunction:

matdeck console

As we can see above, both Matdeck and Python need seemingly little code for such a fundamental program. While MatDeck script needs less code, the difference is inconsequential. The main distinction between the codes is how coherent the MatDeck code is comparison to the Python code. Python code uses ambiguous language that is hard to follow and can only be interpreted by advanced programmers. The Matdeck code is straightforward and systematic. However, MatDeck cade can be combined with Python code in MD documents to allow for the optimal use.