Hacker News new | past | comments | ask | show | jobs | submit | UglyToad's comments login

I've been experimenting with this, it makes testing trivial and removes the coupling that inevitably occurs with multi method interfaces.

However I think there's one missing enhancement that would turn it from esoteric and difficult to reason about to actually usable that the language will never get.

This is being able to indicate a method implements a delegate so that compilation errors and finding references work much more easily.

E.g. suppose you have:

    delegate Task<string> GetEntityName(int id)

    public async Task<string> MyEntityNameImpl(int id)
I'd love to be able to mark the method:

    public async Task<string> MyEntityNameImpl(int id) : GetEntityName
This could just be removed on compile but it would make the tooling experience much better in my view when you control the delegate implementations and definitions.


If you want to enforce things, use an interface. If you want to accept anything that fits use a delegate.

I'm not sure I understand your use case where you need to conflate the two. You want to enforce the contract but with arbitrary method names?

I suppose you could wire up something like this but it's a bit convoluted.

    interface IFoo {
     string F(String s);
    }
    
    class Bar {
     public string B(String s){
      return "";
     }
    }

    // internal class, perhaps in your test framework
    class BarContract : Bar, IFoo {
     public string F(string s) => B(s);
    }


My aim is to use dependency injection to inject the minimal dependency and nothing more. Versus the grab bag every interface in a medium-complexity C# project eventually devolves into.

I've had this on my blogpost-to-write backlog for a year at this point but in every project I've worked on an interface eventually becomes a holding zone for related but disparate concepts. And so injecting the whole interface it becomes unclear what the dependency actually is.

E.g. you have some service that does data access for users, then someone adds some Salesforce stuff, or a notification call or whatever. Now any class consuming that service could be doing a bunch of different things.

The idea is basically single method interfaces without the overhead of writing the interface. Just being able to pass around free functions but with the superior DevX most C# tools offer.

I guess I want a more functional C# without having to learn F# which I've tried a few times and bounced off.


If anything, there is little reason to use a named delegate over the Func nowadays too. The contract in this case is implied by you explicitly calling a constructor or a factory method so a type confusion, that Go has, cannot happen.


The idea with the named delegate would be if you need some way to:

    delegate Task<string> GetUserEmail(int userId);
This provides more guidance than taking in a:

    Func<int, Task<string>> getUserEmail
If you can annotate implementations of the delegate the tooling support becomes even nicer. Not all Funcs with the same shape have the same semantics, in my ideal C#-like language.

Edit: I completely forgot the main reason which is if using a DI container it can inject the named delegate for you correctly in the constructor. Versus only being able to register a single func shape per container.


Having built recurring stuff in the past (date based with no time component, luckily for me) I think you gain a lot of usability gains for generating a row for each occurrence of the event.

Inevitably the user will come back and say "oh, I want it monthly except this specific instance" or if it's a time based event "this specific one should be half an hour later". You could just store the exceptions to the rule as their own data-structure but then you need to correlate the exception to the scheduler 'tick' and if they can edit the schedule, well, you're S.O.O.L either way but I think having concrete occurrences is potentially easier to recover from.


But the problem is the accounting jargon is counter (contra?) to the layman's gut understanding.

If I get credited or I use a credit card money came from nowhere, woohoo. If I have a debit well that sounds like debt and my money decreased, boo.

I get that actually there's a good reason for the names but a field that doggedly sticks to non intuitive jargon that runs counter to every usage yet encountered for outsiders could do with some different non-overloaded terms.


Sounds sort of like the Citroen Ami? Slightly below your ideal range and quite expensive too but the same concept.


For sure as others have mentioned review it yourself in the web interface of whichever PR tool you use. (Generally after having a break first)

This is something of a superpower for catching things before review and in my experience makes the actual third party review pointless 95% of the time.


The other complication was that a change in the law was made to assume computer systems were correct by default due to the problems with the existing law around breathalysers and speed cameras:

"In 1997 the Law Commission published a paper which went into some detail about the use of mechanical and computer evidence in court. It seemed a little too fixated with the effective workings of speedometers, traffic lights and breathalysing devices called ‘Intoximeters.’ It concluded that the present law is ‘unsatisfactory’ because of the necessity for prosecutors to ‘prove that the computer is reliable.’"[0]

The amended law changed the burden of proof from the prosecution proving the system functioned correctly to the defence proving it didn't, without access to the systems being used to prosecute them.

[0]: The Great Post Office Scandal, Nick Wallis


> The amended law changed the burden of proof from the prosecution proving the system functioned correctly to the defence proving it didn't, without access to the systems being used to prosecute them.

It is mind boggling that someone thought it is OK to put this into law. What happened to the idea of innocent until proven guilty?


Seems obvious what happened in context: the government got tired of people “weaseling out” of speeding tickets and breathalyzers (think of the kids!!!) and wrote a law saying the machine right by default unless you had a reason to think otherwise. And of course prosecutors never rest at constructing a novel theory to win cases, so soon enough it was being used in serious cases and not speeding tickets…

