DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Java
  4. Would Java Be Better Off Without Primitives?

Would Java Be Better Off Without Primitives?

James Sugrue user avatar by
James Sugrue
CORE ·
May. 27, 09 · Interview
Like (0)
Save
Tweet
Share
9.97K Views

Join the DZone community and get the full member experience.

Join For Free

Gilad Bracha raises a fantastic point in his latest blog entry, that Java would be efficient as it is now without having primitives. In fact, Gilad says that Java's original sin is that it's not a proper object oriented language.

As one example, consider type char. When Java was introduced, the Unicode standard required 16 bits. This later changed, as 16 bits were inadequate to describe the world’s characters.

In the meantime, Java had committed to a 16 bit character type. Now, if characters were objects, their representation would be encapsulated, and nobody would very much affected how many bits are needed. A primitive type like char, however, advertises its representation to the world. Consequently, people dealing with unicode in Java have to deal with encoding code points themselves.

The blog entry proves that, even when considering potential performance issues with arrays, there wouldn't have been a significant performance hit to Java had it been fully object oriented. 

While this is something that Gilad has discussed at length, it's something that I had never thought about before. I just accepted primitives as part of the language.  One commenter suggested that using a source keyword in Java 7 and being able to have this change available - although that does seem unlikely.

I also discussed this with Kirk Knoernschild, who isn't a fan of primitives either. 

We had a method that updated a db2 database and essentially encapsulated a SQL statement. The arguments passed into the method were the values inserted/updated/deleted. Because the method took primitives, there was no way to pass in null. So even for columns that were nullable on the database, developers were inserting zero. And there is a big difference between zero and null. The two cannot be treated the same in many cases.

 

Is this something that others in the community consider to be an issue? 

Java (programming language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • DevOps for Developers: Continuous Integration, GitHub Actions, and Sonar Cloud
  • Introduction to Spring Cloud Kubernetes
  • REST vs. Messaging for Microservices
  • Solving the Kubernetes Security Puzzle

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: