vendredi 2 décembre 2011

Veille technologique semaine 48

Pour le bulletin de cette semaine, je vous propose les sujets suivants :

  • Une synthèse de JavaOne qui s'est tenue début octobre à San Francisco.
  • JavaFX 2.0 est sortie en version finale.
  • JavaFX l'avenir du client en Java ?
  • JavaFX et NetBeans 7.1
  • JavaFX et les charts
  • Les premières informations au sujet du JDK 9, mentionnée à la conférence Devoxx.
  • Les fonctionnalités du JDK 7 : un résumé.
  • Les expressions lambda pour le JDK 8.
  • Les énuméré en Java.
Bonne lecture.




JavaOne
La conférence JavaOne 2011 s’est tenue la semaine passée à San Francisco. Comme chaque année, elle a été l’occasion d’un grand nombre d’annonces, de keynotes et de plans sur le futur de Java. On notera après avoir pris la température auprès de la communauté, que celle-ci semble moins inquiète que dans un récent passé: Oracle est là depuis un moment maintenant, les choses semblent s’être stabilisées et clarifiées. La récente arrivée de Java 7 ne doit pas y être pour rien. Parmi les diverses annonces, on retiendra surtout :

  • Java 8 est retardé à début 2013. Nous aurons le temps de vous reparler des nouveaux apports.
  • Java ME tend à se rapprocher de Java SE et vise à en devenir un sous ensemble. L’intérêt est d’unifier les communautés de ces 2 versions.
  • Java EE 7 est en préparation, orienté Cloud et multi-tenancy
  • JavaFX n’est pas mort. Les mauvaises langues diront que le projet ressort du placard chaque année pour JavaOne. Mais Oracle semble décidé à le faire avancer: il devrait progressivement devenir complètement OpenSource et une version 3 est prévue, intégrée directement dans le JDK 8.
  • Pour rêver un peu, quelques pistes pour le JDK 9 ont été évoquées. On parle de VM s’adaptant toutes seules aux applications (plus de XmX et autres barbaries ?!), d’un nouveau Meta Object Protocol améliorant le support entre langages… Là encore, nous aurons laaaargement le temps d’en reparler !
 
JavaFX 2.0 Released, Java 9 Outlined During JavaOne Keynote
Mark Reinhold, Chief Architect for Java at Oracle, gave details of developments in Java 8 and beyond, and announced the GA release of JavaFX 2.0 during his keynote session at the JavaOne conference in San Francisco.

The two big themes for Java 8 are modularity via Jigsaw, and project Lambda. Discussing Jigsaw, Mark Reinhold emphasized the need for seamless integration between it and OSGi. IBM is collaborating on this work via OpenJDK, and indeed the first project that IBM will set up within the OpenJDK will look to explore and demonstrate working interoperability between the two modularity frameworks.



L’avenir des clients Java passera par JavaFX
Durant la dernière conférence JavaOne 2011, Oracle a dévoilé sa stratégie concernant les applications clientes Java. Sans surprise, Oracle mise sur JavaFX.
Pour rappel, JavaFX est une API pour développer des RIA (desktop ou mobile), apparue il y a quelques années, mais qui n’a pas rencontré le succès escompté. Face à cet échec, une nouvelle version 2.0 de JavaFX a été présentée à la conférence JavaOne 2010.



Oracle Sets Out Two Year Plan for Client-side Java
Given that Oracle is predominantly focused on enterprise software, it has been tempting to assume that the vendor would largely ignore client-side Java. It became clear at JavaOne this year, however, that Oracle is making a renewed push on the desktop, spearheaded by JavaFX. It will also be open-sourcing the entire JavaFX platform via OpenJDK.



Hello JavaFX 2.0: Introduction by NetBeans 7.1 beta
 
Over the years since the 2007 JavaOne announcement of JavaFX, I have been somewhat critical of what it has to offer. After Oracle's announcement at JavaOne 2010 that JavaFX would abandon the proprietary JavaFX Script and instead support standard Java APIs, I began to wonder [8] if it was time to invest in learning JavaFX. With the JavaOne 2011 announcements [9] that Oracle intends to pursue standardization of JavaFX as part of Java SE and to open source JavaFX, it is now an easy decision to invest time and energy into learning JavaFX 2.0. In this post, I publicly begin that process. The last couple times I looked at JavaFX, I stopped after feeling disillusioned and resentful. I am expecting better results this time.



Using JavaFX Charts

This tutorial describes the graphical charts available in the javafx.scene.chart package of the JavaFX SDK and contains the following chapters:
  • Introduction to JavaFX Charts
  • Pie Chart
  • Line Chart
  • Area Chart
  • Bubble Chart
  • Scatter Chart
  • Bar Chart
Each chapter provides code samples and applications to illustrate how to use a particular chart. You can find the source files of the applications and the corresponding NetBeans projects in the Application Files.



Premières infos sur Java 9 à Devoxx ?
Il semblerait que la conférence Devoxx nous ait apporté quelques informations concernant les lignes directives de Java 9.

On devrait y retrouver les reified generics et l'unification des primitives.






The 55 New Java 7 Features You (Probably) Didn't Hear About
Slides from deck presented at EclipseConEurope 2011, on November 2ndin Ludwigsburg, Germany.



Les lambda expressions dans Java 8
Durant cet été, l’actuel architecte de Java auprès d’Oracle, Brian Goetz, a fourni des informations intéressantes sur l’implémentation des lambda expressions dans le futur Java 8 et de ses conséquences sur le langage. Par lambda expression comprenez ici closure ou fonction anonyme, qu’il est possible de stocker dans une variable ou de retourner depuis une méthode ou depuis une autre fonction, et bien sûr d’appeler. L’intégration des lambda expressions se fait dans le cadre de la JSR 335 (JSR 335: Lambda Expressions for the Java Programming Language), aussi appelé Lambda Project.




Java Lambda Syntax based on C#, Scala 
One of the most anticipated new features of Java 8 is the introduction of Lambdas, which are anonymous functions that can be passed around like data in arguments and variables. However, the syntax for these wasn't widely decided, with polls asking for input on what would be most familiar to others. A recent posting on the lambda-dev mailing list announced the conclusion that the Java Lambda syntax will be based on C# syntax. This is already widely known and used (as C# had delegates back in 1.0, support for delegate functions in 2.0 and lambda expressions in 3.0).



Java Enum Tutorial: 10 Examples of Enum in Java
Enumeration (Enum) in Java was introduced in JDK 1.5 and it is one of my favorite features of J2SE 5. Java Enum as type is more suitable on certain cases for example representing state of Order as NEW, PARTIAL FILL, FILL or CLOSED.

