1

00:00:00,860  -->  00:00:04,290
Jaw Why is referred to as it type safe language.

2

00:00:04,290  -->  00:00:07,470
And in this lesson we'll see what that means.

3

00:00:07,470  -->  00:00:12,960
The reason we are not looking at this concept of type safety is because it is relevant to what we saw

4

00:00:12,960  -->  00:00:15,540
in casting objects specifically.

5

00:00:15,630  -->  00:00:21,720
We encounter a few compile time and runtime errors on those are due to the result of applying typesafe

6

00:00:21,720  -->  00:00:22,920
needles.

7

00:00:22,950  -->  00:00:26,610
So let's go ahead and see what biosafety means.

8

00:00:27,060  -->  00:00:33,330
According to Wikipedia bike safety is the extent to which a programming language prevents something

9

00:00:33,330  -->  00:00:34,680
called pipefitters.

10

00:00:35,010  -->  00:00:37,840
So let's see what bipedally means.

11

00:00:38,170  -->  00:00:44,980
Type errors are certain bot kind of errors that could lead to undesirable program behavior.

12

00:00:45,420  -->  00:00:49,340
Let's look at a couple of examples.

13

00:00:49,380  -->  00:00:55,650
One example could be in Wilkin nonexisting method on an object in our history.

14

00:00:55,770  -->  00:00:59,780
The class stuff does not include a Proview mattered.

15

00:00:59,970  -->  00:01:04,350
So we should not be able to invoke this method on a staff object.

16

00:01:04,350  -->  00:01:10,380
We already know that Java's compiler will not allow us to do this but some languages that are not safe

17

00:01:10,760  -->  00:01:16,290
could allow this and it could lead to some undesirable behavior.

18

00:01:16,290  -->  00:01:23,010
Second example is related to memory safety on one specific example is buffer overflow which is usually

19

00:01:23,010  -->  00:01:26,700
associated with languages like C and C++.

20

00:01:26,700  -->  00:01:32,690
Let's consider this example declaration in C language where a catenary is initialized with the string

21

00:01:32,730  -->  00:01:38,330
hello and this will get co-presenter in memory as shown here after hello.

22

00:01:38,370  -->  00:01:45,090
We have a null character indicating that I need a string after null character in the adjacent memory

23

00:01:45,090  -->  00:01:45,930
location.

24

00:01:45,960  -->  00:01:52,270
We have some data from some other variable and this gives the character a non Nazi.

25

00:01:52,380  -->  00:01:57,920
We want to insert the katak to be in the very next position 6.

26

00:01:58,050  -->  00:02:05,700
However it would be invalid as it is outside the RSA range but in a pipe unsafe language this could

27

00:02:05,760  -->  00:02:09,360
override that data in the next memory location.

28

00:02:09,360  -->  00:02:14,020
So you can see that he has got over it done with chiropody.

29

00:02:14,160  -->  00:02:20,080
So basically what happened was data got corrupted undocks an undesirable behavior.

30

00:02:20,610  -->  00:02:24,200
So these are kind of pipe errors that are typesafe language.

31

00:02:24,240  -->  00:02:30,950
We're trying to avoid some languages trying to put two in pipefitters at compile time.

32

00:02:30,990  -->  00:02:38,220
Some do it only a runtime while some others do that but compile time and run time and what does it both

33

00:02:38,220  -->  00:02:44,790
compile time as well as runtime types if checks that are done at compile time is also referred to as

34

00:02:44,880  -->  00:02:48,250
a static type checking one of checks done at runtime.

35

00:02:48,250  -->  00:02:51,070
Is your footrests dynamic like chicken.

36

00:02:51,600  -->  00:02:56,370
C and Pascal are examples of languages that use only static type checking.

37

00:02:56,850  -->  00:03:03,810
While Ruby and Python are examples of languages that use only dynamic electrican not let's look at couple

38

00:03:03,810  -->  00:03:07,450
of stocktake by picking examples in Java.

39

00:03:07,590  -->  00:03:11,770
We know that in Java they get a compiler error when we do this.

40

00:03:11,820  -->  00:03:15,450
That is we cannot assign a larger type with a smaller type.

41

00:03:15,480  -->  00:03:22,380
So here we are trying to assign a double literal to an incredible and we also know that the solution

42

00:03:22,380  -->  00:03:30,890
for this is to insert an explicit cast and we also know that we cannot work on non-existing matter here

43

00:03:30,900  -->  00:03:37,590
the reference type stuff does not include the proof review method on compiler promptly the parser solution

44

00:03:37,590  -->  00:03:41,440
once again is to insert an explicit cast.

45

00:03:41,450  -->  00:03:45,510
Finally genetics is all about types of beat at compile time.

46

00:03:45,820  -->  00:03:51,780
Before generics many of the errors were only caught at runtime but with the introduction of generics

