Why Python is a terrible language for education

The interpreted language Python is a lot of fun. It’s great for quick and dirty lash-ups, and has list comprehensions whilst being easier to use that Haskell. There are many great reasons why you would never deploy it in a production environment, but that’s not what this article is about.

In the UK, the government decided that schoolchildren needed to learn to code; and Python was picked as the language of choice.

Superficially it looks okay; a block structured BASIC and relatively easy to learn. However, the closer I look, the worse it gets. We would be far better off with Dartmouth BASIC.

To fundamentally understand programming, you need to fundamental understand how computers work. The von Neumann architecture at the very least. Sure, you can teach CPU operation separately, but if it’s detached from your understanding of software it won’t make much sense.

I could argue that students should learn machine code (or assembler), but these days it’s only necessary to understand the principle, and a high level language like BASIC isn’t that dissimilar.

If you’re unfamiliar with BASIC, programs are made up of numbered lines, executed in order unless a GOTO is encountered. It also incorporates GOSUB/RETURN (equivalent to JSR/RTS), numeric and string variables, arrays, I/O and very little else. Just the basic building blocks (no pun intended).

Because of this it’s very quick to learn – about a dozen keywords, and familiar infix expression evaluation, and straightforward IF..THEN comparisons. There are also a few mathematical and functions, but everything else must be implemented by hand.

And these limitations are important. How is a student going to learn how to sort an array if a language has a built-in list processing library that does it all for you?

But that’s the case for using BASIC. Python appears at first glance to be a modernised BASIC, although its block structured instead of having numbered lines. That’s a disadvantage for understanding how a program is stored in sequential memory locations, but then structured languages are easier to read.

But from there on, it gets worse.

Types

Data types are fundamental to computing. Everything is digitised and represented as an appropriate series of bits. You really need to understand this. However, for simplicity, everything in python is treated as an object, and as a result the underlying representation is completely hidden. Even the concept of a type is lost, variables are self-declaring and morph to whatever type is needed to store what’s assigned to them.

Okay, you can do some cool stuff with objects. But you won’t learn about data representation if that’s all you’ve got, and this is about teaching, right? And worse, when you move on to a language for grown-ups, you’ll be in for a culture shock.

A teaching language must have data types, preferably hard.

Arrays

The next fundamental concept is data arrays; adding an index to a base to select an element. Python doesn’t have arrays. It does have some great built in container classes (aka Collections): Lists, Tuples, Sets and Dictionaries. They’re very flexible, with a rich syntax, and can be used to solve most problems. Python even implements list comprehensions. But there’s no simple array.

Having no arrays means you have to learn about the specific characteristics of all the collections, rather than simple indexing. It also means you won’t really learn simple indexing. Are we learning Python, or fundamental programming principles?

Structuring

Unlike BASIC, Python is block structured. Highly structured. This isn’t a bad thing; structuring makes programs a lot easier to read even if it’s less representative of the underlying architecture. That said, I’ve found that teaching an unstructured language is the best way to get students to appreciate structuring when it’s added later.

Unfortunately, Python’s structuring syntax is horrible. It dispenses with BEGIN and END, relying on the level of indent. Python aficionados will tell you this forces programmers to indent blocks. As a teacher, I can force pupils to indent blocks many other ways. The down-side is that a space becomes significant, which ridiculous when you can’t see whether it’s there or not. If you insert a blank line for readability, you’d better make sure it actually contains the right number of spaces to keep it in the right block.

Please generate and paste your ad code here. If left empty, the ad location will be highlighted on your blog pages with a reminder to enter your code. Mid-Post

WHILE loops are support, as are FOR iteration, with BREAK and CONTINUE. But that’s about it. There’s no DO…WHILE, SWITCH or GOTO.

You can always work around these omissions:

do
<something>
until <condition>

Becomes:

while True: 
<something>
if <condition>:
break

You can also fake up a switch statement using IF…ELSEIF…ELSEIF…ELSE. Really? Apart from this being ugly and hard to read, students are going to find a full range of control statements in any other structured language they move on to.

