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".
@FBIagentObama4 жыл бұрын
*Sup dude*
@TheElvisnator4 жыл бұрын
Finally a comment that isn't older than the video Tom Scott be like: *_The laws of time aren't mine anymore_*
@alanreader48154 жыл бұрын
How many people have used the phrase "Tom Scott for 10 per cent off" as the the password. :D
@ИванСнежков-з9й4 жыл бұрын
I love how even the advertisement is educational.
@TheKingsIdiot4 жыл бұрын
One of the few ads i have seen that was informative while being an ad.
@lucabaldassi60244 жыл бұрын
0:19 the way the text on the screen and Tom's hand raise at the same time is unsettling
@spockbaca54754 жыл бұрын
He’s too powerful
@mrkrunch43404 жыл бұрын
True Power
@paulhermes9904 жыл бұрын
@Shareaffi I thank you kind stranger ;w;
@paulhermes9904 жыл бұрын
@Shareaffi I because we are the same person in two separate locations thanks to a super position... Maybe
@gaalidas48364 жыл бұрын
Spontaneous quantum entanglement. I hate it when that happens.
@Tyranisaur4 жыл бұрын
"Implicit conversions are great" - Famous last words
@BrentFiore4 жыл бұрын
"Implicit conversions are great" == true (since the string is not null) Can't argue with that
@hannessteffenhagen614 жыл бұрын
@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).
@happysongs4kyrone3 жыл бұрын
hai ooga monki here mmm ibudnenrtaansdnd mmmm syeysyes oogoooogoa
@harrychufan3 жыл бұрын
Explicit is better than implicit!
@msq70413 жыл бұрын
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
@MrMysticphantom4 жыл бұрын
PHP: "A language notable for MANY questionable design decisions" I laughed, cried and grimaced so hard at the mention of that absolutely true fact.
@Kyrelel4 жыл бұрын
PHP is simply C for Kids
@jemesmemes90264 жыл бұрын
Snooby66 c isn’t a programming language it’s a scripting language... smh
@Apoc2K4 жыл бұрын
PHP 5.4 was my personal Vietnam.
@gaalidas48364 жыл бұрын
Nice... comparing computer languages to being sent to war. I approve of this comparison.
@Colopty4 жыл бұрын
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.
@vaclavtrpisovsky4 жыл бұрын
Thanks for undermining my trust in high-level programming languages. I'm switching to Assembly.
@kensmith56944 жыл бұрын
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.
@lordcirth4 жыл бұрын
Just use a strongly-typed language like Haskell! It's quite trustworthy, and powerful too!
@kadblue20004 жыл бұрын
@@kensmith5694 In other words 2 lines of python code.
@kensmith56944 жыл бұрын
@@kadblue2000 Better yet: 1 line of APL Python is quite bad at dealing with hardware.
@R3lay04 жыл бұрын
Assembly? More like ASSembly. Real men write binary machine code.
@kdlk91394 жыл бұрын
When “true + true” fades away it doesn’t fully disappear 4:35 Sorry Tom, I’m a big fan of your work
@GentlemanlyOtter4 жыл бұрын
Good eyes
@Arcturus3674 жыл бұрын
true
@hanswurst83174 жыл бұрын
Actually got a short burn-in paranoia
@AGmarsen4 жыл бұрын
@@Arcturus367 genius
@gaalidas48364 жыл бұрын
Wow... nice catch.
@rekagaal4 жыл бұрын
"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...
@lyrimetacurl04 жыл бұрын
Probably started at 1.5
@zyaicob4 жыл бұрын
Straight out of college baby
@thoughtyness4 жыл бұрын
For those too lazy to look it up, he’s 35 to 36 according to Wikipedia
@Shaun.Stephens4 жыл бұрын
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.
@KL_Stereo4 жыл бұрын
@@Shaun.Stephens Such insight. Be sure to enlighten us mere mortals in all of Tom's future videos as well, brother
@tyberfen50094 жыл бұрын
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
@geli95us4 жыл бұрын
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
@Corbald4 жыл бұрын
@@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)); }
@jamesmnguyen4 жыл бұрын
@@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.
@theminer37464 жыл бұрын
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.
@gaalidas48364 жыл бұрын
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.
@HorzaPanda4 жыл бұрын
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
@scottcampbell27074 жыл бұрын
I used REXX (on VM/CMS) at university. REXX is like the opposite of strictly typed.
@charleslambert33684 жыл бұрын
Not sure if you're an old CS graduate or a young scientist.
@HorzaPanda4 жыл бұрын
@@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
@cygil14 жыл бұрын
"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.
@europeansovietunion73724 жыл бұрын
Speaking of pain, I've learned programming with pneumatic circuits, debugging was physically painful sometimes (we had to wear security goggles as well).
@dontaskmewhy87344 жыл бұрын
I change the hdmi 1 to hdmi 2 and thats already enough coding for my grandparents
@chonkydog62624 жыл бұрын
Don't Ask Me Why хаха
@chonkydog62624 жыл бұрын
смешно
@dontaskmewhy87344 жыл бұрын
@@chonkydog6262 smehno? Did i say that right? Im learning russian
@chonkydog62624 жыл бұрын
Don't Ask Me Why как я должен знать я тебя не могу слышать на ютубе
@chonkydog62624 жыл бұрын
Don't Ask Me Why smeshnk
@FinBoyXD4 жыл бұрын
I really like strongly typed languages. If I want to cast it I can do it myself. Otherwise I want to see an error.
@FurryDanOriginal4 жыл бұрын
this!
@gloweye4 жыл бұрын
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-zb5zd4 жыл бұрын
Check out ABAP then. It's a Cobol derivative used in SAP
@thefakepie11264 жыл бұрын
@@LieutenantVague yup , you know very little about programming !
@welltypedwitch4 жыл бұрын
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
@anselmschueler4 жыл бұрын
In python, however, "1.5"*2 is "1.51.5"...
@foolo14 жыл бұрын
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.
@tovekauppi16164 жыл бұрын
Olof Andersson I think the unusual bit is that the * is used to add two of the same string to a longer string.
@JNCressey4 жыл бұрын
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.
@bulbyvr4 жыл бұрын
Prob because python thinks "1.5"*2 = "1.5" + "1.5" woah hey there that's a concat symbol
@muizzy4 жыл бұрын
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.
@BenjaminLovelady4 жыл бұрын
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.
@57thorns4 жыл бұрын
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.
@JNCressey4 жыл бұрын
@@57thorns, import typing
@Spoco4 жыл бұрын
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.
@zeffonian3 жыл бұрын
Like JNCressey said, you can use typehints
@vegahimsa30573 жыл бұрын
When in doubt, force the conversion. let num = x - 0; let str = x + "";
@RussanoGreenstripe2 жыл бұрын
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.
@casperes09124 жыл бұрын
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.
@MrTridac4 жыл бұрын
C++ auto x = "50"; // another example
@LorenzoDelmonte05304 жыл бұрын
Same in py
@mntalateyya4 жыл бұрын
@@LorenzoDelmonte0530 Not exactly. Python only checks the types at runtime.
@fashnek4 жыл бұрын
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.
@danielbennett57264 жыл бұрын
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.
@AaronTheGerman4 жыл бұрын
[0:16] Can we just talk about how the green title screen in the background perfectly reacts to Tom's hand gestures? :D
@user-vn7ce5ig1z4 жыл бұрын
What? How so? 🤨
@mirjanbouma4 жыл бұрын
I love these IT themed videos, they make this noob understand much better what dark magic makes my pc work.
@howardbaxter25144 жыл бұрын
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.
@mirjanbouma4 жыл бұрын
@@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.
@samuvisser4 жыл бұрын
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
@mirjanbouma4 жыл бұрын
@@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...
@TorutheRedFox2 жыл бұрын
@@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
@lukew11004 жыл бұрын
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!
@FlashMustache4 жыл бұрын
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).
@WilcoVerhoef4 жыл бұрын
Yup, everything is an object
@rolaroli4 жыл бұрын
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.16204 жыл бұрын
@@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
@henke374 жыл бұрын
That's the official story. Reality... is more complex.
@sysosmaster4 жыл бұрын
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)
@ProfessorSyndicateFranklai4 жыл бұрын
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.
@HetuNandu4 жыл бұрын
Loved what you did with 42 and * there
4 жыл бұрын
that was 21 in binary tho
@anishagrawal70684 жыл бұрын
The meaning of the universe, life and everything
@jmtikka4 жыл бұрын
Actually 42 is The Answer to the Ultimate Question of Life, the Universe, and Everything.
@ReneSebastian4 жыл бұрын
This! 👏🏻
@Swapnil6384 жыл бұрын
Love how you make sponsor segments interesting.
@Asasnol214 жыл бұрын
I was classically trained in C and then decided to learn JavaScript. A dark time in my life.
@kensmith56944 жыл бұрын
At least you weren't going between C++ and JavaScript and back.
@cameronmyron57763 жыл бұрын
I really hope you can get past this dark time in your life. Best wishes.
@flex96633 жыл бұрын
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.
@JurgenBlitz4 жыл бұрын
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.
@gnif4 жыл бұрын
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).
@UjangBoyor4 жыл бұрын
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
@WorstDeveloper4 жыл бұрын
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.
@BlazeStorm4 жыл бұрын
As a non coder, that part at the end about password length was especially useful and insightful for me, thanks Tom!
@DrunkGeko4 жыл бұрын
I am about to get my computer science degree and i still watch these videos, they are just fun :)
@Panj04 жыл бұрын
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.
@jaewok5G4 жыл бұрын
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
@benjaminbrady23854 жыл бұрын
Top five densest things in the universe: Normal Stars Red Dwarfs Neutron Stars Black Holes Node Modules
@Cythil4 жыл бұрын
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.)
@puskajussi374 жыл бұрын
#6 Me
@Knee-Lew4 жыл бұрын
or in Composer: "Vendor"
@gaalidas48364 жыл бұрын
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.
@benjaminbrady23854 жыл бұрын
@@Cythil yes, a very interesting point. If I remember correctly a black hole will always be *less* dense the more mass it has
@Mordanepic10 ай бұрын
Whenever my favorite KZbinr becomes a school assignment you know I’m choosing the right path
ah yes, the holy trinity of not understanding type conversion after just watching a video about it
@hobrin42424 жыл бұрын
@BattleNo0bFaiLTV== easy language
@martiddy4 жыл бұрын
"0" == [""] --> true
@teasdaye4 жыл бұрын
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
@axelprino4 жыл бұрын
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.
@kensmith56944 жыл бұрын
In C an initialized pointer is taken as true. That which people call strings is really a pointer to some memory.
@ClokworkGremlin4 жыл бұрын
"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.
@dustojnikhummer4 жыл бұрын
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"
@agiar20004 жыл бұрын
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!"
@takatamiyagawa56884 жыл бұрын
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.
@Spartan3224 жыл бұрын
@@takatamiyagawa5688 Tuples are supported in C++ and C# and give you the same capability.
@supremelordofthebathroom71974 жыл бұрын
@@agiar2000 Quick question: Is Python a strongly-typed language? I'm a beginner & I am using it.
@6yjjk4 жыл бұрын
That hand gesture scrolling the screen moment at 0:19 is a thing of beauty.
@somekek67343 жыл бұрын
omg hahahaha
@noxabellus4 жыл бұрын
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-zb5zd4 жыл бұрын
There are cases where weak typing are very helpful, especially in dynamic scenarios... Though that's even further from beginner coding.
@TheNewTimeNetwork4 жыл бұрын
@@Markus-zb5zd Optionally typed languages like TypeScript and PHP7 are good for such dynamic scenarios.
@AllUpOns4 жыл бұрын
@@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-zb5zd4 жыл бұрын
@@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-zb5zd4 жыл бұрын
@@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.
@yubrajbhoi19864 жыл бұрын
A great example of why some people hate operator overloading with a passion.
@QuantumLeclerc4 жыл бұрын
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.
@meetaverma83724 жыл бұрын
He's 36 👀👀
@meetaverma83724 жыл бұрын
Also I would have been concerned with that too but why
@earthwormo11754 жыл бұрын
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!
@unom95154 жыл бұрын
2:21 "but this is just the Basics..." I see what you did there...
@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.
@robnorris47704 жыл бұрын
4:03 Body language says “been there, done that”.
@Okabim4 жыл бұрын
1:32 Underrated comment. It's a common beginner mistake to use floats to store money, but that comes with a whole heap of problems that could cost you dearly.
@gordonrichardson29724 жыл бұрын
Okabim Yep, rounding floating point numbers can be a complete pain, but is necessary in financial calculations.
@kensmith56944 жыл бұрын
@@gordonrichardson2972 Actually no you can use longer fixed point and make the rounding less trouble. It means you need to store fractions of a cent.
@gordonrichardson29724 жыл бұрын
Ken Smith If you use complex arithmetic functions such as exponents, fixed point numbers are inadequate. Its a complex topic, beyond the scope of this video.
@kensmith56944 жыл бұрын
@@gordonrichardson2972 The topic in this thread is about storing amounts of money. Complex functions are not generally used for accounting. BTW: I have done an awful lot of math functions in DSP like applications in fixed point values. These include exp() and trig functions. This is all beyond either the scope of either the video or the discussion here.
@mcsmileycorp4 жыл бұрын
The amount of times I've spent a day bugfixing something only to realise I didn't make something static is immeasurable.
@MCRogueHaven4 жыл бұрын
I was literally calculating that password question yesterday, but i didn't know how many symbols most websites accept. Thank you for answering that!
@user-vn7ce5ig1z4 жыл бұрын
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-lukas2 жыл бұрын
Using the . can look like a reference tho. Imagine string1.string2, you could see that as taking the "string2" member of "string1" variable
@blumoogle2901 Жыл бұрын
Or you can go String result = String.concatenate(arg1, arg2); No overloading. Everything repeated is a function.
@thelastcube.4 жыл бұрын
This a really nice reference for new programmers to learn certain basic stuff including datatypes
@Malidictus3 жыл бұрын
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.
@TheDefpom4 жыл бұрын
Your not the only one that screws up the single =, I miss that from time to time, and like you I’ve been coding for decades...
@Emanuel-sla-h5i4 жыл бұрын
01:26 Of course it's 42, that is THE answer after all!
@peNdantry3 жыл бұрын
... closely followed by an asterisk (ASCII code 42), commonly used to represent 'everything'... I think Tom is a closet Hitchhiker's Guide fan :)
@ausernameiguess70583 жыл бұрын
I was looking to see if someone pointed that out!
@matthewgough95334 жыл бұрын
Best Dashlane ad I've seen. The math breakdown was brilliant!
@sebbes3334 жыл бұрын
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)
@teun46204 жыл бұрын
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 Жыл бұрын
Its sort of both strongly and weakly typed
@md.imamulislam74 жыл бұрын
3:22 technically, that's probably a type coercion.
@bengoodwin21414 жыл бұрын
Doing things this way is very useful but also often very frustrating
@Liggliluff4 жыл бұрын
(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.
@masaufuku17352 жыл бұрын
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.
@02orochi2 жыл бұрын
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__L2 жыл бұрын
@@masaufuku1735 especially stacking fractional damage reduction buffs and the like.
@algotkristoffersson15 Жыл бұрын
The problem is that they tried to make your health not go bellow 0 rather than just having the death check use
@RedwoodGeorge4 жыл бұрын
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...
@LynxSnowCat4 жыл бұрын
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.
@aragonnetje4 жыл бұрын
In many languages he's right though
@sgbench4 жыл бұрын
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.
@LynxSnowCat4 жыл бұрын
@@sgbench ( laughs uproariously )
@kabobawsome4 жыл бұрын
@@sgbench Depending on the number of horrible practices you want to use, there can be 3 or even 4 different states in a Boolean.
@iwonderwhy96813 жыл бұрын
Why am I watching Tom explain the stuff I already know and enjoying it? Btw, love your work.
@reconcyl54284 жыл бұрын
Thank you for never conflating weak typing and dynamic typing, or type inference and dynamic typing.
@AnomNum4 жыл бұрын
I've finally read a title and understood it before watching the video. A dream come true.
@Donmegamuffin4 жыл бұрын
I'd like to see "====" : Is this the same object in memory ;)
@fluffycritter4 жыл бұрын
Donmegamuffin python has the “is” operator for that :)
@Colopty4 жыл бұрын
And ===== for whether it's the same object from a philosophical viewpoint.
@ilidumb44874 жыл бұрын
But ====== checks if it's the same object from a religious viewpoint.
@piguyalamode1644 жыл бұрын
in Java "==" works like that(for objects, the same number is always the same object in memory)
@_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 ^^
@adamt60244 жыл бұрын
Love these videos, even being an experienced programmer I still find my self learning from these well put together videos
@RyebuckCoppercap4 жыл бұрын
As an absolute novice at programming, I prefer strong typing as it's harder to accidentally screw up 😅
@peterhornik85694 жыл бұрын
good for you
@LPAtkins2 жыл бұрын
Automatic type conversion caught me out good with VB6/VBA as 6600 * 1000 results in an integer overflow
@Aragubas3 жыл бұрын
0:19 the way tom hand raises and the text on the background monitor xD
@wanderingrandomer4 жыл бұрын
"I've been coding for about 30 years" Dude, how young did you start?!
@Jay-to7yz4 жыл бұрын
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
@jasper26244 жыл бұрын
This is correct, I live in the UK, I am 16 and I have been programming for about 10 years.
@meetaverma83724 жыл бұрын
Also he's 36 so it was infact 6 yrs old
@chris-rios4 жыл бұрын
I wish I been doing it since 6 because of how easy it is to learn
@wiktoreriksson45663 жыл бұрын
I have been coding since 6 too
@abdusco4 жыл бұрын
Almost 6m long take with no cuts. Wouldn't expect anything less from Tom.
@pawelkusmierek1094 жыл бұрын
"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.
@57thorns4 жыл бұрын
In which of them is it easier to find your typos?
@tomasderner75114 жыл бұрын
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).
@miracoulousme4 жыл бұрын
@@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 ...
@pawelkusmierek1094 жыл бұрын
@@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.
@LonesomeTwin4 жыл бұрын
I still type retrun far too often
@gaalidas48364 жыл бұрын
Interesting point there. I remember by professor in basic C# programming class was not a fan of JavaScript's implicit variables. He'd complain "it's just a Var. What the heck is a var? Why... it's everything, at the same time, with no control at all... its chaos!" And hes right. You actually have to do extra work to make sure your variables are what you expect them to be. At least we have that "use strict" thing to even put out. That makes it potentially less chaotic.
@mattwinward31684 жыл бұрын
0:49 You completely missed the opportunity to write out “Tom Scott” in binary.
@craigkollai28064 жыл бұрын
I love the 42 and * in your examples!
@silvanostagni4 жыл бұрын
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! :) :) :)
@mediumjohnsilver4 жыл бұрын
Silvano stagni In the 1980s I loved to code in mainframe assembler and program “down to the bare metal”. 😀
@AndreaZzzXXX4 жыл бұрын
Silvano I know the feeling :-) PS: are you italian ?
@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.
@imbaedin4 жыл бұрын
A JavaScript '+' has a third use: integer parsing. Making 1+ + "1" = 2
@pepkin884 жыл бұрын
Technically converts to Number, but yes.
@sentjojo4 жыл бұрын
Ouch
@yoyoyonono3 жыл бұрын
@@pepkin88 aka parsing
@cameronmyron57763 жыл бұрын
Every day we stray farther from God...
@maelstrom572 жыл бұрын
@@yoyoyonono JavaScript has a parseInt function but it doesn't exactly work like the unary operator. +"" --> 0 parseInt("") --> NaN
@SarahIsWeird4 жыл бұрын
I like explicit typing because it can prevent my dumb arse from putting in stupid bugs. Also when you said you still mess up = and ==, I felt that
@GeoDetective4 жыл бұрын
string person = "I "; string subject = "loose programming languages!"; string opinion = "hate "; return person + opinion + subject;
@lychy6454 жыл бұрын
@xinflict30784 жыл бұрын
ihatelooseprogramminglanguages
@kabobawsome4 жыл бұрын
@@xinflict3078 Actually, it would be "Ihateloose programming languages"
@Me-da-Ghost4 жыл бұрын
@@kabobawsome No read it again. The last line is "return person ("I ") + opinion ("hate ") + subject ("loose programming languages!");"
@jacobdaniels32464 жыл бұрын
is this c++? Srry Im a C guy. I'm assuming it's not java bc it's String in java I think
@kebien60203 жыл бұрын
1:19 "In general you will at least have: Integer" JavaScript has left the chat
4 жыл бұрын
"You will at least have integer." *laughs in JavaScript*
@sysosmaster4 жыл бұрын
Javascript has integer (internally). And Boolean. And.... ;)
4 жыл бұрын
@@sysosmaster No, numbers are floating-point. There are the new "bigint", though.
@RobotnikPlays4 жыл бұрын
There's a great article that catalogues a lot of PHP's... eccentricities, called "PHP: A fractal of bad design". Definitely worth a read of you're into this sort of stuff
@theonlyari4 жыл бұрын
4:42- speaking of bugs that come out later... your true + true is still visible :D
@JNCressey4 жыл бұрын
I don't see it
@theonlyari4 жыл бұрын
@@JNCressey Neither did Tom. Its almost like its transparent, but not 100%.
@honmameiko13337 ай бұрын
Typescript really saves my life, implicit type casting just drives me mad and uneasy
@JohnnieHougaardNielsen4 жыл бұрын
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.
@iggyvolz4 жыл бұрын
In PHP, you can type declare(strict_types=1); so it will (almost) never silently convert types. The only conversion it will do is int to float, or anything to string if a string is specifically requested
@_mels_4 жыл бұрын
1:25 isn't that 21?
@sayanghosh69964 жыл бұрын
yes
@liudleon8704 жыл бұрын
It is
@TristanPopken4 жыл бұрын
Yes, yes it is
@BeejJorgensen4 жыл бұрын
101010 is 42. 010101 is 21. Just a think-o, probably. :)
@Geekgaucho10 ай бұрын
Great video!! Everything in computing is a “tradeoff” that’s what I love about it!
@dustinryan-roepsch87124 жыл бұрын
"You will at least have integer" *cries in javascript*
@igorswies59133 жыл бұрын
BTW if you need more precision than 2^53 integers then you can use BigInt
@StefanLopuszanski4 жыл бұрын
I would have added that you should have talked about "type-safe" over "strong / weak" since it seems definitions on those tend to vary.
@Landhund04 жыл бұрын
Damn Tom, you're looking *sharp* today ^^
@kjaamor20572 жыл бұрын
I didn't come home from a day of developing to not not express a lack of dispassionate absence of views on a subject for which my ambivalence only reflects my total interest in maintaining an equality of knowledge with those presently unfamiliar with the subject but with no less ability than myself to become knowledgeable in it.
@akshaybodla1634 жыл бұрын
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.
@swapode2 жыл бұрын
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-lukas2 жыл бұрын
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
@additionaddict55244 жыл бұрын
This is why I love Typescript
@michellehanson73294 жыл бұрын
Were you really 5 when you started coding?! Impressive!
@BaadJim4 жыл бұрын
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?
@SerBallister4 жыл бұрын
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.
@benjones85434 жыл бұрын
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 :).
@kittechno84014 жыл бұрын
Me: Starts coding with C and microchips This video : YOU'RE A REAL CODER ! Me : Well yes, but no.
@BradyPostma3 жыл бұрын
I know enough programming to teach this same material, but I have no hope of being as entertaining and compelling as Tom while doing it.
@depressedsmile94874 жыл бұрын
The best excuse ever: "This is just the basics"
@skinnybowser2 жыл бұрын
Your content and delivery is outstanding. Thank you!
@Kapin054 жыл бұрын
I personally prefer Python's average-strength typing - you needn't declare variable types but it'll rarely convert them for you.
@whuzzzup4 жыл бұрын
To this date I don't understand why print() won't automatically convert int to str. It's stupid.
@Kapin054 жыл бұрын
@@whuzzzup I remember it doing that, did they change it at some point?
@whuzzzup4 жыл бұрын
@@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")
@Kapin054 жыл бұрын
@@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.
@alexp60133 жыл бұрын
@@whuzzzup or you use the method format of the string, and then the code is readable, like python is made to look like