I think the question would benefit from a frame change:
If you were employed by company A and had only been working for them
for 4 months would you then accept a job offer from company B?
The answer will vary according to the exact situation but most people would only choose to move if there is a strong tangible benefit to doing so.
For what its worth I ...
It sounds like you feel you owe them something. You don't. They changed the job, you found a better opportunity, that's business. They will be used to people coming and going, it happens.
Start looking for a job now. Get that offer in writing and accept it, then just hand in your notice. It's up to them to have a plan in place for when people leave.
It's fine, as long as you are careful with thing like notice periods.
It's not that uncommon for people to start work and then get a better offer only a few months later. If it's significantly better then it's unreasonable to expect them to stick with the first offer, which is demonstrably below market rate.
Sometimes people quit after a few months because ...
You know what sticks out more than a short interlude at company A? Being unemployed for half a year.
Even worse if you don't already have a written offer from company B.
Also, you might like job A way more than job B. There's nothing to lose from accepting job offer A and then after a few weeks decide if you want to stay, want to do a personal time-out until ...
Do you think company would want to hire you, knowing you'll only be working for them for 3 months?
If the answer is "yes", then tell them upfront you can only join for a few months, and it's perfectly fine to do this. You and they will both get something good out of it.
If the answer is "no", and you're not telling them upfront, then by ...
Is it ok to accept A, starting working and quit before B start date?
There are lots of details missing from your post that would help us give a more precise answer, but in general terms no, it's not ok.
Here are some reasons why it would not be ok or why it could be harmful or backfire on you:
You will most likely burn all bridges will company A by ...
Regarding moving on to a new job.
My advice to programmers, in the current market, is now just leave and then take a new job.
Obviously, the traditional advice in all professions is of course find your new job, then leave.
Presently, the programming field is so hot, it is better to leave and be free. Because of two reeasons
(A) it's far better to say you're ...
When voluntarily leaving one permanent white-collar job for another, you perform these steps in this exact order for safety and professionalism:
While you're interviewing, do quiet pre-research to figure out details about timing when you want to leave your current job. What is your required notice? (Two weeks is customary in the US if there is not a notice ...
How can I make a decision on which job to take?
You decide what is most important - to you, in your career, in this particular stage of your career progression.
You have properly laid out a number of attributes that help frame a job choice:
Potential to hone hard skills
Potential to refine soft skills
Impressive company name
Work with experienced, ...