SlideShare a Scribd company logo
1 of 37
Download to read offline
Algebra
• What is common between the following?
– 1 + 1 = 2
– 2 + 3 = 5
– 6 + 7 = 13
• Answer:
– a + b = c
What is the benefit of it?
Benefits Of Algebra
1. Readability
– Which one is easier to read?
I. The square feet of an area is the length
multiplied by the width
II. length * width = area
2. Easier calculation
– Sample question,
• We have ducks and lambs
• There is a total of 50 heads
• There is a total 150 feet
• How much ducks and how much lambs do we have?
Solution
1. Each duck has 1 head and 2 feet
2. Each lamb has 1 head and 4 feet
3. We got
I. Ducks + Lambs = 50 (heads)
II. (Ducks * 2) + (Lambs * 4) = 150 (feet)
4. Divide the second equation by 2
(Ducks * 2) + (Lambs * 4) = 150
/2
(Ducks) + (Lambs * 2) = 75
5. Subtract the first equation
(Ducks) + (Lambs * 2) = 75
- Ducks + Lambs = 50
Lambs = 50
Algebra Functions
A function in algebra is:
1. A formula
2. That returns a value
3. That can take arguments
4. The return value is always the same, if the
arguments are the same
Example:
1. Add(a,b) is a function
2. CurrentTime() is not a function
3. Void DoSomethingNoReturn is not a function
Algebra function syntax:
area = f(length, width) = length * width
Functions In Computers
• Function vs Sub
– Databases separate between a function (that returns
a value) and stored procedures (that is like a
subprogram but doesn’t return a value)
– Also basic distinguishes between a function that
returns a value and a “sub” (subroutine or
subprogram) that doesn’t return a value
– Other imperative languages consider everything as
functions
• Same return value
– MySQL has a keyword “deterministic”
– In functional languages a variable is not changeable,
and a function always returns the same value (as in
algebra)
• A function with no arguments is in fact a constant
Boolean Algebra
• True = 1
• False = 0
• True AND True = True
• True AND False = False
• True OR False = True
• True Xor True = False
• True Xor False = True
• Not True = False
• Not False = True
Computers And Boolean Algebra
1. If and while statements
2. The hardware logic gates are based on
“Nand” and “Not” circut transistors
Computer Language history
• Machine Language
– Assembly Language
• Fortran (FORmula TRANsalator)
– Algol
» B
• C (UNIX) by K&R
• C++ [c = c + 1]
• Java
• C#
• JavaScript
• PHP
• Basic
– VB6
– VBA
– VBS
– VB.Net
Sample Memory Transistor
“Not” (Inverter)
Chip Is On (1)
On (1) Off (0) – We ignore this side
“Not” (Inverter)
“Not” (Inverter)
Chip Is Off (0)
Off (0) On (1) – We ignore this side
“Not” (Inverter)
Program Internal
Sections
.text.data.bss
Stack
Virtual Memory Layout
Operating
System
Reserved
.data
Break
(Heap)
.text
.bss
S
t
a
c
k
0
FFFFFFFF
How The Sections Work
.text
.data
Instruction1
Instruction2
OpCode Operand1 Operand2
ADD 01010101 11110000
a = 1
b = 1
a + b
00000001
00000001
Variable a @(01010101)
Variable b @ (11110000)
Code
Indirection
.text
.dataInstruction1
Instruction2
OpCode Operand1 Operand2
ADD 11110011 11111111
a = 1
b = 1
c* = &a
d* = &b
c* + d*
00000001
00000001
Variable a @(01010101)
Variable b @ (11110000)Code
01010101Variable c @ (11110011)
11110000Variable d @ (11111111)
I
n
d
i
r
e
c
t
Example A “C” “Array”
myArray = array()
i = 1
myArray[i] = 0
00000001
i @(01010101)
myArray @ (11110000)
Code
myArray[i] == myArray[1] == myArray + 1 @ (11110001) 00000000
Index value
(indirection)
Back To Memory
a = 0
p* =&a
11110001
Whole_Memory_Array
Pointer p @(01010101)
Code
a =Actual pointed variable = Whole_Memory_Array[p]@ (11110001) 00000000
Pointer value
(indirection)
Intro To Binary
Switch = Bit
8 Switches = 8 Bits = Byte
1 = On
0 = Off
We can have only 0 or 1
Is there any way to get real numbers?
Lets Take an Example From Regular
(Decimal) Numbers
• 0
• 1
• 2
• 3
• 4
• 5
• 6
• 7
• 8
• 9
• ?????
We have only 9 numerals
So how do we proceed?
Lets Take an Example From Regular
(Decimal) Numbers
• 0
• 1
• 2
• 3
• 4
• 5
• 6
• 7
• 8
• 9
• ?????
The answer is combination
• 10
• 11
• 12
• …
• 20
• 21
• ….
• 30
• ….
• 99
• ?????
• 100
• 101
• ….
• 200
• …..
Back To Binary
• 0
• 1
• ???
The answer is combination
• 10
• 11
• ?????
• 100
• 101
• 110
• 111
• ??????
• 1000
• 1001
• 1010
• 1100
• 1101
• 1110
• 1111
• ??????
Binary Compared To Decimal
• 0
• 1
• 2
• 3
• 4
• 5
• 6
• 7
• 8
• 9
• ……
• 00000000
• 00000001
• 00000010
• 00000011
• 00000100
• 00000101
• 00000110
• 00000111
• 00001000
• 00001001
• ……..
• 0
• 1
• 2
• 3
• 4
• 5
• 6
• 7
• 10
• 11
• ……
Decimal Binary Octal
Negative Numbers
• Rule 1: Negative has a 1 in front
Ex: 100000001
• Rule 2: The 2’s complement
1. The 1’s Complement – Xor all bits
Ex: 000000001 - (Decimal “1”)
Xor: 111111110
2. The 2’s Complement – Add 1
Ex: 000000001 - (Decimal “1”)
Xor: 111111110
Add 1: 111111110 - (Decimal “-1”)
Converting Between Smaller And Larger Types
byte a = 1
short b = a
Code
00000001
0000000000000001
Correct
unsigned byte a = 255
short b = a
11111111
0000000011111111
Correct
byte a = -1
short b = a
11111111
0000000011111111
Wrong
11111111
1111111111111111Correct
Positive Values
Negative Values
Identifiers Turned Into Memory
Addresses
1. The identifiers that are being turned into memory
addresses:
– Global Variables
– Functions
– Labels
2. The identifiers that are NOT being turned into memory
addresses, (are only used to measure the size to reserve):
– Custom types
– Struct
– Class names
3. The identifiers that are used as offsets:
– Array index
– Class (and struct) field (NOT function) member
– Local variables
Variables
• Size of the reserved memory is based on the type
• There might be the following types
1. Built-in type – which is just a group of bytes, based on the compiler
and/or platform
2. Custom type – which is just a series of built in types
3. Array (in C and C++) – which is just a series of the same built-in type
(but no one keeps track of the length, so it is the programmers job)
4. Pointer – system defined to hold memory addresses
5. Reference – a pointer without the possibility to access the memory
address
6. Handle – a value supplied by the operating system (like the index of an
array)
7. Typedef and Define – available in C and C++ to rename existing types
Variables are a “higher language – human
readable” name for a memory address
Labels
• There is no size associated with it
• Location
– In assembly it might be everywhere
• In fact in assembly it is generally the only way to declare a
variable, function, loop, or “else”
• In Dos batch it is the only way to declare a function
– In C and C++ it might be only in a function – but is only
recommended to break out of a nested loop
– In VB it is used for error handling “On error goto”
– In Java it might only be before a loop
Labels are a “higher language – human
readable” name for a memory address
Label Sample In Assembly
.data
.int
var1:
1
var2:
10
.text
.global
start:
mov var1 %eax
call myfunc
jmp myfunc
myfunc:
mov var2 %ebx
add %eax %ebx
ret
Label Sample In Java (Or C)
outerLabel:
while(1==1)
{
while(2==2)
{
//Java syntax
break outerLabel;
//C syntax (not the same as
before, as it will cause the loop again)
goto outerLabel;
}
}
Boolean Type
• False == 0 (all switches are of)
• True == 1 (switch is on, and also matches
Boolean algebra)
• All other numbers are also considered true (as
there are switches on)
• There are languages that require conversion
between numbers and Boolean (and other are
doing it behind the scenes))
However TWO languages are an
exception
Why Some Languages Require conversion
•Consider the following C code, all of them are perfectly valid:
if(1==1) //true
if(1) //true as well
if(a) //Checks if “a” is non-zero
if(a==b) //Compares “a” to “b”
if(a=b) //Sets “a” to the value of “b”, and then
//checks “a” if it is non-zero, Is this by
//intention or typo?
•However in Java the last statement would not compile, as it is
not a Boolean operation
•For C there is some avoidance by having constants to the left, ie.
if(20==a) Instead of if(a==20)
Because
if(20=a) Is a syntax error
While
if(a=20) Is perfectly valid
Implicit Conversion
• However some languages employ implicit
conversion
• JavaScript considers
– If (1) : true
– If (0) : false
– If (“”) : false
– If (“0”) : true
• Php Considers
• If (“0”) : false
• If (array()) : false
Boolean In Visual Basic
• True in VB = -1
• To see why let us see it in binary
– 1 = 00000001
– 1’s complement = 1111111110
– 2’s complement = 1111111111
• So all switches are on
But why different than all others?
To answer that we need to understand the difference
between Logical and Bitwise operators, and why do
Logical operators short circuit?
Logical vs bitwise
• Logical
– Step 1 – Check the left side for true
– Step 2 – If still no conclusion check the right side
– Step 3 – Compare both sides and give the answer
• Bitwise
– Step 1 – Translate both sides into binary
– Step 2 – Compare both sides bit per bit
– Step 3 – Provide the soltuion
Example Bitwise vs Logical
• Example 1
If 1==1 AND 2==2
Logical And Bitwise And
Step 1: 1==1 is true 1==1 is true=00000001
Step 2: 2 ==2 is true 2==2 is true=00000001
Step 3:
True 00000001
And True 00000001
= True 00000001
More Examples
• Example 2
If 1==2 AND 2==2
Logical And Bitwise And
Step 1: 1==2 is false 1==2 is false=00000000
Step 2: return false 2==2 is true =00000001
Step 3: N/A 00000000
AND 00000001
00000000
• Example 3
If 1 AND 2
Step 1: 1 is True 00000001
Step 2: 2 is True 00000010
Step 3: True 00000000
Bitwise vs Logical Operators
Operator C Basic VB.Net
(Logical)
Logical AND && N/A AndAlso
Logical OR || N/A OrElse
Logical NOT ! N/A N/A
(Bitwise)
Bitwise AND & AND AND
Bitwise OR | OR OR
Bitwise XOR ^ XOR XOR
Bitwise NOT ~ NOT NOT
Back To VB
• Since we have only a bitwise NOT we have to
make sure it works on Boolean
NOT On 1
1 = 00000001 = True
NOT = 11111110 = True
NOT On -1
-1 = 11111111 = True
NOT = 00000000 = False
Beware Of The Win32 API
Boolean In Bash Shell Scripting
# if(true) then echo “works”; fi
# works
#
# if(false) then echo “works”; fi
#
# if(test 1 –eq 1) then echo “works”; fi
# works
#
# if(test 1 –eq 2) then echo “works”; fi
#
# echo test 1 –eq 1
#
# test 1 –eq 1
# echo $?
# 0
# test 1 –eq 2
# echo $?
# 1
#
# true
# echo #?
# 0
# false
# echo #?
# 1

More Related Content

What's hot

L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variablesteach4uin
 
Python language data types
Python language data typesPython language data types
Python language data typesHoang Nguyen
 
Python programming
Python programmingPython programming
Python programmingsaroja20
 
Aaa ped-3. Pythond: advanced concepts
Aaa ped-3. Pythond: advanced conceptsAaa ped-3. Pythond: advanced concepts
Aaa ped-3. Pythond: advanced conceptsAminaRepo
 
Ruby data types and objects
Ruby   data types and objectsRuby   data types and objects
Ruby data types and objectsHarkamal Singh
 
Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and commentsNilimesh Halder
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Threeamiable_indian
 
An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : PythonRaghu Kumar
 
C# Programming: Fundamentals
C# Programming: FundamentalsC# Programming: Fundamentals
C# Programming: FundamentalsMahmoud Abdallah
 
Oop with c++ notes unit 01 introduction
Oop with c++ notes   unit 01 introductionOop with c++ notes   unit 01 introduction
Oop with c++ notes unit 01 introductionAnanda Kumar HN
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| FundamentalsMohd Sajjad
 
PPT on Data Science Using Python
PPT on Data Science Using PythonPPT on Data Science Using Python
PPT on Data Science Using PythonNishantKumar1179
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slidesrfojdar
 