In case you’re still simmering about citing GOTO; yes it is important. That’s what CPUs do. Occasionally you’ll need it, or at least see it. And therefore a teaching language must support it if you’re going to teach it.

Object Orientation

And finally, we come on to the big one: Object Orientation. Students will need to learn about this, eventually. And Python supports it, so you can follow on without changing language, right? Wrong!

Initially I assumed Python supported classes similar to C++, but obviously didn’t go the whole way. Having very little need to teach advanced Python, I only recently discovered what a mistake this was. Yes, there is a Python “class”, with inheritance. Multiple inheritance, in fact. Unfortunately Python’s idea of a class is very superficial.

The first complete confusion you’ll encounter involves class attributes. As variables are auto-creating, there is no way of listing attributes at the start of the class. You can in the constructor, but it’s messy. If you do declare any variables outside a method it silently turns them into global variables in the class’s namespace. If you want a data structure, using a class without methods can be done, but is messy.

Secondly, it turns out that every member of a class is public. Always. You can’t teach the very important concepts of data hiding; how to can change the way a class works but keep the interface the same by using accessors.

And talking of interfaces, what about pure virtual functions? Nope. Well there is a way of doing it using an external module. Several, in fact. They’re messy, involving an abstract base class. And, in my opinion, they’re pointless; which is leading to the root cause why Python is a bad teaching language.

All Round Disaster

Object oriented languages really need to be compiled, or at least parsed and checked. Python is interpreted, and in such a way as it can’t possibly be compiled or sanity checked before running. Take a look at the eval() function and you’ll see why.

Everything is resolved at run-time, and if there’s a problem the program crashes out at that point. Run-time resolution is a lot of fun, but it contradictions object orientation. Things like pure virtual functions need to be checked at compile time, and generate an error if they’re not implemented in a derived class. That’s their whole point.

Underneath, Python is using objects that are designed for dynamic use and abuse. Anything goes. Self-modifying code. Anything. Order and discipline are not required.

So we’re teaching the next generation to program using a language with a wide and redundant syntax and grammar, incomplete in terms of structure, inadequate in terms of object orientation, has opaque data representation and typing; and is ultimately designed for anarchic development.

Unfortunately most Computer Science teachers are not software engineers, and Python is relatively simple for them to get started with. The problem is that they never graduate.

Baofeng DM-9HX programming software





Until Baofeng gets around to putting it on its web site, you can download a copy here  DM-9HX Program Software. Use at your own risk, but it came direct from the CD.

I assume this is probably Baofeng’s copyright, although it’s never been claimed.  I asked last year if it was okay to pass it on, and haven’t been told I can’t.

 

Talkmobile APN data settings for Android

If you’re trying to get Talkmobile working with the current version of Android and have tried various settings on the Web with no luck. The Talkmobile web site itself is also incorrect. Here are the real ones as of right now…

Go to “Access Point Names” under setting somewhere. You’ll see Vodafone ones already there, probably. Ignore them.

Create a new one. Call it “Talkmobile” or whatever you fancy. The only three settings you need to change are:

APN Name: talkmobile.co.uk

User name: wap

Password: wap

Proxy: 212.183.137.12

Port: 8799

APN Type: * (if this doesn’t work try “Default”)

I haven’t given the MMS settings because I leave them blank and avoid rip-off charges!

Baofeng DM-9HX First Look Review

The DM-9HX looks the same as the UV-9HX which is the same as the UV-5R. Everything fits.

It’s finally here – Baofeng has released its proper digital version of the UV-5R and you can just-about get it in the UK by direct import (although I gather Moonraker have a few).

I reviewed their first digital model, the DM-5R, and concluded it was a bad idea as it only implemented Tier 1 and therefore could only talk to identical transceivers. A real pity. There is supposed to be a Tier-II version, the DM-5R Plus, but I don’t know anyone who’s seen one and even the specifications say it’s isn’t compatible with Motorola. Anyway, it seems to be history or myth now the DM-9HX has arrived.

The DM-9HX does Tier II, and should talk to DMR sets from other manufacturers and work through repeaters. I haven’t personally tested this properly as yet, but indications are good. So with that in mind, on with an initial review:

I’ll assume you know previous Baofeng models well enough and concentrate on the differences. But just in case you don’t, the legendary Baofeng UV-5R series are cheap and cheerful handheld dual-band FM 2m/70cm transceiver with a speaker/mic socket and an MSMA connector for whatever antenna you choose. There is a tri-band model, and they all seem to have a built-in torch.  A number of variations in case style exist, including waterproof, as do versions with uprated RF. But they’re pretty much identical at the user level; and they’re the mainstay of many people’s community PMR set-ups as well as a no-brainer for Ham use.

Baofeng announced it was going to produce a digital version, which was physically interchangeable with previous models but with added DMR capability. This is a great proposition for people like me, with dozens of UV-5R batteries, antennas, chargers, cases and so-on. It protects your investment whilst allowing controlled migration to DMR. It’s been a long time coming, but now it’s here.

So first off – the interoperability is there. It uses exactly the same accessories as the UV-5R. It’s the same size and looks like a UV-5R – apart from the all-new display. Good job. The only physical difference is the programming cable, which is a direct USB feed into the microphone socket. And it doesn’t work with CHIRP. If you look closely, the label also says DM-9HX (check the picture near the top) and the keypad is overprinted for digital mode – alpha instead of menu shortcuts. The DM-5R/Plus had a black VFO button but they’ve gone back to orange with this model. I’ve had to put a rubber sleeve on it to find it amongst the others.

The new dot-matrix screen is more flexible and easier to read,

Inside the box you get a new “digital” antenna, the standard charger and the large battery. I’ve yet to test how much difference the fancy antenna makes; for ease of carrying, and like-for-like comparison, I swapped it for a standard battery and a stubby antenna. Moonraker supplied a standard Beofeng headset (yeah) with theirs; others don’t. The charger is the same, and it comes with the larger BL-5 12Wh battery although the smaller type still fit.

It also comes with an English manual, which is reminiscent of the one supplied with the DM-5R. It doesn’t actually relate to the DM-9HX, which is different enough for this to matter.  But we’re radio amateurs, right? We like fiddling with things to find out how they work.

Compared to the analogue models, the user interface is much improved in terms of sanity, while remaining similar in some respects. The buttons do more-or-less the same, with the side ones being programmable. Alpha text entry on the keypad is now Nokia-like, with the # key switching case and three alpha characters on each number key.

The display is a high-res monochrome dot-matrix instead of a segmented LCD found on the analogue models and the DM-5R. It’s very clear to read, and back-lit either permanently or on a timer. There are also no more voice prompts. This is either a good or bad thing, depending on your taste.

Instead of settings being arranged in one long numbered list, in the new world they’re in a hierarchy of menus. Some settings are in odd places, but in general it’s a big improvement and easy to get around. The layout in the manual is simply incorrect, but even then it didn’t take too long to find most things. Some, however, were more difficult – read on and save yourself some trouble.

One handy feature of Beofeng analogue sets is the “dual watch”. This allows you to monitor two frequencies, and optionally lock on to the active one for transmissions. Although it appears in the manual, it wasn’t in the menu. The truck is to turn off “Power Saving” mode, after which it appears. There’s no sensible explanation of “Power save” mode, but it’s on by default.

Another oddity is tone squelch. CTCSS can be set on T, R and C. I’m not sure what ‘C’ is but I suspect it simply sets both T and R at once. The same menu identifies itself as setting DCS modes, but doesn’t appear to allow any such thing. I’ve yet to find a way of doing it on the radio, but you can from the programming software. This turns out to be true of quite a few things, for not apparently good reason.

Remember the analogue channel saving game, where you could write current settings to a memory and it sometimes worked? It was always a bit hit-and-miss in my experience, so I left it to CHIRP, but the DM-9HX has dropped the option entirely from the radio but it’s still described in the manual.

I struggled to program our local repeater in to the set, and discovered the following:

It’s not possible to save current VFO settings to a memory.

It is possible to edit a memory when in MR mode, to an extent.

This is logical, but is a PITA if you’ve just got something working in VFO mode. and you want to save it. If you do want to store to a channel, switch to MR mode, choose the channel and then edit. The editing menu options vary from VFO mode, just to make life interesting. For example, you can’t program an offset transmit frequency using the direction/offset menu settings (they’re disabled in MR, but not in VFO). However, you can enter separate Tx and Rx frequencies directly (calculating the Tx in your head, of course). It’s a bit illogical, but it works.

Another thing you’ll need to know is that a memory location is either designated as Digital or Analogue. This is set using the programming software, and cannot be changed on the radio. Neither can unused memory locations be brought in to use. As shipped, a mixture of sixteen analogue and digital channels were configured by default; you’re going to need the programming software if you want to make use of the memory, but saying that, making quick tweaks to an existing memory on the radio is much easier than it was before. As a suggestion, you might want to define a load of channels in software early on, so you have enough to choose from when programming using the radio.

One big worry with the first unit I tested (I have others waiting) is that the CTSS appeared not to work on receive. However, leaving it set on Tx it seemed to work for both. Further investigation needed on this one.

And so to the programming software:

I received the programming cable and a small anonymous CD containing many files. One of these was a ZIP with a name in English identifying it as related to the DM-9HX, so I installed it. It was the right one, but it’s hard to tell because it came up in Chinese, and does so every time. Keep going through the menus until you find “English”, select the option and all will be well – assuming you don’t speak Chinese.

The cable is a USB lead, with multi-ring plugs that go into the mic socket. I’d have liked to see a micro-USB socket on the radio for programming, but it works. Windoze recognises without the need for any special COM port driver. Yeah! It recognises it as a mouse, but it works.

After this rocky start, I’m pleased to report that the programming software has worked perfectly so far. Some of the terminology for settings doesn’t match the radio, manual or any known term I know of but you can figure it out easily enough.

There’s no manual for the software, but it does have useful help information that appears in a lower window pane. A lot of additional options related to digital operation, such as phone books and zones. As a GUI, it works as you might expect.

For locking down the radio, you can select which menus are available to the user in a way that seems very flexible. You can also set the allowed frequencies, as you could with the analogue sets.

There is, however, one serious limitation to the software. I have found no way of importing/exporting memories to a spreadsheet. You have to enter them all, one at a time, using dialogue boxes. This is NOT cool.

Will CHIRP support this? Well no one has been inclined to add support for the DM-5R since 2016, but then again who would want to use one? Unfortunately, looking at the technicalities and very different nature of DMR it’d take some work to add, although it’s been propo DMR-6X2sed for 0.5.0.

The programming for another Beofeng DMR, the DMR-6X2, does import/export CSV so it’s entirely possible I’ve just not figured it out yet but I’ve looked closely.

Conclusion

That’s about it for this quick look. I’ve done some RF tests, the results are to follow, as is some proper photography. I’ve spoken to friends over analogue. The sound quality was described as fine, but through a repeater to mobile stations.

To conclude, after the false-start on the DM-5R, the DM-9HX delivers – both in terms of DMR functionality, compatibility and as a major step forward in usability. With a few rough edges.

 

Facebook has user data slurped

The following has just appeared on Facebook’s press release page:

Security Update

“On the afternoon of Tuesday, September 25, our engineering team discovered a security issue affecting almost 50 million accounts….”

“Our investigation is still in its early stages. But it’s clear that attackers exploited a vulnerability in Facebook’s code that impacted… a feature that lets people see what their own profile looks like to someone else.”

Mark Zuckerberg’s understated response to the incident was “I’m glad we found this and fixed the vulnerability. It definitely is an issue that this happened in the first place. I think this underscores the attacks that our community and our services faces.”

Wall Street’s response so far has been a 3% drop in Facebook’s stock.

I’m now waiting to see which of my sock puppets is affected.

Tesco Bank hit with £30m fine for computer breach

According to a Sky News exclusive, the FCA is set to clobber Tesco Bank with a fine of £30m over the data breach in late 2016, where £2.5m was snaffled from thousands of its customer’s current accounts. Except it turned out it wasn’t; only fifty accounts were actually plundered, not for very much, and it was all sorted.

So how does this warrant such a huge fine? It’s hard to see, but the first two theories I have are that Sky News has got of wrong, or the FCA has gone seriously bonkers. If they’re touching miscreant institutions for £600K per customer inconvenienced, RBS and NatWest are toast.

So what’s it all about? Well we don’t know what Tesco Bank actually did. My best guess is that someone cloned cards and cashed out at ATMs. That’s the easiest way, and there is no evidence this was widespread or sophisticated. And its interesting that only current accounts were hit; not credit – which is where the big money is in retail banking fraud.

But that’s just a guess. Why would the FCA be so exercised about some card fraud?

There is not shortage of other theories. There is the usual criticism of the patent company and its insecure non-banking systems. The usual unpatched server card is played. Yes, everyone knows Tesco self-checkouts use Windows XP. There ate criticisms of the lack of protective monitoring. Lack of AV. But this comes from commentators whose employer’s business is selling such things. There is talk of an inside job, which is possible but they didn’t take them for much if it was.

So if the FCA is really that cross with Tesco Bank, why?

The question no one is asking is why Tesco Bank announced a major breach, affecting so many people? Here I’m stacking guesses, but just for fun…

If I’m right about it being ATM bandits, could it be that staff investigating found something horrible and hairy, and jumped to the conclusion it was behind it? They did the right thing, and told everyone about the vulnerability, but the black hats hadn’t. The FCA would have been unimpressed, regardless of the consequences, and whacked them according.

If I’m right, it’s a bit rough on Tesco Bank, fined as a result of being robbed. But this is all one guess based on another. The truth may be still stranger.

Don’t ring 020 3287 4777 or 020 3239 6767

I’ve heard more than one report from local people about calls they’ve received on the landline telephones giving a recorded message. These have a CLID of 020 3287 4777 (and possibly 020 3239 6767). The recorded message says that an arrest warrant has been issued for them and they’re to call back on this number immediately.

If you fancy calling this number you can speak directly to a scammer. When our local cops did they got someone claiming to be HMRC asking for their name and national insurance number.

Please let any vulnerable people in your circle know this is a scam. The police don’t go around trying to arrest anyone using a recorded message.

I’m sure they’ll hop to a different telephone number when this one gets shut down, so be aware of the technique.

Facebook shares worth a punt

The confected row about Facebook and CA’s mining of the latter’s users’ data beggars belief. Facebook’s raison d’être is to profile its users and sell the information to anyone needing to target messages (adverts). The punters sign up to this because access is free. They might not understand what they’re agreeing to; a quick look at Facebook shows that many users are far from the brightest lights in the harbour. Buy hey, it’s free!

This is basically how Web 2.0 works. Get the punters to provide the content for you, collect information of value to sell to advertisers, and use the money to pay for the platform. Then trouser a load of tax-free profit by exploiting the international nature of the Internet.

So why the brouhaha now? Where has the moral outrage been for the last ten years? How come punters have only just started talking of a boycott (about twelve years after I did)? What’s changed?

The media has suddenly taken notice because some messages were sent on behalf of Donald Trump’s presidential campaign. What might broadly be called “left-wing” politicians have been exploiting unregulated social media to sway opinion for a very long time. Some became very uncomfortable when Trump gained traction by “speaking directly to his supporters” on Twitter. And now they’ve finally woken up to the way that the simple majority using a social media platform are able to propagate fake news and reinforce their simplistic beliefs.

But it wasn’t until the recent revaluations that Donald Trump was using it that anyone batted an eyelid.

This rabbit hole goes very deep.

Does this spell the end of Facebook? I somehow doubt it. Social media addicts are just that. They don’t want to lose all their virtual “friends”. They want people to “like” them. Those that realise it’s a load of fluff try to cut back, or “detox” for a few weeks, but they always come back for more. And for those who see social media for what it and have nothing to do with it are constantly pressured by the addicts, like a drug user turned pusher.

“You don’t use Facebook? How are we supposed to contact you?”

No. This row doesn’t spell the end of Facebook. I know MySpace, bix, CompuServe, Geocities and the rest went out of fashion, but Facebook and Twitter are too well established, and even promoted on the BBC. And if the addicts were outraged enough to move to a different platform, where would they go? Part of their addiction comes from Facebook being “free”, and no one has come up with an alternative business model that works. They’ll stick with the devil they know.

Meanwhile investors have the jitters and the share price has fallen. This won’t last.

 

TalkMobile GPDR security weirdness

I needed a pair of talkMobile SIMs to fit new handsets, so used their recommended option of Web Chat.:

Why do people on the phone think they can use GDPR in the same bonkers way they used to use the DPA 1998? Probably because most of the people they talk to have never read it.

Info at 9:50, Jul 27: Thank you for choosing to chat with us. An agent will be with you shortly.

Info at 9:50, Jul 27: You are now chatting with AbdAllah.

AbdAllah at 9:50, Jul 27: Hello, you’re chatting with AbdAllah, one of Talkmobile’s Help Team. How may we assist you today?

Frank at 9:50, Jul 27: Need a new smaller SIM. Please send one. Thanks.

AbdAllah at 9:51, Jul 27: Sure, no worries.

AbdAllah at 9:51, Jul 27 We’ll check that for you straight away.

AbdAllah at 9:51, Jul 27: For the security of the account, could you please confirm the full name, first line of your address and post code along with your date of birth?

Frank at 9:52, Jul 27: Frank J Leonhardt, XXXXXXXXXXX, PINNER, Middx XXX XXX

Frank at 9:52, Jul 27: I never give anyone I don’t know my DOB for security reasons, so you don’t have it anyway.

AbdAllah at 9:53, Jul 27: We have it, of course, that’s why we asking as we want to make sure that we talk to the account holder.

AbdAllah at 9:54, Jul 27: All chats are 128-byte SSL (Secure Socket Layer) encrypted. This helps to protect the confidentiality of all information provided.

Frank at 9:55, Jul 27: No, you don’t have it. You might have a date but it won’t be my DOB. And this chat is TLS v3.0 encrypted. SSL has been defunct for a while now.

Frank at 9:55, Jul 27: Is it perchance the first of january 1970?

Frank at 9:55, Jul 27: The time zero on Unix?

AbdAllah at 9:57, Jul 27: I quite sure that this chat is completely secured and there’s nothing to worry about, It’s a major company and out IT and data protection team are up to date.

Frank at 9:57, Jul 27: Great!

Frank at 9:58, Jul 27: However, it’s very unlikely I would ever have told you my real DoB.

AbdAllah at 9:59, Jul 27: No problem.

Frank at 9:59, Jul 27: So is it 1/1/1970?

Frank at 9:59, Jul 27: Might be 1/6/66

Frank at 9:59, Jul 27: (the mark of the antichrist)

AbdAllah at 10:01, Jul 27: Actually, we have to pass the security questions first.

Frank at 10:02, Jul 27: So it’s none of the above?

Frank at 10:02, Jul 27: In which case it’s something random.

AbdAllah at 10:02, Jul 27: Excuse me, we need to be accurate, please?

Frank at 10:02, Jul 27: Try another question. How about payment details?

Frank at 10:03, Jul 27: I DO NOT KNOW what DoB you might have for me. It’s not my real one.

AbdAllah at 10:04, Jul 27: We can not go further before the security questions.

Frank at 10:05, Jul 27: How about I call the bank and cancel the DD?

AbdAllah at 10:06, Jul 27: Why?

Frank at 10:06, Jul 27: I need to prove I am who I say I am, right?

Frank at 10:06, Jul 27: Only I could cancel the DD.

AbdAllah at 10:06, Jul 27: It’s all about your data protection, Mr Frank.

Frank at 10:07, Jul 27: You mean GDPR?

AbdAllah at 10:07, Jul 27: Yes, exactly.
AbdAllah at 10:08, Jul 27:I do apologize but if you do not answer the question we can not go any further.
Frank at 10:10, Jul 27: So how do we get passed this point? Using DoB as ID is a very bad thing, as I’ve said may times.
At this point their representative hung  up so I called instead and spoke to someone reasonable, who sorted it out immediately using an alternative question. And someone who understood the implications herself! So I’m still happy with TalkMobile and I’ll probably be with them for another ten years.
But someone really needs to sort out their GPDR training, and point out that it’s no blanket excuse.