Learn the computer science behind #JavaScript by looking at how it works under the hood. Understand why JS is called a …
38 Comments
Leave a Reply
You must be logged in to post a comment.
Learn the computer science behind #JavaScript by looking at how it works under the hood. Understand why JS is called a …
You must be logged in to post a comment.
This was excellent; nice work!
classic
4:00, I didn't know C++ was cleaner/shorter on initialization:
for (struct Dog {bool barks = true;} Pug; //Creates object 'Pug' on the stack. The 'for' is optional, just to show obj. scope.
!Pug.barks; ); //Failed condition: it'll exit for, killing object from stack.
Pug.barks; //Compiling error: ‘Pug’ was not declared in this scope.
This is not inheritance: 'Pug' was just an object from class 'Dog'. To make that:
struct Puppy {bool rolls = true;} puppy; //Creates optional object on stack.
for (struct Dog: Puppy {bool barks = true;} Pug; //Creates 'Pug' as 'Dog' that inherited 'Puppy'.
!Pug.rolls; ); //Failed condition: it'll exit for, killing object from stack.
puppy.rolls; //Ok, but compiling warning: statement has no effect [-Wunused-value]
Pug.barks; //Compiling error: ‘Pug’ was not declared in this scope.
2:40, this is unfair: that cartoon showed interpreter reading legal instructions, while the compiler saw errors. The actual difference is that interpreter will show to you your errors at each instruction, while compiler will list all your errors, not "leaving you on your own" – of course, compiler errors can be combined to raise new ones, but that is a minor a detail .
3:28, C++14 (since 2014) has a much better solution:
const auto foo = "hello world!"; //foo is deduced as 'const char *', but you can convert it to 'std::string' at any time.
const auto bar = 23; //It's an int, because literal number defaults to int.
const auto baz = 42F; //A float. Just trying to complicate matters.
constexpr auto fun () {
return bar + baz; //Returns float: int + float = float. Always the more detailed 1 wins. Even fun will return its value at compiling time.
}
All of that at compiling time, not losing performance, as it would happen at runtime.
7:25, in C++ that object would still be in the stack (compiler manages memory):
struct MyCounter { int value = 0; } myCounter;
const auto increment = [&]() { //A lambda f().
const auto step = 1;
myCounter.value++;
};
increment(); increment(); increment();
————- // —————-
//Now forcing use of the heap (not recomended):
struct MyCounter { int value = 0; }; // myCounter;
std::vector <MyCounter> myC (1); //Alocates 1 object 'MyCounter' on the heap. Destructor will free the memory automatically. But you can always call the 'clear' f().
auto &myCounter = myC[0]; //Reference to that object. Just to keep the 'myCounter' name.
//The rest is the increment stuff…
2:40, this is unfair: that cartoon showed interpreter reading legal instructions, while the compiler saw errors. The actual difference is that interpreter will show to you your errors at each instruction, while compiler will list all your errors, not "leaving you on your own" – of course, compiler errors can be combined to raise new ones, but that is a minor a detail .
3:28, C++14 (since 2014) has a much better solution:
const auto foo = "hello world!"; //foo is deduced as 'const char *', but you can convert it to 'std::string' at any time.
const auto bar = 23; //It's an int, because literal number defaults to int.
const auto baz = 42F; //A float. Just trying to complicate matters.
constexpr auto fun () {
return bar + baz; //Returns float: int + float = float. Always the more detailed 1 wins. Even fun will return its value at compiling time.
}
All of that at compiling time, not losing performance, as it would happen at runtime.
At 5:25, cntr-shift-J raises a console window with tonnes of errors and no interpreter for me to add my one function, what am I doing wrong (browser is firefox)?
omg no one ever explained to me th task queue n stuff every javascript tutorial or course i ever did just left me confused n baffled but this is different! u know ur stuff n it shows n i understand everything quickly! ill b follllowing th rest of ur course 🙂
StackOverflow 😂😂😂
dynamic weak typing doesn't mean types aren't specified (what you're thinking of is inferred typing, which is the opposite of manifest typing which is what langs like C have). Dynamic means types are checked at runtime (as opposed to at compile time as is the case with static typing), and weak typing means that the language is more permissive when it comes to implicit type conversions. So in C, as it is weakly typed, you can, say, take the result of malloc and store it in a typed pointer without specifying a type conversion, and the compiler will happily do it with no complaints. C++ is strongly typed and doesn't allow implicit void pointer conversions, which is why the same exact program will raise a compile error.
But JavaScript uses a special type of weak typing which you might call "super weak typing", but the rest of the world calls it duck typing. If it looks like a duck…it's a duck. Doesn't matter that it's a pigeon vaguely in the shape of a duck and obviously not a duck, 1 == "1" will evaluate true, because it "looks like" a duck. Duck typing is the source of a lot of JavaScript's jank.
"javascript is a high level interpreted dynamically typed multi-paradigm prototype-based language" 🔥
4:11 Damn, I need to memorize this 😂
This is excellent material.
You talked javascript like I've never learned. But I've been in the business for over 20 years. These Information overwhelms me.
you are GOD
The cartoon used is from the 1983 show Bits and Bytes
I would like to learn more about how the data types become known at runtime. That's the main thing that has confused me so far in my js ventures.
Awesome video.
i feel like your videos is biscuits for the brain
Really Great Video
I know everything aT 0:18
Really cool video. Shows me just how much I need to learn haha. I dream of being able to rattle of this stuff like you do with ease. But key point at the end if to just start learning/building.
why did you drink helium before recording this video?
Inter dimensional TV
I love you man!
This guy just rick rolled me!
Entendi porra nenhuma mas vou estudar muito pra entender tudo nos próximos meses
All this info might not be necessary to write JavaScript, but it sure does help to understand what's going on under the hood.
high-level single-threaded, garbage-collected, interpreted (or just-in-time compiled), prototype-based, multi-paradigm, dynamic language with a non-blocking event loop🔥, way to sum it.!!!
The viewer count at 5:20 : 📉
Ok, that's enough. The stupid insert videos are infuriating.
why this video is in chinese ?
Great video! Really helps put all the pieces of the picture in perspective. Does anyone know what that awesome old interpreter-compiler animation from?
Oh, I love how javascript developers say that C and Java are compiled into binaries 🙂
No, Java is not compiled into binaries. It's compiled into bytecode that is JIT'ed [in most cases] by JVM into low-level system instructions.
Love the clips from the 1983 TVOntario series "Bits and Bytes", my introduction to (home) computing.
I am glad I came across this channel.
talk so fast you have to cut it
Why javascript gets so much hate? despite being the most spreaded language.
Thanks a lot for this in depth explanation