(not that it’s fundamentally just with speeding tickets either really! but it's also kind of understandable, you're the 27th person the judge has heard today trying to weasel out of a speeding ticket with the same set of "but the machine could have been wrong!" excuses. And frankly the brits seem to be a lot more "pragmatic" about individual right vs societal ones... the political class there seems to respect the people there exceptionally little even by political-class standards lol)


The old "this time it's different" trope strikes again.


This is the UK legal system...They have been torturing Julian Assange in front of everybody for years...


the UK legal system has many flaws but the handling of Assange was not one of them

he breached his bail conditions and was rightly jailed for it


Julian Assange has been imprisoned for seven years in the UK, for what were charges in the UK of a maximum, and that is a maximum of five years. The UK Legal system regularly releases on bail people accused of murder...yes murder. Assange, was setup in court sitting away from his lawyers, inside the glass-panelled dock of the court, like if he was some modern, Hannibal Lecter, ready to jump and eat the brains of the judge. Using nothing more than the similar psychological tactics, copied from Putin in Russian. Don't even pretend the court is impartial, just make the accused show up in court, with no communication with the lawyers, and inside a cage...

Judges in the UK have been so impartial they publicly made statements of him being a narcissist, not even pretending to even appear impartial. Nils Melzer, the United Nations special rapporteur on Torture and Other Cruel, Inhuman or Degrading Treatment or Punishment, concluded after visiting Assange in prison is treatment was nothing more than torture...

Yeah totally normal...for the UK legal system...


> the UK Legal system regularly releases on bail people accused of murder...yes murder.

it turns out there's consequences for jumping bail


That's a tricky law to have on the books. In general, I would agree that computer testimony (e.g. log records) is usually trustworthy, but that's with relatively simple processes such as writing information into a log or recording times and events. However, it shouldn't be applied to larger systems with more complicated functioning such as accounting software unless the results can also be backed up with detailed logs that can be verified to produce the stated result.

The fact that the Fujitsu employees had complete and un-audited access to all the remote terminals should have made the computer testimony unreliable, but of course the post office lied about that and denied that anyone had remote access.


Nick (and two former subpostmasters) gave a talk to the University of Manchester a couple of years ago: https://www.youtube.com/watch?v=jpkSIGd7Z68



This is a tricky one, because you could just claim that the system wrote audit trails that show you did something due to a bug. How do you prove it either way?


I think any (financial crime) case built solely on computer evidence is too weak to be prosecuted, even if that means you end up accepting some non-zero amount of financial crime. "it is better a hundred guilty persons should escape than one innocent person should suffer" as someone once said.

In the case of the sub-postmasters the Post Office, as far as I'm aware, never proved where these stolen sums supposedly went. The computer evidence was thought terminating and was the only thing (except false confessions under duress) used to secure these convictions, rather than proper investigative work.


Yeah, it seems crazy to me that they didn't have to prove where this money went. I suspect the majority of people caught stealing money in any other capacity are probably caught by the changes to their lifestyle being noticed before the financial irregularities are ever spotted.