47

00:03:51,780  -->  00:03:56,420
and Jollof I knew many of those errors at compile time access.

48

00:03:56,700  -->  00:03:58,060
And that is what is before.

49

00:03:58,350  -->  00:04:02,740
You would want to detect as many errors as possible at compile time itself.

50

00:04:03,060  -->  00:04:07,200
So when we get to generics you will see me using the phrase type safety.

51

00:04:07,200  -->  00:04:15,660
Quite a big Nona's checkout to a couple of examples on how GBM uses dynamic type checking to prevent

52

00:04:15,660  -->  00:04:18,360
some of the pipe errors.

53

00:04:18,540  -->  00:04:25,140
We saw this example when discussing object winds are going to cost promising the compiler that variable

54

00:04:25,140  -->  00:04:32,640
S will always reference either an editor object or one of its subtypes but render the method with a

55

00:04:32,640  -->  00:04:33,720
stop object.

56

00:04:33,750  -->  00:04:40,500
We get a runtime error art class class exception indicating that the Stav object could not be Castner

57

00:04:40,500  -->  00:04:41,670
to Ed..

58

00:04:42,150  -->  00:04:47,240
We know that this is because stuff can be an editor but it can also be something else like an email

59

00:04:47,240  -->  00:04:47,980
address.

60

00:04:48,540  -->  00:04:55,410
So people who enter type for JVM destroying this runtime error thus avoiding any undesirable behavior

61

00:04:55,410  -->  00:04:57,080
.

62

00:04:57,080  -->  00:05:05,190
And this example demonstrates prevention of buffer overflow type error here Qaderi is first initialized

63

00:05:05,190  -->  00:05:11,860
with the characters hello and then we are trying to access element index location file which is altered

64

00:05:11,940  -->  00:05:13,400
off I responded.

65

00:05:13,830  -->  00:05:16,190
So the get runtime error card again.

66

00:05:16,190  -->  00:05:22,770
This sort of bonnes exception as you can see the name of the error does the story so we can see the

67

00:05:22,770  -->  00:05:27,880
dynamic by checking Crozon in order to avoid any undesirable behavior.

68

00:05:28,290  -->  00:05:34,950
Basically Java static budgeting is enforced to prevent as many type errors as possible at compile time

69

00:05:34,950  -->  00:05:35,830
itself.

70

00:05:36,270  -->  00:05:40,830
However it is impossible to prevent all of that by bettors only at compile time.

71

00:05:41,280  -->  00:05:46,840
So the ones that cannot be prevented at compile time are they can get off at runtime using dynamic type

72

00:05:46,880  -->  00:05:47,680
checking.

73

00:05:48,060  -->  00:05:54,740
So John Law uses both static and dynamic type checking and response doesn't typesafe language.

74

00:05:54,750  -->  00:06:01,080
Also note that since toxically type languages do all the chicks at compile time itself and do not need

75

00:06:01,080  -->  00:06:07,320
any additional checks at runtime they can still be faster than dynamically typed languages which have

76

00:06:07,320  -->  00:06:10,940
to do all of the checks at runtime.

77

00:06:10,950  -->  00:06:17,970
No sometimes people incorrectly use terms like strongly typed system to refer to static typing on Veeck

78

00:06:17,970  -->  00:06:20,880
type system to refer to dynamic typing.

79

00:06:21,450  -->  00:06:26,750
Unfortunately there is no standard definition for strong or weak type systems.

80

00:06:27,030  -->  00:06:31,670
But let's look at some acceptable views for these two items.

81

00:06:31,890  -->  00:06:37,240
Strong typing generally means that there are no loopholes in that type system.

82

00:06:37,290  -->  00:06:40,800
That is a pipe system of a language gives certain guarantees.

83

00:06:41,010  -->  00:06:42,680
If the language is strongly typed.

84

00:06:42,870  -->  00:06:49,500
You cannot go out and undo something but in reality it does not and is on the other hand Veeck typing

85

00:06:49,500  -->  00:06:54,340
means that the type system has some loopholes and hence can be subverted.

86

00:06:54,330  -->  00:07:02,190
Invalidating any guarantees and in this respect July is considered as a strongly typed language.

87

00:07:02,190  -->  00:07:09,740
Some experts say that C is a Beagley type language as it seems to have several loopholes so that support

88

00:07:09,740  -->  00:07:14,070
type safety on July is considered as a type safe language.

89

00:07:14,070  -->  00:07:19,730
It is very strict about type safety and uses both static and dynamic typing.

90

00:07:19,740  -->  00:07:23,140
I'm also including some relevant pointers in the supplementary notes.

91

00:07:23,490  -->  00:07:25,640
If you're interested you can check them out.

92

00:07:25,890  -->  00:07:26,300
Thank you