vendredi 2 septembre 2011

Veille technologique semaine 35

Pour le bulletin de cette semaine, je vous propose les sujets suivants :
  • une réflexion sur les compétences d'un développer.
  • Une synthèse des métriques des bugs dans les logiciels.
  • Le choix d'un OS pour les systèmes embarqués : Windows ou Linux ?
  • IBM a le record mondial de data center avec 120Po (120 millions de giga octets).
  • IBM propose le premier supercalculateur de 20P flops (20 millions de Giga flops) avec 100 000 processeurs, avec des transactions mémoires faite par le matériel : le processeur PowerPC. C'est un 64 bits à 18 coeurs avec 1,5 milliards de transistors, 1,6Ghz pour 205 Gflops à 55 Watts.
  • Les différents moyens de modulariser en Java
  • Le JSR (Java Specification Request) 107 au sujet d'un cache standard est (enfin) prévus pour JEE 7 (Java Enterprise Edition 7).
  • La version 2 du framework Java Disruptor : architecture de programmation concurrente pour consommer de 40 à 50 millions d'événements par seconde (hors réseau). Ceci démontre que les performances de dépendent pas de la technologie (langage Java dans cet exemple), mais plutôt de l'architecture (dynamique dans cet exemple).
  • Une proposition dévolution du langage pour le JDK 8 : les Virtual Extension Methods
  • Explication de la gestion automatique des ressources (ARM : Automatic Resource Management) du JDK 7 : un concept proposé par C# depuis longtemps, repris par le JDK 7. C'est un concept nécessaire au langages à garbage collector.
  • Un résumé sur les IO et les NIO en Java.
Bonne lecture.


Quel type de développeur êtes-vous ?
Etes-vous un expert ou un développeur sénior ? Quelle définition donnez-vous au mot « consultant sénior » ? La définition et la qualification d'un profil représente un gros travail. C'est un sujet tellement vaste, que je me suis dis : il faut que j'en parle avec eux. Bref me voilà de retour pour bloguer sur ce sujet…


How many bugs do you have in your code?
If you follow Zero Bug Tolerance of course you're not supposed to have any bugs to fix after the code is done. But let's get real. Is there any way to know how many bugs you're missing and will have to fix later, and how many bugs you might already have in your code? Are there any industry measures of code quality that you can use as a starting point?

On average 85% of bugs introduced in design and development are caught before the code is released (this is the average in the US as of 2009). His research shows that this defect removal rate has stayed roughly the same over 20 years, which is disappointing given the advances in tools and methods over that time.

We introduce 5 bugs per Function Point depending on the type of system being built (1 Function Point to
about 50-55 lines of Java code). Web systems are a bit lower surprisingly, at 4 bugs per Function Point; other internal business systems are 5, military systems average around 7.

Which means that for a small application of 1,000 Function Points (50,000 or so lines of Java code), you could expect around 750 defects at release.


Embedded operating systems: Linux versus Windows
Should you choose Linux or Windows for your next embedded project?
Before you begin an embedded project, you have a number of choices to make. Some of these decisions about hardware will be no-brainers based on the target device or the specific purpose of the embedded system. However, deciding on an operating system isn't always so clear cut. Assuming your development team is comfortable working with both Linux and MS Windows, you should closely examine the pros and cons of each OS to see which one will provide the most value for your project.


IBM assemble un centre de stockage de 120 Po
IBM vient de battre le record du monde en la matière en assemblant une unité de stockage de 120 Po, soit 120 millions de Gigaoctets. Ce système est composé de 200 000 disques durs à plateau (ce qui fait des unités à 600 Go).

Cette capacité colossale permettrait de stocker 60 copies de la plus grosse archive d'Internet existante ou encore 24 milliards de fichiers MP3 bien encodés.


Bien entendu l'exploit n'est pas tant de mettre 200 000 disques durs dans un même endroit mais bien de les gérer ensemble et aussi de régler le problème des pannes inévitables avec un tel nombre de produits. C'est là que se situe l'expertise qu'IBM veut mettre en avant. Tout est géré par des systèmes experts qui reconstruiront en tâche de fond et de manière totalement transparente les données des disques qui viendraient à mourir ce qui vu leur nombre
doit arriver plusieurs fois par jour.

Cet assemblage utilise un système de fichier appelé GPFS qui a été développé pour améliorer grandement l'accès aux données et les débits en créant des sortes de RAID 0 sur plusieurs grappes de disques et qui a permis, il y a peu de temps, de battre un autre record en indexant 10 milliards de fichiers en seulement 43 minutes.

Maintenant, IBM compte vendre ce type de solution aux possesseurs de supercalculateurs, mais aussi aux sociétés qui font du Cloud. Si cette pratique se généralise, il faudra en effet qu'ils aient des quantités difficiles à appréhender de stockage dans leurs centres de données.


IBM's new transactional memory: make-or-break time for multithreaded revolution
The BlueGene/Q processors that will power the 20 petaflops Sequoia supercomputer being built by IBM for Lawrence Livermore National Labs will be the first commercial processors to include hardware support for transactional memory.

Transactional memory could prove to be a versatile solution to many of the issues that currently make highly scalable parallel programming a difficult task.

Most research so far has been done on software-based transactional memory implementations. The BlueGene/Q-powered supercomputer will allow a much more extensive real-world testing of the technology and concepts. The inclusion of the feature was revealed at Hot Chips last week.


Modules, modules, modules …
I think everybody will agree that writing modular applications and modularity in general is a good thing. But how does support for modularity look like, both from the Java and Scala languages and various Java/Scala frameworks? There's a lot of different approaches! Let's look at some of them. Below "protection" means how well modules are separated either at compile-time or run-time.


JSR-107, JCache: Alive and Going to be Part of Java EE 7
Distributed caching is the tip of the spear for performance and scalability, yet Java does not have a completed standard caching mechanism yet. JSR- 107, the JCache API, is being actively worked on and will be included in Java EE 7. JSR-107 has gained some notoriety over the years because it is one of the older JSRs yet has never been completed, but given the increased demand for caching, JSR-107 will finally see the light of day.


Disruptor 2.0 Released
Significantly improved performance and a cleaner API are the key takeaways for the Disruptor 2.0 concurrent programming framework.

Performance
Significant performance tuning effort has gone into this release. This effort has resulted in a ~2-3X improvement in throughput depending on CPU architecture. For most use cases it is now an order of magnitude better than queue based approaches. On Sandybridge processors I've seen 40-50 million events processed per second.


