Why TRUE + TRUE = 2: Data Types
HTML-код
- Опубликовано: 12 ноя 2024
- INT, BOOLEAN, STRING and FLOAT: these are the things that data is made of. • Sponsored by Dashlane - for free on your first device @ www.dashlane.c...
MORE BASICS: • The Basics
Written with Sean Elliott / seanmelliott
Directed by Tomek
Graphics by Mooviemakers www.mooviemake...
Audio mix by Haerther Productions haerther.net/
I'm at tomscott.com
on Twitter at / tomscott
on Facebook at / tomscott
and on Instagram as tomscott
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.
"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
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.
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).
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
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.
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.
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 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
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
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'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.
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.
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? 🤨
Love how you make sponsor segments interesting.
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.
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 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
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
As a non coder, that part at the end about password length was especially useful and insightful for me, thanks Tom!
"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.
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!
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
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.
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
Whenever my favorite RUclipsr becomes a school assignment you know I’m choosing the right path
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.
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 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.
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 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.
Doing things this way is very useful but also often very frustrating
The amount of times I've spent a day bugfixing something only to realise I didn't make something static is immeasurable.
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.
(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
This a really nice reference for new programmers to learn certain basic stuff including datatypes
2:21 "but this is just the Basics..."
I see what you did there...
That hand gesture scrolling the screen moment at 0:19 is a thing of beauty.
omg hahahaha
4:03 Body language says “been there, done that”.
A great example of why some people hate operator overloading with a passion.
3:22 technically, that's probably a type coercion.
I've finally read a title and understood it before watching the video. A dream come true.
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 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.
Why am I watching Tom explain the stuff I already know and enjoying it? Btw, love your work.
"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
Best Dashlane ad I've seen. The math breakdown was brilliant!
Thank you for never conflating weak typing and dynamic typing, or type inference and dynamic typing.
Love these videos, even being an experienced programmer I still find my self learning from these well put together videos
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
When you know nothing about coding but find Tom's videos interesting and fun to watch.
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.
I was literally calculating that password question yesterday, but i didn't know how many symbols most websites accept. Thank you for answering that!
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)
Almost 6m long take with no cuts. Wouldn't expect anything less from Tom.
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
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...
"You will at least have integer."
*laughs in JavaScript*
Javascript has integer (internally). And Boolean. And.... ;)
@@sysosmaster No, numbers are floating-point.
There are the new "bigint", though.
0:19 the way tom hand raises and the text on the background monitor xD
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.
This is why I love Typescript
As an absolute novice at programming, I prefer strong typing as it's harder to accidentally screw up 😅
good for you
Definitely looking forward to your basics video on floating points.
0:49 You completely missed the opportunity to write out “Tom Scott” in binary.
Cool vid, very glad to see Language File and The Basics videos returning
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 know nothing about computer science, but I like to think if I got into it one day, I’d already know everything I need to know from Tom
Damn Tom, you're looking *sharp* today ^^
This is a very underrated channel !
The best excuse ever: "This is just the basics"
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.
"You will at least have integer"
*cries in javascript*
BTW if you need more precision than 2^53 integers then you can use BigInt
Nice video Tom, Often people pick up a coding course and come in without knowing what an int or a float is.
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 ?
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...
I don't think I have to go to school after watching this RUclips channel
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
Great video!! Everything in computing is a “tradeoff” that’s what I love about it!
I have a computer architecture exam in 2 days.
I don't regret the time I procrastinated.
That was far more interesting than any commercial ever
uploaded 18 seconds ago, i'm truly lucky
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.
Sounded like you had had very painful experiences when you talked about the "0" ending up as false
Tom is the type of guy to programmatically advertise password managers
1:25
isn't that 21?
yes
It is
Yes, yes it is
101010 is 42. 010101 is 21. Just a think-o, probably. :)
Your content and delivery is outstanding. Thank you!
This is why everyone makes fun of us javascript programmers
I don't understand why people are bashing it. So, every language has a few peculiarities ... what EVER.
Typescript for the win!
I have been watching your videos for so long, that it turns out that somehow I have not been subscribed. Like what!?! I am now subscribed!
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.
Great video, you explained topics that can take days in a computer science class.
Those simple times when string variables had to start with $ sign...
what language is this
@@igorswies5913 im assuming assembly
Ive been watching since 2013! still watch your content its still so good keep up the work!
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%.