Improving Intermediate Codes - Computerphile

  Рет қаралды 54,286

Computerphile

Computerphile

Күн бұрын

Пікірлер: 77
@bcham7373
@bcham7373 4 жыл бұрын
The professor is an absolute treasure, so enjoyable to listen to.
@woodywoodlstein9519
@woodywoodlstein9519 4 жыл бұрын
He’s the fcking best. Love this man.
@Torcher999
@Torcher999 4 жыл бұрын
An absolute tenure.
@tHeplAyiER
@tHeplAyiER 4 жыл бұрын
Indeed! Amazing :D
@bigpickles
@bigpickles 4 жыл бұрын
I don't really understand much of this, but I sure as hell love listening to Professor Brailsford. What a gem.
@FriendlyNeighborhoodNitpicker
@FriendlyNeighborhoodNitpicker 4 жыл бұрын
My favorite part of this is at 4:13- you can feel the assembly and the binary poking up through the C!
@sladflob
@sladflob 4 жыл бұрын
Love the bit about being able to "feel the machine code poking up through C code". Reminds me of my old prof, Jeff Rohl, saying C was really "glorified machine language", with just a tinge of disgust :-)
@richardpratt7114
@richardpratt7114 4 жыл бұрын
Currently taking a class on compiler design and programming paradigms. Your insight into these related topics are so valuable to me. Thank you.
@fslurrehman
@fslurrehman 4 жыл бұрын
I literally feel like I spent huge money to get Visa and got admission in University and now sitting in office of this Professor to learn better. This is the best video series on Computerphile.
@Antiorganizer
@Antiorganizer Жыл бұрын
"I think we just emerged from that with our brains intact..." I think that every compiler developer deserves a nobel prize. The amount of torture is incredible.
@mihallex
@mihallex 4 жыл бұрын
Perfect weekend start with a Professor Brailsford video
@AndersJackson
@AndersJackson 2 жыл бұрын
The language OCaml (H) can produce byte code (I*) and native machine code (B*) in many languages (cross compiler) (B1*) and (B2*)- And it has an virtual machines to run (I*) code. And yes, all written i OCaml.
@woodywoodlstein9519
@woodywoodlstein9519 4 жыл бұрын
Awe please professor Dave, live forever ok ?
@profdaveb6384
@profdaveb6384 4 жыл бұрын
I'll try my best. ... Just keep the supportive comments coming in :-)
@woodywoodlstein9519
@woodywoodlstein9519 4 жыл бұрын
ProfDaveB Lol. Thx Professor Ty for making time for all of these amazing stories and tutorials. I hope you are working on a book. Cheers from Canada. !
@sherlockholmes6849
@sherlockholmes6849 4 жыл бұрын
You are like a Grand Father in CS to me . Hoping that we will get continuous contents like this from you until Natural Rule Applies to you. Love from Bangladesh
@OPENXAIMER
@OPENXAIMER 4 жыл бұрын
Took the Compilers I last Semester. How we were to design the compiler was to have the compiler in "modules" so it had to produce intermediate code then run a routine that would read the intermediate code and it would produce assembly for MIPS architecture. And then if needed we could program another module that would take the intermediate code and translate it on another architecture without changing anything else on the compiler.
@StefanReich
@StefanReich 4 жыл бұрын
Mathematicians use really bad variable names.
@TesterAnimal1
@TesterAnimal1 3 жыл бұрын
The three hardest problems in computing. Naming things, cache invalidation and off by one errors...
@galier2
@galier2 4 жыл бұрын
I think Dr.Brailsford would love to learn how the compilers in the D language work. There are 3 compilers existing DMD, LDC and GDC. DMD is the reference compiler with its frontend written in D generating intermediate syntax trees. The dmd compiler also has a backend, also written in D but quite limited in scope, x86 and limited optimization. ldc and gdc on the other hand are the same dmd frontend, but connected to the more advanced backends of llvm and gcc respectively. So the interesting part is the intermediate representation of the code, which allows to represent the same code for 3 different backends. What's unusual in that arrangment is that some optimisation passes are already done in the frontend (inlining f.ex.) part so that it's the intermediate code that benefits already from some amelioration.
@imacds
@imacds 4 жыл бұрын
I think this would have been easier to follow if the 4 starting programs were labeled, for example with "#1"-"#4" circled in the top, to better distinguish the initial starting written programs from the generated programs. That way the fact that all these other programs are being generated using the starting programs would be clearer and easier to follow, rather than tons of programs coming from nowhere.
@mrflamewars
@mrflamewars 4 жыл бұрын
Professor Brailsford is so nice to listen to. He could babble on reading the US tax code and he would still be soothing.
@Yupppi
@Yupppi 8 ай бұрын
This is the most difficult concept to wrap head around in my humble opinion. I've watched this multiple times trying to figure out how it works to write a compiler in the language you're writing the compiler in. I can kinda process it and I think I understand, but it still always feels like I might be missing something in there. I think it's the T diagrams where the first one of the chain doesn't make sense because it has something as the output that is not part of the process, rather the result of the chain but showing up at the beginning of the process. Like H-H-I* => H-B'-I => H-I-I* makes very little sense to me. I'd describe it as H-B'-I*, or maybe it's supposed to be H-I*-B', or maybe there's so many iterative processes that go back and forth that I just don't build a mental model for it, but perhaps that's wrong and shows what I don't understand about it. Seems like a lot of languages today like to compile to something like C or at least interop with C. Now we have Rust and Zig and others.
@black_platypus
@black_platypus 4 жыл бұрын
Ah man... I love abstraction! It's one of the things that make programming so beautiful! :)
@nikanj
@nikanj 4 жыл бұрын
I you want to watch/rewatch Professor Brailsford's entire series on compilers on Computerphile in order here they are in order: Bootstrapping with T-Diagrams - kzfaq.info/get/bejne/htCVeJtzyJ-aeI0.html Self Compiling Compilers - kzfaq.info/get/bejne/orCWZcxpnNDLdnU.html The UNCOL Problem - kzfaq.info/get/bejne/praPrax7uNaXh3U.html Improving Intermediate Codes - kzfaq.info/get/bejne/is96oZx1m9K-XY0.html
@Computerphile
@Computerphile 4 жыл бұрын
Thanks for this, I will make a playlist >Sean
@iabervon
@iabervon 4 жыл бұрын
It's worth noting that C can be pretty different from machine code, in ways that make it hard to write a direct compiler. If the program is something like "while (x > 0 && f(x, y && g(y)) x--;" the flow control and use of registers is very different from how it looks, especially if you want to notice that "y && g(y)" may not have to be repeated, depending on the definition of g().
@TheBodgybrothers
@TheBodgybrothers 4 жыл бұрын
What a cliff hanger, i want to know how B double dash compiles B dash interpreter to improve the intermediate code that makes better B double dash compiler on B dash.
@zelloxy
@zelloxy 4 жыл бұрын
Love listening to this. As a Systems Architect focusing on high level languages i love going deep like this with architecture and history!
@dipi71
@dipi71 4 жыл бұрын
Before you can compile your compiler-compiler, you first have to compile your compiler-compiler-compiler. Turtles all the way down. Well, almost. Cheers!
@22RH544
@22RH544 4 жыл бұрын
Aside from being one of the most informative sources on the internet he has a good taste of music as well (in my opinion) as demonstrated by the CD on his desk.
@forthrightgambitia1032
@forthrightgambitia1032 4 жыл бұрын
As I understand though Java only does the compilation for code that is frequently run. I understand this is to avoid the cost of compiling code that is rarely used and therefore doesn't affect speed as much as it would take to compile it (JIT compilation). But after seeing this video I am not entirely sure why Java doesn't compile everything before run time instead. Is it because it was originally intended to be run in web applets?
@Jankoekepannekoek
@Jankoekepannekoek 4 жыл бұрын
Portability. Java source programs are compiled into java class files in java bytecode which are still platform-agnostic. Those class files are usually packaged into a 'jar' file (glorified zip file) that can then be run by a Java Virtual Machine. The JVM can decide whether to interpret the bytecode or compile it down to machine code at runtime and then run that generated code - this is the JIT compilation process you were talking about. The java bytecode is the intermediate format - and it can be run on any platform that has a JVM available.
@imacds
@imacds 4 жыл бұрын
Compiling takes a really long time. Even small programs can take many minutes to compile on modern hardware. While it might improve performance a little while running, the cost would all have to be paid up front the first time you run the program on your machine. Imagine having to wait 1-5 minutes for your java program to "compile" the first time you try running it. Additionally, this now fully compiled code is no longer portable, so you have an increased memory footprint as you have to keep the compiled version of the code for any subsequent runs on the machine while also keeping an intermediate code copy as to maintain portability. It increases the complexity in sharing the code: If I want to send you the program, I have to make sure I send you the bytecode not the compiled code by accident otherwise you're out of luck! Any time the code updates even slightly, you will have to dump the compiled code and compile it all over again. I believe there are setting which can make java run this way, but the hassle of it generally outweigh the benefits.
@iabervon
@iabervon 4 жыл бұрын
The main reason is that the JIT compiler can collect profile information on which way your code actually usually goes at each branch from the particular run of the program. This allows it to compile a binary that will run faster on your actual input when there's a trade-off to be made. They wanted to generate the binary on the machine where it would run for portability and optimizing for your particular CPU model, but they could have compiled each program fully the first time you ran it and kept it if they weren't trying to benefit from having information about what you're doing this time.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 4 жыл бұрын
Java bytecode, like Microsoft IL, is primarily designed for interpretation, with compilation more of an afterthought. LLVM is designed for compilation to efficient target code, not interpretation. It is built around SSA specifically for this reason.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 4 жыл бұрын
@@imacds I don’t see that at all. Small programs compile quite quickly on a Linux system. A large program, like Blender (more than a million source lines) I can build in about 10 minutes.
@hakanolausson1367
@hakanolausson1367 4 жыл бұрын
Mr Brailsford you are quite amazing at using your profound knowledge to translate some quite damn complex concepts (for me at least) into something that makes sense. Thank you!
@alterYFritz1
@alterYFritz1 4 жыл бұрын
First of all, good videos! Even though I'm not in the field of computer science I can follow along, but I would like to learn a more about "Creating a compiler" and eventually your own language. Is there a good text book for this/those topic/s one could read?
@tsnp423
@tsnp423 4 жыл бұрын
Yeah, check out the "Red Dragon Book" by Aho and others. Also, if you wanna see the actual process of fully working compiler implementation, thanks watch Bisqwit's videos on you, he is incredible! Also, it's always quite possible to roll down your compiler, just do dig down in Computer Science and Software Engineering, learn some automata theory, various optimization tricks, computer architecture... This journey can be really interesting and you can become a 'natural geek' :) All the best to you.
@joshuahillerup4290
@joshuahillerup4290 4 жыл бұрын
In practice is I* well defined? What I mean is, are there different implementations of I that I have to worry about, where an I* for one implementation is terrible for another?
@iabervon
@iabervon 4 жыл бұрын
Usually I* in practice means that the compiler has noticed things like the program saying days*60*60*24 instead of days*86400, and gone ahead and done that math. It can also come up with special versions of functions that only work if you call them with particular arguments and skip work that isn't needed with those arguments, and swapped those in where they will definitely work. This sort of optimization doesn't depend on the target binary, although it may want to ask the back-end about some trade-offs, like how expensive a function call is.
@joshuahillerup4290
@joshuahillerup4290 4 жыл бұрын
@@iabervon ah, Ok, so mostly stuff that you would do for compiling to any target?
@parrotraiser6541
@parrotraiser6541 4 жыл бұрын
IBM COBOL compilers in the 1960s and '70s used to excrete Assembler as the intermediate code. A Haskell interpreter played an important role in the development of Perl 6. Now Perl 6 compiles itself.
@isabellabihy8631
@isabellabihy8631 4 жыл бұрын
Not only in the 1960s and 1970s, they still do. So do FORTRAN, PL/1 and the latest COBOL compilers.
@parrotraiser6541
@parrotraiser6541 4 жыл бұрын
@@isabellabihy8631 Thanks for the information. (Reading the compiler's Assembler output helped me learn it.)
@Damstraight68
@Damstraight68 4 жыл бұрын
This video has helped me, along with the previous computerphile video on recursion so I will share my thought. We are creating computers which do not run on traditional binary, quantum computers. Therefore, Intermediate code compilers will become the bleeding edge in order to nest quantum and traditional machines together. Moreover, as computing advances past quantum computers, as it surely will, intermediate code will still be needed to therefore nest those machines with the latter. This will create a 4D computational architecture with compilers acting in the 4th dimension, as in, over time. This architecture mirrors our current understanding physics and is therefore possible, probable, and dare I say inevitable. *sidebar* Legacy codes which back date may also be needed; however, this is just a loose end I have been unable to tie thus far.
@Diadras
@Diadras 4 жыл бұрын
Who do amazing people like him that know so much and have experienced so much... Have such a low quality monitor and headphones? Is it really that someone that probably doesnt value picture and sound quality, can be happy with such low quality products?
@OpenKeith
@OpenKeith 4 жыл бұрын
word address machines are better than byte address machines
@Nookerdog777
@Nookerdog777 4 жыл бұрын
Username checks out
@lawrencedoliveiro9104
@lawrencedoliveiro9104 4 жыл бұрын
Consider that byte-addressability was touted as a big advantage back in the days of ASCII and other 7/8-bit character sets. Now that Unicode is becoming pretty much universal, is that still so important?
@pendergastj
@pendergastj 3 жыл бұрын
why?
@tnetroP
@tnetroP 4 жыл бұрын
That Rubik's Cube isn't straight. My OCD is kicking in :)
@fablungo
@fablungo 4 жыл бұрын
Thanks for ruining this video for me 😂 this can't be unseen.
@tnetroP
@tnetroP 4 жыл бұрын
@@fablungo My work here is done :)
@charlescox290
@charlescox290 4 жыл бұрын
Doesn't gcc do this already?
@theantipope4354
@theantipope4354 4 жыл бұрын
Yes. It's how most modern compilers work.
@johnhupperts
@johnhupperts 4 жыл бұрын
I can see why low level programmers would be upset by python hobbyists standing on shoulders of abstraction of abstraction of abstraction
@naaj100
@naaj100 4 жыл бұрын
as a low level programmer, can confirm
@Alche_mist
@Alche_mist 4 жыл бұрын
As a Python hobbyist dabbling into Coconut (even higher level of abstraction - that thing _transpiles to Python_), I see it. But, as a scientist as well, I value the shoulders of giants I stand upon and don't want them to be upset about it - after all, standing on the shoulders of giants is moves humanity forward _with ever-growing speed_.
@Nookerdog777
@Nookerdog777 4 жыл бұрын
Same lol i call them Coders as opposed to programmers as a low key insult haha
@shickster1
@shickster1 4 жыл бұрын
inCeption
@MrGoatflakes
@MrGoatflakes 4 жыл бұрын
I really wonder about the dislikes
@CaptainWumbo
@CaptainWumbo 4 жыл бұрын
This way madness lies.
@procactus9109
@procactus9109 4 жыл бұрын
Its hard to tell if any of this is relevent today.
@theantipope4354
@theantipope4354 4 жыл бұрын
It's 100% relevant today. New high-level languages, new architectures, & new intermediate languages are appearing all the time.
@jpratt8676
@jpratt8676 4 жыл бұрын
No it's not hard to tell at all. Almost all modern compilers use an intermediate language, many even use LLVM (as the professor mentioned).
@lawrencedoliveiro9104
@lawrencedoliveiro9104 4 жыл бұрын
Windows developer, still believing that x86 is the (rapidly-shrinking) centre of the world? Compare an open-source OS like Linux, which runs on every major processor architecture for which GCC can generate code - that’s about two dozen of them at the moment. And userland apps that run under Linux are just as portable. Addition of new architectures hasn’t stopped. Consider the new hotness that is RISC-V. Meanwhile, Windows is still struggling to move off x86 onto ARM ...
@MyAvitech
@MyAvitech 4 жыл бұрын
Hi
@sp3cterproductions
@sp3cterproductions 4 жыл бұрын
Great and you?
@edmondmovsisyan2224
@edmondmovsisyan2224 4 жыл бұрын
i am fine as well
@NoNameAtAll2
@NoNameAtAll2 4 жыл бұрын
hello hello
@sp3cterproductions
@sp3cterproductions 4 жыл бұрын
@@kenkiarie you've never eaten a fantasy? What?
@chaoslab
@chaoslab 4 жыл бұрын
@CraigOverend
@CraigOverend 4 жыл бұрын
^2
@luciojb
@luciojb 4 жыл бұрын
This is root at computer science
@buffmypickles
@buffmypickles 4 жыл бұрын
Who else is going to waste their money with Google's IT support certificate?
Optic Flow Solutions - Computerphile
12:54
Computerphile
Рет қаралды 46 М.
The Art of Code - Dylan Beattie
1:00:49
NDC Conferences
Рет қаралды 4,7 МЛН
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 12 МЛН
女孩妒忌小丑女? #小丑#shorts
00:34
好人小丑
Рет қаралды 43 МЛН
لااا! هذه البرتقالة مزعجة جدًا #قصير
00:15
One More Arabic
Рет қаралды 51 МЛН
Can This Bubble Save My Life? 😱
00:55
Topper Guild
Рет қаралды 61 МЛН
Lamport on the origins of  Paxos
8:03
Turing Awardee Clips
Рет қаралды 4,3 М.
Why It Was Almost Impossible to Make the Blue LED
33:45
Veritasium
Рет қаралды 24 МЛН
SpaceX Finally Adresses Important Starship Catch Problem!
20:37
What about it!?
Рет қаралды 164 М.
Wearable Tech Discussed - Computerphile
10:36
Computerphile
Рет қаралды 32 М.
Has Generative AI Already Peaked? - Computerphile
12:48
Computerphile
Рет қаралды 956 М.
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 12 МЛН