Virtual Extension Methods (or, wedging multiple inheritance into the JVM)
Goals
• Encourage the creation of more abstract, highperformance libraries
• Secondary goal: encourage a more side-effect-free programming model
• Simplify the consumption of such libraries through a concise code-as-data mechanism
• Provide for better library evolution and migration
• Collections are looking long in the tooth
• Lambdas without broad library support would be disappointing
• Secondary goal: keep doors open
• Function types (but requires reification)
• Control abstraction (but lots of work needed to get there)


Garbage collection with Automatic Resource Management in Java 7
This post provides a brief overview of a new feature introduced in Java 7 called Automatic Resource Management or ARM. The post delves how ARM tries to reduce the code that a developer has to write to efficiently free the JVM heap of allocated resources.
One of the sweetest spots of programming in the Java programming language is automatic handling of object de-allocation. In Java world this is more popularly known as garbage collection; it basically means that developers do not have to worry about deallocating the object allocated by their code. As soon as a developer is finished with using the object he can nullify all references to the object and then the object becomes eligible for garbage collection.


Java NIO vs. IO
When studying both the Java NIO and IO API's, a question quickly pops into mind:
When should I use IO and when should I use NIO?
In this text I will try to shed some light on the differences between Java NIO and IO, their use cases, and how they affect the design of your code.

vendredi 26 août 2011

Veille technologique semaine 34

Pour le bulletin de cette semaine, je vous propose les sujet suivants :
  • Une analyse du changement de stratégie d'HP au sujet du PC et de WebOS.
  • La mutation de l'industrie de l'informatique : l'ère post PC ?
  • Dans la série des anniversaires, après les 20 ans du Web, les 30 ans du PC, c'est les 20 ans de Linux.
  • L'organisation OASIS publie un document de référence pour les architectures orienté services : Reference Architecture Foundation for Service Oriented Architecture (SOA-RAF).
  • Un article qui fait l'analyse de l'utilisation du format XML pour la communication homme-machine.
  • Les diagrammes et la communication entre humains : le cerveau préfère un dessin plutôt qu'un long discourt.
  • La mise à jour de la doc JavaFX 2.0 : les charts, les effets sur les textes, ...
  • Introduction du langage Scala pour les programmeurs Java.
  • Une deuxième diffusion de l'article sur la gestion des exceptions en Java.
  • Un article sur la modularité prévue par le JDK 8 et celle proposée par OSGi.
  • 10 conseils pour l'écriture des commentaires dans le code : c'est toujours un exercice difficile.
Bonne lecture.


HP quitte le PC
"Nous sommes incroyablement enthousiastes sur les opportunités autour de webOS, ainsi que le sont nos 300 000 employés, nos 110 000 commerciaux et intégrateurs, nos 13 000 partenaires dans la grande distribution… beaucoup de monde est emballé par le potentiel de webOS, mais nous avons aussi beaucoup de travail devant nous".
Ces propos tenus durant une interview à This Is My Next par Stephen DeWitt,
Senior Vice President de la nouvelle division webOS global Business Unit ne datent pas d'avril 2010, au lendemain de l'annonce du rachat de Palm, mais d'il y a seulement un mois. Et le reste de l'interview, conduite avec la compagnie de Jon Rubinstein, expatron de Palm, était à l'avenant. Pleine de superlatifs sur la manière dont HP allait gérer l'avenir de la plateforme, diversifier l'offre produit, améliorer l'OS et soigner sa relation avec ses clients. Honnête aussi dans la reconnaissance de certains problèmes qui avaient entaché le lancement de la première tablette webOS.


Post-PC : le bouleversement de toute une industrie
Avec le rachat de Motorola par Google et l'abandon du matériel par HP, les cartes continuent d'être redistribuées dans un marché résolument très fluide.
Du côté du PC, c'est une véritable hécatombe : les plus grands fabricants se sont éteints ou retirés du marché les un après les autres : IBM, Gateway, Compaq, et maintenant HP, faisaient pourtant figure de forteresses imprenables, avec des chiffres de vente plus que respectables. Ces prestigieuses sociétés ont été victimes d'une guerre tarifaire sanglante, et à vrai dire inéluctable.


March of the Penguin: Ars looks back at 20 years of Linux
The Linux kernel was originally created by Linus Torvalds, a Finnish computer science student, and first announced to the world on August 25, 1991—exactly 20 years ago today. At the time, Torvalds described his work as a "hobby" and contended that it would not be "big and professional" like the GNU project.

 
Reference Architecture Foundation for Service Oriented Architecture Review announced by OASIS
OASIS has just announced a public review for Reference Architecture Foundation for Service Oriented Architecture (SOA-RAF). This new document is a result of several years of work for the OASIS SOA Reference Model TC and represents an extension of the concepts and relationships defined in the OASIS Reference Model for Service Oriented Architecture.
SOA-RAF defines Service Oriented Architecture (SOA) as an architectural paradigm (style), occupying the boundary between business and IT. It is neither wholly IT nor wholly business, but reflects concerns of both worlds. Neither business nor IT completely own, govern and manage this SOA ecosystem. Both sets of concerns must be accommodated in the SOA ecosystem to fulfill its purposes. As a result, SOA-RAF focuses on SOA as an approach to integrating business with the information technology.


Soapbox: Humans should not have to grok XML
Summary: Today the computing world tends toward using XML for any and all formal specifications and data descriptions. The author, a big fan of XML, asks a blasphemous question: "Is XML totalitarianism a good idea?" In this opinion piece, Terence Parr, co-founder of jGuru, demonstrates that XML makes a lousy human interface. He also provides questions to ask yourself to determine if XML is appropriate even for your project's program-to-program interface needs.


What Meets the Eye
Yes, diagrams. All of us use diagrams in one way or another. Mostly, diagrams are used to enhance communication and to illustrate what exactly one is talking about.
"But that's it. Diagrams are sketches which are meant to be thrown away without deserving a second look."


What's New in the JavaFX 2.0 Beta Docs
New JavaFX 2.0 Beta docs have been added and some of the existing docs have been updated to coincide with the release of the JavaFX 2.0 Beta SDK (build 40).


An Introduction to Scala for Java Developers
Scala combines the object-oriented and functional programming paradigms, using a concise syntax that is fully compatible with Java and runs on the JVM. Support for the functional programming style, and in particular Lambda expressions which are not now expected to be added to Java until JavaSE 8 in 2012, can help reduce the amount of boiler plate code that you are required to write, arguably making it easier to focus on the task in hand. This article provides an introduction to Scala.


La gestion des exceptions en java
En auditant des applications pour des clients d'OCTO, je me suis aperçu que la gestion des exceptions est un élément qui fait souvent défaut au même titre que la gestion des transactions.
Ce billet était à l'origine des notes personnelles qui avaient pour but de me servir de piqure de rappel et je me suis dit qu'un article de blog serait peut être utile à tous.
Ce sujet prête souvent à discussions et il faut parfois adapter au cas par cas, néanmoins avoir un cadre de bonnes pratiques peut s'avérer très utile.


