12 ms·
A Modern Compiler for the French Tax Code
- weinzierl 6y ago> In France, income tax is computed from taxpayers' individual returns, using an algorithm that is authored, designed and maintained by the French Public Finances Directorate (DGFiP). This algorithm relies on a legacy custom language and compiler originally designed in 1990, which unlike French wine, did not age well with time. This interesting. When it comes to legacy code we think of COBOL and FORTRAN most of the time, but probably there is a huge amount of even more exotic code out there that does its duty day in day out.
- Icathian 6y agoMy entire industry (subset of healthcare) mostly uses a single application for 95% of our core business functions. That application is written in Visual FoxPro and is, predictably, pretty terrible. Obviously it isn't going to get better, either, but it'll be a decade or more before there's a serious competitor.
- ghaff 6y agoI'm not near the space any longer (in a former life, the healthcare industry was a big customer of our computer systems). But a significant portion of healthcare in the US used to use a proprietary language called MUMPS. https://en.wikipedia.org/wiki/MUMPS https://en.wikipedia.org/wiki/MUMPS
- alextheparrot 6y agoEpic has been trying to move on for years, or so a recruiter told me half a decade ago. Their job posting now describes “Using leading-edge technologies and languages like JS, TS, and C#”, though I wouldn’t put a bait and switch past them.
- ghaff 6y agoMEDITECH, maybe others, had a proprietary operating system too. (We had a special deal to sell them hardware without an OS at a time when they were normally bundled.) Eventually they moved on to NT.
- akx 6y agoYeah, well, they have a thing called TS2M, referred to e.g. here... https://www.reddit.com/r/epicsystems/comments/9pmsjj/ts2m_in_use/ https://www.reddit.com/r/epicsystems/comments/9pmsjj/ts2m_in...
- p_l 6y agoMUMPS is quite popular in finance, mostly through Cache product. Including for new developments.
- legulere 6y agoHah I’m also working in healthcare and we also use Visual FoxPro for storing data. Luckily most of the Visual FoxPro UI is gone.
- semi-extrinsic 6y agoIn my country, with an admittedly quite simple tax code, the authorities used to publish each year official COBOL code that computed income tax. They switched to Java in 2018-ish - and to Github instead of a random FTP server. Doing your taxes has also been a no-op for many people the past decade or so. You don't do anything except read the tax report, unless you spot some mistakes or items missing in the report that was autofilled by the government, then you can go into the web form and submit the amendments necessary.
- ukd1 6y agoCool - which country? Could you link to the Github repo?
- pratik661 6y agoI’m guessing it’s Estonia. It’s really ahead with digital governance.
- skeletal88 6y agoEstonian here - no it is not Estonia. Here our income tax declaration is very simple, the tax office already knows how much salary we have earned, and there aren't many deductions, so most people either don't have to file taxes at all, or just click next a few times and get their tax returns after a week or so. For 90% of people it takes less than 5 minutes.
- 1f60c 6y agoI think it's Norway. (I just googled GP's email address (it's in their profile).)
- semi-extrinsic 6y agoYeah, it's Norway. https://github.com/Skatteetaten/trekktabell https://github.com/Skatteetaten/trekktabell
- 6y ago
- toolslive 6y agoIn Belgium, calculation of the pensions was done in a mix of BS2000 assembly language and COBOL until at least 2007, when they entered a race to switch to Java before the last of the original developers retired.
- specialist 6y agoI worked for an org that tried to modernize, again, their mainframe legacy code, and failed. I always thought it'd be easier to use an emulator and keep using the old stuff. Then over time whittle the code base down to just the business logic.
- toolslive 6y agoSo you think they still had a 1970s mainframe ? No: Siemens themselves replaced it with an x84 based emulator in the 90s (which ran on a desktop machine).
- knaq 6y agoWe have it right here. Hacker News is written in the Arc programming language, which was developed by Paul Graham and Robert Morris. https://en.wikipedia.org/wiki/Arc_(programming_language) https://en.wikipedia.org/wiki/Arc_(programming_language)
- speps 6y agoFrom some of the same authors: https://github.com/CatalaLang/catala https://github.com/CatalaLang/catala HN comments: https://news.ycombinator.com/item?id=24948342 https://news.ycombinator.com/item?id=24948342
- secondcoming 6y agoTranslating legal texts to mathematical form is very interesting. It could decimate most legal jobs if a lawsuit can be converted to mathematical form and then 'executed' against the laws that are also in mathematical form. You get your judgement and the explanation as to how that conclusion was reached, all automatically. It could even cause headaches if contradictions in legal judgements are detected. It all relies on the conversions to mathematical form being done correctly though which, given that some laws can be intentionally vague, may be impossible.
- petercooper 6y agoIn countries or legal frameworks based around civil law, I think that could possibly occur. It would be impossible to do this in a formulaic way in legal areas covered by common law, although having digitized legal "assistants" that could bring up and analyze relevant precedents seems almost guaranteed (if they don't exist already?)
- Bayart 6y agoCivil law probably has a big edge in computer-driven legal implementation, if that's where things are headed. I have no idea what would be in it for Common Law countries. Perhaps they'd be more driven towards using data mapping techniques to lay out networks of heterogeneous legal stuff (jurisprudence etc.).
- dane-pgp 6y ago> It could even cause headaches if contradictions in legal judgements are detected. I remember hearing an anecdote about researchers who tried to formally specify the benefits system of some European country, and they found that the system was slightly non-deterministic, in the sense that the outcome for the citizen would depend on which order various government departments processed the various forms that the citizen used to enrol into various programmes they were eligible for. It makes me wonder if these mathematical formalisations should support some kind of fuzzing, to check that entities doing things in slightly different orders (or earning slightly more/less) don't produce dramatic changes in outcome.
- naringas 6y ago
- Eikon 6y agoHere's the source code of the implementation of the tax code: https://github.com/etalab/calculette-impots-m-source-code https://github.com/etalab/calculette-impots-m-source-code
- rozab 6y agoThe languages breakdown is interesting. It seems GitHub refuses to admit defeat and categorises the .m files into various other languages which use the extension (M, MATLAB, Objective-C, Mathematica and Mercury). I wonder if they use some sort of fuzzy ML solution for categorising them rather than conventional parsing.
- Eikon 6y agoHere you go! https://github.com/github/linguist#how-linguist-works https://github.com/github/linguist#how-linguist-works
- remram 6y agoWonder no more! https://github.com/github/linguist/blob/7c2adbdb15d4efd25d92cd5ed20d0025f0d32d28/lib/linguist/heuristics.yml#L265 https://github.com/github/linguist/blob/7c2adbdb15d4efd25d92... As most AI, it's regex and ifs all the way down.
- deleted 6y ago[deleted]
- riffraff 6y ago
- eightnoneone 6y agoShould run pretty quick on a new M1 MacBook Air.
- ape4 6y agoThey opitimized it by removing dead code etc. So I wonder if that could be fed back into the original laws to simplilfy them.
- anticristi 6y agoI was rather thinking about fuzzying it to find gaps in tax laws.
- mjul 6y agoIn a previous job we built an advisor for banking and pensions using a mathematical optimiser solving over a model of the Danish tax rules. It would normally find enough tax savings to retire about a year earlier by finding the best savings strategies (e.g exploiting dynamic and temporal effects between taxation on spouses retiring at different times, using the house mortgage as a savings buffer to shift pension payouts to lower tax years etc). It was quite an eye opener.
- stevesimmons 6y agoYou should write a blog post or a HN story about that!
- mjul 6y agoI can give a few highlights: it had an exact model of a personal economy (savings, pensions, debt, houses, cars, boats and other assets) and the tax system and a projection engine capable of predicting the future cash flows for a person. The projections were the basis for advising the client how to best manage their finances. The advisor model could request an optimisation of how to best allocate the assets and liabilities over time from a mixed integer programming model built with GAMS. The latter optimisation model was not exact but it could generate close-to-optimal strategies for e.g. pension savings, buying houses and how to best spend the savings after retirement. The best strategies were then fed back into the exact model, evaluated and presented to the user. It requires a pretty complex tax system to really generate a lot of value for the clients so its value was lower in the neighbouring countries that had separated their social systems more from the tax system.
- creuset 6y agoMost of the French socio-fiscal system can be simulated in Python through https://github.com/openfisca/openfisca-france/ https://github.com/openfisca/openfisca-france/.
- vishnugupta 6y agoDuring one of those rabbit hole journeys I discovered that Dutch Tax authorities use MPS, a DSL creation language/tool by JetBrains [1] It makes me wonder, why haven't DSLs caught up? Their claim that it allows developers spend more time implementing the business logic makes sense. But somehow that promise hasn't been realised. I'm curious to know from those who tried DSLs. [1] https://www.jetbrains.com/mps/documentation/ https://www.jetbrains.com/mps/documentation/
- ethbr0 6y agoThe nearest I've been able to articulate this is lack of overlapping skillsets & departments' tendencies to hire people who look like them. The kind of person who (a) lives in business problem land & (b) is proficient in programming language design (even guided DSL generation)... doesn't exist. At least not in hireable numbers. And those that do are buried deep in the guts of consultancies, who can afford to pay them way more than customers can. It's a shame, because it results in suboptimal software. And suboptimal tooling available to the devs that do work in that space. The best solution I've seen are products that lower the knowledge barrier of entry (at least for creating a proof of concept) + designing for non-programmers as your primary users.
- denismerigoux 6y agoHi, OP here :) I've come to the same conclusion about programming language creation. However, for a very large organization, it makes sense to have a team in charge of language tooling (see Dropbox/Python, Facebook/Hack/Flow, Apple/Swift). Which is why I'm trying to convince the French state that they should have such a team of permanent people.
- ethbr0 6y agoI worked in a similar kind of role recently, in a large public retail company. The only advice I'd give would be to lean hard on finding, maturing, and then advertising end-user champions. Cross-department / -traditional boundary products are frustratingly difficult to push top-down, as the leader of the space that "owns" the product (i.e. IT) doesn't directly see the value, because they're not the end user (business). What mostly work for me was being as loud as possible with open-attendence educational events, continually taking meetings from interested areas, and then mentoring developing teams. The goal is to help them create a killer product using your product, such that (highly-placed leader on their side) talks to (your leader) in glowing terms about your product. And that usually happens because your product helped them get a win that moved an important metric to them. Hint: Ask them about things they've always wanted to do, but couldn't because it was technically impractical. There's probably at least one diamond in there that would be "easy" with your product. Hint2: Think more broadly about the kind of thing you're trying to do, and get your team in that area. I've worked under CFOs as often as I've worked under CTOs, because "saving money" is near and dear to the former. (Adapt as necessary to how French government works. Good luck!)
- nitsky 6y agoIf tax codes are so complex that authorities struggle to maintain the code that implements them, how are humans supposed to understand them well enough to follow the incentives they are designed to create?
- dragontamer 6y agoMost people don't know about the muscles or bone structures in their hands, but most people seem to know how to use their hands anyway, despite the gross complexity involved.
- valuearb 6y agoMost people aren’t at a gross disadvantage to those who know how to game the system or bribe authorities to make their hands work far better than others.
- consp 6y agoMost of the time you only need a small subset which is manageable. I once tried to increase my deductions as a normal citizen but this went nowhere quickly as you need to create giant loopholes to get it done as a person. Businesses on the other hand are the ones using the complex stuff and they can hire an expert (in this case expensive doctors in the case of the body metaphor of the other poster) at quite some cost.
- ip26 6y agoLike every other piece of software they are probably spending 90% of their time on edge & corner cases while citizens are spending 90% of their time solidly in the simple core functionality.
- tester34 6y agoI've been asked to write parser of _my_country_law_ and something that's capable of doing diffs and putting it together (diff+original=>newest version) docs without knowledge in that domain after seeing sample doc I've estimated it on something like 1 week of work (XD) month later I've been crying and having like 20-30% done this shit has been so sensitive (insanely error prone) and debugging was time costly. I think I didn't spent enough time on thinking about its architecture, but on the other hand my experience was pretty small with this stuff easy & fast to test and reliably have solid abstraction over original documents have solid abstraction over operation (e.g Article 5's meaning is changed) _____________ project died because it was needed "fast" (in that time there was very specific peroid of changes in law) and we weren't getting to the viable version fast enough
- mywittyname 6y agoI feel like legislation is a field that would benefit a great deal from the progress that software engineering has made in a number of fields. It's already evolved somewhat into a DSL. With some nudging and technical leadership, I suspect that we could move it over entirely into a format that can be readily parsed, tested, and version control. The tax code is especially well-suited to this, because it's a lot of rules and math formulas. In fact, I bet most tax software probably does something very similar to this.
- logicx24 6y agoI heard about the startup Legalese [1] a while ago, which does exactly this. [1]: https://legalese.com/ https://legalese.com/
- sjy 6y agoThe current buzzword for this is “rules as code” and many governments are exploring it. You’re right that it is particularly relevant to complicated financial laws like the tax code, and necessarily has been done in a limited way by tax software for many decades now. I am skeptical that this technology can meaningfully assist us in resolving contentious legal questions – it’s more about generating wizards that can help you navigate a 1,000 page tax statute by only showing you what’s relevant to your problem.
- sandcha 6y agoThe French government and parliament also use this implementation of the law (taxes, benefits, ...) : https://github.com/openfisca/openfisca-france https://github.com/openfisca/openfisca-france It's open source and contributive so, a common structure is used by multiple countries. They are listed here : https://openfisca.org/en/countries/ https://openfisca.org/en/countries/
- valuearb 6y agoI remember when the US tax code was going to be simplified so that an entire tax return form could be printed on a post card.
- sjburt 6y agoThe majority of tax payers actually don’t have very complex taxes, if you only have w-2 income and don’t itemize deductions, you just need the single page 1040. Even small businesses aren’t complicated if they have proper bookkeeping, or if you’re just deducting mortgage interest. The piles of tax regulations really are for wealthy people and corporations with complicated accounting.
- rsynnott 6y agoYou'll notice they never specified how big the writing was going to be.
- kccqzy 6y agoWas that the 9-9-9 plan? To be honest such simple tax rules was eye-opening and refreshing but I don't think it was particularly fair.
- valuearb 6y agoIt actually goes back to the flat tax proposals to set the top rate to 28% with very few deductions. The idea was that you don’t have some rich paying the top rate of 39%, and some paying near zero (cough, cough, Mr. Trump) due to a large discrepancies in deductions.
- Taniwha 6y agoHere in NZ we got rid of almost ALL deductions the tax system is so simple that almost all people with one job pay exactly the right tax through employer PAYE (as someone who runs a small company I do my PAYE with 1 line of spreadsheet formulae, it's easy). This means most people don't need to file, if you want to it's a 1-2 page web form, and, starting last year, the IRD will do it for you anyway and directly credit your refund (with interest) to your bank account without you asking
- tlb 6y agoI wonder if you could backpropagate gradients all the way through the tax calculation, so it could tell me what to change about my finances to minimize taxes.
- simonebrunozzi 6y ago> This algorithm relies on a legacy custom language and compiler originally designed in 1990, which unlike French wine, did not age well with time. Gotta love the sense of humour.