• Post Reply Bookmark Topic Watch Topic
  • New Topic

What goes behind definition of data types?  RSS feed

 
sharath chan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm new to Java(Coding too) and I came across Data Types. short,int,long,boolean etc.. I do understand that these're primitive data-types. But what exactly is data-type. When we say data-type int is there any code behind that defines or accepts data of type integer? How is the relation defined on data behind scenes. I tried my best to ask my question clearly. Hope I made sense. Thanks for anyone who attempt to answer my question.
 
Carey Brown
Saloon Keeper
Posts: 3266
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
long, int, short, char, byte, float, double, boolean are "built in" types that the JVM knows how to handle. The JVM is the Java Virtual Machine which is started when you run "java". Java programs are compiled down to byte-code which is machine independent. A JVM is written for each platform that runs Java, so a Windows program has it's own JVM and a Mac has it's own. These JVMs then interpret the byte-code files and execute them in a manor consistent with the platform.

A data-type is either a built-in type or a class that someone has defined. There are grey areas too. I believe an array works in a class-like fashion but is built into the JVM.
 
sharath chan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanl you Carey. I'll do more research on it. I've looked into some reading on JVM. In what language is the JVM written? Can write our own JVM? When we say different JVM for windows, Mac os etc, does it mean JVM depends on Operating System?
 
Carey Brown
Saloon Keeper
Posts: 3266
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JVMs, I'm guessing, are written in C++. No, you can't write your own JVM (unless you have an army of developers behind you, and a few lawyers). When you are just starting out on your Java journey there is so much to know about the language itself. It is sufficient at this point to have a general awareness of where the JVM fits into the compiling and running of Java. Delving into the specifics at this point just diverts your concentration away from the language.
 
Stephan van Hulst
Saloon Keeper
Posts: 7933
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that most compilers and virtual machines are written in the same language that they compile/run. The reason for this is that you don't want development of your language to be dependent on another language. This is a bit of a chicken and egg problem, and it is solved by first writing a small portion of the compiler in a different language, enough that you can write the next version of the compiler in the language that you can compile with the first version. Operating system specific implementations of parts of the JVM and standard library are written in C++ though, because you can't write native code in Java.

However, as Carey has stated, you don't need to know all of this to be a Java programmer. A data type is just a label that tells the compiler and the runtime how to interpret a sequence of bytes. While some data types are built into the language, you can also define your own data types with classes, interfaces and enums.
 
Tim Holloway
Bartender
Posts: 18781
74
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:JVMs, I'm guessing, are written in C++. No, you can't write your own JVM (unless you have an army of developers behind you, and a few lawyers).


Maybe you can't, but I did - back in the previous millennium. There's nothing special about writing a bytecode interpreter or a compiler if you've studied the subject (and I can see my copy of the Aho and Ullman "Dragon book" from here).

Actually, Java is a lot easier to write a compiler for than C++ - which drove me crazy with its ambiguous scoring system for function overloading. In Java, if you can't easily determine which overload to use, it's not a coin toss, it's a compiler error.

Armies of developers, in fact, rarely create good software. Most of the Unix and Gnu programs had no more than 3 authors at most, and it has been my experience that most heavy-duty systems are likewise created by individuals or small groups.

As for lawyers, it used to be a given that computer languages were uncopyrightable. Specific code was copyyrighted - in the USA, anything you write becomes copyrighted instantly and automatically, even without filing for it. but if I wanted to write my own Java compiler, that was perfectly legal. Some have been trying to kill that concept - Oracle has been trying for years to legally encumber Java on Android, for example, with little success.

What makes Java great, however, isn't the core compiler and JVM. It's the rich class libraries that have been developed by many people in many places. And in the refinements such as JIT compiling. A single person can write this stuff, but to do a really good job, you're better off standing on the shoulders of giants. I started back in an era where everytime you needed an in-memory sort you had to design and implement it yourself, and that's not very much fun after a while.

But for most applications developers, knowing how to build a language system is about as common as a motorist knowing how to build an internal combustion engine. And as neccessary.
 
Carey Brown
Saloon Keeper
Posts: 3266
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:As for lawyers, it used to be a given that computer languages were uncopyrightable. Specific code was copyyrighted - in the USA, anything you write becomes copyrighted instantly and automatically, even without filing for it. but if I wanted to write my own Java compiler, that was perfectly legal. Some have been trying to kill that concept - Oracle has been trying for years to legally encumber Java on Android, for example, with little success.

Yes, but Google had to shell out a bunch for their lawyers to defend their position.
 
Peter Rooke
Ranch Hand
Posts: 897
7
Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anyone said Type System yet? 
 
Tim Holloway
Bartender
Posts: 18781
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:
Tim Holloway wrote:As for lawyers, it used to be a given that computer languages were uncopyrightable. Specific code was copyyrighted - in the USA, anything you write becomes copyrighted instantly and automatically, even without filing for it. but if I wanted to write my own Java compiler, that was perfectly legal. Some have been trying to kill that concept - Oracle has been trying for years to legally encumber Java on Android, for example, with little success.

Yes, but Google had to shell out a bunch for their lawyers to defend their position.


And Oracle, who, infamously has more lawyers than almost any tech firm other than IBM or Apple, lost.

And that was just an attempt to claim infringement on common header files.

I refuse to worry. About 60 years of precedent is working against them.
 
dro ned
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Rooke wrote:Has anyone said Type System yet? 


Thanks peter. I'll do some reading on this.
 
SunnyKumar Singh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Data type tell us the types of value e.g integer, character, string, float, etc.

In java, there are two types of data types

1) primitive data types like int, short, char, long, float, double, boolean byte.
2) non - primitive data types like array, enumeration, string, etc.

 
Campbell Ritchie
Marshal
Posts: 56227
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't say non‑primitive: say reference types.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!