Code vs Data (Metaprogramming) - Computerphile

  Рет қаралды 107,233

Computerphile

Computerphile

Күн бұрын

Why are code and data so separate? Robert Smith of Rigetti Quantum Computing explains how he uses Lisp code to generate Lisp data which he can use as Lisp code...
/ computerphile
/ computer_phile
This video was filmed and edited by Sean Riley.
Computer Science at the University of Nottingham: bit.ly/nottsco...
Computerphile is a sister project to Brady Haran's Numberphile. More at www.bradyharan.com

Пікірлер: 291
@user-zz6fk8bc8u
@user-zz6fk8bc8u 6 жыл бұрын
@2:52: *Reversed reverse Polish Notation* or as sane people would call it... polish notation ;-)
@SouravTechLabs
@SouravTechLabs 6 жыл бұрын
@science no it's at 2:50
@user-zz6fk8bc8u
@user-zz6fk8bc8u 6 жыл бұрын
@Sourav Goswami - Thanks. Fixed it.
@SteveHodge
@SteveHodge 6 жыл бұрын
Or as people who prefer descriptive rather than arbitrary names for things, "prefix notation".
@alanvitullo
@alanvitullo 6 жыл бұрын
Dude, please start a programmer's channel with a LOT more code. These videos are a tease.
@debjyotibiswas3793
@debjyotibiswas3793 6 жыл бұрын
Agreed. Show me some code.
@greenlight2k
@greenlight2k 6 жыл бұрын
If you want more code, check out "The Coding Train" channel ;-) Its... Javascript... but there you go...
@TheCandyDragon
@TheCandyDragon 6 жыл бұрын
aah, that channel is so fun
@debjyotibiswas3793
@debjyotibiswas3793 6 жыл бұрын
Yes Daniel Shiffman is very cool. But hate JS are there any other channels which are not JS.
@debjyotibiswas3793
@debjyotibiswas3793 6 жыл бұрын
Yes and JS is very easy to understand. The problem arises when JS is used interchangeably with node and starts doing weird things.
@ninjalacoon
@ninjalacoon 6 жыл бұрын
Linear algebra has this same kind of duality between data and function. A matrix is just a collection of data in most cases but when you multiply a matrix by some other matrix or a vector the matrix acts as a transform or a "function/code" on the data that passes through it. A change of basis is a transform matrix that acts as a function while at the same time could be further transformed by rotations and scaling matrices and act again as just data.
@Luredreier
@Luredreier 5 жыл бұрын
Think of meta programming as inventing something new like multiplication or even pluss in math prior to those things being invented. Or any other new concept. For instance, there was a time when no one had invented zero. Math at the time had to be done with numbers with a value since there was no zero. In a programming language with metaprogramming you can invent such a new concept as zero, define it and use it instead of defining it every single time you need to use the concept.
@Evan490BC
@Evan490BC 4 жыл бұрын
Well, almost. A matrix is a *representation* of an operator relative to the given basis.
@pablo_brianese
@pablo_brianese 3 жыл бұрын
Love this comment
@OverThinkKS
@OverThinkKS 2 жыл бұрын
Please learn about geometry algebra
@ToveriJuri
@ToveriJuri 2 ай бұрын
@@OverThinkKS Linear algebra taught me to like math
@tsunaminoai
@tsunaminoai 6 жыл бұрын
"So could you give us an example?" "Oh sure, definitely. So lets say you wanted to draw an owl. First you just draw some circles. Right? Then you draw the rest of the owl, which I wont do here because its obvious."
@qwertyman1511
@qwertyman1511 6 жыл бұрын
as i understand it: first, a function is a set of instructions. second, we can create data during runtime. third, we can interpret data as instructions. fourth, we can run interpreted data as a function. you created code at run time. the program wrote parts of itself.
@cj37373
@cj37373 6 жыл бұрын
Andrew McAuliffe you can base code on input from the user if you desire so
@ElagabalusRex
@ElagabalusRex 6 жыл бұрын
The way he described it, metaprogramming is the same as creating a library, which doesn't sound right.
@quadricode
@quadricode 6 жыл бұрын
ElagabalusRex you can create libraries of syntactic abstractions. That’s part of the point. :)
@quadricode
@quadricode 6 жыл бұрын
Kris2510 great, written out example!
@sweetspotendurance
@sweetspotendurance 6 жыл бұрын
I love listening to this guy talk, I don't know why
@jaymalby
@jaymalby 6 жыл бұрын
Really nice broad pass over metaprogramming 👍
@ArumesYT
@ArumesYT 6 жыл бұрын
This duality between data and code is much more common than most people think. One very simple example: most of us view a .c file as code. But to the compiler, it's data.
@Roxor128
@Roxor128 6 жыл бұрын
Exactly. The very existence of compilers and interpreters relies on that duality.
@davidwuhrer6704
@davidwuhrer6704 6 жыл бұрын
But can a C program evaluate, change, compile, and assemble it's own data at runtime?
@-notakil
@-notakil 6 жыл бұрын
I want more from Robert Smith. This guy is good.
@emilemil1
@emilemil1 6 жыл бұрын
To me that for-loop example seems very similar to defining a function that takes other functions as its arguments, though perhaps with a nicer syntax. Would love some more in-depth examples.
@marios1861
@marios1861 5 жыл бұрын
the for loop takes a variable name, the starting value, the ending value, the increment and the body of code to be executed with each iteration. Can you make a function that you give as input a body of code? Can you bend the syntax of the language you use in any way you see fit?
@albertosimeoni7215
@albertosimeoni7215 2 жыл бұрын
Is the standard C++ loop... The right example in C++ for metaprogramming are Virtual classes / methods
@KnownNever
@KnownNever 6 жыл бұрын
Am I correct to say that Lisp as he describes it is better off for math problems while C is better off for dealing with memory... cause that makes scenes why you would rather use Lisp over C for something like Quantum problems as stated in last video
@vyrsh0
@vyrsh0 6 ай бұрын
All abstract problems, while C is better for memory as you said
@scottfranco1962
@scottfranco1962 6 жыл бұрын
"reverse RPN" is not Reverse Reverse PN, it is just PN. Polish notation is like + 1 2 or add 1 and 2, RPN is 1 2 +. Polish notation was specifically prefix notation, which was considered more natural than 1+2 because you can write +1 * 2 3 to mean 1+(2*3), and indeed, this is a common notation used in compiler intermediate codes. However, RPN is considered even more natural than this because 2 3* 1+ exactly expresses operands and the operators that use them in proper order. Thus get 2, get 3, multiply, then get 1, and then add to the result of 2*3. It also is stack machine friendly. If there never were such a thing as polish notation, I'd agree that reverse RPN makes sense, but polish notation was a thing before RPN.
@Roxor128
@Roxor128 6 жыл бұрын
Oh, dear. The comment-formatting system has gotten tripped up by your example and parsed the asterisks for multiplication as instructions to make the text bold.
@scottfranco1962
@scottfranco1962 6 жыл бұрын
Thanks! Fixed it.
@Roxor128
@Roxor128 6 жыл бұрын
I really wish they'd just use a subset of HTML or pseudo-HTML for the formatting. These errors would be so much less likely.
@brianbarefootburns3521
@brianbarefootburns3521 6 жыл бұрын
Would be interesting to see a clarification of how this topic compares to compilers in general -- because, of course, compilers are programs that write programs. I was waiting for the comparison and distinction to be made in this video, but it never happened.
@vicplichota
@vicplichota 6 жыл бұрын
Forth is another wonderful language that still stands the test of time. This vid mentions Postscript, which is very much a variant of Forth.
@grivar
@grivar 6 жыл бұрын
Duality: Tom Scott or John Green?
@jaymalby
@jaymalby 6 жыл бұрын
RE now I can’t unsee it 😂
@AlterMacGyver
@AlterMacGyver 6 жыл бұрын
Trick question, Griffin McElroy
@taba1950
@taba1950 6 жыл бұрын
Arguably better than both
@mal2ksc
@mal2ksc 6 жыл бұрын
Tom Green.
@grivar
@grivar 6 жыл бұрын
Or is is John Scott?
@Majorohminus
@Majorohminus 6 жыл бұрын
I'd love to see someone debug a metaprogram that contains thousands of lines of business logic :)
@albertosimeoni7215
@albertosimeoni7215 2 жыл бұрын
During my job in a company i find a procedure that was modified costantly in 4 years ( a T-SQL store procedure) that has around 3000 rows with some part of code that write code that was executed... It takes about 1 week to under stand it...and about 1 time over 2 month it need to be modified...The source of this madness is called SAP
@Alsteraib985
@Alsteraib985 6 ай бұрын
A lot better than the Java mess.
@juancarlosgallegos3902
@juancarlosgallegos3902 6 жыл бұрын
I did not really understand this, he seems to be skipping some important details in his explanation?
@maestbobo
@maestbobo 4 жыл бұрын
I mean, it's obvious what he's saying. I don't understand what you're finding difficult about it.
@ZeedijkMike
@ZeedijkMike 6 жыл бұрын
I'm getting all warm and fuzzy when I see the _LISP_ syntax. Brings back good memories from when I used it with AutoCAD.
@LuizBGomide
@LuizBGomide 6 жыл бұрын
How different is that from ANY other interpreter? Or writing instructions directly to memory updating code on fly?
@TakanashiYuuji
@TakanashiYuuji 6 жыл бұрын
It's not. Most languages have some kind of 'eval' feature.
@heller166
@heller166 6 жыл бұрын
yeah i also don't understand what is so special about it.
@AMcAFaves
@AMcAFaves 6 жыл бұрын
It is a more abstracted way to modify code. You are modifying the code at an Abstract Syntax Tree level. (And with abstraction can come more power.)
@cmckain13
@cmckain13 6 жыл бұрын
TakanashiYuuji 0ⁿ
@nitowa
@nitowa 6 жыл бұрын
The special part is, that the program doesn't have to be recompiled by the programmer to introduce new features, formally this is called "at runtime". Simply speaking your program is conjuring itself while it's running, and doesn't come with all the necessary code (as defnined in the video) but instead it has the data necessary to create the code. A popular counterexample would be C, which requires you to compile it for the given architecture before executing it. C cannot add (for example) a function that was passed from the keyboard as C-code, despite being valid C code, and it cannot be executed at runtime. If you're looking for an "interpreted" language, you might find Java to be a suitable example (I know it's technically compiled, but it's also interpreted at the same time, so there's that). Although Java may modify the JVM runtime however it likes, changing the functionality of a method/function is prohibited, which severely limits its at-runtime capabilities (in practice it's possible but produces very patternized code and complex structures)
@APSStevens
@APSStevens 6 жыл бұрын
I will remain indebted for sparking my interest in Lisp.
@safirswe
@safirswe 3 жыл бұрын
I want to look at the video teased at the end, "fighting obsolescence", but can't find it anywhere. Anyone got a link?
@BeastinlosersHD
@BeastinlosersHD 6 жыл бұрын
How is the for loop example (and how it is an example of metaprogramming if a for loop didnt originally exist in the syntax) different from inline functions or #define
@udxs6782
@udxs6782 6 жыл бұрын
Isn't RRPN just Polish Notation?
@aDifferentJT
@aDifferentJT 6 жыл бұрын
2:53 normally called Forward Polish Notation
@defense200x
@defense200x 6 жыл бұрын
This is a rather confusing example of the usage of Metaprogramming
@quadricode
@quadricode 6 жыл бұрын
Unusual Activities you didn’t have for loops before, now you do. Is it confusing because everybody already has them? Maybe a better example would be: Imagine you wanted to specify logical constraints a la prolog. You can use metaprogramming to add such a facility to your program. But that means you’d have to explain what prolog is...
@webgpu
@webgpu 6 жыл бұрын
that's what you get when you assign that "confusing" guy to present this video..
@defense200x
@defense200x 6 жыл бұрын
I mean, I get it, actually I would to turn data into code for a project I'm currently working on but the language im working in (C++) won't let me :p
@zacharymetz9975
@zacharymetz9975 6 жыл бұрын
you could implement a scripting language then you could execute instruction that were created
@greenlight2k
@greenlight2k 6 жыл бұрын
Hmmm... can i think about this similar to Lambda-Expression in C# or Java? Which, like... IS program code at compile time and BECOMES data at runtime? Or, is that too far fetched? ^^
@jakejakeboom
@jakejakeboom 6 жыл бұрын
A lambda expression is a functional concept so yes, that's somewhat similar.
@kwanarchive
@kwanarchive 6 жыл бұрын
The comparison breaks down when you try to pick apart the lambda-expression - which you can't do in C# or Java. You can create a lambda, but you can't pull it apart and pick bits and pieces out of it. With metaprogramming, you would be able to compose functions together, and then later on, pick them apart and, say, recompose the functions in a different way based on some conditions for optimization. C# and Java have no way to do this.
@shanehebert396
@shanehebert396 6 жыл бұрын
Currying using lambdas is an example of how to achieve some of what the video talks about.
@Luredreier
@Luredreier 5 жыл бұрын
You can then get data that becomes code at runtime too...
@RoGeorgeRoGeorge
@RoGeorgeRoGeorge 6 жыл бұрын
Where's the rest?
@acharris
@acharris 5 жыл бұрын
Is it possible to get similar meta programming capabilities in languages other than lisp? IE are there other programming languages that can do similar meta programming?
@rafeu2288
@rafeu2288 2 жыл бұрын
Rust lang is another language with a somewhat powerful macro system. But it seems Homoiconicity is one of the qualities that make meta-programming easier to implement.
@glowingone1774
@glowingone1774 Жыл бұрын
Nim, im not sure about "rust" but people have built whole DSL's with it in nim.
@laughingvampire7555
@laughingvampire7555 27 күн бұрын
this idea that has been championed by lisp was how the original Assembly programmers did the code, they wrote Assembly to write Assembly because RAM was very expensive in the past. However when computers started to get cheaper, then people started to get lazy and try to achieve the dream of a programming language that looks like English.
@CypressPunk34
@CypressPunk34 6 жыл бұрын
wouldnt reversed reverse polish notation just be polish notation?
@davidwuhrer6704
@davidwuhrer6704 6 жыл бұрын
Yes.
@AB-Prince
@AB-Prince 6 жыл бұрын
Could you do a video on how to group logic gates to acomplish complex actions, such as multiplication, division, and converting binary to different two exponent bases
@davidwuhrer6704
@davidwuhrer6704 6 жыл бұрын
I think they already did, using domino bricks.
@rafeu2288
@rafeu2288 2 жыл бұрын
I would recommend you check the video game "Turing Complete" on steam, it goes there and beyond, allowing you to learn how to implement a full 8-bit Harvard Style computer.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 6 жыл бұрын
5:37 Assuming the increment of i lies at the bottom of that squiggle somewhere ... otherwise you’ve just written an endless loop.
@umblapag
@umblapag 6 жыл бұрын
Interesting to learn a bit about lisp
@rkpetry
@rkpetry 6 жыл бұрын
*_...but tight code is used repeatedly-on scads of data; (Amer. scads, Brit. jillions)..._* *_...on the other hand, the similarity shows in loop parameters, i++, list descriptors,..._* *_...((in the control/addressing variables-but not, in the data itself/results per se))..._*
@adamlanghans
@adamlanghans 5 жыл бұрын
It doesn't seem like Robert Smith understands what he is saying. There wasn't much of an explanation here.
@donotsellmydata2089
@donotsellmydata2089 4 жыл бұрын
To iterate is imperative and to recuse is functional?
@BeCurieUs
@BeCurieUs 6 жыл бұрын
Hmmm still not getting it, I hope there are more of these.
@CaptainJeoy
@CaptainJeoy 4 жыл бұрын
It's just a method of abstracting useful functions as an evaluable data
@inomo
@inomo 3 жыл бұрын
@Computerphile can we have a video about the Julia programming language?
@habtamuassegahegn4283
@habtamuassegahegn4283 5 жыл бұрын
hey phile can you explain exactly about symbolic data from the book structure and interpration of computer program
@daniellindner355
@daniellindner355 5 жыл бұрын
is all of this related to code? like Metaprogramming and/or Software defined Networking? Where can i learn these things? Are they being taught in Computer Science?
@noxabellus
@noxabellus 6 жыл бұрын
I would just like to suggest to anyone that is interested in this, check out terra lang :) It's basically a scriptable compiler and deserves more love
@Eichro
@Eichro 6 жыл бұрын
I'm assuming that in Lispland eval isn't evil?
@surabax
@surabax 6 жыл бұрын
You don't use eval directly in Lispland, you define macros instead.
@capoiosct
@capoiosct 6 жыл бұрын
nim-lang.org can do that and its procedural.
@AMcAFaves
@AMcAFaves 6 жыл бұрын
capoiosct If that is the case, then nim wouldn't just be procedural, it would be multi-paradigm, because then you could just write macros to add OOP, functional or any other paradigm functionality to the language. :-)
@ProjektRakete
@ProjektRakete 7 ай бұрын
Is this the latest "Programmers are also human" video?
@lawrencedoliveiro9104
@lawrencedoliveiro9104 6 жыл бұрын
Von Neumann understood this perfectly well. The only ones who have forgotten tend to use languages like Java or C#. Oh, and PHP.
@GreyDeathVaccine
@GreyDeathVaccine Жыл бұрын
Don't be a hater. Use the best tool to solve problem at hand.
@chpsilva
@chpsilva Жыл бұрын
​@@GreyDeathVaccine couldn't have said better
@dickjohnson4447
@dickjohnson4447 6 жыл бұрын
5:37 this is what you had to write to iterate ten times, yes but in assembly you could: times 10 instr instr (some instruction you want to do 10 times)
@zacharymetz9975
@zacharymetz9975 6 жыл бұрын
Whats the difference between lisp and a langue where i can run the eval() from javascript?
@cobblebrick
@cobblebrick 3 жыл бұрын
Aren't compilers in general an implementation of metaprogramming?
@simplylinn
@simplylinn 6 жыл бұрын
That "assembly" for the for-loop is not actually that correct. The evaluation of the repeat condition is actually made before you enter the loop in a standard for-loop. What he wrote down is more akin to a do-while loop, which runs trough the loop once unconditionally, and then repeats if the condition evaluates to true. Actually, it's a bit of a hybrid, because he set the iteration-variable at the top, and is still using an iteration variable.
@hikaruyoroi
@hikaruyoroi 6 жыл бұрын
I really like this guy
@tacchinotacchi
@tacchinotacchi 6 жыл бұрын
I'm not sure where he is going with this. So, you're not happy with the tools a language give you such as for loops. So, do you want to be able to make your code flow in whatever fashion you want? Use labels on C. Yes, it will be considered spaghetti code, because it is. Also a c source file IS data, although stored less efficiently. So is Java code, and so is Java bytecode and assembly. A smart enough program could write programs in any of these languages. The difference is that some are readable, and some aren't. Judge for yourself which are.
@Luredreier
@Luredreier 5 жыл бұрын
It's not about not being happy about for loopes. It's about being able to *implement* for loops on the fly in a language where it doesn't exist already. Or any other feature for that matter. If you can come up with a new consept you can implement it and use user input as a part of the implementation if desired. You can change the code itself based on user input. And sure, you can write a program that can write code for its own code. However what about writing a program that can write the code used to run itself during the runtime? Regarding the spagetti code argument. Yes, partially. But it doesn't have to be.
@NikiHerl
@NikiHerl 6 жыл бұрын
Please try to get the interviewees to explain their subjects more concretely (i.e. with code samples)
@RealCaptainAwesome
@RealCaptainAwesome 6 жыл бұрын
I had a guy demo lisp for me yesterday for the first time, now it is everywhere.
@YourMJK
@YourMJK 6 жыл бұрын
Can't you also create assembler code in a C program and then execute it? Isn't that the same?
@kwanarchive
@kwanarchive 6 жыл бұрын
You can't take the generated code and make it into data again within the language. You'd have to disassemble the generated code, recreate the C from it (which is hard due to optimizations) and somehow make it recompilable. The other way is for your C program to create a miniature VM to interpret byte code your program creates, but that, again, takes you out of the language.
@MasthaX
@MasthaX 6 жыл бұрын
Isn't it true most programming languages have an eval function where you could pass data (string, var, number, etc) to be evaluated and executed?
@notnullnotvoid
@notnullnotvoid 6 жыл бұрын
Only some scripting languages have this, and compiled languages generally can't. Eval also usually operates on program text, rather than directly on a generated AST.
@piotrz3403
@piotrz3403 6 жыл бұрын
reverse reverse polish notation = polish notation
@bimbumbamdolievori
@bimbumbamdolievori 3 жыл бұрын
A very powerful tool which I lost control over on day 2🤣🤣🤣now i kinda see where the elixir quote comes from...
@Mike-qt4fr
@Mike-qt4fr 6 жыл бұрын
Love this man!
@SteinCodes
@SteinCodes 6 жыл бұрын
So Macros are also a type of MetaProgramming?? right!
@NiDeCo
@NiDeCo 6 жыл бұрын
Haskell doesn't have for-loops though :P It uses recursion, it being functional and all.
@liln4444
@liln4444 6 жыл бұрын
Shout out Julia
@m.h.6470
@m.h.6470 6 жыл бұрын
so its like the eval function in javascript and php which have been around for ages... and are generally considered as "dangerous", especially if you use it with user input.
@malusmundus-9605
@malusmundus-9605 2 жыл бұрын
Anytime you handle data from an unknown source it's dangerous... you have to predict what might come and handle it.
@m.h.6470
@m.h.6470 2 жыл бұрын
@@malusmundus-9605 and therein lies the hubris... unless you restrict the data, you can't possibly predict everything and handle it - especially with user input. A hacker can use these weak points to execute code without your knowledge and gain access to systems or data.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 6 жыл бұрын
Code is just data to a lower-level processor. What is the lowest-level processor? Is it the laws of physics?
@esobrev
@esobrev 9 ай бұрын
i feel bad for the computer scientists who worked on programs writing programs like this. because their way was the much more elegant, much more beautiful and pragmatic approach to programs that write programs. but instead we just went with this huge mess we call GPT-3 and language models. now nobody cares about this stuff even though it’s some of the coolest programming science out there.
@BitcoinJake09
@BitcoinJake09 6 жыл бұрын
I remember programming in QBasic with subs and things like be for learning java and functions :p
@abdulrahmanalzeidi3811
@abdulrahmanalzeidi3811 6 жыл бұрын
this is somewhat similar to templates in c++ no?
@jaymalby
@jaymalby 6 жыл бұрын
guild man similar- C++ templates generate code for you, but in very rigid and structured ways and you write the templates in a special templating language instead of using C++ code to manipulate other C++ code directly as a data-structure.
@punkkap
@punkkap 2 жыл бұрын
>Is there a simple example of that?
@esobrev
@esobrev 9 ай бұрын
he literally gave an example
@Fiercesoulking
@Fiercesoulking 6 жыл бұрын
So wrong what he shows as data is for all I know already code , data refers to the values of the datatypes(he refers to them as data)
@diegonayalazo
@diegonayalazo 2 жыл бұрын
Thanks
@NitinSethi22
@NitinSethi22 6 жыл бұрын
Beautiful
@user255
@user255 6 жыл бұрын
Any actually useful real world examples of these features?? To me it seems the core idea of Lisp is now obsolete.
@soufta5872
@soufta5872 8 ай бұрын
Actually, everything is data (even machine code is made of "data").
@procactus9109
@procactus9109 6 жыл бұрын
Subroutines don't count ?
@quadricode
@quadricode 6 жыл бұрын
ProCactus you can’t make a for-loop subroutine for example. Subroutines are a great type of abstraction, but they don’t allow you to introduce new *syntax*.
@procactus9109
@procactus9109 6 жыл бұрын
I can with an index and an if.
@noyb154
@noyb154 6 жыл бұрын
data is to code what information is to knowledge
@damejelyas
@damejelyas 6 жыл бұрын
Write programs that can write programs he means create a language and use it
@Wizball
@Wizball 6 жыл бұрын
A bit retro to use dot matrix paper ;)
@DavidBadilloMusic
@DavidBadilloMusic 6 жыл бұрын
Isn't this metaprogramming sort of what High-Level programming languages are?
@FinaISpartan
@FinaISpartan 6 жыл бұрын
How is this any different from C's #define?
@gracicot42
@gracicot42 6 жыл бұрын
Final Spartan you cannot have instructions that write defines and you cannot then generate code that are using those defines. Macros are expanded before even compilation starts. Templates in C++ are a bit closer to what is shown in this video, since you can manipulate types and their structure as data and output new types. For example, I have a function that takes a lambda as parameter (a lambda is simultaneously a type and it's instance) and that function returns a new lambda with slightly different parameters.
@HrHaakon
@HrHaakon 6 жыл бұрын
#DEFINE gives you text substitutions. defmacro let you tell the compiler what you want done with something. You can tell it how JSON works and from then onwards, you can give your compiler JSON and it will give you an object back out.
@marceloconceicao2587
@marceloconceicao2587 6 жыл бұрын
#define is VERY limited on what it can do. You cannot, for instance, change/create a #define based on user input because #defines are preprocessors (They are evaluated at compile time (even before that, actually)) And even regular programming is very hard to do with defines. Try to pass a macro as a parameter to another macro . Spoliers: You can't. The preprocessor definitions are evaluated only once
@MidnightSt
@MidnightSt 6 жыл бұрын
how is this different from #define ? ...completely. define is basically a shortcut/automation of string search and replace. what he's talking about in the video is basically programmaticaly building expression trees (code as data), which you can then execute by traversing them.
@PetrSojnek
@PetrSojnek 6 жыл бұрын
The better example would be function like printf. You fill in parameters that will tell you what you do with other parameters. Essentially the "format string" is data that defines procedure to be applied on the rest of data.
@dannygjk
@dannygjk 6 жыл бұрын
I think it's meaningless to say that before high level languages For... did not exist. The only way that makes sense is to say that literally it didn't exist. Which is also meaningless really because conceptually it doesn't matter which language you use to implement the idea it is conceptually the same thing.
@samsharma8621
@samsharma8621 6 жыл бұрын
Wheres mike pound
@WarZzed300
@WarZzed300 5 жыл бұрын
You can also directly obfuscate your code for exemple, turning it into base64 data and create "eval" function that decode and read it. So powerful !
@chenzhuoyu1992
@chenzhuoyu1992 6 жыл бұрын
Arbitrary code execution built into the language itself
@quadricode
@quadricode 6 жыл бұрын
Zhuoyu Chen everything is determined at compile time, unless you use EVAL yourself at runtime.
@jamma246
@jamma246 6 жыл бұрын
I don't feel like I understood the point from the video. It just seems like a really ad hoc way of doing functional programming.
@p.kay_____
@p.kay_____ 3 жыл бұрын
Woah woah woah
@desmondwilson3416
@desmondwilson3416 2 жыл бұрын
x is not defined...
@lawrencedoliveiro9104
@lawrencedoliveiro9104 6 жыл бұрын
4:16 But watch out for the security implications of this, if the code you generate was based on input from a potentially malicious user. Unfortunately, I think this is the fatal flaw in the whole concept. This is why it is better to build your own interpreter on top of the base language -- as you could, for example, in Python -- and then generate code for this interpreter from the data. That way you get more control over what exactly the code can do.
@stoneskull
@stoneskull 6 жыл бұрын
i don't think you even need to build an interpreter.. there's plenty of meta-programming ability in python..or even using text files that can be manipulated having code in them and can be imported in..
@franzlyonheart4362
@franzlyonheart4362 3 жыл бұрын
0:12 what
@UltimatePerfection
@UltimatePerfection 6 жыл бұрын
Really, did we need this video? To a computer there's really no difference between data and code. That's why old consoles under certain conditions execute data as code or use code as data (usually with an awful result, see Pokemon's Glitch City for an example or Missingno, really)
@quadricode
@quadricode 6 жыл бұрын
QVear Very rarely is “programs as data” a paradigm exploited in most popular computer languages.
@rodbhar6522
@rodbhar6522 6 жыл бұрын
Lisp looks like an overly complex version of Forth
@Pax_Veritas
@Pax_Veritas 6 жыл бұрын
yep, mmhmmm, mmhmmm, yep, yea, mmhmm, yes
@JohnsonLobster
@JohnsonLobster 6 жыл бұрын
Damn that's a sibilant voice...
@joyalmathew2156
@joyalmathew2156 6 жыл бұрын
Did this guy bump his forehead?
@brotherfiretribe9566
@brotherfiretribe9566 2 жыл бұрын
What happened to this buddy's forehead
@nateshrager512
@nateshrager512 6 жыл бұрын
LISP: Lots of Irritating Strings of Parentheses
@hereb4theend
@hereb4theend 5 жыл бұрын
Large Insect Sucking People
@darthnihiluz5305
@darthnihiluz5305 6 жыл бұрын
evals have never lead to bad things
@tusharkuntawar6170
@tusharkuntawar6170 2 жыл бұрын
(No offence) non-chad tom scott here
@frankfahrenheit9537
@frankfahrenheit9537 6 жыл бұрын
So you can use this stuff to extend the language? Add "for loops" ? What a great example. Actually nobody needs "for" loops if you have an "if" and a "goto " and an integer variable. After compilation, a for loop as any other fancy construct is converted to "gotos" at machine level.
@DusteDdekay
@DusteDdekay 6 жыл бұрын
Actually nobody needs if and variables if you have an ldx, a dex and bne, but then again, nobody needs mnemonics if they just cared to remember their opcodes like proper men :D
@jellyboy00
@jellyboy00 6 жыл бұрын
It sounds very dangerous in terms of computer security XD
@jellyboy00
@jellyboy00 6 жыл бұрын
Well, I had tried to use php object to generate javascript for AJAX and use the same object to do SQL query the AJAX request in php. I kind of understand what he is talking about.
@quadricode
@quadricode 6 жыл бұрын
It’s not at all dangerous. It’s not like using eval() in JavaScript.
@bopstarsstuff970
@bopstarsstuff970 6 жыл бұрын
good video
@un2mensch
@un2mensch 6 жыл бұрын
That reminds me, I'm actually seeing The Cure in July
@judgeomega
@judgeomega 6 жыл бұрын
reflection
Quantum Instruction Set - Computerphile
19:05
Computerphile
Рет қаралды 207 М.
Optimising Code - Computerphile
19:43
Computerphile
Рет қаралды 147 М.
WORLD BEST MAGIC SECRETS
00:50
MasomkaMagic
Рет қаралды 53 МЛН
Man Mocks Wife's Exercise Routine, Faces Embarrassment at Work #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 5 МЛН
А ВЫ ЛЮБИТЕ ШКОЛУ?? #shorts
00:20
Паша Осадчий
Рет қаралды 9 МЛН
Machine Code Explained - Computerphile
20:32
Computerphile
Рет қаралды 118 М.
Lambda Calculus - Computerphile
12:40
Computerphile
Рет қаралды 1 МЛН
What is a Monad? - Computerphile
21:50
Computerphile
Рет қаралды 603 М.
Python Hash Sets Explained & Demonstrated - Computerphile
18:39
Computerphile
Рет қаралды 117 М.
The Rise & Fall of LISP - Too Good For The Rest Of the World
17:44
Gavin Freeborn
Рет қаралды 40 М.
Essentials: Pointer Power! - Computerphile
20:00
Computerphile
Рет қаралды 464 М.
Metaprogramming and JIT Compilers - A Brief Overview
15:59
VoxelRifts
Рет қаралды 26 М.
Why LISP Is The Language of Legends
9:05
Sammy Engineering
Рет қаралды 34 М.
Multithreading Code - Computerphile
15:54
Computerphile
Рет қаралды 385 М.
Why You Should Learn Lisp In 2024
21:50
Gavin Freeborn
Рет қаралды 65 М.