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".
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
"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.
Speaking of pain, I've learned programming with pneumatic circuits, debugging was physically painful sometimes (we had to wear security goggles as well).
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.
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.
"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...
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.
@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).
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
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?
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
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
@@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)); }
@@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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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)
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.
@@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.
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
@@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...
@@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
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.
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!
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 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.
@@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.
@@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.
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.
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).
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.
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.
"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.
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!"
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.
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.)
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.
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)
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.
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.
@@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.
(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.
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.
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
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.
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...
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
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!
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. :-\
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.
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 :).
"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.
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).
@@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 ...
@@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.
In JavaScript, `===` is doing exactly that on objects. Which is why `{} === {}` returns `false` and you have to fallback to `deep.equal` / `_.isEqual` implementations ^^
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.
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! :) :) :)
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.
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.
In Julia, the language I use most often being a mathematician, * is used for string concatenation, for a really smart reason. In algebra, almost always any commutative operation is denoted with a plus, and a (possibly) non-commutative operation is denoted with *. String concatenation is not a commutative operation; "dog"*"cat" != "cat"*"dog". Hence the multiplication symbol rather than a plus sign.
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.
6:05 it doesn't even make the life easier, you are just choosing between an slight slap in the face from the compiler or melting your brain debugging for hours. Its not controversial, if you don't supply types to the compiler (or use type-inference), then you are not supplying data the compiler needs to help you and even do part of the job of figuring correct software behavior. Its just an stupid kind of laziness from the programmer. its not even about typing (pun intended), because with modern type inference, you can do something like "let x = 1.0" and x will be "float", compilers can figure it out. Its just laziness for not knowing what you're doing, because if you don't know and use static typing, then you can't ship bugged software, but with dynamic typing you can, and everything looks fine and then it all explodes. That's why its an absolute must for "real" programmers to learn how to deal with their tools.
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.
I'm watching a video about the basics like I do my 300 level computer science homework. It feels nice to know that I do indeed know the basics, especially since I use them everyday.
Javascript is not implicitly typed. It's a dynamically typed. An implicitly typed language would be where it figures out what type the variable is when you initially declare, but then it never changes after that. In javascript, you can set x to 1.5 and then immediately change it to "hello world"--the type is dynamic because it changes.
@@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")
@@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.
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.
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.
I am a hobby coder who started with Basic in the 90s and went to TurboPascal and later Delphi/Lazarus. When MS released their Visual C++ for free I thought I should try to finally get over to C++. So I had a task for it. I needed to sort a bunch of files by certain things in their names. Easy stuff, I thought. Good thing to get used to another syntax. I spent 4 hours trying to get a folderstring into a findfirst instruction and then I gave up. It might be that I am too stupid, but it was just so frustrating that I wasn't able to do such an easy thing because of a bunch of special string types that were not compatible to each other and I simply couldn't figure out how to convert a hardcoded string to that string type that "findfirst" expected. If that is "real coding" then screw that. I am still happy with my object pascal.
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.
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.
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
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".
*Sup dude*
Finally a comment that isn't older than the video
Tom Scott be like: *_The laws of time aren't mine anymore_*
How many people have used the phrase "Tom Scott for 10 per cent off" as the the password. :D
I love how even the advertisement is educational.
One of the few ads i have seen that was informative while being an ad.
0:19 the way the text on the screen and Tom's hand raise at the same time is unsettling
He’s too powerful
True Power
@Shareaffi I thank you kind stranger ;w;
@Shareaffi I because we are the same person in two separate locations thanks to a super position... Maybe
Spontaneous quantum entanglement. I hate it when that happens.
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
I used REXX (on VM/CMS) at university. REXX is like the opposite of strictly typed.
Not sure if you're an old CS graduate or a young scientist.
@@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
"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.
Speaking of pain, I've learned programming with pneumatic circuits, debugging was physically painful sometimes (we had to wear security goggles as well).
PHP: "A language notable for MANY questionable design decisions"
I laughed, cried and grimaced so hard at the mention of that absolutely true fact.
PHP is simply C for Kids
Snooby66 c isn’t a programming language it’s a scripting language... smh
PHP 5.4 was my personal Vietnam.
Nice... comparing computer languages to being sent to war. I approve of this comparison.
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.
Thanks for undermining my trust in high-level programming languages. I'm switching to Assembly.
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.
Just use a strongly-typed language like Haskell! It's quite trustworthy, and powerful too!
@@kensmith5694 In other words 2 lines of python code.
@@kadblue2000
Better yet: 1 line of APL
Python is quite bad at dealing with hardware.
Assembly? More like ASSembly. Real men write binary machine code.
When “true + true” fades away it doesn’t fully disappear 4:35
Sorry Tom, I’m a big fan of your work
Good eyes
true
Actually got a short burn-in paranoia
@@Arcturus367 genius
Wow... nice catch.
"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...
Probably started at 1.5
Straight out of college baby
For those too lazy to look it up, he’s 35 to 36 according to Wikipedia
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.
@@Shaun.Stephens Such insight. Be sure to enlighten us mere mortals in all of Tom's future videos as well, brother
"Implicit conversions are great" - Famous last words
"Implicit conversions are great" == true (since the string is not null)
Can't argue with that
@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).
hai ooga monki here mmm ibudnenrtaansdnd mmmm syeysyes oogoooogoa
Explicit is better than implicit!
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
I really like strongly typed languages. If I want to cast it I can do it myself. Otherwise I want to see an error.
this!
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?
Check out ABAP then. It's a Cobol derivative used in SAP
@@LieutenantVague yup , you know very little about programming !
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
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
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
@@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));
}
@@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.
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.
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.
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.
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.
@@57thorns, import typing
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.
Like JNCressey said, you can use typehints
When in doubt, force the conversion. let num = x - 0; let str = x + "";
I change the hdmi 1 to hdmi 2 and thats already enough coding for my grandparents
Don't Ask Me Why хаха
смешно
@@chonkydog6262 smehno? Did i say that right? Im learning russian
Don't Ask Me Why как я должен знать я тебя не могу слышать на ютубе
Don't Ask Me Why smeshnk
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.
In python, however, "1.5"*2 is "1.51.5"...
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.
Olof Andersson I think the unusual bit is that the * is used to add two of the same string to a longer string.
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.
Prob because python thinks "1.5"*2 = "1.5" + "1.5" woah hey there that's a concat symbol
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.
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.
C++
auto x = "50"; // another example
Same in py
@@LorenzoDelmonte0530 Not exactly. Python only checks the types at runtime.
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.
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.
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).
Yup, everything is an object
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.
@@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
That's the official story. Reality... is more complex.
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)
[0:16] Can we just talk about how the green title screen in the background perfectly reacts to Tom's hand gestures? :D
What? How so? 🤨
I love these IT themed videos, they make this noob understand much better what dark magic makes my pc work.
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.
@@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.
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
@@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...
@@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
I was classically trained in C and then decided to learn JavaScript. A dark time in my life.
At least you weren't going between C++ and JavaScript and back.
I really hope you can get past this dark time in your life. Best wishes.
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.
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.
Loved what you did with 42 and * there
that was 21 in binary tho
The meaning of the universe, life and everything
Actually 42 is The Answer to the Ultimate Question of Life, the Universe, and Everything.
This! 👏🏻
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!
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
There are cases where weak typing are very helpful, especially in dynamic scenarios...
Though that's even further from beginner coding.
@@Markus-zb5zd Optionally typed languages like TypeScript and PHP7 are good for such dynamic scenarios.
@@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.
@@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.
@@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.
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.
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).
Whenever my favorite TH-camr becomes a school assignment you know I’m choosing the right path
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.
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.
In C an initialized pointer is taken as true.
That which people call strings is really a pointer to some memory.
"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.
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"
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!"
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.
@@takatamiyagawa5688 Tuples are supported in C++ and C# and give you the same capability.
@@agiar2000 Quick question: Is Python a strongly-typed language? I'm a beginner & I am using it.
Love how you make sponsor segments interesting.
I am about to get my computer science degree and i still watch these videos, they are just fun :)
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.
As a non coder, that part at the end about password length was especially useful and insightful for me, thanks Tom!
Top five densest things in the universe:
Normal Stars
Red Dwarfs
Neutron Stars
Black Holes
Node Modules
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.)
#6 Me
or in Composer: "Vendor"
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.
@@Cythil yes, a very interesting point. If I remember correctly a black hole will always be *less* dense the more mass it has
That hand gesture scrolling the screen moment at 0:19 is a thing of beauty.
omg hahahaha
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)
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.
Okabim Yep, rounding floating point numbers can be a complete pain, but is necessary in financial calculations.
@@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.
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.
@@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.
Meanwhile in Javascript:
0 == "0" --> true
0 == [ ] --> true
"0" == [ ] --> false
very intuitive.
ah yes, the holy trinity of javascript
ah yes, the holy trinity of not understanding type conversion after just watching a video about it
@BattleNo0bFaiLTV== easy language
"0" == [""] --> true
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
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.
He's 36 👀👀
Also I would have been concerned with that too but why
(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.
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.
Or u could just use decimals..
To be fair its not as performant as doubles which might be crucial in games but theyre underratef
@@masaufuku1735 especially stacking fractional damage reduction buffs and the like.
The problem is that they tried to make your health not go bellow 0 rather than just having the death check use
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
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.
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...
The amount of times I've spent a day bugfixing something only to realise I didn't make something static is immeasurable.
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
2:21 "but this is just the Basics..."
I see what you did there...
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!
4:03 Body language says “been there, done that”.
A great example of why some people hate operator overloading with a passion.
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. :-\
Using the . can look like a reference tho. Imagine string1.string2, you could see that as taking the "string2" member of "string1" variable
Or you can go String result = String.concatenate(arg1, arg2);
No overloading. Everything repeated is a function.
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.
01:26
Of course it's 42, that is THE answer after all!
... closely followed by an asterisk (ASCII code 42), commonly used to represent 'everything'...
I think Tom is a closet Hitchhiker's Guide fan :)
I was looking to see if someone pointed that out!
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 :).
"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.
In which of them is it easier to find your typos?
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).
@@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 ...
@@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.
I still type retrun far too often
Why am I watching Tom explain the stuff I already know and enjoying it? Btw, love your work.
3:22 technically, that's probably a type coercion.
Love these videos, even being an experienced programmer I still find my self learning from these well put together videos
"I've been coding for about 30 years"
Dude, how young did you start?!
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
This is correct, I live in the UK, I am 16 and I have been programming for about 10 years.
Also he's 36 so it was infact 6 yrs old
I wish I been doing it since 6 because of how easy it is to learn
I have been coding since 6 too
1:19 "In general you will at least have: Integer"
JavaScript has left the chat
I'd like to see "====" : Is this the same object in memory ;)
Donmegamuffin python has the “is” operator for that :)
And ===== for whether it's the same object from a philosophical viewpoint.
But ====== checks if it's the same object from a religious viewpoint.
in Java "==" works like that(for objects, the same number is always the same object in memory)
In JavaScript, `===` is doing exactly that on objects. Which is why `{} === {}` returns `false` and you have to fallback to `deep.equal` / `_.isEqual` implementations ^^
I've finally read a title and understood it before watching the video. A dream come true.
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.
In many languages he's right though
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.
@@sgbench ( laughs uproariously )
@@sgbench Depending on the number of horrible practices you want to use, there can be 3 or even 4 different states in a Boolean.
When you know nothing about coding but find Tom's videos interesting and fun to watch.
A JavaScript '+' has a third use: integer parsing.
Making
1+ + "1" = 2
Technically converts to Number, but yes.
Ouch
@@pepkin88 aka parsing
Every day we stray farther from God...
@@yoyoyonono JavaScript has a parseInt function but it doesn't exactly work like the unary operator.
+"" --> 0
parseInt("") --> NaN
Doing things this way is very useful but also often very frustrating
As an absolute novice at programming, I prefer strong typing as it's harder to accidentally screw up 😅
good for you
Best Dashlane ad I've seen. The math breakdown was brilliant!
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! :) :) :)
Silvano stagni In the 1980s I loved to code in mainframe assembler and program “down to the bare metal”. 😀
Silvano I know the feeling :-)
PS: are you italian ?
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.
1:25
isn't that 21?
yes
It is
Yes, yes it is
101010 is 42. 010101 is 21. Just a think-o, probably. :)
0:19 the way tom hand raises and the text on the background monitor xD
I was literally calculating that password question yesterday, but i didn't know how many symbols most websites accept. Thank you for answering that!
Damn Tom, you're looking *sharp* today ^^
Great video!! Everything in computing is a “tradeoff” that’s what I love about it!
Thank you for never conflating weak typing and dynamic typing, or type inference and dynamic typing.
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.
The best excuse ever: "This is just the basics"
In Julia, the language I use most often being a mathematician, * is used for string concatenation, for a really smart reason. In algebra, almost always any commutative operation is denoted with a plus, and a (possibly) non-commutative operation is denoted with *. String concatenation is not a commutative operation; "dog"*"cat" != "cat"*"dog". Hence the multiplication symbol rather than a plus sign.
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.
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...
4:42- speaking of bugs that come out later... your true + true is still visible :D
I don't see it
@@JNCressey Neither did Tom. Its almost like its transparent, but not 100%.
0:19 , his hand sync with the background . Quantum physics at its finest
6:05 it doesn't even make the life easier, you are just choosing between an slight slap in the face from the compiler or melting your brain debugging for hours. Its not controversial, if you don't supply types to the compiler (or use type-inference), then you are not supplying data the compiler needs to help you and even do part of the job of figuring correct software behavior. Its just an stupid kind of laziness from the programmer. its not even about typing (pun intended), because with modern type inference, you can do something like "let x = 1.0" and x will be "float", compilers can figure it out.
Its just laziness for not knowing what you're doing, because if you don't know and use static typing, then you can't ship bugged software, but with dynamic typing you can, and everything looks fine and then it all explodes. That's why its an absolute must for "real" programmers to learn how to deal with their tools.
Even strong dynamic typing like in Python is a huge improvement over JS.
But if you use weak typing and DO know what you’re doing it is more effective than strong typing
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.
Its sort of both strongly and weakly typed
"You will at least have integer"
*cries in javascript*
BTW if you need more precision than 2^53 integers then you can use BigInt
I'm watching a video about the basics like I do my 300 level computer science homework. It feels nice to know that I do indeed know the basics, especially since I use them everyday.
Sounded like you had had very painful experiences when you talked about the "0" ending up as false
This a really nice reference for new programmers to learn certain basic stuff including datatypes
HAH! As soon as i saw the video title, i knew that Javascript had to be in there.
Javascript is not implicitly typed. It's a dynamically typed. An implicitly typed language would be where it figures out what type the variable is when you initially declare, but then it never changes after that. In javascript, you can set x to 1.5 and then immediately change it to "hello world"--the type is dynamic because it changes.
I personally prefer Python's average-strength typing - you needn't declare variable types but it'll rarely convert them for you.
To this date I don't understand why print() won't automatically convert int to str. It's stupid.
@@whuzzzup I remember it doing that, did they change it at some point?
@@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")
@@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.
@@whuzzzup or you use the method format of the string, and then the code is readable, like python is made to look like
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.
string person = "I ";
string subject = "loose programming languages!";
string opinion = "hate ";
return person + opinion + subject;
ihatelooseprogramminglanguages
@@xinflict3078 Actually, it would be "Ihateloose programming languages"
@@kabobawsome No read it again. The last line is "return person ("I ") + opinion ("hate ") + subject ("loose programming languages!");"
is this c++? Srry Im a C guy. I'm assuming it's not java bc it's String in java I think
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.
Were you really 5 when you started coding?! Impressive!
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?
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.
I am a hobby coder who started with Basic in the 90s and went to TurboPascal and later Delphi/Lazarus. When MS released their Visual C++ for free I thought I should try to finally get over to C++. So I had a task for it. I needed to sort a bunch of files by certain things in their names. Easy stuff, I thought. Good thing to get used to another syntax.
I spent 4 hours trying to get a folderstring into a findfirst instruction and then I gave up. It might be that I am too stupid, but it was just so frustrating that I wasn't able to do such an easy thing because of a bunch of special string types that were not compatible to each other and I simply couldn't figure out how to convert a hardcoded string to that string type that "findfirst" expected. If that is "real coding" then screw that. I am still happy with my object pascal.
I have a computer architecture exam in 2 days.
I don't regret the time I procrastinated.
I would have added that you should have talked about "type-safe" over "strong / weak" since it seems definitions on those tend to vary.
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.
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.
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
Automatic type conversion caught me out good with VB6/VBA as 6600 * 1000 results in an integer overflow
Forget implicit or explicit type conversions, when I type
1 + "Cows"
I expect the answer to be "Cowt"
I've heard too many horror stories about Javascript to know whether this is a joke