Hey guys!
So we have different data types in Javascript. When Baue Carnes teaches JS for beginners or the Basic Js in FCC curricula he says that:
" in Computer Science data is anything that is meaningful to the computer!"
So my question is what is the theory or point of so many data types in javascript, CS or any programming languages?
Can you explain or link to a teohry video?
The computer doesnât âknowâ what a number, or a string of text, or something that is true or false, or a list of values is, it needs to be told. If you didnât have a way to tell it, how would it be able to do anything?
how do we do that? does it depend on languages ? is there a specific data type that computers understand?
I think youâre maybe misunderstanding a bit. Programming languages are an abstraction so that a person can give a computer instructions. Machine code, which is basically the lowest level of language, and is the actual instructions that the CPU runs, is just binary numbers, one after the other (so thereâs your âdata typeâ that CPUs understand â a processor takes instructions in binary and processes them). Itâs basically unreadable by a human. So you have programming languages, which let you write programs in a human-readable language, which then gets converted to machine code which the computer understands. And itâs easier to write program logic using things like "hello"
, or [1,2,3]
, or true
and false
, or 43.7
than it is to write millions of lines like 000000 00001 00010 00110 00000 100000
I actually know what binary code is, whatâs a programming language is and how compilers, interpreters translate human readable code to machine code.
But I am new to CS thatâs why asked.
Trying to understand this:
https://www.cs.utah.edu/~germain/PPS/Topics/data_types.html
Iâm not quite sure what youâre asking then â you seem to have answered your own question. Data types exist so that you can specify what type of data youâre programming with, so that in turn the compiler can convert it to the correct machine instructions. The article you linked is talking about data types used in the C programming language, when he says âthe computer only knows aboutâ heâs kinda really saying âthe C compiler only knows aboutâ
Thatâs what ı am trying to understand he says âcomputersâ you say c language
My question is the idea of data type in programming languages and CS.
I said â I knowâ what binary code is but I meant the intro just taking cs101.
ı actually have no idea how computer work, what computer handles binary code? how it sees the data types. Itâs probably advanced topic for me. or the wrong question
When it comes to data, all a computer can understand is 1 and 0. But sometimes we, the programers, want to store different things. Storing a Boolean is easy. Itâs either a 1 or a 0.
But integers or strings or decimal numbers are more complicated to store. Data types are how we, the programers, communicate via our code with the computer about how we want to store and read our data. In JavaScript the details are handled automatically for you, but in more low level languages like C you need to declare your variables and their type.