• (nodebb)

    var waitForFristEvent() { wait(1000);}

  • (nodebb)

    I assume, in that code, all the //C85 type comments represent changes tied to a ticket tracking system, and no one understands source control well enough to think about why that’s not a good practice.

    Is it "not a good practice"? If it is, indeed not a good practice, why not? Does it allow me to see the ticket number immediately without having to dig into the intricacies of git blame and the fact that the code has been reformatted (with commits each time, obviously) at least five times since the interesting change, alongside a dozen commits for renaming variables or otherwise refactoring the code?

    To be sure, it shares the common weakness of all comments, that the comment and the code might not be related any more(1), but at least it is right there in the code in front of my eyes instead of buried below seventeen layers of irrelevant commits.

    (1) But that is a problem with all comments, not just the ones that contain ticket references.

  • Michal Molhanec (google)

    So, government project was overpriced and have terrible quality? At least, there is something you can rely on :)

  • (nodebb)

    What is it with people using closure as a way to hide variables? Makes the code difficult to read. If you need encapsulation, create "classes" using prototype feature. Private members are prefixed with underscore.

  • (nodebb) in reply to Michal Molhanec

    Remember Obamacare rollout? To be fair, lots of projects in private sector are run terribly, too. I'd say the difference is, private sector has a chance of failure and public sector has a higher chance of failure.

  • (nodebb) in reply to Steve_The_Cynic

    Well, among other things, what is the scope of that comment? And why did ticket C85 need them to do whatever it was that was done (which is entirely unclear).

    I'd rather see "//Do this because <reason>" as a comment. If you need to discover why <reason> came into being, look at the commit history. And there are various ways of making that more relevant nowadays.

  • Michal Molhanec (google) in reply to Mr. TA

    Yeah, I agree. I mean, this site is full of "enterprisey" solutions. The thing is, in private sector it's owner/investor money and if he runs the company badly he will go bust. In public sector? Nobody really have any responsibility.

  • WTFGuy (unregistered)

    On a hunch I typed [Javascript wait] into Google, and the very first example that came up , even in a pretty "Google understands & explains" box was this: http://www.endmemo.com/js/pause.php which contains the following gem:

    Let's write a wait function:

    function wait(ms)
    {
    var d = new Date();
    var d2 = null;
    do { d2 = new Date(); }
    while(d2-d < ms);
    }
    

    Sheesh! For 300M Euros I'd hope for a little less obvious copypasta.

    And both examples recompute the end condition on every iteration despite the fact it's a constant, albeit differently. In the Italian code any decent compiler would hoist the computation outside the while while in the endmemo code they expressed it in a way that can't be hoisted. OTOH, this is JavaScript, so there ain't no steenkin' optimization.

    This also shows the classic attitude of business: My CPU cycles are precious; those on client/user machines I don't own are free for me to waste.

  • (nodebb) in reply to Steve_The_Cynic

    Is it "not a good practice"? If it is, indeed not a good practice, why not?

    1. What you need to see at a glance is why the code is the way it is. You don't need a reference to a system that will probably have been replaced by the time someone needs to reference it.
    2. These types of comments get really strange when you remove code. Do you put a comment where the code used to be? If you do that, will the next guy think the line below it was added?
    3. The people that tend to recommend this approach are people that use these comments instead of source control. If you are doing source control properly, these comments are redundant and possibly incorrect. The history in source control is never wrong.

    I once inherited a code base from a team that did the whole "Initials, date, ticket number" comment thing very consistently. The source was at least 20% comments. Not a single one of the comments was useful in any way. Now, if I could do a blame and see the age of each bit of code and the evolution of how it got that way, that would have been useful.

  • doubtingposter (unregistered) in reply to Jaime

    "The history in source control is never wrong." Except when we're talking about git, where the history is more of an interactive sketch than carved in stone.

    I agree with Steve The Cynic, posting the ticket number related to a certain decision can be good practice. Especially if:

    1. It's not used too often
    2. only where it would instead have to be an essay-long explanation in comments
    3. it's guaranteed that the ticket system in question will be used by everyone seeing the code (for the forseeable future)
  • Dave H (unregistered)

    Isn't it convenient how you get to decide on what we agree to? Maybe keep your political opinions out of this website please.

  • (nodebb) in reply to Michal Molhanec

    In a public-sector project there's a hell of a lot more bikeshedding and fiefdom protection. And if it's public-facing, a good chance of repurposing come next electoral cycle. Civil servants who have had their jobs for decades aim to mitigate the disruption caused by the passing cavalcade of politicians.

  • (author) in reply to Dave H

    Ah yes, "taxes are important to society," is truly the hottest of takes. I should know better than to be openly controversial about things which have been the standard since we've had anything resembling nation states.

  • Dave H (unregistered) in reply to Remy Porter

    The income tax started in 1913 and it was extremely controversial at the time. And I've seen zero evidence that it has been beneficial to the USA since. Maybe you could provide some? Or, like I said in my first post, just leave this site a-political.

  • alexmagnus (unregistered)

    The income tax is not the world's only tax though :D

  • ... (unregistered) in reply to Steve_The_Cynic

    "without having to dig into the intricacies of git blame"

    Maybe the fact you need to manually maintain metadata for the code in the code itself is a sign that git is actually a bad tool for tracking changes to code

  • (nodebb) in reply to thosrtanner

    For sure you need more than just the ticket number, and if you expend effort in the comments, you can obviate the need for the number itself, but criticising the practice on the grounds that the information is in version control is nonsense.

  • Rigangia (unregistered) in reply to Michal Molhanec

    And you probably haven't heard the infamous tale of italia.it and its €90M disaster :)

  • (nodebb) in reply to ...

    Maybe the fact you need to manually maintain metadata for the code in the code itself is a sign that git is actually a bad tool for tracking changes to code

    Doesn't matter which version control system you use; the line of reasoning is the same (except that maybe git is worse because of people rewriting history as a "well that's how we do it" practice, but please don't get me started on bad ways to use git).

    Heck, RCS is worse (obvious truth is obvious, I know) because you can't even see the list of things that were modified together.

  • Anon (unregistered) in reply to WTFGuy

    So the code is suboptional by doing an arithmetic operation every iteration, we could optimize it moving the arithmetic operation out of the loop so this code will be able to do nothing much faster.

    Personally I would move the "var d2" to inside the loop and remove the null assignment, and minify the entire code, will still waste client CPU cycles but at least will save some bandwidth.

  • Remington Smithington (unregistered) in reply to Mr. TA

    It's a problem of any large organization. The larger the organization, the less accountability, and the less accountability, the more likely a project is to fail.

  • Remington Smithington (unregistered) in reply to Dave H

    It was so controversial that 2/3rds of both houses of Congress and 3/4 of the states ratified it. That's about as uncontroversial as it gets anymore given these days it's hard to get people to agree on objective reality.

  • Dave Taylor (unregistered) in reply to WTFGuy

    For 300M Euros I'd hope for a little less obvious copypasta.

    It was written by Italians, you were expecting maybe copyschnitzel?

  • Dave H (unregistered) in reply to Remington Smithington

    They agreed to it on the premise that it would "only" be 2% and "only" apply to the very wealthy. Sound familiar?

  • SyntaxError (unregistered) in reply to WTFGuy

    Without realizing I searched on duckduckgo (my default), the www.endmemo.com was the 5th result. Duckduckgo's first result was:

    https://stackoverflow.com/questions/16873323/javascript-sleep-wait-before-continuing The accepted answer suggests to use setTimeout().

    Was able to reproduce using google.

  • Your Mammas name (unregistered)

    Adding the change ticket number to the code is pretty common in companies where the code is likely to be audited by people who code care about comments as a way to read the program but as a tracking device.

  • sizer99 (google) in reply to Anon

    | So the code is suboptional by doing an arithmetic operation every iteration

    The code is terrible because it's doing a 100% duty cycle spinloop. If you optimize it as suggested, then it's just spinning faster, doing more useless 100% duty cycle loops in the same amount of time. You're just improving the granularity imperceptibly.

    The proper way is doing a timed callback or an await sleep (which is a timed callback under the covers) that takes 0.001% CPU.

  • (nodebb)

    Little correction INPS is what should be the "social security service" is (public pension service, unemployment benefits & the likes). Revenue is a different beast (call AdE).

    Fun fact, a recent disaster on same INPS site happened due to COVID-19 relief scheme. Site basically melted down under a load such 100 requests per second (or was it per minute? can't remember). Some hastily caching solution was put in place to prevent, aptily configured to cache everything. Including dynamically generated profile pages, so people would start seeing other's people data...

  • (nodebb) in reply to Remington Smithington

    Politicians' agreement, even supermajority, is not proof of correctness. Yes some taxes are needed. No, income tax isn't good policy. Yes, western governments tend to spend way too much money. No, paying taxes isn't always the moral thing to do (example: your government decided to commit genocide).

  • Matthew (unregistered) in reply to Mr. TA

    Isn't income tax one of the only good taxes? The fact that it's scaling based on wealth means that it affects those that can afford it more. I can understand arguments against any form of flat tax, such as GST/VAT. But income tax is about as fair as it can be.

  • Meir (unregistered) in reply to Remington Smithington

    Sure, because it was pitched (and originally implemented) as a tax only on the very wealthy - the 1%, or maybe the 0.1%. Rather doubtful that there would have been that kind of consensus for an income tax on the 95%, which is what it became.

  • Meir (unregistered) in reply to Matthew

    Doesn't mean that there aren't arguments against it. See https://en.wikipedia.org/wiki/Income_tax#Criticisms for examples; you can debate the pros and cons of those arguments, but they do exist.

  • morten (unregistered) in reply to Dave Taylor

    Only in the north

  • Pietro (unregistered)

    Oh well these train wrecks are easily explained: in Italy, those who have any talent for programming will search and find jobs in the private sector - better paid, more career opportunities. This leaves the public sector to deal with the "leftovers" i.e. people with no talent, maybe not even holding a CS degree, and often managed by middlemen whose only merit is to have the right political connections (i.e. most of the 300 Million euros go to these middlemen and their cohorts, not to the developers)

  • Pietro (unregistered) in reply to Rigangia

    Oh my goodness... italia.it was a spectacular disaster. It still is actually, their certificate is expired and a nice red lock shows up in the address bar. A black hole of taxpayer money - but I guess it also kept some well-connected people happy and wealthy.

  • (nodebb)

    Hey hey, yet another way to spin your users' fans, drain their batteries and stick them with a big power bill. There's GOTTA be a way to do this in a GPU with WebGL and make it even more effective.

    Considering it's a whole nation, maybe somebody could cook up a nice web extension (chrome plugin) to intercept this stuff and do it better.

    Addendum 2020-04-23 06:45: Browser Javascript has left bad programmers with nowhere to hide.

  • At Least Bad Code is Optional (unregistered)

    Oh dear, there's always some no-tax nutter on the internet isn't there ... Remy didn't say "we agree" about the specifics of the US income tax, but the idea that paying some tax is the tradeoff for civilised society goes back to, well, the dawn of civilised society. Someone has to pay for services and infrastructure, after all.

    As to the code itself: to do this properly in JS you have to use setTimeout and asynchronous callbacks. Lots of (bad) web devs' brains hurt at the idea of not having pure procedural control. A busy wait in a scroll handler is a real top grade WTF to be sure.

    Unfortunately public procurement rules tend to result in some bunch of monkeys underbidding and being awarded the contract, even though they don't know how to write code. So public sector IT projects have a higher than average number of disaster zones. Private companies, of course, aren't immune, but because a bad web presence can affect reputation and therefore profitability, they tend to procure a bit more sensibly and also come back and fix crap a bit sooner.

  • GerryX (unregistered) in reply to At Least Bad Code is Optional

    Yeah, I seem to recall someone saying something like "Give unto Caesar what is Caesar's" some 200 odd years ago. I gather he was somewhat influential.

  • (nodebb) in reply to Matthew

    Different income tax rates basing on income level are immoral, because at least in USA, it puts half of the voters in a situation where they don't pay for what they vote for. It's literally 6 wolves and 4 sheep deciding what to eat. Also this leads to political gamesmanship about who gets preferential treatment and obviously lots of corruption. Secondly, even flat income tax punishes local producers vs foreign ones. Thirdly, it discourages saving. VAT is also terrible, because it costs a lot to comply and raises prices significantly.

    I think the best form of taxation is sales tax. It's way easier to collect for businesses, easy for governments to enforce, collects from locals and visitors and foreign producers equally, and is less prone to politicization.

  • (nodebb) in reply to Mr. TA

    It's literally 6 wolves and 4 sheep deciding what to eat.

    I've got some bad news for you; even a flat tax creates a situation where the poor decide how the middle income's money will be spent. The only way to fix it would be that everyone pays the same amount of tax. This of course creates even bigger problems, like minimum wage being barely enough to pay your tax bill, and part time workers going into debt to the government for life.

  • (nodebb) in reply to Mr. TA

    And with a sales tax, it's still "wolves and sheep", except based on outputs instead of incomes. What it sounds like you're looking for is not a one-person, one-vote system but a one-dollar, one-vote system.

  • Federico R. (unregistered) in reply to Dave H

    The problem with taxes, besides being taken against people's will on the threat of violence / imprisonment (which could be deemed immoral, in the same way as you would consider immoral paying protection money, "pizzo", to your local mafia), is that they get allocated by people (politicians) which are corruptible and centralised (aka inefficient).

    Any amount of tax that goes in a governmental black box will be used to pay bureaucrats' salaries decided by bureaucrats, to spend on private companies and then it will return some value to taxpayers.

    So why do we want to put a rarely monitored middle man that just need to buy enough media power to convince people to keep them in their place? Why put a middle man between a service provider and people? Because we're afraid of the market.

    We think that if we start using private police and private insurance instead of public police, inequality will rise. But will it? Charities for homeless or sick people could very well cover people with nothing and no income, and they could do it voluntarily. Rich public figures feel the need to give back to people who don't have nothing - not because they're particularly altruistic, but because they're buying reputation and media exposure. Just looking at COVID, millionaire and billionaire spending is helping a lot more than government who can't even setup a website to give money to their citizens.

    Everyone else who has income or money, will be a consumer and different brands of private insurance / private police will come up offering different levels of services based on income. Incidentally if you don't have much money, you will also be targeted less and be cheaper to process. Think if you had to pay for you local neighbourhood watch. Would that much different than having policemen around? It would definitely mean wasting less taxes on bureaucrats and 300M projects for sure.

  • (nodebb) in reply to Federico R.

    It's a good thing private companies don't have administration costs. :-)

  • Shosei (unregistered)

    “Incidentally if you don't have much money, you will also be targeted less and be cheaper to process. “ - assumes facts not in evidence. There are areas all over the world where the poor are effectively at the mercy of criminals due to ineffectual police. the end result is usually gangs absorbing every child with marketable skills. There’s also nothing in your solution preventing your “private police” from becoming one more gang of thugs accountable to no one.

    Your proposed system is effectively what the world had prior to the formation of public police forces and infrastructure, and it didnt work. And in addition to the issues with offloading the police force, you also have the issue of common costs. Who, under your proposal, is paying for common costs like infrastructure? Roads and bridges don’t build themselves, and only the richest groups or individuals have the budgets for large projects like that. Heck, one of the major reasons Rome was so successful was because the government handled infrastructure.

  • (nodebb) in reply to At Least Bad Code is Optional

    No, to do this properly you use CSS position: sticky;. And tell people to stop using IE; it's 2020 already.

  • Some Ed (unregistered) in reply to Federico R.

    Most of the people I see complaining about taxes a lot are individuals who have managed to get put into positions, or managed to put themselves into a position, where they are getting paid for other people's work.

    Please understand that I do understand the value of management. However, I also understand the ethics of the situation. It's complicated, I get that. But we live in a world where business executives are paying themselves more than a hundred times what their lowest paid employees are making... and they're also paying companies to provide them 'off the books' labor that are being paid even less than that, so that it's not as obvious how exceedingly evil they are being.

    A very large portion of the money the government spends on supporting people who live below the poverty line is a direct result of these evil practices. They need to live somehow, so the government has to step in, or everything breaks down when the people these companies depend on exploiting die. I understand the companies think they can just replace them, but I'm not talking about the specific individuals they're currently exploiting, but the entire class. At that point, everything breaks down.

    If wealthy people want to be taxed less, they should be responsible individuals and do the jobs more efficiently that they claim the private sector can do more efficiently. A lot of those require working with the government in ways they're not interested in doing.

    When I have heard of companies trying this, they generally try to do too little to be of any use. Which is probably what you should expect from someone who caused a problem by trying to ignore something important, and then tried to complain about having to pay attention to the important thing again.

Leave a comment on “Bad Code and Taxes”

Log In or post as a guest

Replying to comment #514753:

« Return to Article