What's hot (20)

L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python programming
Python programmingPython programming
Python programming
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Python revision tour II
Python revision tour IIPython revision tour II
Python revision tour II
 
Aaa ped-3. Pythond: advanced concepts
Aaa ped-3. Pythond: advanced conceptsAaa ped-3. Pythond: advanced concepts
Aaa ped-3. Pythond: advanced concepts
 
Ruby data types and objects
Ruby   data types and objectsRuby   data types and objects
Ruby data types and objects
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and comments
 
Python basics
Python basicsPython basics
Python basics
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
 
An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : Python
 
C# Programming: Fundamentals
C# Programming: FundamentalsC# Programming: Fundamentals
C# Programming: Fundamentals
 
Oop with c++ notes unit 01 introduction
Oop with c++ notes   unit 01 introductionOop with c++ notes   unit 01 introduction
Oop with c++ notes unit 01 introduction
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
M C6java3
M C6java3M C6java3
M C6java3
 
PPT on Data Science Using Python
PPT on Data Science Using PythonPPT on Data Science Using Python
PPT on Data Science Using Python
 
Notes on c++
Notes on c++Notes on c++
Notes on c++
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
Generics
GenericsGenerics
Generics
 

Viewers also liked

Viewers also liked (10)

K map
K mapK map
K map
 