Successful modularity depends on your dependency model
What We Depend On Jigsaw is implementing a module system for Java 8 that deviates from the (modular) spirit of Java in a way that is bad for the language and will cause untold headaches for the Java community in the future. In this article, I will argue that the Jigsaw design does not fit Java because it ignores packages and uses the wrong dependency model by exporting types and importing modules.


10 best practices to follow while writing code comments
Comments are an important part of writing code not only in java but whatever programming or scripting language you use. At the same time this is one of the most abused things also. Both writing no comment and writing too
much comment is bad and in this article I am going to share with you guys some 0f the rule and best practices I follow while writing comments. Before that let's first see what is the purpose of having comment in the code? Why do
we need comment, isn't writing code is enough. Some of the people I have met always argue that we are getting paid for writing code and not comment :).

vendredi 19 août 2011

Veille technologique semaine 33

Pour le bulletin de cette semaine, je vous propose les sujets suivants :
  • Google rachète la division mobile de Motorola pour 12,5 milliards de dollars. Ce rachat est visiblement motivé par les brevets plutôt que par la production de téléphones.
  • Le PC IBM que l'on connaît à 30 ans : 1981-2011. L'un de ces pères n'y croit plus. IBM a déjà revendu sa filiale de fabrication de PC. HP vient d'annoncer également la filialisation de sa division de fabrication de PC, pour se recentrer sur le service (comme IBM).
  • Le standard C++0x (pronounced "see plus plus oh ex") a été voté la semaine dernière. C'est une étape importante pour le C++ qui termine plus de dix ans de travaux. La version précédante date de 1998 (mise à jour en 2003). Les compilateurs intègrent déjà peu à peu une grande partie de ce standard (Visual Studio de Microsoft, GCC, ...). Quelques explication des évolutions.
  • Une étude du CNRS sur la fiabilité des supports CD et DVD.
  • Un article d'IBM sur sa technologie métronome pour l'implémentation d'un garbage collector temps réel (déterministe). Le langage Java et le déterminisme ne sont pas incompatible. C'est une qualité liée à d'implémentation.
  • Un exemple de l'utilisation de l'automatique unlock() d'un verrou avec la fonction du JDK 7 try-with-resource.
Bonne lecture.

Google prend le contrôle de Motorola Mobility
C'est un coup de tonnerre qui a fait trembler le monde de la téléphonie mobile hier lorsque Google a annoncé avoir racheté la division Mobility de Motorola pour la coquette somme de 12,5 milliards de dollars en cash. C'est l'acquisition la plus importante de l'histoire de Google. Pour 12,5 milliards de dollars, l'achat de Motorola Mobility à lui seul dépasse largement les 9,1 milliards que la société a payés pour ses 136 acquisitions antérieures.
Avec ce rachat, Google va donc acquérir les moyens de produire des téléphones mobiles, mais il ne faut pas s'y tromper, au-delà de la marque et de la gamme de matériels, le but de cette opération est surtout de prendre possession des 17 000 brevets (en plus des 7 500 qui attendent approbation), dont est propriétaire Motorola, un des pionniers du téléphone portable.
On ne pourra plus dire que Google n'est pas suffisamment armé dans la guerre des brevets qui fait rage entre les acteurs principaux de la téléphonie mobile. C'est une belle revanche pour Google qui s'était vue exclue de
l'arrangement  pour l'achat des milliers de brevets du canadien Nortel, il y a quelques semaines.
Un accord existe entre les deux marques, il faut maintenant que les autorités financières ainsi que l'assemblée générale des actionnaires de Motorola Mobility approuvent la vente. Si tout se passe bien, l'opération devrait être effective fin 2011, début 2012.



Google to acquire Motorola Mobility for $12.5 billion
Google revealed on Monday that it will buy handset maker Motorola Mobility, giving the search giant an entrance into the hardware business and allowing it to compete with Apple more directly by building devices tailored specifically for its Android mobile operating system.


Un des pères du PC lui dit adieu
Mark Dean est un ingénieur vétéran d'IBM, qui participa au développement du PC/AT, du bus ISA, du PS/2 70 et 80, et de la carte graphique couleur du premier PC, fabriqué par IBM en réponse à l'Apple II en 1981.
Celui-ci, aujourd'hui directeur technique d'IBM pour la région Moyen Orient et Afrique, publie sur son blog une oraison funèbre pour la machine qu'il contribua à mettre au point : « C'est surprenant pour moi de penser que le 12 août marquera le 30è anniversaire de l'IBM Personal Computer. Je suis fier d'avoir compté parmi les dizaines d'ingénieurs IBM qui ont conçu la première machine, et d'avoir eu la chance de mener la conception des PC ultérieurs à travers les années 80. »


We have an international standard: C++0x is unanimously approved
The final ISO ballot on C++0x closed on Wednesday, and we just received the results: Unanimous
approval. The next revision of C++ that we've been calling "C++0x" is now an International Standard! Geneva will take several months to publish it, but we hope it will be published well within the year, and then we'll be able to call it "C++11."


C++0x
From Wikipedia, the free encyclopedia
C++0x (pronounced "see plus plus oh ex") is the unofficial name of the new standard for the C++ programming language (originally, finalization was expected in 2008 or 2009, but the "0x" was retained). C++0x is intended to replace the existing C++ standard, ISO/IEC 14882, which was published in 1998 and
updated in 2003. These predecessors are informally but commonly known as C++98 and C++03. The new standard will include several additions to the core language and will extend the C++ standard library, incorporating most of the C++ Technical Report 1 (TR1) libraries — with the exception of the library of mathematical special functions. As of 12 August 2011, the C++0x specification has been approved by the ISO.


C++0x Core Language Features In VC10: The Table
When we announced that the Visual Studio 2010 Release Candidate Is Now
Available For Download, a reader, Igor, asked us to provide a table summarizing
which C++0x Core Language features are implemented in VC10. So, here it is!


C++0x Support in GCC
C++0x is the working name of the next ISO C++ standard, due by the end of this decade, which introduces a host of new features into the standard C++ language and library. This project seeks to implement new C++0x features in GCC and to make it one of the first compilers to bring C++0x to C++ programmers.
C++0x features are available as part of the "mainline" GCC compiler in the trunk of GCC's Subversion repository and in GCC 4.3 and later. To enable C++0x support, add the command-line parameter -std=c++0x to your g++ command line. Or, to enable GNU extensions in addition to C++0x extensions, add -std=gnu++0x to your g++ command line.
Important: because the ISO C++0x draft is still evolving, GCC's support for C++0x is experimental. No attempt will be made to maintain backward compatibility with implementations of C++0x features that do not reflect the final C++0x standard.


