Turning the Clock Back to Make Computing Fun Again: It's All Going Python and Packet Analysis

Turning the Clock Back to Make Computing Fun Again: It's All Going Python and Packet Analysis

Introduction

I'm a died-in-the-wool .NET/C#/ASP.NET MVC developer, and I was dead against Python when I first started using it. It's lack of variable definition seemed archaic and it suffered from all the problems that BASIC and ActionScript 1.0 had.  But I've grown to love it, and see its place in the development process, especially in getting things setup quickly, and without installing any pieces of software or having any restrictions in the machine type or the operating system. It's certainly not going to replace the core part of software development, but it provides a quick way of accessing code, without getting locked into a certain operating system or computer type.

C# and Java, with their managed environment and strict controls on syntax, were both meant to address these problems, but have increasingly strangled the developer in what they can do on a system, especially in watching for problems in the development process and in the run-time environment. We move away from x86 architectures with Linux kernels, the need to simplify things becomes important for compatibility, and we can just assume that we can get access to the bloated .NET and Java frameworks. On a chip wit 16KB of memory, a full .NET solution is not quite going to fit.

In BASIC, I could just declare a new variable anywhere in the program by just assigning it a value (the program magically knows the data type of the object). This auto-assignment cuts out a great deal of complexity for the developer, as they do not need to understand complex data structures and classes.

The problems of Python

So if I had a variable call MyVar1, and then I wanted to use it later, I might use "MyVar01", but not match the names, but I think they do, and the program will not operate correctly as they will not match. Unfortunately Python and BASIC allow you to do that.

When I used to teach software we had a general rule ... "DO NOT USE GLOBAL VARIABLES!" which meant you had variables that were contained in the main program, and then these were passed into and out of modules. In Python the user often declares variables which can be used within modules without passing them, and where variables within modules could have the same name as global variables (and cause an incorrect linkage). For example the standard variable for an index counter is I. If I declare it as a global variable, and then use it in functions, the values will be linked, and my global variable could get modified within a function.

A final problem is the lack of structure in the syntax of blocks, and where a TAB space is used to define the structure. All it does it get rid of the parenthesis, and forces the developer to make sure their code can be readable. There's a slight feeling of FORTRAN all over again, but it produces tight code which your eye can quickly scan. Python is not a language that likes files with 1,000s of lines of codes ... it just wants enough code to do that function, and that's it!

How Python overcomes its weaknesses

The most difficult lectures in software development were the ones around defining classes and objects. I've spoken with many students on software development programmes, and there's always a feeling that they don't actually understand what they are doing with object-orientation, class definitions, and in the creation of objects. So if they struggle, most other people with struggle. So Python just say ... leave it ... I'll do it, and takes away a massive amount of complexity, and allows the user to get on with what they want to do ... which is quick produce something that works.

Python overcomes many of its problems by keeping things short, and for the developer to make sure that the code is rock-solid and works well. So the point of Python is that we create short programs which we link together, and I make sure they are all tested well for their inputs and output (just like a function in a program). But the true strength is that I can just run them like any other program, with the complexity of compile it.

The TAB for structure in Python seemed a little strange, but once you get used to it, it's actually okay.

So if you can get around the syntax problem, I've found that Python opens up a whole new world which was closed in Java and C# ... unmanaged/C++ code. Increasing we now compile native code onto whatever machine we are running on, as everyone supports C and C++. While Java and C# don't like the programs accessing "bad code", Python thrives on running code natively, and will happily interface with a C++ library. This now allows access to natively written code, and use all the amazing libraries which have been developed. So I thought I'd showcase one example ... WinPCap.

It's all going to the network

Like it or not, much of the work done now in Computer Security focuses on network activity, especially in the analysis of application layer protocols, such as HTTP, Telnet, FTP and so on. What we need thus is software which easily interfaces to standard libraries like LibPCap and WinPCap (winpcap.dll). While .NET allows access to the library it can be time-consuming in recompiling the code, so Python offers an excellent alternative, as it can be focused to the task in-hand.

Rather than add horribly formatted code in LinkedIn, I have created a tutorial here:

https://www.asecuritysite.com/csn09112/software01

Previously with this tutorial, I'd have to tell students to install Visual Studio, or use the C# compiler, but they might have Macs, so I'd say run it on a VM, and then have to go and get that ... and so on. Now it's a copy and a paste on any machine with Python, and it's off and running, and we can get on with learning some key principles ... which is the understanding of network packets. So here's the tutorial:

Conclusions

It's "horses for courses" in picking software for a task. Python is a "back-end" language ... you never see it, but it's fast and efficient, and gets the job done.  It doesn't have the overhead of all the fancy programming languages, it just gets on with its task and does it, and leaves.

Using Python feels a bit like the days of batch programming ... it knows what it has to do, and it takes something in, and processes it, and outputs it. For the front end, systems need to be robust, with lots of checking for errors, so it's go to be a language such as C# or Java. As the code grows, the development environment tried to manage things to spot problems.

The framework too tries to control things too. This has increasingly restricted things for developers, but Python frees them from the restrictions, and also allows the code to be ported across systems. So it has now matched what C# and Java tried to do - create code which can be ported across system - and added a trumph card of being all to integrate with must of the native code on the system (and still be compatible).

All this takes us back to the 1980s, when we wrote small programs which we called up from our main programs ... and back to BASIC. Personally it makes it more fun again, and I love using Python code ... I appreciate that I often grab existing code and modify it, but that the way it used to be with BASIC, where you'd by a magazine with some code and type it in and run it. So things feels like we are going back to our roots.

The computer systems we have now are powerful with lots of memory and processing power, but the future is towards small devices with limited resources ... and other overblown software development environment does not cope well with them. So well done to Python, it has succeeded in turning back the clock, and allow us to get back to our roots. It's not the complete answer, but for most it allows the access to code that would normally involve a considerable investment in time to setup properly. For most people they just want to flash an LED, or automate a task, and not set up a complex enterprise system. The ability to code will be an increasing requirement in industry as we move to a completely software defined infrastructure, and Python will play a core part of this drive.

You must pay respect, though, to the true King of Software Development ... C/C++ ... pweh! ... what a route it has taken .. and been bashed about a bit, and has now pushed aside all of the other languages and is the true King of the Hill! When I taught software development I used to have many heated debates about whether we should teach C or Pascal, but time has now shown that it is C/C++ that has truly shown how to create a native language which every system can agree on. Python and C/C++ go together seamlessly, and both provide the most basic foundation possible.

Every single graduate from a Computing School, no matter their subject area, should leave a good grounding in software development, and Python provides the one language which an Interactive Design student can use alongside a Networking Engineering student, and alongside a Data Analyst. Like it or not, software and networks are the true focus of our Cyber Age ... and these are the skills which will be in demand.

Basil MANOUSSOS, BSc,MSc,MBCS, ACSFS

BCS Influence Board | Forensic Scientist | Cyber Awareness Evangelist | Expert Witness (Digital Evidence) | Doctoral Candidate |Visiting Lecturer, Sheffield Hallam Uni |

9 年

Interesting article ! But despite limitations, some programing languages did change the world!

回复

要查看或添加评论,请登录

Prof Bill Buchanan OBE FRSE的更多文章

社区洞察

其他会员也浏览了