I used to dread this approach (it’s part of why I like Typescript monorepos now), but LLMs are fantastic at translating most basic types/shapes between languages. Much less tedious to do this than several years ago.
Of course, it’s still a pretty rough and dirty way to do it. But it works for small/demo projects.
Each layer of your stack should have different types.
Never expose your storage/backend type. Whenever you do, any consumers (your UI, consumers of your API, whatever) will take dependencies on it in ways you will not expect or predict. It makes changes somewhere between miserable and impossible depending on the exact change you want to make.
A UI-specific type means you can refactor the backend, make whatever changes you want, and have it invisible to the UI. When the UI eventually needs to know, you can expose that in a safe way and then update the UI to process it.
This completely misses the point of what sharing types is about. The idea behind sharing types is not exposing your internal backend classes to the frontend. Sharing types is about sharing DTO definitions between the backend and the frontend. In other words, sharing the return types of your public API to ensure when you change a public API, you instantly see all affected frontend code that needs to be changed as well. No one is advocating for sharing internal representations.
IIRC, the grocery chain I worked for used to have an offline mode to move customers out the door. But it meant that when the system came back online, if the customers card was denied, the customer got free groceries.
IIRC, the grocery chain I worked for used to have an offline mode to move customers out the door.
Chick-fil-a has this.
One of the tech people there was on HN a few years ago describing their system. Credit card approval slows down the line, so the cards are automatically "approved" at the terminal, and the transaction is added to a queue.
The loss from fraudulent transactions turns out to be less than the loss from customers choosing another restaurant because of the speed of the lines.
The POS I work on also has this feature. Line busters take the order and payment but we have a toggle where you can immediately “approve” and queue it up. If the payment fails then the person handing you your food will see it on the order and ask you for alternative payment. It helps prevent loss and speeds up the line overall.
Yea, good old store and forward. We implemented it in our PoS system. Now, we do non PCI integrations so we arn't in PCI scope, but depending on the processor, it can come with some limitations. Like, you can do store and forward, but only up to X number of transactions. I think for one integration, it's 500-ish store wide (it uses a local gateway that store and forwards to the processors gateway). The other integration we have, its 250, but store and forward on device, per device.
In many places it's also possibly just a left over feature from older times. I worked at a major UK supermarket in the mid-00s, and their checkout system had this feature. But it was like that because that's how it was originally built, it wasn't a 'feature' they added.
Credit card information would be recorded by the POS, synced to a mini-server in the back office (using store-and-forward to handle network issues) and then in a batch process overnight, sent to HQ where the payment was processed.
It wasn't until chip-and-PIN was rolled out that they started supporting "online" (i.e. processed then and there) card transactions, and even then the old method still worked if there was a network issues or power failure (all POSes has their own UPS).
The only real risk at the time was that someone tried to pay with a cancelled credit card - the bank would always honour the payment otherwise. But that was pretty uncommon back then, as you'd have to phone your bank to do it, not just press a button in an app.
I was shopping at a mall with a visa vanilla card once. I got it as a gift and didn't know the limit. No matter what I bought the card kept going -- and I never got a balance of what was on the card. Eventually, later that day it stopped. I called customer support and asked how much was left on the balance. They told me they had no idea my balance - but everything I bought was mine.
I remember that banks will try to honor the transactions, even if the customer's balance/credit limit is exhausted. It doesn't apply only to some gift cards.
I used python on a large code base for quite a while. Many team members did not like type hints, and a codebase that doesn't maintain type hints makes it harder to use them.
However, if I had a choice, rather than use typehints in python, I would much rather just use a statically typed language. Short, tiny scripts in python? Sure. Anything that grows or lives a long time? Use something where the compiler helps you out.
When you buy a house and get a mortgage, you are going to be paying MUCH more in interest (than expected). Over the course of the mortgage, you are going to be paying MUCH more than the sticker price. Between closing costs and taxes and fees maintenance, you will need more cash than you think.
My advice is look at the numbers very carefully and choose something that is (below) or fits your budget. Sudden financial issues like the loss of a job or new vehicle purchase can put a big strain on all this.
This is a topic that often comes up, but once you pry, people usually overlook inflation. As an example, let's say you took out a $300,000 mortgage 30 years ago. The inflation adjusted cost of that today is $634,546 [0], so figuratively you end up paying more than double the sticker price just because of inflation.
Eh? This is totally backwards. The amount you owe is fixed, e.g. 300k. Inflation means that that 300k is worth less and less as time goes on. Therefore, inflation is a good thing for debtors!!!
No, it isn't backwards when you consider the perspective of the bank. They give you 300k now, if you only paid them back 300k in total they would be incredibly deep in the red. Interest is there to offset that fact and then some. Even if the bank ended up at net zero after inflation, they would still be deep in the red because of the opportunity cost. In other words, inflation means what you're paying back to the bank is worth less and less as the time goes on. Banks are not in the business of charity, so the debtors have to cover the gap, plus profit.
> In other words, inflation means what you're paying back to the bank is worth less and less as the time goes on.
Well yes, that's exactly my point. The $1 you pay back to the bank 25 years ago is worth MORE than the 1$ you paid yesterday. But you still only need to pay back a fixed $300k.
Obviously agree that interest paid is where the bank charges you for the loan, but your original point about inflation meaning your actually paying back the inflation adjusted value of the loan makes no sense.
I think this phrasing misses the point. If you paid back anything less than the inflation adjusted cost, the bank would lose money on the loan. Hence, the minimal amount you have to actually pay back is the inflation adjusted cost at the end of your mortgage, simplified to the 600k in the above comment. In the real world both inflation and interest happen continuously, but it's easier to exemplify without that fact.
What?? Something’s off in your statement. Inflation is actually a good thing when it comes to buying a house. You buy a house, get a (fixed) mortgage, and make set payments for the next 30 years. However, the payment amount never changes so as inflation takes effect over the years, your “real” payment gets cheaper and cheaper. In my case, the $1500/month I started paying in 2011 was worth a lot more than $1500 is worth today.
Americans are obsessed with owning a home at all cost. This means that you are effectively bidding against people that do not even do the math. They are ready to spend Millions of dollar on something that is comparatively cheap to rent.
The fact that absolutely everyone wants to buy pushed prices through the roof. The good news is that you can take the other side of this bet. it's called renting.
Currently in most places in the US you will save literally millions over the 30 year mortgage by renting and investing in the market instead.
Reminder that renting and owning is functionally almost exactly the same thing.
Never trust your realtor and never trust other homeowner that most of the time never did the math (We all know those people: "I bought my home for 500k 15 years ago. It is now worth 1M$, therefore I made 500k$").
In other words, let other people take the irrational side of this bet and take the rational side by renting. It's an arbitrage opportunity.
An important fact that this doesn't account for is that, in the United States, living in housing that you own is highly tax-advantaged, at least if you can get a mortgage on it. For example, mortgage interest is tax-deductible for owner-occupied housing (whereas landlords usually can't deduct interest on their mortgages and so those taxes are passed on to renters), and mortgage rates for owner-occupied housing are far below market due to government subsidies and guarantees (whereas landlords have to pay higher rates that, again, they pass on to renters). This isn't good policy, but as long as it's the case, buying a single-family home is a smarter financial choice for most Americans than renting one.
I live in the US and I'm aware of this. Those tax deductible interest should be calculated in the complex buy vs rent equation.
In fact, even when taking them into account, it still doesn't make sense for most Americans to own. (In today's market).
Renting and investing is still the way to go for at least 75% of Americans (this is slightly more nuanced for low cost of living areas, but hold true for any MCOL or HCOL areas).
Eventually the math could make sense again, but right now owning is a huge luxury that will cost you millions in the long run.
I invite you to play with this calculator:
www.nytimes.com/interactive/2024/upshot/buy-rent-calculator.html
I am a renter so I don't have a horse in this race, but renting is many times the financially worse choice even in HCOL.
Why? Because rent inflates like crazy over here! In the Bay Area 7%+ a year is completely expected, and 10% is not unusual. I have been all over the Bay Area for more than a decade (San Francisco proper, East Bay, South Bay) and know this well. It's been nuts.
Random example: the 1 bedroom apartment that I lived in 2012 and was then going for $1,500 a month, is now going for $3,800 in the exact same building (with no/minimal renovations it seems, I just looked it up). An ~8% YoY increase. That will do it to any buy vs rent calculator, very easy to break even in under 5 years, and that's excluding the speculative ability to refinance if interest rates go down from the current 7%, in which case it becomes a huge boost.
Renting as a long term choice just works in European countries where normal people can lock in 5+ year leases with no or minimal rent increases. America is too profit-seeking and greedy for that.
I still rent for flexibility reasons, but I definitely see it as a luxury lifestyle choice, the most financially responsible thing would be to buy, even in HCOL.
All this in my opinion and personal experience, totally fine if people see it differently.
SF is the poster child of a HCOL where buying makes absolutely no sense.
Even if rent increases a lot, the buy to rent ratio is so horrible that it could continue to increase for MANY more years before buying could make sense.
I invite you to use the NYT Rent or buy calculator, It is clear as day:
www.nytimes.com/interactive/2024/upshot/buy-rent-calculator.html
I just did, picturing exactly the situation I'm in right now:
- Rent: $3,500
- Home price: $700,000 (a similar unit just sold for this price a few months ago in my building)
- Rent increase: 8%
- All other parameters left as default, which seem reasonable (and as I said, there might be chances of refinancing over the next 10 years, which would drastically skew the picture, but I'm leaving that assumption out)
The ratio of 0.5% monthly rent/price is common for non-luxury "dated" condos all over the city, so I think my situation reflects well the typical renter.
Once again, in my personal experience, guided by a decade+ of living here, what people miss is the crazy rate of rent inflation. There is always a massive rent increase right around the corner, and God forbid if you are forced to move (because the landlord wants you to, it happened a couple times), then you take a gigantic hit at market rate. Once you factor in these occasional resets and the standard yearly increase, you get very close to 10% rent increase.
Is this a condo with an outrageous HOA that you are not including? Many such cases that explain why condos are valued so much lower.
In SF I have been renting a 1.6M$ townhouse for 4k$/month, and that is very typical of what you can find in SF and in SV.
That has been my experience. Rent increase have been outrageous, but not as bad as the ratio between renting and buying. I would still rent even if my rent went up 50%...
I think you're leaving out other expenses. You'll be paying HOA fees (one friend in SF pays ~$1000 a month and I've heard of worse). You'll also be paying property tax at around $650 a month. You'll probably be paying some maintenance that your landlord would have had to cover (though maybe HOA fees cover some of that?)
On a related note, how do routine inspections work in the US? Does someone walk through the house taking photos every 6 or 12 months, making sure you're keeping the place clean and no damage etc? That's how it is here in Australia, and is absolutely the worst aspect of renting IMHO.
"Routine inspections are common in many states but not universal. Some states, like California and Texas, explicitly allow periodic inspections with proper notice, while others may have stricter regulations limiting landlord access unless there's a specific reason (e.g., repairs or suspected lease violations)."
> Why? Because rent inflates like crazy over here! In the Bay Area 7%+ a year is completely expected, and 10% is not unusual. I have been all over the Bay Area for more than a decade (San Francisco proper, East Bay, South Bay) and know this well. It's been nuts.
If you live in rent controlled housing in SF, your rent increases are gonna be a lot less than 10% a year. And you're unlikely to ever be evicted due to a house sale.
During our last apartment search, it was not particularly difficult to find a rent controlled apartment.
Rent controlled housing (depending on how implemented) can effectively create “land gentry” who have access to a valuable asset at below market prices that they can’t sell.
Nevertheless, I think it's unconscionable to let landlords arbitrarily increase rent and evict people at will. Rent control and increasing the housing supply should be orthogonal issues, more or less.
So take a bad deal now with the promise of maybe refinancing in 10 years. If that even ever happens again. And most of the interests are being paid upfront.
Interest rates will never fall to pandemic-era levels again. It was a once-in-a-lifetime event that catapulted the equity of those who were smart enough to pounce on a house during a world-shaking event.
Sure but almost never close to zero. And how much are you really going to save when they go from 6.5% to 4.5% in 10 years? While most of the interests will already be paid?
Hell, most people will not even want to live in the same place in 10 years.
Honestly this sounds like yet another argument from a realtor to push prices irrationally to all time high.
That's just perspective. The loan is 30 years. The monthly payment never changes right? So you can think of monthly payments as flat principle + interest that's constant.
It's the same thing. The only difference is in taxes.
If you refinance your monthly rate goes down. And you get a tax break.
It's not all numbers, though. Both have a lot of intangibles that can and should affect your decision.
Owning can feel suffocating at times, and like a ball and chain at others. You can't just decide you don't like it or the area anymore and go. Maintenance is also no joke.
Renting feels ephemeral. Getting kicked out at lease end sucks, it's hard to uproot everything and start over. Having inane rules and a landlord constantly drive by can make you feel both infantile and spied on.
I've done both off and on and those are my own thoughts on the two.
Financially only it's easy to pick a winner. But for some, one of these factors may be worth the extra however much money the difference is.
The best way to calculate those intangible is to associate a value to them, Most people love to say that owning is so good because they can decide on their own house improvement.
Ok, but how much do you really value this over? Is it worth 2M$ over 30 years? Because in a lot of cases this is what you leave on the table by deciding to own.
I agree there are pluses to living in a house. One, you can rent a house. But also, there are benefits for kids living in apartments, condos as well. If we're just talking about money, maybe the things you can afford (more travel with your kids, more activities for your kids, more money for kids hobbies, etc...). More time (instead of spending time maintaining your house, gardening, mowing the lawn, etc... you can spend that time with your kids).
I'm not saying an apartment is better than a house. I'm only saying it's not about "rich when your old" vs "kids treehouse and go kart".
Thinking about all the things I loved about my house. Had a pool (but so do many apartment complexes). Could be much noisier than I can in an apartment. Had a garage for tools. I thinking most of the other things I liked have analogs in apartments/condos. But again, you can rent a house.
In the U.S., renting a single-family home is not usually a particularly good idea. Because of the tax disadvantages that I mentioned upthread, but also because the market's relatively thin (in part because of said tax disadvantages) and this makes it harder to find a house you like as much.
(You can pay people to do maintenance tasks on your house, and if you rent then you're already indirectly paying for that. Professional landlords benefit a bit from economies of scale and such, but it's a minor difference.)
>> if you rent then you're already indirectly paying for that.
Quick note: People repeat this non stop ("The cost is passed down to the renter"). This has been proven false many times. The cost to the landlord is mostly irrelevant to the renter.
Rent is set by offer and demand in a particular market.
Just try to increase your place 1000$ above market rates because "Maintenance and taxes", your renters will move. So it obviously doesn't work like this.
I think you are missing the point entirely and have an "holier than you attitude"
The whole point of optimizing for some things is exactly so that I can spend more time with my kids and wife. I will be retired in the next year (in my 40s) and spend time with them while most people will continue to work in their 70s to pay their mortgage.
I am regularly traveling the world with my son and loved ones while most people use their weekend to "repair their homes".
The exact reason I do all of this is to spend way more time with my loved ones. Most people that act in autopilot mode never think about this and therefore end up not spending time with their kids (But Go Kart around the yard!)
You seem to think the only way forward is to provide a house to your family. I think retiring early, spending more time with them and experiencing the world is a good trade off for renting. I would invite you to consider different point of views
But mortgage interest is an itemized deduction, which means it only becomes a tax benefit when your interest + other deductions exceed the standard deduction. And if you do take the deduction, only the delta between it the standard deduction is a benefit.
>Reminder that renting and owning is functionally almost exactly the same thing.
I don't even know where to start, but no, they are not the same thing. You get to live there, that's largely where the similarities end.
>"I bought my home for 500k 15 years ago. It is now worth 1M$, therefore I made 500k$").
Assuming 2k rent (for a 500k home), renting would have cost you $360000, and that's just a net loss. On a 30 year mortgage, the mortgage would be 2100 a month. You would have paid off $196000, be able to realize the gains, and it's incredibly unlikely you spent $196000 on repairs in 15 years. And your mortgage would not have increased in that time.
I don't even know where to start. The math is incredibly more complex than the back of the napkin example you just gave. (downpayment, taxes, hoa, repairs, insurance, realtors, closing fees??)
But you are proving my point, you "think" you came ahead (while ending up paying way way more). Functionally you live in the same place, and the system managed to extract more money from you.
>and it's incredibly unlikely you spent $196000 on repairs in 15 years.
You have $196000 of buffer on all these (downpayment, taxes, hoa, repairs, insurance, realtors, closing fees??). This number doesn't even include the earnings if you sold the house, in your hypothetical example of the price doubling in 15 years, you actually have $696000 to play with here.
Though it's funny you mention taxes since deducting mortgage interest is one of the biggest tax benefits most people have access to.
Look I don't know why your so anti-house, but you really might want to run the numbers again. You provided two numbers, I did further math on them, and your reply was simply 'the math is incredibly more complex'. This is hardly a fruitful argument from my end.
>Functionally you live in the same place, and the system managed to extract more money from you.
I'm honestly sorry you feel this way. You are only hurting yourself.
Again, the back of the napkin math you do doesn't work. Educate yourself and search online or on this thread. A ton of people agree with me and the math once you dig deep.
> Reminder that renting and owning is functionally almost exactly the same thing.
Erm, apart from the bit where you, you know, own the property meaning you can put pictures on the wall, and that's just the start...
But I've always said, if you have no desire to use the benefits of owning (ie. modifying it), then it's more of a liability as now you have to pay for repairs etc.
I feel like most of the response to housing comments are from coastal US perspectives where the math really does not work at the moment. But that is not the case everywhere nor outside of the US.
You wait and invest In something else and you try to convince your spouse that living in a super nice neighborhood as a renter isn’t a bad deal. But sometimes you lose rational arguments on feels and that’s just life
* Met a guy who bought a place in Manhattan Beach LA. He said it was the best investment of his life. It was more than he and his wife could afford be she insisted. Of course maybe they just got lucky that nothing bad happened the would have forced them to sell.
* Have a friend that looked for over 20 years. He go out looking 2 or 3 times a month. Everything was always beyond what he was willing to spent, people out bid him etc. Finally he just came to the realization that if he didn't buy he'd never live in a house (one of his goals). So, he bought, higher than he would have. He seems pretty happy to have a house. He's been in it 6-7 years now and at least according to RedFin it's worth less than he bought it for but I don't think he cares. He's happy to be living in his own house and not an apartment.
I had the same outcomes as above it seemed overpriced but I bought in anyway and the forced savings made it a good investment anyways. But ultimately it was a good investment because my initial view of where the market was heading was completely incorrect.
> When you buy a house and get a mortgage, you are going to be paying MUCH more in interest (than expected). Over the course of the mortgage, you are going to be paying MUCH more than the sticker price. Between closing costs and taxes and fees maintenance, you will need more cash than you think.
This. No idea why people fall into the hype of owning a house they can't afford in the long term.
> I have the same issue every year with a ride on lawn mower. Do I just pay someone weekly or buy one outright and do it myself? In this case I loathe mowing,
I bought mine, ran great for 4 years, then ran into a bunch of trouble, which made me recognize the other hidden cost of ownership is simply just maintenance. A very expensive mower just sitting there, nearest potential repair shop far away, no idea how I'd even get it there let alone the cost. And if I decide I don't want it, I've got to pay to get rid of it now too.
Luckily I was able to watch a bunch of youtube videos and order myself some parts to get it up and running again, but definitely sunk quite a bit of time and energy into it.
I just scrapped an ICE mower for a battery powered one. No more winterizing, changing oil, or worrying about filling with gas. I still don’t like mowing, but it sucks a little less now
Sure, but you're just deferring moderate yearly maintenance cost for a rig that will need to be totally overhauled in 5 years due to battery degradation with current battery tech offered in mowers
At least, that's the conclusion I came to this year when researching ride-on battery mowers vs ICE. Electric push mowers seem like a no brainer though
That's actually the situation I was in though. When your electric mower breaks you're probably on your own. I would not want to go back, but going forward definitely has it's own issues.