CD et DVD : des supports peu fiables ?
L'Académie des sciences et l'Académie des technologies ont publié conjointement un rapport intitulé « Longévité de l'information numérique ». La conclusion en est simple : nos supports de stockage, CD, DVD et disques durs, ne sont que très peu fiables. Franck Laloë, co-auteur du rapport et directeur de recherche au CNRS, résume : « les fabricants ont voulu nous faire croire que leurs supports de stockage conserveraient nos données une éternité. Ce n'est pas le cas ».


REALTIME GARBAGE COLLECTION
Traditional computer science deals with the computation of correct results. Realtime systems interact with the physical world, so they have a second correctness criterion: they have to compute the correct result within a bounded amount of time. Simply building functionally correct software is hard enough. When timing is added to the requirements, the cost and complexity of building the software increase enormously. In the past, realtime systems have made up a relatively small portion of the total amount of software being produced, so these problems were largely ignored by the mainstream computer science community. The trend in computer technology, however, is toward an ever-increasing fraction of software having some kind of timing requirement.


Automatically Unlocking with Java 7
In this newsletter we explore my favourite new Java 7 feature "try-with-resource" and see how we can use this mechanism to automatically unlock Java 5 locks.

vendredi 12 août 2011

Veille technologique semaine 32

Pour le bulletin de cette semaine, je vous propose les sujets suivants :
  • Le web a 20 ans : historique.
  • Le début de l'ère post-PC : ou l'évolution possible des appareils numériques.
  • Une fois n'est pas coutume, un article sur une fonction du dernier Mac OSX : la fonction quitter d'une application qui perd de l'importance.
  • Un article au sujet de la plateforme Java dans le monde de l'embarqué. Le don d'ubiquité de Java.
  • Le JDK 7 vient de sortir, et les outils se mettent à jour. Première sortie de la version 3.8M1 d'eclipse avec le support JDK 7. Version complète prévue pour septembre.
  • Une liste des fonctionnalités du langage Java qui n'ont pas été reconduit (aujourd'hui) dans le langage scala.
  • La technologie d'IHM JavaFX 2.0 vient juste de sortir en version béta, que déjà des utilisation en langage Groovy apparaissent : GroovyFX. Cela illustre l'intérêt d'avoir une technologie interroperable nativement entre langages.
  • Deux articles sur la définition de l'injection de dépendances : une explication et les conséquences de conception.
  • Le groupe Khronos annonce la version 4.2 de la spécification d'OpenGL.
  • Le type nullable et les types non nullable : le langage Kotlin propose une solution.
Bonne lecture.


Le Web fête ses 20 ans
Le 6 août 1991, Tim Berners-Lee mettait en ligne le premier site Web au CERN (Organisation européenne pour la recherche nucléaire) à Genève.

Il ne faut pas mélanger Internet et Web : Internet est le système de réseaux interconnectés utilisant des protocoles communs (TCP/IP), le World Wide Web étant une application d'Internet comme le courriel, IRC ou FTP en sont. Ainsi au début des années 1990, le CERN est le plus grand noeud Internet d'Europe et un des plus grands du monde. Le principal problème est alors d'organiser l'information et d'y accéder de manière persistante et cohérente, divers protocoles — diverses applications d'Internet — étant utilisés. Gopher, FTP ou Usenet étaient alors parmi les protocoles les plus populaires — sans oublier l'email.


Twentieth Anniversary of the World Wide Web
This weekend was the 20th anniversary of the World Wide Web project announcement on the alt.hypertext group. On August 6th, 1991, Tim Berners Lee posted:


Pourquoi le "post-pc" révolutionne l'informatique
Avec l'iPad, Steve Jobs a sonné le glas de l'informatique telle que nous l'avons toujours connu et qu'il a contribué à lancer et façonner : l'ère du "post-pc" connaissait son avènement. Pourquoi ces appareils, un temps moqués par certains observateurs comme de "gros iPod touch", représentent-ils un enjeu stratégique majeur pour tous les acteurs de l'industrie ?
Entendons-nous d'abord sur le terme tel qu'initié par Steve Jobs : le "post-pc", ça n'est pas "l'après pc", mais "au-delà du PC".


L'interruption automatique des apps dans OS X Lion
Comme le remarque Tidbits, OS X Lion pousse le mimétisme avec iOS dans la manière dont il gère les applications jusqu'à décider de lui-même de la fermeture d'une application pour libérer des ressources. Cette fonction d'« interruption automatique » des applications, une véritable rupture du système de multitâche, est censée améliorer « l'expérience utilisateur » selon Apple.


A Fresh Look at Embedded with Greg Bollella, Chief Architect, Embedded Java
Greg Bollella has been a leader in the Embedded Java and real-time Java space since Java first moved into the embedded space. In the 1990s, he worked at IBM where he led the Real-Time for Java Expert Group under the Java Community Process (JCP). In 2000, he joined the highly regarded Sun Microsystems Laboratories. His work in exploring the uses of Real-Time Specification for Java (RTSJ) in controlling physical systems--from rockets to power plants to automobiles--led him to be named a Sun Distinguished Engineer.
Now, as Chief Architect, Embedded Java for Oracle, he is continuing his work in integrating Java into the rapidly changing embedded space. He holds a Ph.D. from the University of North Carolina at Chapel Hill.
We met with him to get an update on Java and the embedded space.


Eclipse 3.8M1 Brings Java7 Support
The Eclipse Foundation has released Eclipse 3.8M1, which is the first milestone release with Java7 support. Although there were beta releases available before, it could not be officially called Java7 until after the latter's release, and as such, the recently-released Eclipse Indigo (3.7).
Java7 support will come to Eclipse 3.7.1, which is due to be released in September. The integration builds for 3.7.1 already contain the Java7 support found in Eclipse 3.8M1, which is already supported in IntelliJ IDEA 10.5 and NetBeans 7.0.1

New changes include:
  • Diamond operators suggested by content assist
  • Redundant type literals can be removed and replaced with the diamond operator
  • Content assist can be used to insert types into diamonds
  • Multi-catch can be extended with a "Surround with try/multi-catch", complementing the existing "Surround with try/catch"
  • Multi-catch can be extended with new exception types
  • Exception blocks can be combined into a single multi-catch block
  • Resources closed with try-with-resources can detect thrown exceptions and add to (multi-)catch blocks
  • Strings-in-switch can be converted to a nested if/else
  • The Java7 execution environment has been added for dependency on execution environments

