Why TRUE + TRUE = 2: Data Types

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ก.พ. 2020
  • INT, BOOLEAN, STRING and FLOAT: these are the things that data is made of. • Sponsored by Dashlane - for free on your first device @ www.dashlane.com/tomscott
    MORE BASICS: • The Basics
    Written with Sean Elliott / seanmelliott
    Directed by Tomek
    Graphics by Mooviemakers www.mooviemakers.co.uk/
    Audio mix by Haerther Productions haerther.net/
    I'm at tomscott.com
    on Twitter at / tomscott
    on Facebook at / tomscott
    and on Instagram as tomscott

ความคิดเห็น • 1.8K

  • @TomScottGo
    @TomScottGo  4 ปีที่แล้ว +846

    And that's the last in this run of the Basics! Thanks to Dashlane for sponsoring all these: you can get their password manager for free on your first device at www.dashlane.com/tomscott - there's a 30-day free trial, and 10% off with my code, "tomscott".

    • @FBIagentObama
      @FBIagentObama 4 ปีที่แล้ว +6

      *Sup dude*

    • @TheElvisnator
      @TheElvisnator 4 ปีที่แล้ว +22

      Finally a comment that isn't older than the video
      Tom Scott be like: *_The laws of time aren't mine anymore_*

    • @alanreader4815
      @alanreader4815 4 ปีที่แล้ว +6

      How many people have used the phrase "Tom Scott for 10 per cent off" as the the password. :D

    • @user-jp7tw3sd3x
      @user-jp7tw3sd3x 4 ปีที่แล้ว +10

      I love how even the advertisement is educational.

    • @TheKingsIdiot
      @TheKingsIdiot 4 ปีที่แล้ว +9

      One of the few ads i have seen that was informative while being an ad.

  • @lucabaldassi6024
    @lucabaldassi6024 4 ปีที่แล้ว +1407

    0:19 the way the text on the screen and Tom's hand raise at the same time is unsettling

    • @spockbaca5475
      @spockbaca5475 4 ปีที่แล้ว +219

      He’s too powerful

    • @mrkrunch4340
      @mrkrunch4340 4 ปีที่แล้ว +50

      True Power

    • @paulhermes990
      @paulhermes990 4 ปีที่แล้ว +13

      @Shareaffi I thank you kind stranger ;w;

    • @paulhermes990
      @paulhermes990 4 ปีที่แล้ว +6

      @Shareaffi I because we are the same person in two separate locations thanks to a super position... Maybe

    • @gaalidas4836
      @gaalidas4836 4 ปีที่แล้ว +36

      Spontaneous quantum entanglement. I hate it when that happens.

  • @MrMysticphantom
    @MrMysticphantom 4 ปีที่แล้ว +2974

    PHP: "A language notable for MANY questionable design decisions"
    I laughed, cried and grimaced so hard at the mention of that absolutely true fact.

    • @Kyrelel
      @Kyrelel 4 ปีที่แล้ว +42

      PHP is simply C for Kids

    • @jemesmemes9026
      @jemesmemes9026 4 ปีที่แล้ว +47

      Snooby66 c isn’t a programming language it’s a scripting language... smh

    • @Apoc2K
      @Apoc2K 4 ปีที่แล้ว +111

      PHP 5.4 was my personal Vietnam.

    • @gaalidas4836
      @gaalidas4836 4 ปีที่แล้ว +34

      Nice... comparing computer languages to being sent to war. I approve of this comparison.

    • @Colopty
      @Colopty 4 ปีที่แล้ว +91

      Doesn't help that PHP wasn't even a programming language to begin with, it started as a markup language that just sort of grew out of control in terms of scope. The reason the design decisions seem bad is that they weren't really design decisions as much as they were adding stuff to the language randomly with no regards for the rest of it.

  • @Tyranisaur
    @Tyranisaur 4 ปีที่แล้ว +1880

    "Implicit conversions are great" - Famous last words

    • @BrentFiore
      @BrentFiore 3 ปีที่แล้ว +166

      "Implicit conversions are great" == true (since the string is not null)
      Can't argue with that

    • @hannessteffenhagen61
      @hannessteffenhagen61 3 ปีที่แล้ว +22

      @Gero Van Mi with proper strict typing a string just isn't a boolean at all, so a comparison to boolean wouldn't be a false statement, it wouldn't be a statement at all. It'd just be incorrect syntax, just like "down Tremor falling is" isn't an English sentence.
      (FYI this would still be the case in dynamically typed languages, the difference between dynamic and static typing is _when_ you detect errors, not what sentences are or aren't valid).

    • @happysongs4kyrone
      @happysongs4kyrone 2 ปีที่แล้ว +3

      hai ooga monki here mmm ibudnenrtaansdnd mmmm syeysyes oogoooogoa

    • @harrychufan
      @harrychufan 2 ปีที่แล้ว +9

      Explicit is better than implicit!

    • @msq7041
      @msq7041 2 ปีที่แล้ว +7

      Yea, id rather have it throw me an error, or even better dont even let me compile it, like F#...
      If theres an implicit conversion theres something going wrong, and id rather know sooner than later

  • @rekagaal
    @rekagaal 4 ปีที่แล้ว +2301

    "I have been coding for about 30 years"
    Jesus, in my mind you've been permanently ~25 since 2015. I have to readjust to what Wikipedia claims is your age, but even then, you started super young if that's true...

    • @lyrimetacurl0
      @lyrimetacurl0 4 ปีที่แล้ว +306

      Probably started at 1.5

    • @zyaicob
      @zyaicob 4 ปีที่แล้ว +25

      Straight out of college baby

    • @thoughtyness
      @thoughtyness 4 ปีที่แล้ว +282

      For those too lazy to look it up, he’s 35 to 36 according to Wikipedia

    • @Shaun.Stephens
      @Shaun.Stephens 4 ปีที่แล้ว +84

      You haven't yet grasped that visible ageing is a big no-no in 'public figures' and these days is something only poor people do?
      21st century public figures who make an (un)reasonable amount of money have modified Little Patty’s creed from "Live well, die young, and have a good-looking corpse". They removed the "die young" part.

    • @Cresanova
      @Cresanova 4 ปีที่แล้ว +107

      @@Shaun.Stephens Such insight. Be sure to enlighten us mere mortals in all of Tom's future videos as well, brother

  • @dontaskmewhy8734
    @dontaskmewhy8734 4 ปีที่แล้ว +824

    I change the hdmi 1 to hdmi 2 and thats already enough coding for my grandparents

    • @chonkydog6262
      @chonkydog6262 4 ปีที่แล้ว +6

      Don't Ask Me Why хаха

    • @chonkydog6262
      @chonkydog6262 4 ปีที่แล้ว +2

      смешно

    • @dontaskmewhy8734
      @dontaskmewhy8734 4 ปีที่แล้ว +2

      @@chonkydog6262 smehno? Did i say that right? Im learning russian

    • @chonkydog6262
      @chonkydog6262 4 ปีที่แล้ว

      Don't Ask Me Why как я должен знать я тебя не могу слышать на ютубе

    • @chonkydog6262
      @chonkydog6262 4 ปีที่แล้ว

      Don't Ask Me Why smeshnk

  • @kdlk9139
    @kdlk9139 4 ปีที่แล้ว +1743

    When “true + true” fades away it doesn’t fully disappear 4:35
    Sorry Tom, I’m a big fan of your work

  • @vaclavtrpisovsky
    @vaclavtrpisovsky 4 ปีที่แล้ว +393

    Thanks for undermining my trust in high-level programming languages. I'm switching to Assembly.

    • @kensmith5694
      @kensmith5694 4 ปีที่แล้ว +38

      The good thing about assembly is that it is totally self documenting. You can look at a line of code and see exactly what it does. :)
      BTW: I have written something nearing a million lines of ASM.

    • @lordcirth
      @lordcirth 4 ปีที่แล้ว +3

      Just use a strongly-typed language like Haskell! It's quite trustworthy, and powerful too!

    • @kadblue2000
      @kadblue2000 4 ปีที่แล้ว +62

      @@kensmith5694 In other words 2 lines of python code.

    • @kensmith5694
      @kensmith5694 4 ปีที่แล้ว +8

      @@kadblue2000
      Better yet: 1 line of APL
      Python is quite bad at dealing with hardware.

    • @R3lay0
      @R3lay0 3 ปีที่แล้ว +44

      Assembly? More like ASSembly. Real men write binary machine code.

  • @HorzaPanda
    @HorzaPanda 4 ปีที่แล้ว +714

    I was taught Fortran at University. They told us to start with "implicit none" and then declare all our variable explicitly
    Kind of a pain, but it did mean if you accidentally typo'd a variable name it would flag it for you immediately

    • @scottcampbell2707
      @scottcampbell2707 4 ปีที่แล้ว +1

      I used REXX (on VM/CMS) at university. REXX is like the opposite of strictly typed.

    • @charleslambert3368
      @charleslambert3368 4 ปีที่แล้ว +27

      Not sure if you're an old CS graduate or a young scientist.

    • @HorzaPanda
      @HorzaPanda 4 ปีที่แล้ว +23

      @@charleslambert3368 If that's at me, young scientist. I started my physics degree in 2007 and they switched to Python for the year after me XD

    • @cygil1
      @cygil1 4 ปีที่แล้ว +25

      "IMPLICIT NONE" is actually the default, intended way of using Fortran 90+, not merely good style. The only reason the Fortran 90 standard retained implicit behavior at all is to retain backwards compatibility with the now deprecated Fortran 77.

    • @europeansovietunion7372
      @europeansovietunion7372 4 ปีที่แล้ว +11

      Speaking of pain, I've learned programming with pneumatic circuits, debugging was physically painful sometimes (we had to wear security goggles as well).

  • @anselmschueler
    @anselmschueler 4 ปีที่แล้ว +3815

    In python, however, "1.5"*2 is "1.51.5"...

    • @foolo1
      @foolo1 4 ปีที่แล้ว +727

      That makes sense, since the "1.51" is quoted, so it's just like any string that is duplicated. If the quotes were not there, it would have been another case.

    • @tovekauppi1616
      @tovekauppi1616 4 ปีที่แล้ว +151

      Olof Andersson I think the unusual bit is that the * is used to add two of the same string to a longer string.

    • @JNCressey
      @JNCressey 4 ปีที่แล้ว +158

      And you can also multiply lists.
      [None]*3 goes to [None,None,None]. Great for initializing long arrays.
      But be careful.
      [[None]*width]*height looks okay as a 2 dimensional array - until you start trying to assign values in it.

    • @bulbyvr
      @bulbyvr 4 ปีที่แล้ว +89

      Prob because python thinks "1.5"*2 = "1.5" + "1.5" woah hey there that's a concat symbol

    • @muizzy
      @muizzy 4 ปีที่แล้ว +154

      Python is a strong dynamically typed language, which adds a whole different set of complications to the mix. Essentially: Python is aware of the exact types of all the variables and will throw errors instead of casting, but the type of a variable can be changed while (re)assigning it.

  • @FinBoyXD
    @FinBoyXD 4 ปีที่แล้ว +764

    I really like strongly typed languages. If I want to cast it I can do it myself. Otherwise I want to see an error.

    • @FurryDanOriginal
      @FurryDanOriginal 4 ปีที่แล้ว +21

      this!

    • @gloweye
      @gloweye 4 ปีที่แล้ว +79

      Clearly presented errors help you improve your code. If they happen, you messed up, you know where, and you can fix it.
      Languages like PHP just continue with faulty data, which is not the right thing to do.
      As for those who say "Just use ===", my question is, why isn't >== an operator?

    • @Markus-zb5zd
      @Markus-zb5zd 3 ปีที่แล้ว

      Check out ABAP then. It's a Cobol derivative used in SAP

    • @thefakepie1126
      @thefakepie1126 3 ปีที่แล้ว

      @@LieutenantVague yup , you know very little about programming !

    • @welltypedwitch
      @welltypedwitch 3 ปีที่แล้ว +7

      Kinda, but type casting is not necessarily a great Idea at all. If you can avoid it, you should just not have to coerce types at all

  • @BenjaminLovelady
    @BenjaminLovelady 4 ปีที่แล้ว +291

    Personally, I get really frustrated working with weakly typed languages. Debugging can be hard, but even just understanding what the code is doing can be harder.

    • @57thorns
      @57thorns 4 ปีที่แล้ว +30

      Agreed. While I like solving small to medium sized taks in python because of the expressiveness of the language, I would hate to maintain a large program written exclusively in that language, unless the developers have shown incredible discipline in structuring and documenting and testing the code base.

    • @JNCressey
      @JNCressey 4 ปีที่แล้ว +5

      @@57thorns, import typing

    • @Spoco
      @Spoco 4 ปีที่แล้ว +14

      It's not the weak typing, just bad code and architecture in general. Good luck trying to figure out what's going on in buggy C++ code where every operator has been overloaded and core guidelines ignored.

    • @zeffonian
      @zeffonian 3 ปีที่แล้ว +1

      Like JNCressey said, you can use typehints

    • @vegahimsa3057
      @vegahimsa3057 3 ปีที่แล้ว

      When in doubt, force the conversion. let num = x - 0; let str = x + "";

  • @RussanoGreenstripe
    @RussanoGreenstripe 2 ปีที่แล้ว +10

    4:57 That's why I used the mnemonic "explicitly equals" when writing booleans to remind me to use the second equal. The alliteration and second word reminded me that it was two symbols and not just the one.

  • @tyberfen5009
    @tyberfen5009 4 ปีที่แล้ว +972

    Tom is the kind of guy you listen to, even if you worked yourself through that topic countless times before
    Concerning the topic itself, I prefer explicit declarations, as it makes finding bugs in the program simpler as it forces you to consciously account for these kind of conflicts. I can see why people like to use weak typing, but personally, I rather do not

    • @geli95us
      @geli95us 4 ปีที่แล้ว +36

      I usually like strong typing, but I have to admit that having c++ remind you that you can't implicitly cast long to int every 2 seconds really bothers me, even more because in g++, both long and int are the same size

    • @Corbald
      @Corbald 4 ปีที่แล้ว +8

      @@geli95us That's why all my variables, in my mind, explicitly include in place typecasting. I know it's almost exactly like taking an explicit system and forcing it through an implicit hole, but it works for me.
      for (int i; int(i) < int(variable); int(i++)) {
      print(str(i));
      }

    • @jamesmnguyen
      @jamesmnguyen 4 ปีที่แล้ว +4

      @@geli95us I wonder if there's a programming language that allows type conversions if they have the same bit length. Although you might get in trouble when dealing with signed and unsigned integers.

    • @theminer3746
      @theminer3746 4 ปีที่แล้ว +19

      I've started programming many years ago and created many websites using PHP, to be honest, I'm starting to find myself declaring more and more input and output types of my function. It just makes the code better and easier to test.

    • @gaalidas4836
      @gaalidas4836 4 ปีที่แล้ว +18

      I feel like allowing implicit conversions, outside of such amazing things like interpolated strings, is just asking for trouble no matter if they have the same number of bits or not. Controlling your data types will always lead to more stable programs.

  • @FlashMustache
    @FlashMustache 4 ปีที่แล้ว +166

    2:46 the type of a variable doesn't get figured out ("inferred") from the code in JS / Python / PHP. Some languages do work like that, but JS just makes a bucket that can fit everything (with quite some overhead) and then just lets you do whatever you want with it.
    Haskell is a language where it does get inferred from the code using constraint resolution, giving you the (apparent) benefits of not specifying it without that overhead. C#/Java have var, Kotlin has var/val, Scala/Rust have let , C++ has auto, all like Haskell (to various degrees).

    • @WilcoVerhoef
      @WilcoVerhoef 4 ปีที่แล้ว +8

      Yup, everything is an object

    • @rolaroli
      @rolaroli 4 ปีที่แล้ว +9

      Same thing with Swift. Strongly typed language that will "figure it out" for you, but it will under no circumstances do typecasting by itself. So if you want to multiply 2 with 1.4 you have to explicitly cast one to Float/Double or the other to Int. Which is great it some cases - because you can't make a mistake like that, but can be highly annoying when you just want to multiply two numbers and store them in a Double for instance.

    • @ericw.1620
      @ericw.1620 4 ปีที่แล้ว +2

      @@rolaroli OCaml is the same, except it's even more annoying bc it's so strongly typed you can't even multiply ints and floats without typecasting

    • @henke37
      @henke37 4 ปีที่แล้ว +1

      That's the official story. Reality... is more complex.

    • @sysosmaster
      @sysosmaster 4 ปีที่แล้ว +3

      Well, yes and no. It depends on yo javascript compiler. Most will actually store the input in an optimized way (Ea a type of int for numbers a type of double for floats and so on.). If it needs to type juggle it will actually than convert it on the fly if needed. You can see this (and similarly like this in php) if you read the source. Compiled script language in general do not work as they appear from the programmers perspective. (The programmer writing in the script language)

  • @casperes0912
    @casperes0912 4 ปีที่แล้ว +76

    I'll add that you can have implicit declarations within a strongly typed language. Swift does this as an example. So you can make a declaration like
    var x = "50"
    You don't need to declare that x is a string, the declaration is implicit. But in usage it'll be strongly typed, so
    var y = 50
    x+y
    only works if you explicitly cast either of them, like
    Int(x)+y
    Recent Java also has implicit local declaration, though not for global variables.

    • @MrTridac
      @MrTridac 4 ปีที่แล้ว +7

      C++
      auto x = "50"; // another example

    • @LorenzoDelmonte0530
      @LorenzoDelmonte0530 4 ปีที่แล้ว +3

      Same in py

    • @mntalateyya
      @mntalateyya 4 ปีที่แล้ว +3

      @@LorenzoDelmonte0530 Not exactly. Python only checks the types at runtime.

    • @fashnek
      @fashnek 4 ปีที่แล้ว +9

      The var/auto keyword in C++ and Java is NOT an implicit declaration. It's an explicit declaration with a specific type that is well-known at compile time, inferred syntactically according to the language rules. It is ONLY a syntactic convenience.

    • @danielbennett5726
      @danielbennett5726 4 ปีที่แล้ว +4

      Same in C#, however i tend to still declare the type
      int x = 50 rather than var x = 50.
      easier to read the code i find.

  • @Asasnol21
    @Asasnol21 4 ปีที่แล้ว +32

    I was classically trained in C and then decided to learn JavaScript. A dark time in my life.

    • @kensmith5694
      @kensmith5694 4 ปีที่แล้ว +4

      At least you weren't going between C++ and JavaScript and back.

    • @cameronmyron5776
      @cameronmyron5776 2 ปีที่แล้ว

      I really hope you can get past this dark time in your life. Best wishes.

    • @flex9663
      @flex9663 2 ปีที่แล้ว

      learn c# and enjoy some modern intuitive language that isn't dynamically typed.
      c# is java and python's love child and its really great.

  • @AaronTheGerman
    @AaronTheGerman 4 ปีที่แล้ว +77

    [0:16] Can we just talk about how the green title screen in the background perfectly reacts to Tom's hand gestures? :D

  • @noxabellus
    @noxabellus 4 ปีที่แล้ว +182

    Having used both weakly and strongly typed languages for years I have to thoroughly disagree with this common "wisdom" that weak/dynamic typing is helpful in any way. The extra overhead for teaching a beginner is, from my real world experience, about half an hour at most. With the advent of broadly type inferred languages, it doesn't save you much typing, either. On the other hand, strong typing gives you a mental framework to work off of which is extremely beneficial to every level of programmer. Not to mention compilers with good error messaging can provide tons of help especially to beginners, based on these strong types. In my opinion, this is an out dated and incorrect notion that has failed to fall out of favor because of entrenchment

    • @Markus-zb5zd
      @Markus-zb5zd 3 ปีที่แล้ว +13

      There are cases where weak typing are very helpful, especially in dynamic scenarios...
      Though that's even further from beginner coding.

    • @TheNewTimeNetwork
      @TheNewTimeNetwork 3 ปีที่แล้ว +1

      @@Markus-zb5zd Optionally typed languages like TypeScript and PHP7 are good for such dynamic scenarios.

    • @AllUpOns
      @AllUpOns 3 ปีที่แล้ว +8

      @@Markus-zb5zd The only case I can think of where weak typing is useful is when doing low-level programming in assembly or machine code. In any other context, weak types at best break even with strong types. Even "dynamic scenarios" should be handled with explicitly broad types that makes clear the scope of the possible inputs or whatever.
      The only other excuse I know of is that we're stuck with JS in the browser space (for now). And even then, you should use typescript for anything you actually remotely important.

    • @Markus-zb5zd
      @Markus-zb5zd 3 ปีที่แล้ว +1

      @@AllUpOns weak typing can save a lot of redundant code in dynamic code...
      I use it quite regulary.
      But I think this has to be done conscious and not out if habit, string typing should be the standard.

    • @Markus-zb5zd
      @Markus-zb5zd 3 ปีที่แล้ว

      @@TheNewTimeNetwork in our scenario we have no choice of language,... we're uising a late proprietary derivative of COBOL that gives us the option to use strong and weak typing.

  • @sebbes333
    @sebbes333 4 ปีที่แล้ว +13

    5:17 The year is 2050 JavaScript have now "evolved" to the point where a strict comparison is typed like this: _1.5 ============================== "1.5"; // false_
    (30 equal signs)

  • @mirjanbouma
    @mirjanbouma 4 ปีที่แล้ว +60

    I love these IT themed videos, they make this noob understand much better what dark magic makes my pc work.

    • @howardbaxter2514
      @howardbaxter2514 4 ปีที่แล้ว +4

      You want to truly understand how this dark magic works, study circuits, boolean logic, and assembly code. You literally get down to the bare bones of the computer and electrical world. It actually isn't too overly complicated when you get down to it.

    • @mirjanbouma
      @mirjanbouma 4 ปีที่แล้ว +3

      @@howardbaxter2514 I've played Human Resource machine, which is a bit like leaning COBOL, or so I've been told.
      I love logic puzzles but sadly, after two burnouts, I find it hard to properly concentrate on this type of thing. Thank you though, I'll be sure to read up on it.

    • @samuvisser
      @samuvisser 4 ปีที่แล้ว +2

      Always fun when non- programmers are interested in programming related topics. Is a video like this easy to understand for you? For me, it's like 1+1=2 but I've been a programmer for a while. Really interested how you see this

    • @mirjanbouma
      @mirjanbouma 4 ปีที่แล้ว +2

      @@samuvisser yup, that wasn't hard at all.
      I tried some "1=true, 0=false" finagling in Calculator (Apache's open office version of Excel) but I couldn't get it to work. Again, concentration is harder these days, and although my English is quite good I think, it's my second language, so that does make things a bit trickier.
      I'm a child from the DOS and Win3.11 era and I taught myself a number of commands. Like... *Thinking* dir w/o/p I think, would give you the directory alphabetically, multiple files on one line, and per screen, press space (or perhaps any key?) to get the next screen full.
      Ah, if only I'd gotten into IT...

    • @TorutheRedFox
      @TorutheRedFox 2 ปีที่แล้ว

      @@howardbaxter2514 it's really just a bunch of really simple elements strung together to make something more and more complex the higher in level you go

  • @HetuNandu
    @HetuNandu 4 ปีที่แล้ว +39

    Loved what you did with 42 and * there

    •  4 ปีที่แล้ว +5

      that was 21 in binary tho

    • @anishagrawal7068
      @anishagrawal7068 4 ปีที่แล้ว +3

      The meaning of the universe, life and everything

    • @jmtikka
      @jmtikka 4 ปีที่แล้ว +4

      Actually 42 is The Answer to the Ultimate Question of Life, the Universe, and Everything.

    • @ReneSebastian
      @ReneSebastian 4 ปีที่แล้ว +1

      This! 👏🏻

  • @robnorris4770
    @robnorris4770 4 ปีที่แล้ว +13

    4:03 Body language says “been there, done that”.

  • @ProfessorSyndicateFranklai
    @ProfessorSyndicateFranklai 4 ปีที่แล้ว +4

    Also in JS, if you want to evaluate if a value is set to null or not, but one of the valid values IS an empty string, or 0, or etc, that's also where you get problems. It's honestly easier to be more consistent and check for these values explicitly.

  • @ClokworkGremlin
    @ClokworkGremlin 4 ปีที่แล้ว +198

    "Weak typing can reduce frustration and just make programmers' lives easier."
    Weak typing forces you to know exactly what you're doing, and makes screwing up really easy, and the computer probably won't catch it for you. This is the opposite of what you want for beginning programmers.

    • @dustojnikhummer
      @dustojnikhummer 4 ปีที่แล้ว +23

      Yup. Java will throw an error you used a wrong type, which I think is a good thing. "OH, I was not supposed to do that"

    • @agiar2000
      @agiar2000 4 ปีที่แล้ว +36

      I agree. I think a beginner programmer should start with a strongly-typed language, especially a lower-level one, so that they get used to the rigorous rules, so that they get accustomed to thinking about what is going on under-the-hood, since a low-level strongly-typed language will force them to manage it. When you REALLY get what you're doing, then you can use shortcuts. Using shortcuts before you know how they work is a recipe for incomprehensible errors. "Why is it doing that?! I didn't _TELL_ it to do that!"

    • @takatamiyagawa5688
      @takatamiyagawa5688 3 ปีที่แล้ว

      I remember finding Matlab not too difficult. Then C was harder because I had to keep track of all the types (char, short, int, long, long long, float, double), and understand how it handles arrays and pointers. Java seemed nice for the IDE's (Eclipse) ability to tell me what the type of anything was. Then JavaScript was hard because the IDE couldn't tell me what the type of anything was. I figure it worked fine in Matlab because I was only ever storing numbers, or if I was storing objects, I didn't notice.
      Matlab is still the only language I've seen that has the ability to return more than one "thing" from a function built in to the function header.

    • @Spartan322
      @Spartan322 3 ปีที่แล้ว +4

      @@takatamiyagawa5688 Tuples are supported in C++ and C# and give you the same capability.

    • @supremelordofthebathroom7197
      @supremelordofthebathroom7197 3 ปีที่แล้ว +2

      @@agiar2000 Quick question: Is Python a strongly-typed language? I'm a beginner & I am using it.

  • @Liggliluff
    @Liggliluff 3 ปีที่แล้ว +27

    (1:25) Yet people continue to use float/double, and this causes issues in games where the floating point error gives wrong results. Such in one game, where the developer, for some reason, decided that you die when reaching exactly 0 health, and to avoid it going over, it seems to do some check in form of "if damage > health, damage - (damage - health)" or something stupid like that. Rarely, and randomly, your health can suddenly get decimals, and when this happens, you can never die, or almost never. Your health gets closer and closer to 0, but never reaching it. - This would never be an issue if the developer used an int only, and allowed it to be negative. If your health reaches 0 or below, you die.

    • @masaufuku1735
      @masaufuku1735 2 ปีที่แล้ว +16

      IMO this example isn't necessarily a bad use of float/double - a lot of games have multipliers that can result in damage not being an integer, so tracking health as a float that's rounded for the display is fine in those cases. The issue is the death check, which is one that can cause problems even if both values are integers (hence the need to do the weird damage check to set it to zero). It should be testing for less than or equal to 0.
      With that said, if damage *will* always be an integer than an integer should be used for both.

    • @02orochi
      @02orochi 2 ปีที่แล้ว +1

      Or u could just use decimals..
      To be fair its not as performant as doubles which might be crucial in games but theyre underratef

    • @kaitlyn__L
      @kaitlyn__L ปีที่แล้ว

      @@masaufuku1735 especially stacking fractional damage reduction buffs and the like.

    • @algotkristoffersson15
      @algotkristoffersson15 ปีที่แล้ว +4

      The problem is that they tried to make your health not go bellow 0 rather than just having the death check use

  • @Mordanepic
    @Mordanepic 4 หลายเดือนก่อน +1

    Whenever my favorite TH-camr becomes a school assignment you know I’m choosing the right path

  • @WorstDeveloper
    @WorstDeveloper 4 ปีที่แล้ว +7

    I work professionally with Javascript, and let me tell you that every time I get to work in a statically typed language it's like heaven.
    I hope that WASM will be the solution to this hell. Until then, Dart and Typescript it is.

  • @benjaminbrady2385
    @benjaminbrady2385 4 ปีที่แล้ว +162

    Top five densest things in the universe:
    Normal Stars
    Red Dwarfs
    Neutron Stars
    Black Holes
    Node Modules

    • @Cythil
      @Cythil 4 ปีที่แล้ว +7

      A interesting thing about black holes is that they do not have to be that dense if there really really big. (And if you make a black hole the size of the viable universe it would actually have about the same density as the visible universe. That is not to say the universe is a black hole. But it a interesting little factoid.)

    • @puskajussi37
      @puskajussi37 4 ปีที่แล้ว +6

      #6 Me

    • @Knee-Lew
      @Knee-Lew 4 ปีที่แล้ว +1

      or in Composer: "Vendor"

    • @gaalidas4836
      @gaalidas4836 4 ปีที่แล้ว +4

      Technically black holes aren't "big" but rather are "massive" in that they contain a lot of mass. If the singularity theory is accurate, then the black hole is extremely tiny no matter how dense or massive it is.

    • @benjaminbrady2385
      @benjaminbrady2385 4 ปีที่แล้ว +4

      @@Cythil yes, a very interesting point. If I remember correctly a black hole will always be *less* dense the more mass it has

  • @DrunkGeko
    @DrunkGeko 4 ปีที่แล้ว +20

    I am about to get my computer science degree and i still watch these videos, they are just fun :)

    • @Panj0
      @Panj0 4 ปีที่แล้ว +7

      I have been programming (professionally) for over 20 years; I still watch these videos :) I don't think it ever hurts to revisit the basics.

  • @lukew1100
    @lukew1100 4 ปีที่แล้ว

    I joined a tech company a couple of years ago not knowing much about computers at all.
    Your videos really helped me to adapt and understand some things at work and allowed me to excel in my role as an Account Manager there.
    I'm now taking course on basic networking because of the confidence I have in myself to get it. You have helped install that in me.
    Thank you so much Tom!

  • @Malidictus
    @Malidictus 3 ปีที่แล้ว +9

    I know this video is a year old, but... "Implicit" anything is the bane of my existence. Implicit interactions may be "easier" to learn provided you know they exist, but that's an extra level of knowledge needed over explicit declarations. You have to remember them while coding and figure them out while reading unfamiliar code, because they aren't defined anywhere. Explicit declarations place - ideally - all of the information you the programmer actually need to know directly into the code, where it can be manually reference if necessary.

  • @unom9515
    @unom9515 4 ปีที่แล้ว +11

    2:21 "but this is just the Basics..."
    I see what you did there...

  • @gnif
    @gnif 4 ปีที่แล้ว +3

    Well said! I grew up with Delphi which was strictly typed, then moved to PHP which is not (although it's getting there as an opt-in feature now), which was my stepping stone to C and C++ which I now work in every day. Still, today when I need to prototype something I throw it together in PHP or Python, and when happy with the idea/design re-write in C. Without the stepping stone of PHP I don't think I would have ever moved to a lower level language and I would not be involved in the FOSS projects that I am today (Looking Glass, Qemu, Linux (kernel), Kodi, etc).

  • @axelprino
    @axelprino 4 ปีที่แล้ว +2

    As someone who learned to program in C with a professor that kinda hated weak typing I'm screaming internally at the notion of asking if a string is true, it feels like asking if an apple is a number.

    • @kensmith5694
      @kensmith5694 4 ปีที่แล้ว +2

      In C an initialized pointer is taken as true.
      That which people call strings is really a pointer to some memory.

  • @JurgenBlitz
    @JurgenBlitz 4 ปีที่แล้ว +1

    Everytime I watch one of these Basics videos, I curse my luck because these would have helped me SO MUCH when I began programming 2 years ago and I was trying to wrap my head around stuff like this.

  • @Swapnil638
    @Swapnil638 4 ปีที่แล้ว +3

    Love how you make sponsor segments interesting.

  • @md.imamulislam7
    @md.imamulislam7 4 ปีที่แล้ว +20

    3:22 technically, that's probably a type coercion.

  • @adamt6024
    @adamt6024 4 ปีที่แล้ว +1

    Love these videos, even being an experienced programmer I still find my self learning from these well put together videos

  • @yubrajbhoi1986
    @yubrajbhoi1986 4 ปีที่แล้ว +2

    A great example of why some people hate operator overloading with a passion.

  • @Donmegamuffin
    @Donmegamuffin 4 ปีที่แล้ว +60

    I'd like to see "====" : Is this the same object in memory ;)

    • @fluffycritter
      @fluffycritter 4 ปีที่แล้ว +19

      Donmegamuffin python has the “is” operator for that :)

    • @Colopty
      @Colopty 4 ปีที่แล้ว +72

      And ===== for whether it's the same object from a philosophical viewpoint.

    • @ilidumb4487
      @ilidumb4487 4 ปีที่แล้ว +53

      But ====== checks if it's the same object from a religious viewpoint.

    • @piguyalamode164
      @piguyalamode164 4 ปีที่แล้ว +9

      in Java "==" works like that(for objects, the same number is always the same object in memory)

    • @_philipp__
      @_philipp__ 4 ปีที่แล้ว +12

      In JavaScript, `===` is doing exactly that on objects. Which is why `{} === {}` returns `false` and you have to fallback to `deep.equal` / `_.isEqual` implementations ^^

  • @_PsychoFish_
    @_PsychoFish_ 4 ปีที่แล้ว +619

    Meanwhile in Javascript:
    0 == "0" --> true
    0 == [ ] --> true
    "0" == [ ] --> false
    very intuitive.

    • @hexdepixel1165
      @hexdepixel1165 4 ปีที่แล้ว +65

      ah yes, the holy trinity of javascript

    • @robertozvjerkovic2639
      @robertozvjerkovic2639 4 ปีที่แล้ว +72

      ah yes, the holy trinity of not understanding type conversion after just watching a video about it

    • @hobrin4242
      @hobrin4242 4 ปีที่แล้ว +3

      @BattleNo0bFaiLTV== easy language

    • @martiddy
      @martiddy 4 ปีที่แล้ว +42

      "0" == [""] --> true

    • @teasdaye
      @teasdaye 4 ปีที่แล้ว +54

      Good thing none of this is stuff you'll actually ever run into unless you deliberately make some very bad design decisions to prove some weird point

  • @BlazeStorm
    @BlazeStorm 4 ปีที่แล้ว +2

    As a non coder, that part at the end about password length was especially useful and insightful for me, thanks Tom!

  • @benjones8543
    @benjones8543 4 ปีที่แล้ว +2

    Our comp sci class watched this video in lesson :D. Thanks for creating content like this, it really helps me out learning to program and getting ahead in lessons. keep up the great work :).

  • @Costel9000
    @Costel9000 4 ปีที่แล้ว +30

    01:26
    Of course it's 42, that is THE answer after all!

    • @peNdantry
      @peNdantry 3 ปีที่แล้ว +4

      ... closely followed by an asterisk (ASCII code 42), commonly used to represent 'everything'...
      I think Tom is a closet Hitchhiker's Guide fan :)

    • @ausernameiguess7058
      @ausernameiguess7058 3 ปีที่แล้ว +2

      I was looking to see if someone pointed that out!

  • @QuantumLeclerc
    @QuantumLeclerc 4 ปีที่แล้ว +173

    Things I learnt from this video: Tom is over 30 years old, or even over 40. He's also been coding for around 30 years.
    Also some code stuff too idk.

    • @meetaverma8372
      @meetaverma8372 4 ปีที่แล้ว +12

      He's 36 👀👀

    • @meetaverma8372
      @meetaverma8372 4 ปีที่แล้ว +3

      Also I would have been concerned with that too but why

  • @RedwoodGeorge
    @RedwoodGeorge 4 ปีที่แล้ว +1

    Good overview of the basics of data typing, Tom!
    I've spent the past six years coding in a very old language (Cache Object Script) that was written in the 1960's. It's pre-Unix and pre-"C" so the syntax and typing is completely alien - assigning a variable needs a "SET" and lines don't end in a semicolon like nearly all descendants of "C". What makes it more difficult is that I'm also coding in PHP and JavaScript so there's a lot of swapping syntax back and forth as I go from system to system. Fortunately we're replacing the Content Management System that's based on Cache Script and going to PHP so I get to only program in two languages - it'll be like a mental vacation!
    The bottom line, though, is that if you learn the fundamentals of programming then for the most part the languages are just the particular dialect you need to get something done. Loops are still loops, Boolean logic is still AND and OR, data storage, string manipulation and more are all conceptually the same, it's just the phrasing used to accomplish the goals that changes. Over the course of my career I've worked in over 30 different languages - from machine code to object oriented languages and the fundamentals are always the same...

  • @moazalnwesir
    @moazalnwesir 4 ปีที่แล้ว

    please continue to do this list , it very helpful and entertaining !

  • @user-vn7ce5ig1z
    @user-vn7ce5ig1z 4 ปีที่แล้ว +6

    The plus sign is the only mathematical operator that gets overloaded for strings, which makes it inconsistent and easy to mess up. That's why some languages use a different character (often the period) for string concatenation, which makes things more consistent and helps avoid these sorts of problems. Unfortunately a lot of programmers don't realize this and complain about the different character being used for concatenation instead of the plus sign. :-\

    • @jan-lukas
      @jan-lukas ปีที่แล้ว +3

      Using the . can look like a reference tho. Imagine string1.string2, you could see that as taking the "string2" member of "string1" variable

    • @blumoogle2901
      @blumoogle2901 6 หลายเดือนก่อน

      Or you can go String result = String.concatenate(arg1, arg2);
      No overloading. Everything repeated is a function.

  • @LynxSnowCat
    @LynxSnowCat 4 ปีที่แล้ว +9

    I was expecting "1" + "1" = "b"
    Edit:
    Also, I LOL'd at "That's very simple: it's true or false." or null, or open, etc... depending on context. The practical needs of implementation has really done a number on a simple concept.

    • @aragonnetje
      @aragonnetje 4 ปีที่แล้ว +1

      In many languages he's right though

    • @sgbench
      @sgbench 4 ปีที่แล้ว

      To rephrase what you're saying, a Boolean is a property that has exactly two states. Those states have different names depending on the context.

    • @LynxSnowCat
      @LynxSnowCat 4 ปีที่แล้ว +1

      @@sgbench ( laughs uproariously )

    • @kabobawsome
      @kabobawsome 4 ปีที่แล้ว

      @@sgbench Depending on the number of horrible practices you want to use, there can be 3 or even 4 different states in a Boolean.

  • @skinnybowser
    @skinnybowser 2 ปีที่แล้ว

    Your content and delivery is outstanding. Thank you!

  • @UjangBoyor
    @UjangBoyor 4 ปีที่แล้ว

    i rarely let the ad run, simply skip any sponsorship advertisement or just end the video., but i watch the entire tom's sponsorship ad and its really informative

  • @mcsmileycorp
    @mcsmileycorp 4 ปีที่แล้ว +3

    The amount of times I've spent a day bugfixing something only to realise I didn't make something static is immeasurable.

  • @ravendangernavy3575
    @ravendangernavy3575 4 ปีที่แล้ว +3

    I love the basics I don't even write code I just like being able to somewhat understand it!

    • @DVMovies1999
      @DVMovies1999 4 ปีที่แล้ว +2

      I know right! As a system administrator it’s nice to now some of the basics (even tho i have 0% coding experience xD)

    • @gordonrichardson2972
      @gordonrichardson2972 4 ปีที่แล้ว

      Raven Danger Navy If you ever use spreadsheets, an understanding of data types is essential.

  • @mdlagreca
    @mdlagreca 4 ปีที่แล้ว

    Definitely looking forward to your basics video on floating points.

  • @Aragubas
    @Aragubas 3 ปีที่แล้ว +1

    0:19 the way tom hand raises and the text on the background monitor xD

  •  4 ปีที่แล้ว +47

    "You will at least have integer."
    *laughs in JavaScript*

    • @sysosmaster
      @sysosmaster 4 ปีที่แล้ว +1

      Javascript has integer (internally). And Boolean. And.... ;)

    •  4 ปีที่แล้ว +3

      @@sysosmaster No, numbers are floating-point.
      There are the new "bigint", though.

  • @wanderingrandomer
    @wanderingrandomer 4 ปีที่แล้ว +39

    "I've been coding for about 30 years"
    Dude, how young did you start?!

    • @Jay-to7yz
      @Jay-to7yz 4 ปีที่แล้ว +17

      likely around 6, other comments have informed me that in the uk they put many computers in schools and many kids started at a very young age

    • @jasper2624
      @jasper2624 4 ปีที่แล้ว +7

      This is correct, I live in the UK, I am 16 and I have been programming for about 10 years.

    • @meetaverma8372
      @meetaverma8372 4 ปีที่แล้ว +3

      Also he's 36 so it was infact 6 yrs old

    • @chris-rios
      @chris-rios 3 ปีที่แล้ว +4

      I wish I been doing it since 6 because of how easy it is to learn

    • @wiktoreriksson4566
      @wiktoreriksson4566 3 ปีที่แล้ว +1

      I have been coding since 6 too

  • @jaewok5G
    @jaewok5G 4 ปีที่แล้ว

    I can appreciate this … I used to do horrible things with embedded boolean statements in calculations and then use sign as a branching or formatting conditional

  • @6yjjk
    @6yjjk 4 ปีที่แล้ว +1

    That hand gesture scrolling the screen moment at 0:19 is a thing of beauty.

  • @imbaedin
    @imbaedin 4 ปีที่แล้ว +33

    A JavaScript '+' has a third use: integer parsing.
    Making
    1+ + "1" = 2

    • @pepkin88
      @pepkin88 4 ปีที่แล้ว +5

      Technically converts to Number, but yes.

    • @sentjojo
      @sentjojo 4 ปีที่แล้ว

      Ouch

    • @yoyoyonono
      @yoyoyonono 3 ปีที่แล้ว +1

      @@pepkin88 aka parsing

    • @cameronmyron5776
      @cameronmyron5776 2 ปีที่แล้ว

      Every day we stray farther from God...

    • @maelstrom57
      @maelstrom57 2 ปีที่แล้ว

      @@yoyoyonono JavaScript has a parseInt function but it doesn't exactly work like the unary operator.
      +"" --> 0
      parseInt("") --> NaN

  • @_mels_
    @_mels_ 4 ปีที่แล้ว +41

    1:25
    isn't that 21?

  • @thelastcube.
    @thelastcube. 4 ปีที่แล้ว +1

    This a really nice reference for new programmers to learn certain basic stuff including datatypes

  • @craigkollai2806
    @craigkollai2806 4 ปีที่แล้ว

    I love the 42 and * in your examples!

  • @RyebuckCoppercap
    @RyebuckCoppercap 4 ปีที่แล้ว +7

    As an absolute novice at programming, I prefer strong typing as it's harder to accidentally screw up 😅

  • @Landhund0
    @Landhund0 4 ปีที่แล้ว +3

    Damn Tom, you're looking *sharp* today ^^

  • @geekazodium
    @geekazodium ปีที่แล้ว

    as someone who mainly programs in java, I think that strong typing is really helpful with debugging as I don't have to spend any time trying to figure out what a variable's type is, all I have to do is go to the variable declaration and I can immediately know what it contains.

  • @LincolnChamberlin
    @LincolnChamberlin 4 ปีที่แล้ว

    Cool vid, very glad to see Language File and The Basics videos returning

  • @pawelkusmierek109
    @pawelkusmierek109 4 ปีที่แล้ว +50

    "I have been coding for about thirty years and I still absentmindedly screw that up sometimes"
    Tell me about it. I spent 50% of my coding in a loosely typed language that uses:
    = for assignment, == for comparison,
    ~, &, | for logical not, and, or,
    for i = 1:10 .. . end for loops,
    1-based arrays,
    sub arrays defined as (start : end).
    The other 50% is in a strongly typed language that uses:
    := for assignment, = for comparison,
    NOT, AND, OR for logical not, and, or,
    for i := 1 to 10 do ... next for loops
    0-based arrays
    sub arrays defined as [start : size]
    These are not all differences. I screw up all the time, obviously.

    • @57thorns
      @57thorns 4 ปีที่แล้ว +1

      In which of them is it easier to find your typos?

    • @tomasderner7511
      @tomasderner7511 4 ปีที่แล้ว +2

      I would have these problems if I didn't use good IDEs. Admittedly, I don't program in anything obscure enough to not have good linting support (I mostly use stuff from Jetbrains).

    • @miracoulousme
      @miracoulousme 4 ปีที่แล้ว +5

      @@57thorns Oh my God that's what I wanted to type :D In University we mainly use Java and at work we use Delphi (Basically an evolution of Pascal). So sometimes I'll need to switch during the day, which can become a problem especially at exams ...

    • @pawelkusmierek109
      @pawelkusmierek109 4 ปีที่แล้ว +1

      @@57thorns typos that result from these differences - probably similar, because these typically result in syntax errors caught immediately. But typos in variable of function names are far worse in #1, as it does not require declaring variables, so only deals with unknown names at runtime when it actually runs into them, trying to find a match in library folders... #2 is better because it requires declaration end explicit linking of external libraries, so unknown names stop it at compile time.

    • @LonesomeTwin
      @LonesomeTwin 4 ปีที่แล้ว +1

      I still type retrun far too often

  • @maeentell3259
    @maeentell3259 4 ปีที่แล้ว +40

    Honestly, Tom Scott is the best at finding weird but amazing facts!

  • @mcduffchannel
    @mcduffchannel 4 ปีที่แล้ว

    This is great Tom, if always known this in practice, but I'd never had the theory behind my actions. Because of this you can imagine I was big hunting on the reg. With this knowledge under my belt, I trust I'll make better decisions in the future. Cheers!

  • @Geekgaucho
    @Geekgaucho 4 หลายเดือนก่อน

    Great video!! Everything in computing is a “tradeoff” that’s what I love about it!

  • @GeoDetective
    @GeoDetective 4 ปีที่แล้ว +17

    string person = "I ";
    string subject = "loose programming languages!";
    string opinion = "hate ";
    return person + opinion + subject;

    • @lychy645
      @lychy645 4 ปีที่แล้ว +2


    • @xinflict3078
      @xinflict3078 4 ปีที่แล้ว +1

      ihatelooseprogramminglanguages

    • @kabobawsome
      @kabobawsome 4 ปีที่แล้ว +1

      @@xinflict3078 Actually, it would be "Ihateloose programming languages"

    • @Me-da-Ghost
      @Me-da-Ghost 3 ปีที่แล้ว +2

      @@kabobawsome No read it again. The last line is "return person ("I ") + opinion ("hate ") + subject ("loose programming languages!");"

    • @jacobdaniels3246
      @jacobdaniels3246 3 ปีที่แล้ว

      is this c++? Srry Im a C guy. I'm assuming it's not java bc it's String in java I think

  • @Kapin05
    @Kapin05 4 ปีที่แล้ว +25

    I personally prefer Python's average-strength typing - you needn't declare variable types but it'll rarely convert them for you.

    • @whuzzzup
      @whuzzzup 4 ปีที่แล้ว +2

      To this date I don't understand why print() won't automatically convert int to str. It's stupid.

    • @Kapin05
      @Kapin05 4 ปีที่แล้ว

      @@whuzzzup I remember it doing that, did they change it at some point?

    • @whuzzzup
      @whuzzzup 4 ปีที่แล้ว

      @@Kapin05 Well you can, but not in all cases. print(5) works fine, but int+string wont: print(5 "fu") or print(5 + "fu"). You could do print(5, "fu").
      It's the language itself, yes, but sometimes a special case for print() would have been nice that just accepts everything and concatenates it. Thank god for f-strings nowadays, they eased this situation a lot since you no longer have to convert manually but have it done automatically: print(f"{integerVariable} fu")

    • @Kapin05
      @Kapin05 4 ปีที่แล้ว +13

      @@whuzzzup Personally I prefer that you have to call str() when concatenating, it makes code a little easier to read at a glance. Really useful for debugging people's functions quickly when you're not too familiar with the rest of their script.

    • @alexp6013
      @alexp6013 3 ปีที่แล้ว

      @@whuzzzup or you use the method format of the string, and then the code is readable, like python is made to look like

  • @MCRogueHaven
    @MCRogueHaven 4 ปีที่แล้ว

    I was literally calculating that password question yesterday, but i didn't know how many symbols most websites accept. Thank you for answering that!

  • @earthwormo1175
    @earthwormo1175 4 ปีที่แล้ว +1

    Had a problem just last week where I was sending an alert when a variable equaled true, then a change made somewhere else caused the variable to store 1 and 0 instead of true and false. Well my Alert didn't fire, and I didn't know of a problem for days. The day I learned that "= true" and "!= false" are not the same equation, and the latter is far superior when dealing with important alerts!

  • @mattwinward3168
    @mattwinward3168 4 ปีที่แล้ว +6

    0:49 You completely missed the opportunity to write out “Tom Scott” in binary.

  • @JohnnieHougaardNielsen
    @JohnnieHougaardNielsen 4 ปีที่แล้ว +3

    Weak typing makes it easy to get buggy code into the really expensive wilderness. Yes, strong typing is a bit of trouble, but you get a lot of "inaccuracies" ironed out immediately, instead of disasters later.

  • @waiitwhaat
    @waiitwhaat 2 ปีที่แล้ว

    I like strongly typed languages because sometimes when I have to do a small conversion like from float to integer, it shows a warning, which is handly. It's annoying, sure but you get used to it. The only upside to it is that you get lightning speed code execution, which is a deal I'm willing to make for my specific use case.

  • @tokillthelight
    @tokillthelight 4 ปีที่แล้ว +1

    You made that ad for Dashlane fun to watch, Nice!

  • @theonlyari
    @theonlyari 4 ปีที่แล้ว +3

    4:42- speaking of bugs that come out later... your true + true is still visible :D

    • @JNCressey
      @JNCressey 4 ปีที่แล้ว

      I don't see it

    • @theonlyari
      @theonlyari 4 ปีที่แล้ว +1

      @@JNCressey Neither did Tom. Its almost like its transparent, but not 100%.

  • @silvanostagni
    @silvanostagni 4 ปีที่แล้ว +10

    Many moons ago, I started coding using Assembler. I am watching this feeling a bit old (because of the many moons ago), a bit smug (anything you say seems obvious to me), and a bit of a museum piece! :) :) :)

    • @mediumjohnsilver
      @mediumjohnsilver 4 ปีที่แล้ว +2

      Silvano stagni In the 1980s I loved to code in mainframe assembler and program “down to the bare metal”. 😀

    • @AndreaZzzXXX
      @AndreaZzzXXX 4 ปีที่แล้ว +1

      Silvano I know the feeling :-)
      PS: are you italian ?

  • @matthewgough9533
    @matthewgough9533 4 ปีที่แล้ว

    Best Dashlane ad I've seen. The math breakdown was brilliant!

  • @BocchiTheRocks
    @BocchiTheRocks 4 ปีที่แล้ว

    Ive been watching since 2013! still watch your content its still so good keep up the work!

  • @Atarian6502
    @Atarian6502 4 ปีที่แล้ว +5

    Those simple times when string variables had to start with $ sign...

    • @igorswies5913
      @igorswies5913 3 ปีที่แล้ว

      what language is this

    • @B-slug
      @B-slug 2 ปีที่แล้ว

      @@igorswies5913 im assuming assembly

  • @CharlesReinmuth
    @CharlesReinmuth 3 ปีที่แล้ว +2

    4:35 This fade-out was calculated with floating points. 😂

  • @Akens888
    @Akens888 2 ปีที่แล้ว

    Automatic type conversion caught me out good with VB6/VBA as 6600 * 1000 results in an integer overflow

  • @dustinryan-roepsch8712
    @dustinryan-roepsch8712 4 ปีที่แล้ว +15

    "You will at least have integer"
    *cries in javascript*

    • @igorswies5913
      @igorswies5913 3 ปีที่แล้ว +1

      BTW if you need more precision than 2^53 integers then you can use BigInt

  • @michellehanson7329
    @michellehanson7329 4 ปีที่แล้ว +12

    Were you really 5 when you started coding?! Impressive!

    • @BaadJim
      @BaadJim 4 ปีที่แล้ว +2

      I thought the exact same thing. Except to be fair I was taught how to print my name in Basic at that age so I guess technically yes?

    • @SerBallister
      @SerBallister 4 ปีที่แล้ว +2

      In the 80s there used to be BASIC listings in home computer magazines, a lot of people in the UK basically learned from home as a child how to program.

  • @kebien6020
    @kebien6020 3 ปีที่แล้ว +2

    1:19 "In general you will at least have: Integer"
    JavaScript has left the chat

  • @iwonderwhy9681
    @iwonderwhy9681 3 ปีที่แล้ว

    Why am I watching Tom explain the stuff I already know and enjoying it? Btw, love your work.

  • @BertGrink
    @BertGrink 4 ปีที่แล้ว +4

    HAH! As soon as i saw the video title, i knew that Javascript had to be in there.

  • @akshaybodla163
    @akshaybodla163 4 ปีที่แล้ว +5

    This video is great!
    I've been teaching Java and C++ for a few years now (I teach primarily college students and middle schoolers) and I always suggest someone new to coding to start with Java. Part of it is my own bias (i learned coding through FRC and FTC) but I believe the strongly typed languages enforce good coding practices.

    • @swapode
      @swapode 2 ปีที่แล้ว

      Have you considered Rust as a teaching language? To me it seems really well suited since it enforces good practices on a level where OOP languages tend to fail.
      It's kind of interesting. Many programmers struggle quite a bit to learn Rust since you have to be wary of lifetimes, explicit about shared pointers and similar things that other languages hide until you read and understand a bunch of best practice guides that aren't intuitive from the language design. So my theory is that it'd be a good idea to start with Rust and transition to other languages from there.

    • @jan-lukas
      @jan-lukas ปีที่แล้ว

      I think it doesn't matter that much which language you start with, as long as you stick to programming. Then you can and should explore other languages, because some languages have really strange design decisions, "best" practices or abstractions that could mean you don't actually understand what you're doing
      The best languages for these sorts of type systems are C/C++ imo, as only by learning C++ I realized that types are compile time only (in many but not all languages, as Tom showed us). I heard that Haskell is supposed to teach you a lot about "elegant code", but I'm not into that whole "monoid, monad, endofunction" thing yet

  • @minecrafter0505
    @minecrafter0505 3 ปีที่แล้ว +1

    That's why I use Kotlin and IntelliJ. I don't want to declare my variable's type, but if I try to force a float into an Int the IDE or the compiler will remind me nicely.

  • @ElectricGears
    @ElectricGears 4 ปีที่แล้ว

    As I have been teaching myself to code in different languages for various little projects (not doing any advanced type manipulation tricks) I find the strongly typed languages easier. I would rather have the ability to very clearly state my intentions to the compiler and get immediate feedback if there is any confusion or ambiguity.

  • @monad_tcp
    @monad_tcp 4 ปีที่แล้ว +6

    6:05 it doesn't even make the life easier, you are just choosing between an slight slap in the face from the compiler or melting your brain debugging for hours. Its not controversial, if you don't supply types to the compiler (or use type-inference), then you are not supplying data the compiler needs to help you and even do part of the job of figuring correct software behavior. Its just an stupid kind of laziness from the programmer. its not even about typing (pun intended), because with modern type inference, you can do something like "let x = 1.0" and x will be "float", compilers can figure it out.
    Its just laziness for not knowing what you're doing, because if you don't know and use static typing, then you can't ship bugged software, but with dynamic typing you can, and everything looks fine and then it all explodes. That's why its an absolute must for "real" programmers to learn how to deal with their tools.

    • @kunwoododd2154
      @kunwoododd2154 3 ปีที่แล้ว +1

      Even strong dynamic typing like in Python is a huge improvement over JS.

    • @algotkristoffersson15
      @algotkristoffersson15 ปีที่แล้ว

      But if you use weak typing and DO know what you’re doing it is more effective than strong typing

  • @reconcyl5428
    @reconcyl5428 4 ปีที่แล้ว +3

    Thank you for never conflating weak typing and dynamic typing, or type inference and dynamic typing.

  • @amiwatchesyt
    @amiwatchesyt 4 ปีที่แล้ว +2

    As I work with electronics I tend to use strongly typed languages for my programming. In fact sometimes I feel a bit at loss when coding in python. However I fell in love with the JavaScript weak typing this summer when programming a front end

    • @JNCressey
      @JNCressey 4 ปีที่แล้ว

      in python be sure to `import typing`

  • @MeepChangeling
    @MeepChangeling ปีที่แล้ว

    In batch, the langauge I use, you actually just input whatever the hell you like into any var in the same way. Example . You then use switches in the code before the variable if its meant to be seen as an intiger in that moment for that operation, or nothing if its a string.

  • @GummieI
    @GummieI 4 ปีที่แล้ว +19

    Sounded like you had had very painful experiences when you talked about the "0" ending up as false