Karnaugh maps
Karnaugh mapsKarnaugh maps
Karnaugh maps
 
Karnaugh Maps
Karnaugh MapsKarnaugh Maps
Karnaugh Maps
 
KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)
 
K - Map
  K - Map    K - Map
K - Map
 
K map
K mapK map
K map
 
Digital Logic & Design (DLD) presentation
Digital Logic & Design (DLD) presentationDigital Logic & Design (DLD) presentation
Digital Logic & Design (DLD) presentation
 
DLD Practical Lab Work
DLD Practical Lab WorkDLD Practical Lab Work
DLD Practical Lab Work
 
Karnaugh map
Karnaugh mapKarnaugh map
Karnaugh map
 
Basics Of Semiconductor Memories
Basics Of Semiconductor MemoriesBasics Of Semiconductor Memories
Basics Of Semiconductor Memories
 

Similar to [YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2

C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#Hawkman Academy
 
Lesson4.2 u4 l1 binary squences
Lesson4.2 u4 l1 binary squencesLesson4.2 u4 l1 binary squences
Lesson4.2 u4 l1 binary squencesLexume1
 
Java 101 intro to programming with java
Java 101  intro to programming with javaJava 101  intro to programming with java
Java 101 intro to programming with javaHawkman Academy
 
Java 101 Intro to Java Programming
Java 101 Intro to Java ProgrammingJava 101 Intro to Java Programming
Java 101 Intro to Java Programmingagorolabs
 
Getting started in Python presentation by Laban K
Getting started in Python presentation by Laban KGetting started in Python presentation by Laban K
Getting started in Python presentation by Laban KGDSCKYAMBOGO
 
Variables and Statements
Variables and StatementsVariables and Statements
Variables and Statementsprimeteacher32
 
07 control+structures
07 control+structures07 control+structures
07 control+structuresbaran19901990
 
Brixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 RecapBrixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 RecapBasil Bibi
 
Formal Methods lecture 01
Formal Methods lecture 01Formal Methods lecture 01
Formal Methods lecture 01Sidra Ashraf
 
Programming techniques
Programming techniquesProgramming techniques
Programming techniquesPrabhjit Singh
 
C++ Programming Basics.pptx
C++ Programming Basics.pptxC++ Programming Basics.pptx
C++ Programming Basics.pptxZntalemAbebe
 
Lec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsLec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsYashJain47002
 
Building confidence in concurrent code with a model checker: TLA+ for program...
Building confidence in concurrent code with a model checker: TLA+ for program...Building confidence in concurrent code with a model checker: TLA+ for program...
Building confidence in concurrent code with a model checker: TLA+ for program...Scott Wlaschin
 

Similar to [YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2 (20)

C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
Lesson4.2 u4 l1 binary squences
Lesson4.2 u4 l1 binary squencesLesson4.2 u4 l1 binary squences
Lesson4.2 u4 l1 binary squences
 
Vba Class Level 1
Vba Class Level 1Vba Class Level 1
Vba Class Level 1
 
Java 101 intro to programming with java
Java 101  intro to programming with javaJava 101  intro to programming with java
Java 101 intro to programming with java
 
Java 101 Intro to Java Programming
Java 101 Intro to Java ProgrammingJava 101 Intro to Java Programming
Java 101 Intro to Java Programming
 
Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
 
Getting started in Python presentation by Laban K
Getting started in Python presentation by Laban KGetting started in Python presentation by Laban K
Getting started in Python presentation by Laban K
 
Matlab lec1
Matlab lec1Matlab lec1
Matlab lec1
 
ppt_pspp.pdf
ppt_pspp.pdfppt_pspp.pdf
ppt_pspp.pdf
 
Variables and Statements
Variables and StatementsVariables and Statements
Variables and Statements
 
07 control+structures
07 control+structures07 control+structures
07 control+structures
 
C language
C languageC language
C language
 
Brixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 RecapBrixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 Recap
 
Formal Methods lecture 01
Formal Methods lecture 01Formal Methods lecture 01
Formal Methods lecture 01
 
Programing techniques
Programing techniquesPrograming techniques
Programing techniques
 
Clojure intro
Clojure introClojure intro
Clojure intro
 
Programming techniques
Programming techniquesProgramming techniques
Programming techniques
 
C++ Programming Basics.pptx
C++ Programming Basics.pptxC++ Programming Basics.pptx
C++ Programming Basics.pptx
 
Lec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsLec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questions
 
Building confidence in concurrent code with a model checker: TLA+ for program...
Building confidence in concurrent code with a model checker: TLA+ for program...Building confidence in concurrent code with a model checker: TLA+ for program...
Building confidence in concurrent code with a model checker: TLA+ for program...
 

Recently uploaded

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Recently uploaded (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2

  • 1. Algebra • What is common between the following? – 1 + 1 = 2 – 2 + 3 = 5 – 6 + 7 = 13 • Answer: – a + b = c What is the benefit of it?
  • 2. Benefits Of Algebra 1. Readability – Which one is easier to read? I. The square feet of an area is the length multiplied by the width II. length * width = area 2. Easier calculation – Sample question, • We have ducks and lambs • There is a total of 50 heads • There is a total 150 feet • How much ducks and how much lambs do we have?
  • 3. Solution 1. Each duck has 1 head and 2 feet 2. Each lamb has 1 head and 4 feet 3. We got I. Ducks + Lambs = 50 (heads) II. (Ducks * 2) + (Lambs * 4) = 150 (feet) 4. Divide the second equation by 2 (Ducks * 2) + (Lambs * 4) = 150 /2 (Ducks) + (Lambs * 2) = 75 5. Subtract the first equation (Ducks) + (Lambs * 2) = 75 - Ducks + Lambs = 50 Lambs = 50
  • 4. Algebra Functions A function in algebra is: 1. A formula 2. That returns a value 3. That can take arguments 4. The return value is always the same, if the arguments are the same Example: 1. Add(a,b) is a function 2. CurrentTime() is not a function 3. Void DoSomethingNoReturn is not a function Algebra function syntax: area = f(length, width) = length * width
  • 5. Functions In Computers • Function vs Sub – Databases separate between a function (that returns a value) and stored procedures (that is like a subprogram but doesn’t return a value) – Also basic distinguishes between a function that returns a value and a “sub” (subroutine or subprogram) that doesn’t return a value – Other imperative languages consider everything as functions • Same return value – MySQL has a keyword “deterministic” – In functional languages a variable is not changeable, and a function always returns the same value (as in algebra) • A function with no arguments is in fact a constant
  • 6. Boolean Algebra • True = 1 • False = 0 • True AND True = True • True AND False = False • True OR False = True • True Xor True = False • True Xor False = True • Not True = False • Not False = True
  • 7. Computers And Boolean Algebra 1. If and while statements 2. The hardware logic gates are based on “Nand” and “Not” circut transistors
  • 8. Computer Language history • Machine Language – Assembly Language • Fortran (FORmula TRANsalator) – Algol » B • C (UNIX) by K&R • C++ [c = c + 1] • Java • C# • JavaScript • PHP • Basic – VB6 – VBA – VBS – VB.Net
  • 9. Sample Memory Transistor “Not” (Inverter) Chip Is On (1) On (1) Off (0) – We ignore this side “Not” (Inverter) “Not” (Inverter) Chip Is Off (0) Off (0) On (1) – We ignore this side “Not” (Inverter)
  • 12. How The Sections Work .text .data Instruction1 Instruction2 OpCode Operand1 Operand2 ADD 01010101 11110000 a = 1 b = 1 a + b 00000001 00000001 Variable a @(01010101) Variable b @ (11110000) Code
  • 13. Indirection .text .dataInstruction1 Instruction2 OpCode Operand1 Operand2 ADD 11110011 11111111 a = 1 b = 1 c* = &a d* = &b c* + d* 00000001 00000001 Variable a @(01010101) Variable b @ (11110000)Code 01010101Variable c @ (11110011) 11110000Variable d @ (11111111) I n d i r e c t
  • 14. Example A “C” “Array” myArray = array() i = 1 myArray[i] = 0 00000001 i @(01010101) myArray @ (11110000) Code myArray[i] == myArray[1] == myArray + 1 @ (11110001) 00000000 Index value (indirection)
  • 15. Back To Memory a = 0 p* =&a 11110001 Whole_Memory_Array Pointer p @(01010101) Code a =Actual pointed variable = Whole_Memory_Array[p]@ (11110001) 00000000 Pointer value (indirection)
  • 16. Intro To Binary Switch = Bit 8 Switches = 8 Bits = Byte 1 = On 0 = Off We can have only 0 or 1 Is there any way to get real numbers?
  • 17. Lets Take an Example From Regular (Decimal) Numbers • 0 • 1 • 2 • 3 • 4 • 5 • 6 • 7 • 8 • 9 • ????? We have only 9 numerals So how do we proceed?
  • 18. Lets Take an Example From Regular (Decimal) Numbers • 0 • 1 • 2 • 3 • 4 • 5 • 6 • 7 • 8 • 9 • ????? The answer is combination • 10 • 11 • 12 • … • 20 • 21 • …. • 30 • …. • 99 • ????? • 100 • 101 • …. • 200 • …..
  • 19. Back To Binary • 0 • 1 • ??? The answer is combination • 10 • 11 • ????? • 100 • 101 • 110 • 111 • ?????? • 1000 • 1001 • 1010 • 1100 • 1101 • 1110 • 1111 • ??????
  • 20. Binary Compared To Decimal • 0 • 1 • 2 • 3 • 4 • 5 • 6 • 7 • 8 • 9 • …… • 00000000 • 00000001 • 00000010 • 00000011 • 00000100 • 00000101 • 00000110 • 00000111 • 00001000 • 00001001 • …….. • 0 • 1 • 2 • 3 • 4 • 5 • 6 • 7 • 10 • 11 • …… Decimal Binary Octal
  • 21. Negative Numbers • Rule 1: Negative has a 1 in front Ex: 100000001 • Rule 2: The 2’s complement 1. The 1’s Complement – Xor all bits Ex: 000000001 - (Decimal “1”) Xor: 111111110 2. The 2’s Complement – Add 1 Ex: 000000001 - (Decimal “1”) Xor: 111111110 Add 1: 111111110 - (Decimal “-1”)
  • 22. Converting Between Smaller And Larger Types byte a = 1 short b = a Code 00000001 0000000000000001 Correct unsigned byte a = 255 short b = a 11111111 0000000011111111 Correct byte a = -1 short b = a 11111111 0000000011111111 Wrong 11111111 1111111111111111Correct Positive Values Negative Values
  • 23. Identifiers Turned Into Memory Addresses 1. The identifiers that are being turned into memory addresses: – Global Variables – Functions – Labels 2. The identifiers that are NOT being turned into memory addresses, (are only used to measure the size to reserve): – Custom types – Struct – Class names 3. The identifiers that are used as offsets: – Array index – Class (and struct) field (NOT function) member – Local variables
  • 24. Variables • Size of the reserved memory is based on the type • There might be the following types 1. Built-in type – which is just a group of bytes, based on the compiler and/or platform 2. Custom type – which is just a series of built in types 3. Array (in C and C++) – which is just a series of the same built-in type (but no one keeps track of the length, so it is the programmers job) 4. Pointer – system defined to hold memory addresses 5. Reference – a pointer without the possibility to access the memory address 6. Handle – a value supplied by the operating system (like the index of an array) 7. Typedef and Define – available in C and C++ to rename existing types Variables are a “higher language – human readable” name for a memory address
  • 25. Labels • There is no size associated with it • Location – In assembly it might be everywhere • In fact in assembly it is generally the only way to declare a variable, function, loop, or “else” • In Dos batch it is the only way to declare a function – In C and C++ it might be only in a function – but is only recommended to break out of a nested loop – In VB it is used for error handling “On error goto” – In Java it might only be before a loop Labels are a “higher language – human readable” name for a memory address
  • 26. Label Sample In Assembly .data .int var1: 1 var2: 10 .text .global start: mov var1 %eax call myfunc jmp myfunc myfunc: mov var2 %ebx add %eax %ebx ret
  • 27. Label Sample In Java (Or C) outerLabel: while(1==1) { while(2==2) { //Java syntax break outerLabel; //C syntax (not the same as before, as it will cause the loop again) goto outerLabel; } }
  • 28. Boolean Type • False == 0 (all switches are of) • True == 1 (switch is on, and also matches Boolean algebra) • All other numbers are also considered true (as there are switches on) • There are languages that require conversion between numbers and Boolean (and other are doing it behind the scenes)) However TWO languages are an exception
  • 29. Why Some Languages Require conversion •Consider the following C code, all of them are perfectly valid: if(1==1) //true if(1) //true as well if(a) //Checks if “a” is non-zero if(a==b) //Compares “a” to “b” if(a=b) //Sets “a” to the value of “b”, and then //checks “a” if it is non-zero, Is this by //intention or typo? •However in Java the last statement would not compile, as it is not a Boolean operation •For C there is some avoidance by having constants to the left, ie. if(20==a) Instead of if(a==20) Because if(20=a) Is a syntax error While if(a=20) Is perfectly valid
  • 30. Implicit Conversion • However some languages employ implicit conversion • JavaScript considers – If (1) : true – If (0) : false – If (“”) : false – If (“0”) : true • Php Considers • If (“0”) : false • If (array()) : false
  • 31. Boolean In Visual Basic • True in VB = -1 • To see why let us see it in binary – 1 = 00000001 – 1’s complement = 1111111110 – 2’s complement = 1111111111 • So all switches are on But why different than all others? To answer that we need to understand the difference between Logical and Bitwise operators, and why do Logical operators short circuit?
  • 32. Logical vs bitwise • Logical – Step 1 – Check the left side for true – Step 2 – If still no conclusion check the right side – Step 3 – Compare both sides and give the answer • Bitwise – Step 1 – Translate both sides into binary – Step 2 – Compare both sides bit per bit – Step 3 – Provide the soltuion
  • 33. Example Bitwise vs Logical • Example 1 If 1==1 AND 2==2 Logical And Bitwise And Step 1: 1==1 is true 1==1 is true=00000001 Step 2: 2 ==2 is true 2==2 is true=00000001 Step 3: True 00000001 And True 00000001 = True 00000001
  • 34. More Examples • Example 2 If 1==2 AND 2==2 Logical And Bitwise And Step 1: 1==2 is false 1==2 is false=00000000 Step 2: return false 2==2 is true =00000001 Step 3: N/A 00000000 AND 00000001 00000000 • Example 3 If 1 AND 2 Step 1: 1 is True 00000001 Step 2: 2 is True 00000010 Step 3: True 00000000
  • 35. Bitwise vs Logical Operators Operator C Basic VB.Net (Logical) Logical AND && N/A AndAlso Logical OR || N/A OrElse Logical NOT ! N/A N/A (Bitwise) Bitwise AND & AND AND Bitwise OR | OR OR Bitwise XOR ^ XOR XOR Bitwise NOT ~ NOT NOT
  • 36. Back To VB • Since we have only a bitwise NOT we have to make sure it works on Boolean NOT On 1 1 = 00000001 = True NOT = 11111110 = True NOT On -1 -1 = 11111111 = True NOT = 00000000 = False Beware Of The Win32 API
  • 37. Boolean In Bash Shell Scripting # if(true) then echo “works”; fi # works # # if(false) then echo “works”; fi # # if(test 1 –eq 1) then echo “works”; fi # works # # if(test 1 –eq 2) then echo “works”; fi # # echo test 1 –eq 1 # # test 1 –eq 1 # echo $? # 0 # test 1 –eq 2 # echo $? # 1 # # true # echo #? # 0 # false # echo #? # 1