What's new for Java 7
Java 7 comes with a set of small enhancements to the Java language (aka Project Coin), a new byte code to dynamically invoke methods and many additions to the libraries. The Eclipse compiler implements all the new features of Java 7 and all Eclipse JDT features like e.g. search and refactoring have been updated to support Java 7. Besides that, some new features got added:
  • Improved Type Inference for Generic Instance Creation (Diamond)
  • Multi-catch
  • try-with-resources statement
  • Simplified Varargs Method Invocation
  • Strings in switch
  • Polymorphic Methods
  • Miscellaneous

What features of Java have been dropped in Scala?
Despite more complex and less intuitive syntax compared to Java, Scala actually drops several features of Java, sometimes for good, other times providing replacements on the standard library level. As you will see soon, Scala isn't a superset of Java (like Groovy) and actually removes a lot of noise. Below is a catalogue of the missing features.



Introducing GroovyFX: It's About Time
GroovyFX is an open source project whose goal is to combine the conciseness of Groovy with the power of JavaFX 2.0. Jim Clarke, the originator of the project, and I have been working hard to make GroovyFX the most advanced library for writing JavaFX code with alternative JVM languages. As you are about to see, it is more than a mere DSL that provides some syntactic
sugar for JavaFX code. We have decided that it is past time to share our progress with the wider JavaFX community; this article is long overdue (right, Jonathan?).

This is the first of many articles I'll be writing about GroovyFX. If you want to stay up to date
with the GroovyFX project you can follow this blog or follow me on Twitter.


A beginners guide to Dependency Injection
This article presents a high level overview of Dependency Injection (DI). It aims to present the overall concept of Dependency Injection to the junior developer within the context of how it could be used in a variety of DI containers.
Dependency Injection (DI) or Inversion of Control (IOC) ?


Dependency Injection with Mark Seemann
Mark Seemann, author of Dependency Injection in .NET, talks to us about the differences between DI and Service Locators and the importance of having a Composite Root. He also touches on how these all relate back to the SOLID principals of object oriented design.


Khronos ships OpenGL 4.2 spec, outlines plans for new sensor API
The Khronos group unveiled on Monday the OpenGL 4.2 specification, the newest update to the cross-platform 3D graphics API.
The new spec includes a handful of new features designed to improve the performance of common operations in order to allow developers to more easily create high-performance 3D software. These features include fine-grained modification of textures, more efficient data sharing between shader programs, and the ability to reuse shapes that the GPU has already tessellated without having to tessellate them again.


Nullable types and Non-null types
One of the most common pitfalls in Java programming is accessing a member of a null reference, that results in a NullPointerException, because virtually any reference in a Java program can hold null. It happens so often that we have a casual abbreviation for it: NPE.

Kotlin's type system is aimed to eliminate NullPointerException's from our code. The only possible causes of NPE's may be
1. Someone had explicitly thrown is (throw NullPointerException())
2. Someone called external Java code that caused it
3. There's data inconsistency w.r.t initialization (an uninitialized this available in a constructor is used somewhere)


vendredi 5 août 2011

Veille technologique semaine 31

Pour le bulletin de cette semaine, je vous propose les sujets suivants :
  • la migration de FaceBook avec 30PB (30 Peta Byte) à déplacer.
  • Quelques articles sur le JDK 7 : les nouveautés, les bugs, et les autres langages : JRuby et JDK 7.
  • Un article sur OpenCL : comment utiliser la puissance des processeurs graphiques pour faire du calcul.
  • JUnit et les règles : dans la version 4.7.
  • Les performances des verrou et des synchronizations.
Bonne lecture.


Migration 30 Petabytes sur Hadoop pour Facebook
Dans les architectures distribuées de stockage de données, une nouvelle fait le buzz cette semaine. Quand Facebook décide de déplacer ses datacenters, évidement, il y a de l'octet qui se promène. Victime de son trafic, l'ancien datacenter prévu initialement pour 10 PB a atteint dernièrement les 30 PB (avec pas moins de 10 PB généré en une seule année), soit quelques 30 000 000 Go!
Hadoop est le célèbre framework d'Apache pour la gestion de filesystem distribué. Il est utilisé par Facebook pour la gestion interne d'analyse ainsi que les produits additionnels (comme Facebook Ad Network), avec Hive pour la gestion d'un datawarehouse.
 
Voilà un potentiel sujet pour un prochain challenge USI: comment déplacer 30 PB de filesystem avec une contrainte d'exploitation du système en 24/7, et quelques millions d'utilisateurs de connectés ? (avis aux amateurs de défis !)
Côté infrastructure, 1200 serveurs 8-coeurs ainsi que 800 serveurs 16-coeurs avec chacun 12 To de disque et 32 Go de RAM.
Pour répondre à cette problématiques, les ingénieurs optent pour la solution du basculement total de l'ancien cluster vers le nouveau. Transporter un tel volume de données n'est pas instantané. L'équipe a du développer un système de réplication des changements en continue de l'ancien cluster vers le nouveau, tant que le basculement n'était pas effectué.
 
L'ajout d'un plugin sur Hive permet d'écrire tous ses changements sources dans un fichier d'audit. Le système de réplication est branché sur ce fichier et reproduit en continu les changements sur le nouveau noeud. Ce système n'est pas sans rappelé le mécanisme Change Data Capture d'Oracle !
Ensuite, l'équipe s'enferme dans une war-room, tire à la courte-paille quel ops devra lancer la commande fatidique, et stoppe l'ancien cluster. Je vous laisse imaginer la petite émotion lorsque le bouton Enter du clavier est pressée. Une fois le tour de magie effectué, et le sanity check passé, un changement de DNS ensuite permettra de rentre le système stable, et le stress des équipes redescendre face à la réussite d'un projet aussi colossal !
Ceci est par ailleurs une excellente publicité faite à Hadoop et Hive pour l'intégration dans le monde de l'entreprise.
A titre de comparaison, le nouvel accélérateur à particules du CERN, le LHC bat des records de collisions. Ses chiffres pourtant prodigieux n'arrivent que difficilement à la hauteur des volumétries de Facebook. Avec plus de 10 000 milliard de collision par an, et plus 1 Mo de données par collision, on atteint la barre des 10 Po par an. Cependant, on ne mesure pas l'octet à la valeur qu'il peut représenter.