The amounts people were prosecuted over supposedly stealing were in the tens of thousands of pounds (some made up the alleged discrepancy by paying back some of their own salary). Not something likely to radically alter the lifestyle of a small business owner (if they had been stealing they'd probably have spent it on cash payments to staff and family, gambling habits and boring stuff like mortgage repayments and savings)

It's crazy auditors didn't spot discrepancies especially with the high base rate of reported frauds and errors, but if finding the receipts for stolen money was the threshold for prosecution any remotely competent thief would be in the clear


It's hard to say exactly how much a sub-postmaster makes but from a brief search it seems to be in the range of £30k-£35k. It's not like the kind of money these people had down the back of their couch.

If there is absolutely nothing to corroborate the money going missing, no evidence presented for where or how the money was stolen then there shouldn't be enough to send someone to prison.


As the sibling comment says (max reply depth reached) the sub-postmasters in general were just about getting by. Part of why this scandal is so egregious is that these people were often just-about-managing under terms of an incredibly unfair contract with the PO.

The amounts of money involved may be small to business owners in other domains but for SPMs many were almost bankrupted by trying to replace the sums out of their own earnings as you say. This wouldn't have been a rounding error to their lifestyle, it should have been provable to any halfway decent investigator. And if not? Then they get away with it and it's the price we pay not to live in tyranny.


Blackstone’s ratio is ten to one, not a hundred to one.


> This is a tricky one, because you could just claim that the system wrote audit trails that show you did something due to a bug.

Well, yeah. A defendant should be able to argue that because that can (and did) happen and it's bad to routinely wrongly convict people.


That's not the point I'm making. Obviously it's bad to wrongly convict people.


I guess I don't know what your point is.

I thought when you called it a "tricky one" you were expressing that it might be a bad thing if it were difficult to convict someone based primarily on audit logs.

But if you don't want people to be wrongly convicted, then surely that's a good thing, right? As we know, there's no guarantee a particular audit log is correct.


> But if you don't want people to be wrongly convicted, then surely that's a good thing, right?

Think of it like a diagnostic test, like covid tests. That sort of test has 2 measures, not one (anyone who just says "Test X is 95% accurate!" is selling you something) - specificity and sensitivity. Sensitivity is the percentage of true positives it generates out of all positives, and specificity is the percentage of true negatives it generates out of all negatives.

I don't want people to be wrongly convicted, no, so I want legal tests to have a very high specificity. But I could do that easily, by just throwing every case out as not guilty. The hard bit is raising sensitivity at the same time. You can't just say "if you don't want people to be wrongly convicted", because that justifies far too many things.

> As we know, there's no guarantee a particular audit log is correct.

There's no guarantee anything is correct. Three witnesses could have colluded and someone might go to jail for it, but unless there's a reason to think they colluded, we don't assume that. That's the problem I'm talking about: how do we get a feel for software systems without assuming like the Post Office that they work, or like you that they don't work?


Can wholeheartedly add my recommendation for the book. In fact I think it should be required reading for anyone in the business of software. While I felt it was a bit over-long it is incredibly thorough and well told and covers multiple different aspects of the scandal while making the human cost obvious in a way that aggregate facts and figures don't.


Agree with this, if one is thinking in terms of typing letters out you're working at entirely the wrong level of abstraction and with the wrong primitives.

I often use the example of ".toString" being meaningful whereas ".tosling" is nonsense (unless you have defined it elsewhere). I'm not even sure if that's the correct capitalization of the to string method in JS, but I shouldn't have to care. If my tools can't tell me which one is valid to use in the current context, then the tools are bad and I should look for better tools. (This may not be universally applicable and maybe Lisp is the promised land etc etc. But raw text input speed is a silly metric to prioritize and leads to a local maxima in programming)


It amazes me that these mega wealthy corporations don't understand uh... going abroad.

Like I know it's not so common on the US but here if you pop across to France for a week you get ads for everything in French. Despite my best* efforts I still speak abysmal French. You're not going to sell me shit in French (or indeed anything anyway).

I literally just crossed a border, I didn't become French, please.

This despite me being pretty lazy and generally letting my data get slurped left, right and center.

Perfect market efficiency strikes again...

*Citation needed


I've noticed Google's web properties are particularly bad about this. I'm logged into an account - they know what language I want my search results in because I told them in my account preferences, but if my IP geolocation says I'm in a different country, I must want the UI in the local language, right?


This used to be especially bad in Google Maps. Just because I'm in Japan doesn't mean that I, the US-ian logged into their English-language Google account, can suddenly read Japanese!

If the Gmail UI is in Japanese I can probably muddle through. If train lines and street names are in kanji I'm probably effed.

(Maps has since improved language detection.)


I hate this with search too. It doesn’t seem to understand that some speak many languages. Searching for podcasts in Apple Podcasts will only yield me in my native language and not English ones (or any other language for that matter)


On the other side, I love every time I see a Spanish ad (I know only elementary school and restaurant menu-level Spanish) because it means I'm seeing fewer badly targeted English ads just because I do sometimes love watching Spanish language content with English subtitles. Spanish ads seem frequently less toxic to me. It's a bit of useful misinformation I'm happy to feed the ad targeting algorithms because I want them to have garbage about me. They are garbage-in/garbage-out in general anyway, but the more garbage I intentionally feed them, the happier I feel, because I'm still somewhat in control.

I don't use an ad blocker, I'm okay with generic, untargeted ads. I do block a lot of advertising cookies and I am isolating them from each other in a cat and mouse game. Intentional misinformation is a fun part of that, too.


I can try but will doubtless miss something.

.NET Framework was the .NET we all knew and tolerated. It was on version 4.6/7 or so. Windows specific, requires a full install of the framework on the machine to run. Support for Winforms, WPF, WCF, Webforms, ASP.NET MVC/API etc.

Microsoft wants to make a play for the cloud. Windows Server is expensive and no one likes it. Luckily for Azure OS is irrelevant, whichever server Microsoft still gets paid.

Step forward .NET Core. This takes the .NET runtime and makes it cross-platform (and open-source). Only really supports ASP.NET in the beginning. There are some libraries/APIs that are available in both .NET Framework and .NET Core runtimes. This common interface is .NET Standard, you can basically ignore this now I think but it means libraries can be used from both.

.NET Core goes through multiple versions, 1, 2 and 3. More things are ported to .NET Core but Winforms, WPF and Webforms are left behind. Meanwhile Core becomes a better and better platform for web servers.

.NET Core drops the 'Core' naming, becomes .NET starting at .NET 5. .NET Framework is legacy but gets a bump to .NET 4.8 or so. So basically unless you're doing Winforms/WPF/Webforms you can be on .NET Core/.NET 5+ with minimal issues. Hopefully that clears something up.


You can use .NET 6/7/8 together with WPF or even WinForms if you want to. Everyone is happy to see WebForms die and the other two run on new targets out of the box.


Presumably that's only when using the Windows platform identifiers? This is news to me, thanks for the correction.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: