Inappropriate prosecutions do not come sillier than the one being brought by the attorney general for Northern Ireland against the former Northern Ireland secretary Peter Hain for the arcane offence of "scandalising the court". Mr Hain and his publishers will learn more on Tuesday, when a hearing is due, but enough is already known to conclude that this is a deeply foolish move – all at the taxpayers' expense, of course – which could have unacceptable public interest consequences by restricting proper public comment about the judiciary. The disagreement between Mr Hain and the Northern Ireland judge Paul Girvan would be better settled by almost any lawful means other than these contempt proceedings. They should be stopped now.

In his recent memoirs, Mr Hain strongly criticises Mr Justice (now Lord Justice) Girvan, for the way he handled a 2006 application for judicial review of the appointment of the province's victims commissioner. Now, the Northern Ireland attorney general, John Larkin, has been given leave to prosecute Mr Hain under a rarely used provision which was described by the court of appeal in 1899 as "obsolete in this country". But evidently not in Ulster.

Mr Larkin charges that the passages in Mr Hain's book amount to "unwarranted abuse of a judge in his judicial capacity that undermines the administration of justice in this jurisdiction and consequently constitute a contempt of court". Mr Larkin should grow up. He should also remember Lord Justice Salmon's judgment in 1968 that "the authority and reputation of our courts are not so frail that their judgments need to be shielded from criticism". It followed, he ruled, "that no criticism of a judgment, however vigorous, can amount to contempt of court".

In general, the public trusts the judges. They are right to do so – and the consequences are healthy. Without such trust, the rule of law would struggle – as it has in the past – to have the legitimacy on which it relies. But that does not mean that the judges, either in general or in particular individual cases, must be beyond criticism. The law can sometimes be an ass and so can those who interpret it.

When that happens, the public must have a right to say so. Politicians and the press are among those whose roles require them to be able to criticise the judges on occasion. Sometimes the criticism is ill-judged (as when Tony Blair, while prime minister, attacked the courts over asylum cases). Sometimes it may be expressed in overly forceful terms. If judges want to sue to protect their reputations, let them do so (as some have occasionally done). But judges should not be given special legal protection from criticism. The right to criticise the judges is much more important than the occasional debatable instance of criticism.