Java 7
Ca y est, après une longue attente, Java 7 est sorti la semaine passée, le 28 juillet pour être exact. C'est sous la forme d'OpenJDK, le pendant open-source de l'ancien JDK fermé de Sun qui était jusqu'aux versions 6 l'implémentation de référence, que s'effectue cette sortie.
Nous vous avons tenu au courant assez régulièrement de l'avancement des travaux donc nous ne reviendrons pas en long, large et travers sur tout ce qu'apporte cette version et sur sa gestation
pas toujours facile. Alors bien sûr, certains regretteront l'absence des expressions lambda et du projet Jigsaw (modularité) reportés à Java 8, mais ne boudons pas notre plaisir et profitons:
  • du fork/join
  • la fermeture automatique des ressources auto-closables
  • du support des Strings dans les switch
  • du support du symbole underscore '_' dans les nombres comme séparateur, pour une meilleure lisibilité
  • du multi-catch d'exceptions
  • de l'opérateur diamant apportant une meilleure inférence de type sur la création d'instances génériques
  • de Nio 2 (que nous vous avons récemment présenté) et de ses améliorations sur les E/S: l'ajout des Path du service Watchable ainsi que le support des symlinks pour le filesystem, mais aussi de nombreux apports sur les E/S asynchrones et les sockets non bloquants.
  • invokedynamic, qui devrait accélérer les langages dynamiques qui l'utiliseront
Premiers couacs
Mais comme toute nouveauté, cette nouvelle version du JDK apporte aussi son lot de douleurs. Apache l'a compris avec un bug sur les projets d'indexation et de recherche Lucene et Solr. Après mise à jour vers le JDK 7, des indexes se sont corrompus et des JVM sont tombées par dizaines avec l'erreur la plus connue des étudiants qui commence en langage C: SIGSEGV ou Segmentation Fault !
Les erreurs se portent sur une partie identifiée du projet, l'algorithme Porter Stemming pour l'optimisation de son moteur de recherche dans la langue de Shakespeare. La réponse apportée par l'équipe d'Apache ne s'est pas fait attendre. Après un premier problème d'optimisation des boucles, des effets de bords des nouvelles locales dans le JDK ou encore avec DataInput.readVInt(). Le premier fix est d'utiliser le paramètre de VM *XX:-UseLoopPredicate.*
Pour Solr, le problème venait principalement du fait que la bonne exécution des tests était dépendantes de l'ordre dans lequel ils étaient écrits. Comme quoi, les principes de réalisations des tests unitaires ne sont pas vains !
Il n'en faut pas moins pour que la blogosphère ne s'enflamme en quelques temps, dans des invectives contre JDK 7 et Apache, à tort. En effet, le problème vient plus d'un bug d'implémentation de HotSpot plutôt que des JSR en elle-mêmes. Le conseil est donc d'utiliser le workaround pour les projets Solr et Lucene, et d'attendre le bug fix d'Oracle. Oracle tente de rassurer les foules par ce billet: les corrections de bug des JVM sont en cours.


Adam Messinger Talks to InfoQ About Java 7 and 8
Following on from last week's release of Java 7, InfoQ spoke to Adam Messinger, Vice President of Development in the Fusion Middleware group at Oracle, to get more information about the release and Oracle's plan for Java 8.


Java Programming Language Enhancements
Enhancements in JDK 7


Java7 Hotspot Loop Bug Details
After Java7's GA release last week, an issue was discovered with one of the optimisations enabled by default with the new JIT. Although originally identified by a use-case in the Lucene search indexer, the problem may be more widespread in other codebases as well.
 
This prompted a number of alarmist articles, such as "Don't use Java 7 for anything" which implied that all loops were problematic. In fact, although there is a valid bug (in which loops may be incorrectly unrolled or cause SIGSEGV crashes), this optimisation bug has been present since Java 6 if either the -XX:+OptimizeStringConcat or -XX:+AggressiveOpts optimisations are enabled.
 
In fact, the problem only occurs with specific loops (those which uses conditions which may be mutated by the loop body), as noted in the fix. The problem doesn't occur when running in -Xint (in interpreted mode) but does occur when -server mode, which most server-side applications are likely to use.


JRuby and Java 7: What to Expect
Java 7 has landed, with a modest set of new features and a few major improvements as well. What can you expect from JRuby running on Java 7?
What's In Java 7 The biggest changes in Java 7 are not related to the Java language at all. Sure, there's the "project coin" enhancements to the Java language, which add some exception-handling shortcuts, new literals for numbers, arrays, hashes, the oftrequested "strings in switch" support, and a few other things. But they're modest incremental changes; the real revolution is at the JVM and JDK level.

Invokedynamic
The most important change in Java 7 is the incorporation of a new bytecode -- invokedynamic -- and an API for building chains of "method handles" to back that bytecode up.


GPU Computing with OpenCL
In the past, processor vendors have increased performance by increasing CPU clock rates, but an upper limit is being reached due to factors such as the settling time of CPU circuitry and the dissipation of waste heat. Performance can still be improved by adding additional processors — dual and quad core machines are now becoming commonplace, but adding more than a handful of cores is cost-prohibitive on commodity hardware.

Additional processing power can be achieved by utilizing the GPU of video cards that allow general purpose computing. As far back as 2001, consumer-grade graphics cards from NVidia allowed part of the rendering pipeline to be customized via user-written code, and since then GPUs have advanced to where more general computation is possible. GPU computing is now used in areas such as science, engineering, cryptography, and computer graphics.

As a GPU is designed to execute the same operations on each item of work (such as a pixel of an image, or an element of an array), it can be conceptualized as a large SPMD (Single Program, Multiple Data) processor array supporting data-parallel applications. Applications most suited to this programming model are ones where there is little dependency between the data items in the computation, such as vector addition or image processing. Computations that are task, rather than data, driven, may not benefit as much.


New Feature of JUnit: Rules
I am always surprised how many unknown feature hide in a supposedly simple library. Todays example is JUnit. When inspecting the newest version (4.7) I noted an annotation I hadn't noticed before: @Rule. WTF? I am looking at a testing framework and not at a rules engine, am I? So naturally I tried to find out what it is good for, and since not to much documentation is available my little research resulted in this blog post. Enjoy.


Rules in JUnit 4.9
One of the most useful innovations in the JUnit realm have been Rules. I wrote about Rules here [4]. And I wrote about use cases for JUnit Rules here [5]. Rules are great. And with JUnit  4.9 they get even better.
You can think of Rules as a way to encapsulate setup and teardown of a test in one class instead of two methods. But Rules are also a way to modify the way to execute your tests.
You can run tests a dozen time instead of once. Or in twenty different threads. Interestingly there were only Rules for single tests. So if you want to stick with the comparison with setup and teardown, aka @Before and @After there wasn't a @BeforeClass and @AfterClass equivalent in Rules.


Synchronized vs Lock performance
There are a number of articles on whether synchronized or Locks are faster. There appear to be opinions in favour of either option. In this article I attempt to show how you can achieve different views depending on how you benchmark the two approaches. I have included AtomicInteger to see how a volatile field compares.

