In Java, there are two types of floating-point numbers: float and double. Follow an explanation about why floating numbers in Java is not what you might expect.
This article explains the notion of happens-before in Java, including ways to install it, what guarantee it gives, advantages it brings, and how to use it.
Learn how you can achieve better design using object-oriented and functional approaches. This post includes examples with inheritance and functional interfaces.
Documentation is crucial to development processes and brings many benefits to development delivery. Let's look at some recommendations and tools for Java-based projects.
In this post, learn how businesses depend on continuous integration, how good CI leads to business profit, and tips and recommendations on how to improve CI.
Learn about the thread pool and how to create it in Java from scratch. This post includes an intro, implementation, and testing of a simple thread pool version.
This post covers how to avoid errors before running the application, explains what compile-time safe is and how to use it, and example with Java full-stack application.
In this article, find answers about immutability and its best practices. Practical examples demonstrate the advantages of immutability and related tricks.
Alan Turing, the Father of computer science, invented the Turing machine in 1936. Read this post for more about the Turing machine, explained with examples.
In the second installment of Multithreading and Interviews, read an introduction to the basics of Java Multithreading with Mutex, the Java Monitor Model.
It's a plusure to receive such positive comments! I'll keep in mind that this article recieved such nice feebacks and I'll write some more about related things! Many thanks)
many thanks for feedback, I'm glad to receive such comments. honestly I believe that no one will post anything here but seems in real world not only me annoyed by naked projects without any proper confuence pages.
Thanks for your comments. I do completely agree that some automation/generation is very useful. But sometimes the core problem is missing motivation to do it properly. So if the developer doesn't want to do it, he might easily fail to complete it even with an automated process. As an example it's enough to see how easily scenarios in cucumber tests became unreadable.
Each aspect might be interpret differently. I'm glad to have some feedback here. Personally I'm not classical singleton hater and prefer KISS principle. The most important part of this article is to highlight the problem and raise the discussion.
Seems I found a better solution than just spotbugs plugin that finds potentiall NullPointerException on compilation step: checkerframework.org I'll write article about it - 100%.
Well it's difficult to say how efficient this method (described in article) would be. I don't expect that such games will arouse interest for kids but at least parents can identify is the child predisposed to programming. Thanks for feedback I thought that this work drowned long ago in Google search results.
Thanks for sharing. Problem with mutables keys is painful and not visible from first look. Also it's worth to mention that Chronicle map allows to store data in offheap and help to reduce number of GC calls.
But for me it looks like that it's just a nicer alternative to if if if construction. So in general it doesn't solve the problem at all. I think idea to wrap each potentially nullable field to Optional is not good idea.
Thanks to everyone participated in this holy war. Very infromative, special thanks to Yannic and Mitch. Compile Time Safe problems in Java looks like an not popular topic yet NPE, Illegal Argument exception and so on still takes tops positions.
I'm glad that paid attention to my article. I personally hoped that more people would react on it. But unfortunatelly I didn't explained how significant compile not safe time/type problem is and how expensive there were for business (I think trillons dollars).
Personally I am condescending for the great achievement in code's quality comparing to C/C++ century.
So now returning to raised problems. To answer on them I even had to read again definition of type safe in Wikipedia and potential acceptable answer is that type safetiness might be weak and strong. But before I start I'll just define the problem:
So the statement was - TypeScript and Java are not typesafe because they
accept null value as valid object of any type. And this assumption leads to error
because during runtime we rely on real value instead of null one.
Okay fine it makes total sense but first it worth to mention that TypeScript has strichnullcheck config that makes null is not valid type unless it's specified by developer so such code:
export User{
name: string;
}
const myUser : User = { name: null}
won't be compiled.
But in general TS and Java allows that object can be not initialized and keep null value and allows user to compile such code. Yes both languages designed like this and Yes this code will throw an error during runtime.
And it's bad, it's very bad, it's awful. There are 2 guys I can blame - language design or developer design. In first case we can say "language allowed developer to do mistake" in second case we can say "langauge gave flexibility to developer and he failed to make proper validation".
So what are the conclusions?
1. I can say that Java and TypeScript from this perspective are weakly type safe languages due mentioned problem.
2. The problem of this "type weakness" is consuquence of langauge design and the idea that some object can be not initialized and it's normal. And I can't blame that design because object oriented paradigm in that case is very close to reality - we might have users without last name etc.
3. Is there any ways to reduce potential problem that are comes with this weakness? Yes we can by:
a. writing proper validators
b. following proper testing (eg mutation testing can identify such problems)
c. generating code templates valid by default
d. using IDE plugins that can identify such problems eg @nonnull
Okay that is it. I might add some points but it's already pretty a lof of thing said. I'm a just developer with some experiance, with time I realized how painful this weak type safiteness is but I'm not sure that is any easy solution for it (and if there is I hope new java version will introduce it as it was done in TS with "nonnullcheck" configuration).
And reagrds WS vs GRPC not sure I can say something because GRPC it's just generator and it has to generate valid code. Also GRPC it's basically more than generator because it introduced notion of proto files which makes life easier (if we talk about unification of formats between languages)
Thanks for sharing, Mike. I see that you spent a lot of efforts but don't you think that article is not that transparent for readers? Code is shown as plain text and there is no images that might main ideas?
I do completely agree. Also I strongly support your opinion even if it won't be accepted by the community. Current discussion about exceptions is pretty neutral and personally for me - weak (which is not acceptable because developers need clear arguments and understanding how to use one of the most important parts of the language).
Regards exceptions in general - I had and still have some thoughts about wrong design (e.g. checked exception pollution) but still haven't formulated it. So your article will be a good attempt to do it.
Personally I see that Java is desperately missing a part that will take care about proper validation (i don't know what it should look like). But such a thing might solve validation problems that I personally recognize as top 1 problems in Java (e.g. Null Pointer Exception is a consequence of missing validation).
The only solutions I see here - Is to write best practices examples on github and promote it over the internet as the right pattern to be used.
I've seen how whole Java EE world fell down due it's complexity. Spring was created just because ejb beans had horrible and unclear configuration. Well nothing personal but If lookup for injected dependency will take more than 1-2 seconds I would rather avoid such architecture. Anyway thanks for sharing!
Technical aspects is not the only reason of language popularity. Business favorized Java over C++ one day due it's simplicity. Now Java still on top due big number of solutions provided from the box like spring or big data big data integrations. Also Java community potentially top 1-2 (not sure but seems Phyton community is pretty big).
Scrum master is just a role in Agile methodology that can be applied to any process and doesn't belong to Java development. It's really weird (awful) option. With the same success Java developer can mutate to English teacher.
Thanks for this remark, I do appreciate attentive readers! You are right. As excuse I'll say that 80% of the time I spent photoshoping those images and lost my focus on code. I'll edit images one day but later, currently I'm writing two more articles and they will take time.
Well I didn't expect any other answer. Dzone now is full of Quarkus articles that has only one purpose - promote it. And as I said you can hear here "scalability, performance, reliability" and of course top#1 - "scaled to zero" or similar "pay as you go" - it's just an attemp to sell it to newbies or naive business owners. All mentioned advantages are solved or not critical for real production products. Dear reader, clouds don't bring you a real benefits but put a tiking boom in your business. Don't trust anyone who says something similar. VPS nowdays are cheap and can be easily scaled, some providers give you even options with dynamic memory allocation that makes VPS pretty similar to clouds but without any treats to your business. Scaling/riliability/clustering/etc it's already solved problems in times when there were no clouds technologies at all. All you need from existent clouds providers - it's useful API. But don't host your application there - it will easily cost you 10k usd one day just because one of your dependencies might do circuit network call to itself and it wont be justification for you to avoid your bill.
Serverless is just one more attempt to promote clouds. Serverless = Cloudfull. When experiacned developer hear "efficient solution" or "pay as you go" or "cheaper" he knows - it's just a trap. Cloud pricing is at least 4-6 more expensive comparing to classical VPS/VDS. I hope that most of the audience understand it and wont spread this nonsense created by marketologists for naif business owners. (ps I'm talking about hosting on clouds not about Quarkus)
This article it's good example how awful Spring Validation design is. Mix from hibernate and JSR 380(and related) force developer write so many unnecesary lines. Author didn't mention that for some cases spring just ignore validations based on annotations and don't catch them on @Advice layer. So my personal recommendtaion - just create your own layer, avoid this madness.
Well I would be sceptical and add some critics to each subject.
Java Web based applications are pretty heavy and losing positions to node based servers.
Android apps now would be rather implemented using Kotlin.
Big Data technologies now support Scala rather than Java.
But in general I bet on Java. Java might be the biggest community and low learning barrier (especially java 1.7). Considering new features that have been promised to be introduced in next releases: project valhalla, varhandlers, etc - Java will be popular and well paid in the next 10 years easily (might be even 20).
Initially cyclomatic complexity was created as a metric to describe minimal number of test to fully cover given code. Shorly it's shows number of possible scenarios in the code. Number of scenarios are decided by specification/functional/business requirememnts. Developer can't just change the algorithm if it has more than 10 scenarious. It's not about quality it's about complexity.
Is it worth it to create account and register in order to just convert data? Is there any performace bonuses etc? Why not just use free Jackson library that can do the same from the box? (example: https://www.baeldung.com/jackson-convert-xml-json)
correct, I missed "d" character. I hope readers will understand it. I'll keep it as it is for now. Editing process might take up to week (all changes are moderated).
Well I do agree, but according my experience if you are limited in time you just can't keep unit + integration test then integrations test would be better option. Thanks for correction - you are right, I'll update it)
it's quite dangerous way to use gwt/vaadin/zk/smartgwt/etc as a part of enterprise application. Often they are used if 1. You are going to implement internal feature that won't be maintained after first release (eg admin tool). 2. You can afford frontend developers or fullstack developers.
I think in Windows storing/recovering ram on disk can be done automatically by application and in linux the only issue is to add storing/recovering script in rc.shutdown/rc.local. But I think best case to use that magic is continuues integration jobs.
Comments
May 21, 2024 · Fernando Boaglio
Good artice. But it's not clear why var is used everywhere?
May 26, 2023 · Emmanouil Gkatziouras
I came looking for cooper but found gold. What a gem!
Mar 02, 2023 · James Sugrue
This article was more than 10 years ago but now it's more than relevant! Thanks for that job!
Jul 18, 2022 · Javin Paul
many thanks for concurrency book review!
Jul 18, 2022 · Ram Lakshmanan
I think hashtable doesn't worth to even mention. Isn't depricated?
Jul 18, 2022 · Vicky Singh
is there any additional config that make this library more protected from bots?
Jul 08, 2022 · Dmitry Egorov
It's a plusure to receive such positive comments! I'll keep in mind that this article recieved such nice feebacks and I'll write some more about related things! Many thanks)
Jun 04, 2022 · Dmitry Egorov
welcome!
May 20, 2022 · Per-Åke Minborg
such benchmarking has to be done with JMH framework or related. anyway thanks for sharing.
May 18, 2022 · Dmitry Egorov
many thanks for feedback, I'm glad to receive such comments. honestly I believe that no one will post anything here but seems in real world not only me annoyed by naked projects without any proper confuence pages.
May 15, 2022 · Gunter Rotsaert
very nice, thanks for sharing
May 11, 2022 · Dmitry Egorov
Thanks for your comments. I do completely agree that some automation/generation is very useful. But sometimes the core problem is missing motivation to do it properly. So if the developer doesn't want to do it, he might easily fail to complete it even with an automated process. As an example it's enough to see how easily scenarios in cucumber tests became unreadable.
Apr 11, 2022 · Dmitry Egorov
well CI and CD very close notions I hope readers understood from the context what I meant
Mar 12, 2022 · Dmitry Egorov
Thanks for sharing! Well might be netbeans still relevant in some regions but according my experience in Europe idea rules
Mar 05, 2022 · Dmitry Egorov
why only spring framework? what's is wrong with any other IOC container?
Mar 02, 2022 · Dmitry Egorov
First point was mentioned in article. And second one - well it's possible to wrap it but here we review classical implementation.
Mar 01, 2022 · Dmitry Egorov
Each aspect might be interpret differently. I'm glad to have some feedback here. Personally I'm not classical singleton hater and prefer KISS principle. The most important part of this article is to highlight the problem and raise the discussion.
Feb 07, 2022 · Dmitry Egorov
Thanks for sharing!
Jan 28, 2022 · Dmitry Egorov
thanks for kind words it means a lot to me
Jan 12, 2022 · Dmitry Egorov
Thanks! I do agree that so far there is no good solution for npe problem.
Dec 24, 2021 · Dmitry Egorov
Seems I found a better solution than just spotbugs plugin that finds potentiall NullPointerException on compilation step: checkerframework.org I'll write article about it - 100%.
Dec 24, 2021 · Dmitry Egorov
Well it's difficult to say how efficient this method (described in article) would be. I don't expect that such games will arouse interest for kids but at least parents can identify is the child predisposed to programming. Thanks for feedback I thought that this work drowned long ago in Google search results.
Dec 21, 2021 · Per-Åke Minborg
Thanks for sharing. Problem with mutables keys is painful and not visible from first look. Also it's worth to mention that Chronicle map allows to store data in offheap and help to reduce number of GC calls.
Dec 10, 2021 · Dmitry Egorov
and one more thing about optional, here an example how to use it to avoid NPE:
https://dzone.com/articles/java-8-optional-avoid-null-and
But for me it looks like that it's just a nicer alternative to if if if construction. So in general it doesn't solve the problem at all. I think idea to wrap each potentially nullable field to Optional is not good idea.
Dec 09, 2021 · Amanuel G. Shiferaw
Thanks to everyone participated in this holy war. Very infromative, special thanks to Yannic and Mitch. Compile Time Safe problems in Java looks like an not popular topic yet NPE, Illegal Argument exception and so on still takes tops positions.
Dec 09, 2021 · Dmitry Egorov
I'm glad that paid attention to my article. I personally hoped that more people would react on it. But unfortunatelly I didn't explained how significant compile not safe time/type problem is and how expensive there were for business (I think trillons dollars).
Personally I am condescending for the great achievement in code's quality comparing to C/C++ century.
So now returning to raised problems. To answer on them I even had to read again definition of type safe in Wikipedia and potential acceptable answer is that type safetiness might be weak and strong. But before I start I'll just define the problem:
So the statement was - TypeScript and Java are not typesafe because they
accept null value as valid object of any type. And this assumption leads to error
because during runtime we rely on real value instead of null one.
Okay fine it makes total sense but first it worth to mention that TypeScript has strichnullcheck config that makes null is not valid type unless it's specified by developer so such code:
export User{
name: string;
}
const myUser : User = { name: null}
won't be compiled.
But in general TS and Java allows that object can be not initialized and keep null value and allows user to compile such code. Yes both languages designed like this and Yes this code will throw an error during runtime.
And it's bad, it's very bad, it's awful. There are 2 guys I can blame - language design or developer design. In first case we can say "language allowed developer to do mistake" in second case we can say "langauge gave flexibility to developer and he failed to make proper validation".
So what are the conclusions?
1. I can say that Java and TypeScript from this perspective are weakly type safe languages due mentioned problem.
2. The problem of this "type weakness" is consuquence of langauge design and the idea that some object can be not initialized and it's normal. And I can't blame that design because object oriented paradigm in that case is very close to reality - we might have users without last name etc.
3. Is there any ways to reduce potential problem that are comes with this weakness? Yes we can by:
a. writing proper validators
b. following proper testing (eg mutation testing can identify such problems)
c. generating code templates valid by default
d. using IDE plugins that can identify such problems eg @nonnull
Okay that is it. I might add some points but it's already pretty a lof of thing said. I'm a just developer with some experiance, with time I realized how painful this weak type safiteness is but I'm not sure that is any easy solution for it (and if there is I hope new java version will introduce it as it was done in TS with "nonnullcheck" configuration).
And reagrds WS vs GRPC not sure I can say something because GRPC it's just generator and it has to generate valid code. Also GRPC it's basically more than generator because it introduced notion of proto files which makes life easier (if we talk about unification of formats between languages)
Dec 08, 2021 · Dmitry Egorov
Why java and TS are not type safe?
Dec 01, 2021 · Jackson Jiang
Thanks for sharing, Mike. I see that you spent a lot of efforts but don't you think that article is not that transparent for readers? Code is shown as plain text and there is no images that might main ideas?
Nov 30, 2021 · Dmitry Egorov
I do completely agree. Also I strongly support your opinion even if it won't be accepted by the community. Current discussion about exceptions is pretty neutral and personally for me - weak (which is not acceptable because developers need clear arguments and understanding how to use one of the most important parts of the language).
Regards exceptions in general - I had and still have some thoughts about wrong design (e.g. checked exception pollution) but still haven't formulated it. So your article will be a good attempt to do it.
Personally I see that Java is desperately missing a part that will take care about proper validation (i don't know what it should look like). But such a thing might solve validation problems that I personally recognize as top 1 problems in Java (e.g. Null Pointer Exception is a consequence of missing validation).
The only solutions I see here - Is to write best practices examples on github and promote it over the internet as the right pattern to be used.
Nov 30, 2021 · Dmitry Egorov
Thanks for sharing. Wow it's a pretty a lot text and it will take some time to read. Looks like a good link to add to article.
Nov 26, 2021 · Dmitry Egorov
done)
Nov 21, 2021 · Dmitry Egorov
You overreacting just because you know that you are overhyping BDD. Calm down, no one actually cares.
Nov 21, 2021 · Dmitry Egorov
Thank you for sharing your opinion!
Nov 19, 2021 · Tho Luong
Good article! Thanks for sharing.
Nov 14, 2021 · Ben Foster
There any link to GitHub with provide examples?
Nov 09, 2021 · Arnošt Havelka
I've seen how whole Java EE world fell down due it's complexity. Spring was created just because ejb beans had horrible and unclear configuration. Well nothing personal but If lookup for injected dependency will take more than 1-2 seconds I would rather avoid such architecture. Anyway thanks for sharing!
Nov 09, 2021 · Arnošt Havelka
The only question is - is profit of this approach would be bigger than complexity came together with it?
Nov 07, 2021 · Emmanouil Gkatziouras
well technology is pretty know. it would be useful to have comparison in performance with other protocols or at least some numbers.
Nov 04, 2021 · Bhagyashree Nigade
Clean Code is trash book. Here some example: https://qntm.org/clean
Oct 27, 2021 · Roger Christianson
Technical aspects is not the only reason of language popularity. Business favorized Java over C++ one day due it's simplicity. Now Java still on top due big number of solutions provided from the box like spring or big data big data integrations. Also Java community potentially top 1-2 (not sure but seems Phyton community is pretty big).
Oct 27, 2021 · Jörn Guy Süß
So much of efforts for pretty dead build tool, does it worth it? Anyway thanks for such work!
Oct 23, 2021 · Duncan Brown
Scrum master is just a role in Agile methodology that can be applied to any process and doesn't belong to Java development. It's really weird (awful) option. With the same success Java developer can mutate to English teacher.
Oct 23, 2021 · Reza Ganji
What a pleasant surprise. Seems community dont understand how valuable this article is. Very quality work!
Oct 23, 2021 · Tanaka Mutakwa
It's probably time to stop recommending Clean Code. More details: https://qntm.org/clean
Oct 21, 2021 · Dmitry Egorov
Thanks for this remark, I do appreciate attentive readers! You are right. As excuse I'll say that 80% of the time I spent photoshoping those images and lost my focus on code. I'll edit images one day but later, currently I'm writing two more articles and they will take time.
Sep 27, 2021 · Dmitry Egorov
very pleased to hear)
Sep 24, 2021 · Dmitry Egorov
Thanks! Such feedbacks motivate me to publish more original content!
Sep 20, 2021 · Tyler Hawkins
definitely the best article of this year. I had the same thought but wasn't able to formulate it. GJ Tyler.
Sep 09, 2021 · danieloh30
Well I didn't expect any other answer. Dzone now is full of Quarkus articles that has only one purpose - promote it. And as I said you can hear here "scalability, performance, reliability" and of course top#1 - "scaled to zero" or similar "pay as you go" - it's just an attemp to sell it to newbies or naive business owners. All mentioned advantages are solved or not critical for real production products. Dear reader, clouds don't bring you a real benefits but put a tiking boom in your business. Don't trust anyone who says something similar. VPS nowdays are cheap and can be easily scaled, some providers give you even options with dynamic memory allocation that makes VPS pretty similar to clouds but without any treats to your business. Scaling/riliability/clustering/etc it's already solved problems in times when there were no clouds technologies at all. All you need from existent clouds providers - it's useful API. But don't host your application there - it will easily cost you 10k usd one day just because one of your dependencies might do circuit network call to itself and it wont be justification for you to avoid your bill.
Sep 08, 2021 · danieloh30
Serverless is just one more attempt to promote clouds. Serverless = Cloudfull. When experiacned developer hear "efficient solution" or "pay as you go" or "cheaper" he knows - it's just a trap. Cloud pricing is at least 4-6 more expensive comparing to classical VPS/VDS. I hope that most of the audience understand it and wont spread this nonsense created by marketologists for naif business owners. (ps I'm talking about hosting on clouds not about Quarkus)
Aug 21, 2021 · Trinadh Chakravarthi
This article it's good example how awful Spring Validation design is. Mix from hibernate and JSR 380(and related) force developer write so many unnecesary lines. Author didn't mention that for some cases spring just ignore validations based on annotations and don't catch them on @Advice layer. So my personal recommendtaion - just create your own layer, avoid this madness.
Aug 12, 2021 · Nicolae Sirbu
Nice article but for me OQL language (dump analysing) was a real discovery)
Aug 07, 2021 · Rajnish Kumar
Nice article. I believe that kids education now is underestimated.
Jul 27, 2021 · Lawrence Wachira
Well I would be sceptical and add some critics to each subject.
Java Web based applications are pretty heavy and losing positions to node based servers.
Android apps now would be rather implemented using Kotlin.
Big Data technologies now support Scala rather than Java.
But in general I bet on Java. Java might be the biggest community and low learning barrier (especially java 1.7). Considering new features that have been promised to be introduced in next releases: project valhalla, varhandlers, etc - Java will be popular and well paid in the next 10 years easily (might be even 20).
Jul 11, 2021 · Sumit Verma
What about delivery acknowledges and pricing?
Jun 25, 2021 · Alex Duecode
Initially cyclomatic complexity was created as a metric to describe minimal number of test to fully cover given code. Shorly it's shows number of possible scenarios in the code. Number of scenarios are decided by specification/functional/business requirememnts. Developer can't just change the algorithm if it has more than 10 scenarious. It's not about quality it's about complexity.
Jun 24, 2021 · Brian O'Neill
Is it worth it to create account and register in order to just convert data? Is there any performace bonuses etc? Why not just use free Jackson library that can do the same from the box? (example: https://www.baeldung.com/jackson-convert-xml-json)
Jun 06, 2021 · Luca Venturi
The only question - when it will be production ready?
Apr 17, 2021 · Sarah Davis
Nice job, thanks for sharing!
Apr 13, 2021 · Reza Ganji
Nice job, I would recommend split article in smaller parts.
Mar 26, 2021 · Dmitry Egorov
correct, I missed "d" character. I hope readers will understand it. I'll keep it as it is for now. Editing process might take up to week (all changes are moderated).
Mar 05, 2021 · Sergey Samokhodkin
Nice work!
Oct 22, 2020 · Dmitry Egorov
Well I do agree, but according my experience if you are limited in time you just can't keep unit + integration test then integrations test would be better option. Thanks for correction - you are right, I'll update it)
Jun 10, 2020 · Dmitry Egorov
seems bug. Just recently there was https://dzone.com/articles/mutation-testing-covering-your-code-with-right-tes
Mar 17, 2020 · Shivashish Thkaur
it's quite dangerous way to use gwt/vaadin/zk/smartgwt/etc as a part of enterprise application. Often they are used if 1. You are going to implement internal feature that won't be maintained after first release (eg admin tool). 2. You can afford frontend developers or fullstack developers.
Mar 13, 2020 · Dmitry Egorov
thanks for sharing, I didn't know about that library
Mar 12, 2020 · Dmitry Egorov
thanks for sharing!
Mar 12, 2020 · Dmitry Egorov
many many thanks!
Jan 29, 2020 · Dmitry Egorov
Dec 26, 2019 · Nikita Koksharov
would be courious to compare this implementation and simple off heap hashmap with direct notifications from database
Oct 01, 2019 · Hushen Savani
Spring provides quite good hot reload nowdays.
Oct 17, 2018 · Rafael Salerno
Great job. Well done.
Jul 12, 2018 · Shamik Mitra
there are 48k view, how many developers were confused by that article? Dzone has to moderate that article.
Jul 12, 2018 · Shamik Mitra
it's horrible job. better to write nothing.
May 22, 2018 · Dmitry Egorov
Oh, cool. Actually never thought about it. Nice comment!
May 22, 2018 · Dmitry Egorov
I think in Windows storing/recovering ram on disk can be done automatically by application and in linux the only issue is to add storing/recovering script in rc.shutdown/rc.local. But I think best case to use that magic is continuues integration jobs.