Тёмный

Why TRUE + TRUE = 2: Data Types 

Tom Scott
Подписаться 6 млн
Просмотров 1,1 млн
50% 1

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

Опубликовано:

 

2 фев 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 1,8 тыс.   
@TomScottGo
@TomScottGo 4 года назад
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 года назад
*Sup dude*
@TheElvisnator
@TheElvisnator 4 года назад
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 года назад
How many people have used the phrase "Tom Scott for 10 per cent off" as the the password. :D
@user-jp7tw3sd3x
@user-jp7tw3sd3x 4 года назад
I love how even the advertisement is educational.
@TheKingsIdiot
@TheKingsIdiot 4 года назад
One of the few ads i have seen that was informative while being an ad.
@lucabaldassi6024
@lucabaldassi6024 4 года назад
0:19 the way the text on the screen and Tom's hand raise at the same time is unsettling
@spockbaca5475
@spockbaca5475 4 года назад
He’s too powerful
@mrkrunch4340
@mrkrunch4340 4 года назад
True Power
@paulhermes990
@paulhermes990 4 года назад
@Shareaffi I thank you kind stranger ;w;
@paulhermes990
@paulhermes990 4 года назад
@Shareaffi I because we are the same person in two separate locations thanks to a super position... Maybe
@gaalidas4836
@gaalidas4836 4 года назад
Spontaneous quantum entanglement. I hate it when that happens.
@MrMysticphantom
@MrMysticphantom 4 года назад
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 года назад
PHP is simply C for Kids
@jemesmemes9026
@jemesmemes9026 4 года назад
Snooby66 c isn’t a programming language it’s a scripting language... smh
@Apoc2K
@Apoc2K 4 года назад
PHP 5.4 was my personal Vietnam.
@gaalidas4836
@gaalidas4836 4 года назад
Nice... comparing computer languages to being sent to war. I approve of this comparison.
@Colopty
@Colopty 4 года назад
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.
@rekagaal
@rekagaal 4 года назад
"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 года назад
Probably started at 1.5
@zyaicob
@zyaicob 4 года назад
Straight out of college baby
@thoughtyness
@thoughtyness 4 года назад
For those too lazy to look it up, he’s 35 to 36 according to Wikipedia
@Shaun.Stephens
@Shaun.Stephens 4 года назад
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 года назад
@@Shaun.Stephens Such insight. Be sure to enlighten us mere mortals in all of Tom's future videos as well, brother
@Tyranisaur
@Tyranisaur 4 года назад
"Implicit conversions are great" - Famous last words
@BrentFiore
@BrentFiore 3 года назад
"Implicit conversions are great" == true (since the string is not null) Can't argue with that
@hannessteffenhagen61
@hannessteffenhagen61 3 года назад
@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 3 года назад
hai ooga monki here mmm ibudnenrtaansdnd mmmm syeysyes oogoooogoa
@harrychufan
@harrychufan 2 года назад
Explicit is better than implicit!
@msq7041
@msq7041 2 года назад
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
@kdlk9139
@kdlk9139 4 года назад
When “true + true” fades away it doesn’t fully disappear 4:35 Sorry Tom, I’m a big fan of your work
@OmnivorousOtter101
@OmnivorousOtter101 4 года назад
Good eyes
@Arcturus367
@Arcturus367 4 года назад
true
@hanswurst8317
@hanswurst8317 4 года назад
Actually got a short burn-in paranoia
@AGmarsen
@AGmarsen 4 года назад
@@Arcturus367 genius
@gaalidas4836
@gaalidas4836 4 года назад
Wow... nice catch.
@dontaskmewhy8734
@dontaskmewhy8734 4 года назад
I change the hdmi 1 to hdmi 2 and thats already enough coding for my grandparents
@chonkydog6262
@chonkydog6262 4 года назад
Don't Ask Me Why хаха
@chonkydog6262
@chonkydog6262 4 года назад
смешно
@dontaskmewhy8734
@dontaskmewhy8734 4 года назад
@@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
@HorzaPanda
@HorzaPanda 4 года назад
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 года назад
I used REXX (on VM/CMS) at university. REXX is like the opposite of strictly typed.
@charleslambert3368
@charleslambert3368 4 года назад
Not sure if you're an old CS graduate or a young scientist.
@HorzaPanda
@HorzaPanda 4 года назад
@@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 года назад
"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 года назад
Speaking of pain, I've learned programming with pneumatic circuits, debugging was physically painful sometimes (we had to wear security goggles as well).
@vaclavtrpisovsky
@vaclavtrpisovsky 4 года назад
Thanks for undermining my trust in high-level programming languages. I'm switching to Assembly.
@kensmith5694
@kensmith5694 4 года назад
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 года назад
Just use a strongly-typed language like Haskell! It's quite trustworthy, and powerful too!
@kadblue2000
@kadblue2000 4 года назад
@@kensmith5694 In other words 2 lines of python code.
@kensmith5694
@kensmith5694 4 года назад
@@kadblue2000 Better yet: 1 line of APL Python is quite bad at dealing with hardware.
@R3lay0
@R3lay0 3 года назад
Assembly? More like ASSembly. Real men write binary machine code.
@FinBoyXD
@FinBoyXD 4 года назад
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 года назад
this!
@gloweye
@gloweye 4 года назад
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 4 года назад
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 года назад
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 года назад
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 года назад
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 года назад
@@57thorns, import typing
@Spoco
@Spoco 4 года назад
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 года назад
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 года назад
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.
@Asasnol21
@Asasnol21 4 года назад
I was classically trained in C and then decided to learn JavaScript. A dark time in my life.
@kensmith5694
@kensmith5694 4 года назад
At least you weren't going between C++ and JavaScript and back.
@cameronmyron5776
@cameronmyron5776 3 года назад
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.
@tyberfen5009
@tyberfen5009 4 года назад
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 года назад
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 года назад
@@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 года назад
@@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 года назад
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 года назад
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.
@anselmschueler
@anselmschueler 4 года назад
In python, however, "1.5"*2 is "1.51.5"...
@foolo1
@foolo1 4 года назад
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 года назад
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 года назад
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 года назад
Prob because python thinks "1.5"*2 = "1.5" + "1.5" woah hey there that's a concat symbol
@muizzy
@muizzy 4 года назад
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.
@casperes0912
@casperes0912 4 года назад
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 года назад
C++ auto x = "50"; // another example
@LorenzoDelmonte0530
@LorenzoDelmonte0530 4 года назад
Same in py
@mntalateyya
@mntalateyya 4 года назад
@@LorenzoDelmonte0530 Not exactly. Python only checks the types at runtime.
@fashnek
@fashnek 4 года назад
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 года назад
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.
@AaronTheGerman
@AaronTheGerman 4 года назад
[0:16] Can we just talk about how the green title screen in the background perfectly reacts to Tom's hand gestures? :D
@user-vn7ce5ig1z
@user-vn7ce5ig1z 4 года назад
What? How so? 🤨
@FlashMustache
@FlashMustache 4 года назад
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 года назад
Yup, everything is an object
@rolaroli
@rolaroli 4 года назад
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 года назад
@@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 года назад
That's the official story. Reality... is more complex.
@sysosmaster
@sysosmaster 4 года назад
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)
@Mordanepic
@Mordanepic 5 месяцев назад
Whenever my favorite RU-vidr becomes a school assignment you know I’m choosing the right path
@ClokworkGremlin
@ClokworkGremlin 4 года назад
"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 года назад
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 года назад
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 4 года назад
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 года назад
@@takatamiyagawa5688 Tuples are supported in C++ and C# and give you the same capability.
@supremelordofthebathroom7197
@supremelordofthebathroom7197 3 года назад
@@agiar2000 Quick question: Is Python a strongly-typed language? I'm a beginner & I am using it.
@mirjanbouma
@mirjanbouma 4 года назад
I love these IT themed videos, they make this noob understand much better what dark magic makes my pc work.
@howardbaxter2514
@howardbaxter2514 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 года назад
@@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 года назад
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 года назад
@@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
@benjaminbrady2385
@benjaminbrady2385 4 года назад
Top five densest things in the universe: Normal Stars Red Dwarfs Neutron Stars Black Holes Node Modules
@Cythil
@Cythil 4 года назад
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 Me
@Knee-Lew
@Knee-Lew 4 года назад
or in Composer: "Vendor"
@gaalidas4836
@gaalidas4836 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 года назад
@@Cythil yes, a very interesting point. If I remember correctly a black hole will always be *less* dense the more mass it has
@ProfessorSyndicateFranklai
@ProfessorSyndicateFranklai 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.
@_PsychoFish_
@_PsychoFish_ 4 года назад
Meanwhile in Javascript: 0 == "0" --> true 0 == [ ] --> true "0" == [ ] --> false very intuitive.
@hexdepixel1165
@hexdepixel1165 4 года назад
ah yes, the holy trinity of javascript
@robertozvjerkovic2639
@robertozvjerkovic2639 4 года назад
ah yes, the holy trinity of not understanding type conversion after just watching a video about it
@hobrin4242
@hobrin4242 4 года назад
@BattleNo0bFaiLTV== easy language
@martiddy
@martiddy 4 года назад
"0" == [""] --> true
@teasdaye
@teasdaye 4 года назад
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
@HetuNandu
@HetuNandu 4 года назад
Loved what you did with 42 and * there
4 года назад
that was 21 in binary tho
@anishagrawal7068
@anishagrawal7068 4 года назад
The meaning of the universe, life and everything
@jmtikka
@jmtikka 4 года назад
Actually 42 is The Answer to the Ultimate Question of Life, the Universe, and Everything.
@ReneSebastian
@ReneSebastian 4 года назад
This! 👏🏻
@noxabellus
@noxabellus 4 года назад
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 4 года назад
There are cases where weak typing are very helpful, especially in dynamic scenarios... Though that's even further from beginner coding.
@TheNewTimeNetwork
@TheNewTimeNetwork 3 года назад
@@Markus-zb5zd Optionally typed languages like TypeScript and PHP7 are good for such dynamic scenarios.
@AllUpOns
@AllUpOns 3 года назад
@@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 года назад
@@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 года назад
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)
@robnorris4770
@robnorris4770 4 года назад
4:03 Body language says “been there, done that”.
@QuantumLeclerc
@QuantumLeclerc 4 года назад
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 года назад
He's 36 👀👀
@meetaverma8372
@meetaverma8372 4 года назад
Also I would have been concerned with that too but why
@DrunkGeko
@DrunkGeko 4 года назад
I am about to get my computer science degree and i still watch these videos, they are just fun :)
@Panj0
@Panj0 4 года назад
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.
@JurgenBlitz
@JurgenBlitz 4 года назад
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.
@Liggliluff
@Liggliluff 3 года назад
(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 года назад
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 года назад
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 2 года назад
@@masaufuku1735 especially stacking fractional damage reduction buffs and the like.
@algotkristoffersson15
@algotkristoffersson15 Год назад
The problem is that they tried to make your health not go bellow 0 rather than just having the death check use
@WorstDeveloper
@WorstDeveloper 4 года назад
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.
@gnif
@gnif 4 года назад
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).
@adamt6024
@adamt6024 4 года назад
Love these videos, even being an experienced programmer I still find my self learning from these well put together videos
@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!
@Swapnil638
@Swapnil638 4 года назад
Love how you make sponsor segments interesting.
@unom9515
@unom9515 4 года назад
2:21 "but this is just the Basics..." I see what you did there...
@yubrajbhoi1986
@yubrajbhoi1986 4 года назад
A great example of why some people hate operator overloading with a passion.
@BlazeStorm
@BlazeStorm 4 года назад
As a non coder, that part at the end about password length was especially useful and insightful for me, thanks Tom!
@Malidictus
@Malidictus 3 года назад
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.
@Costel9000
@Costel9000 4 года назад
01:26 Of course it's 42, that is THE answer after all!
@peNdantry
@peNdantry 3 года назад
... 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 года назад
I was looking to see if someone pointed that out!
@axelprino
@axelprino 4 года назад
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 года назад
In C an initialized pointer is taken as true. That which people call strings is really a pointer to some memory.
@benjones8543
@benjones8543 4 года назад
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 :).
@md.imamulislam7
@md.imamulislam7 4 года назад
3:22 technically, that's probably a type coercion.
@mcsmileycorp
@mcsmileycorp 4 года назад
The amount of times I've spent a day bugfixing something only to realise I didn't make something static is immeasurable.
@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
@thelastcube.
@thelastcube. 4 года назад
This a really nice reference for new programmers to learn certain basic stuff including datatypes
@user-vn7ce5ig1z
@user-vn7ce5ig1z 4 года назад
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 2 года назад
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 7 месяцев назад
Or you can go String result = String.concatenate(arg1, arg2); No overloading. Everything repeated is a function.
@Donmegamuffin
@Donmegamuffin 4 года назад
I'd like to see "====" : Is this the same object in memory ;)
@fluffycritter
@fluffycritter 4 года назад
Donmegamuffin python has the “is” operator for that :)
@Colopty
@Colopty 4 года назад
And ===== for whether it's the same object from a philosophical viewpoint.
@ilidumb4487
@ilidumb4487 4 года назад
But ====== checks if it's the same object from a religious viewpoint.
@piguyalamode164
@piguyalamode164 4 года назад
in Java "==" works like that(for objects, the same number is always the same object in memory)
@_philipp__
@_philipp__ 4 года назад
In JavaScript, `===` is doing exactly that on objects. Which is why `{} === {}` returns `false` and you have to fallback to `deep.equal` / `_.isEqual` implementations ^^
@6yjjk
@6yjjk 4 года назад
That hand gesture scrolling the screen moment at 0:19 is a thing of beauty.
@somekek6734
@somekek6734 3 года назад
omg hahahaha
@moazalnwesir
@moazalnwesir 4 года назад
please continue to do this list , it very helpful and entertaining !
@LynxSnowCat
@LynxSnowCat 4 года назад
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 года назад
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 года назад
@@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.
@wanderingrandomer
@wanderingrandomer 4 года назад
"I've been coding for about 30 years" Dude, how young did you start?!
@Jay-to7yz
@Jay-to7yz 4 года назад
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 года назад
This is correct, I live in the UK, I am 16 and I have been programming for about 10 years.
@meetaverma8372
@meetaverma8372 4 года назад
Also he's 36 so it was infact 6 yrs old
@chris-rios
@chris-rios 3 года назад
I wish I been doing it since 6 because of how easy it is to learn
@wiktoreriksson4566
@wiktoreriksson4566 3 года назад
I have been coding since 6 too
@skinnybowser
@skinnybowser 2 года назад
Your content and delivery is outstanding. Thank you!
@Aragubas
@Aragubas 3 года назад
0:19 the way tom hand raises and the text on the background monitor xD
@ravendangernavy3575
@ravendangernavy3575 4 года назад
I love the basics I don't even write code I just like being able to somewhat understand it!
@DVMovies1999
@DVMovies1999 4 года назад
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.
@iwonderwhy9681
@iwonderwhy9681 3 года назад
Why am I watching Tom explain the stuff I already know and enjoying it? Btw, love your work.
@matthewgough9533
@matthewgough9533 4 года назад
Best Dashlane ad I've seen. The math breakdown was brilliant!
@RyebuckCoppercap
@RyebuckCoppercap 4 года назад
As an absolute novice at programming, I prefer strong typing as it's harder to accidentally screw up 😅
@peterhornik8569
@peterhornik8569 3 года назад
good for you
@imbaedin
@imbaedin 4 года назад
A JavaScript '+' has a third use: integer parsing. Making 1+ + "1" = 2
@pepkin88
@pepkin88 4 года назад
Technically converts to Number, but yes.
@sentjojo
@sentjojo 4 года назад
Ouch
@yoyoyonono
@yoyoyonono 3 года назад
@@pepkin88 aka parsing
@cameronmyron5776
@cameronmyron5776 3 года назад
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
@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!
@tokillthelight
@tokillthelight 4 года назад
You made that ad for Dashlane fun to watch, Nice!
@Kapin05
@Kapin05 4 года назад
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 года назад
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 года назад
@@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
@pawelkusmierek109
@pawelkusmierek109 4 года назад
"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 года назад
In which of them is it easier to find your typos?
@tomasderner7511
@tomasderner7511 4 года назад
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 года назад
@@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 года назад
@@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 года назад
I still type retrun far too often
@RedwoodGeorge
@RedwoodGeorge 4 года назад
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...
@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
@Landhund0
@Landhund0 4 года назад
Damn Tom, you're looking *sharp* today ^^
@mattwinward3168
@mattwinward3168 4 года назад
0:49 You completely missed the opportunity to write out “Tom Scott” in binary.
@BocchiTheRocks
@BocchiTheRocks 4 года назад
Ive been watching since 2013! still watch your content its still so good keep up the work!
@LincolnChamberlin
@LincolnChamberlin 4 года назад
Cool vid, very glad to see Language File and The Basics videos returning
@maeentell3259
@maeentell3259 4 года назад
Honestly, Tom Scott is the best at finding weird but amazing facts!
@dustinryan-roepsch8712
@dustinryan-roepsch8712 4 года назад
"You will at least have integer" *cries in javascript*
@igorswies5913
@igorswies5913 3 года назад
BTW if you need more precision than 2^53 integers then you can use BigInt
@earthwormo1175
@earthwormo1175 4 года назад
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!
@CharlesReinmuth
@CharlesReinmuth 3 года назад
4:35 This fade-out was calculated with floating points. 😂
@silvanostagni
@silvanostagni 4 года назад
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 года назад
Silvano stagni In the 1980s I loved to code in mainframe assembler and program “down to the bare metal”. 😀
@AndreaZzzXXX
@AndreaZzzXXX 4 года назад
Silvano I know the feeling :-) PS: are you italian ?
@_mels_
@_mels_ 4 года назад
1:25 isn't that 21?
@sayanghosh6996
@sayanghosh6996 4 года назад
yes
@liudleon870
@liudleon870 4 года назад
It is
@TristanPopken
@TristanPopken 4 года назад
Yes, yes it is
@BeejJorgensen
@BeejJorgensen 4 года назад
101010 is 42. 010101 is 21. Just a think-o, probably. :)
@kebien6020
@kebien6020 3 года назад
1:19 "In general you will at least have: Integer" JavaScript has left the chat
@mdlagreca
@mdlagreca 4 года назад
Definitely looking forward to your basics video on floating points.
@JohnnieHougaardNielsen
@JohnnieHougaardNielsen 4 года назад
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.
@GeoDetective
@GeoDetective 4 года назад
string person = "I "; string subject = "loose programming languages!"; string opinion = "hate "; return person + opinion + subject;
@lychy645
@lychy645 4 года назад
@xinflict3078
@xinflict3078 4 года назад
ihatelooseprogramminglanguages
@kabobawsome
@kabobawsome 4 года назад
@@xinflict3078 Actually, it would be "Ihateloose programming languages"
@Me-da-Ghost
@Me-da-Ghost 4 года назад
@@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
@AnomNum
@AnomNum 3 года назад
I've finally read a title and understood it before watching the video. A dream come true.
@m4rt_
@m4rt_ Год назад
static typing is a superpower. You can have the compiler tell you the errors, and you can fix it in seconds. In languages like JS, you can't, it will just run and possibly give an error or just continue, and you will spend hours tracking it down.
@theonlyari
@theonlyari 4 года назад
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 года назад
@@JNCressey Neither did Tom. Its almost like its transparent, but not 100%.
@reconcyl5428
@reconcyl5428 4 года назад
Thank you for never conflating weak typing and dynamic typing, or type inference and dynamic typing.
@calebcrook5875
@calebcrook5875 4 года назад
When you know nothing about coding but find Tom's videos interesting and fun to watch.
@NeedNot
@NeedNot 4 года назад
Once again love the vid
@Atarian6502
@Atarian6502 4 года назад
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
4 года назад
"You will at least have integer." *laughs in JavaScript*
@sysosmaster
@sysosmaster 4 года назад
Javascript has integer (internally). And Boolean. And.... ;)
4 года назад
@@sysosmaster No, numbers are floating-point. There are the new "bigint", though.
@teun4620
@teun4620 4 года назад
This is why I like Typescript a lot. Typescript is (usually) strongly typed, but you can use the shorthand "any" type when you need the language to just get out of the way.
@ScorpioneOrzion
@ScorpioneOrzion Год назад
Its sort of both strongly and weakly typed
@stovegamesgames6917
@stovegamesgames6917 4 года назад
I have been watching your videos for so long, that it turns out that somehow I have not been subscribed. Like what!?! I am now subscribed!
@akshaybodla163
@akshaybodla163 4 года назад
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 2 года назад
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
@BertGrink
@BertGrink 4 года назад
HAH! As soon as i saw the video title, i knew that Javascript had to be in there.
@comoli8609
@comoli8609 4 года назад
Great video, you explained topics that can take days in a computer science class.
@Geekgaucho
@Geekgaucho 6 месяцев назад
Great video!! Everything in computing is a “tradeoff” that’s what I love about it!
@GummieI
@GummieI 4 года назад
Sounded like you had had very painful experiences when you talked about the "0" ending up as false
@diamondflaw
@diamondflaw 4 года назад
2 + 2 = 5 for very large values of 2
@JNCressey
@JNCressey 4 года назад
possible in python. import ctypes do some magic to get hold of where the built-in number 2 is cached and reassign it the value 2.5
@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!
@craigkollai2806
@craigkollai2806 4 года назад
I love the 42 and * in your examples!
@michellehanson7329
@michellehanson7329 4 года назад
Were you really 5 when you started coding?! Impressive!
@BaadJim
@BaadJim 4 года назад
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 года назад
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.