vendredi 29 juillet 2011

Veille technologique semaine 30

Pour le bulletin de cette semaine, je vous propose les sujets suivants :
  • Sortie du JDK 7, comme prévu, le 28 juillet 2011 : articles sur le contenu avec les détails de la documentation.
  • Un article sur le pattern "Disruptor".
  • OSGi et la gestion des modules partagés.
  • Java et la réflexivité des génériques.
  • La définition des classes non mutables
  • La déclaration des variables : la forme dépends du langage de programmation.
  • La taille des objets en Java.
  • La taille des tableaux en Java.

Bonne lecture.


Java SE 7 Released: First Major Update Since December 2006
Java 7 is generally available from today, the first release of the Java platform since Oracle's acquisition of Sun. The release includes a number of small but welcome changes to the language, incorporates a new file API and the Fork/Join Framework, and improves dynamic language support on the JVM.

For Java 7 language changes have been managed as part of Project Coin (JSR 334), a successor to JSR 201, designed to enhance the Java language with an assortment of small changes to improve productivity. Of particular note is the introduction of "try-with-resources". This is analogous to C#'s using statement but based on a form of the try statement. As a result, whilst the using statement only takes a single resource, try-with-resources is able to handle multiple resources within the scope of a given block. Two changes have been made to exception handling. First, multiple exception types can be named as being handled by a single catch block. The grammar of a catch clause of a try statement is extended to allow a series of exception types, separated by the "OR" operator symbol, "|", to be used in the declaration of the exception parameter. Second, if an exception parameter is not modified and if it is rethrown inside the catch block, you don't now have to add the exception to the method signature.


Java SE 7 Downloads
This release includes new features such as small language changes for improved developer productivity, a new Filesystem API, support for asynchronous I/O, a new fork/join framework for multicore performance, improved support for dynamic and script languages, updates to security, internationalization and web standards and much more.


Java Platform Standard Edition 7 Documentation
Oracle has two products that implement Java Platform Standard Edition (Java SE) 7: Java SE Development Kit (JDK) 7 and Java SE Runtime Environment (JRE) 7.
JDK 7 is a superset of JRE 7, and contains everything that is in JRE 7, plus tools such as the compilers and debuggers necessary for developing applets and applications. JRE 7 provides the libraries, the Java Virtual Machine (JVM), and other components to run applets and applications written in the Java programming language.

What's New in Documentation
Documentation is regularly updated to provide developers with in-depth information about new features in the Java platform.


Java as a platform and a language
Welcome to Java 7. Things around here are a little different than you may be used to. This is a really good thing—we have a lot to explore now that the dust has settled and Java 7 has been unleashed. By the time we finish our journey, you'll have taken your first steps into a larger world—a world of new features, of software craftsmanship, and other languages on the JVM.
 
We're going to warm you up with a gentle introduction to Java 7, but one that still acquaints you with its powerful features. We'll showcase Project Coin, a collection of small yet effective new features. You'll learn new syntax, such as an improved way of handling exceptions (multi-catch). You'll also learn about Automatic Resource Management and how it helps you to avoid bugs in the code that deals with files or other resources. By the end of this paper, you'll be writing Java in a new way and you'll be fully primed and ready for bigger topics.
Let's get going! We'll first dive into a critically important duality that lies at the heart of modern Java. This is a point that we'll come back to again throughout the book, so it's an absolutely essential one to grasp.


Dissecting the Disruptor: Why it's so fast (part one) - Locks Are Bad
Martin Fowler has written a really good article describing not only the Disruptor, but also how it fits into the architecture at LMAX. This gives some of the context that has been missing so far, but the most frequently asked question is still "What is the Disruptor?". I'm working up to answering that. I'm currently on question number two: "Why is it so fast?". These questions do go hand in hand, however, because I can't talk about why it's fast without saying what it does, and I can't talk about what it is without saying why it is that way. So I'm trapped in a circular dependency. A circular dependency of blogging.


OSGi: Because Sharing Shouldn't Be Painful
At the dawn of Windows, applications were statically linked and life was simple; applications carried their own dependencies so there was never confusion. However, this simplicity had its costs.


Java Reflection: Generics
I have often read in articles and forums that all Java Generics information is erased at compile time so that you cannot access any of that information at runtime. This is not entirely true though. It is possible to access generics information at runtime in a handful of cases. These cases actually cover several of our needs for Java Generics information. This text explains these cases.

Here is a list of the topics covered in this text:
1. The Generics Reflection Rule of Thumb
2. Generic Field Types
3. Generic Method Return Type
4. Generic Method Parameter Types



Defining immutable classes
To make a Java class immutable, you must:
  • Make all fields final.
When you define fields as final in Java, you must either initialize them at declaration time or in the constructor. Don't panic if your IDE complains that you don't initialize them at the declaration site. It'll realize that you've come back to your senses when you write the appropriate code in the constructor.
  • Make the class final so that it cannot be overridden.
If the class can be overridden, its methods' behaviors can be overridden as well, so your safest bet is to disallow subclassing. Notice that this is the strategy used by Java's String class.
  • Do not provide a no-argument constructor.
If you have an immutable object, you must set whatever state it will contain in the constructor. If you have no state to set, why do you have an object? Static methods on a stateless class would work just as well. Thus, you should never have a no-argument constructor for an immutable class. If you're using a framework that requires this for some reason, see if you can satisfy it by providing a private no-argument constructor (which is visible via reflection).
Notice that the lack of a no-argument constructor violates the JavaBeans standard, which insists on a default constructor. But JavaBeans cannot be immutable anyway, because of the way the setXXX methods work.
  • Provide at least one constructor.
If you haven't provided a no-argument one, this is your last chance to add some state to the object!
  • Do not provide any mutating methods other than the constructor.
Not only must you avoid typical JavaBeans-inspired setXXX methods, but you must also be careful not to return mutable object references. The fact that the object reference is final doesn't mean that you can't change what it points to. Thus, you need to make sure you defensively copy any object references you return from getXXX methods.


Reversed type declarations
I can't write about Kotlin without first talking about the folly of "reversed" type declarations. Sadly this disease has afflicted Scala, Gosu and now Kotlin (but perhaps its not yet too late for Kotlin ;-).


Java: Getting the size of an Object
Java was designed with the principle that you shouldn't need to know the size of an object. There are times when you really would like to know and want to avoid the guess work. Measuring how much memory an object uses


Java: How much memory do different arrays consume
Arrays can be large and consume a significant amount of memory. It can me worth choosing the most memory efficient array/collection. Comparing array sizes.