Hi. You wondered about the difference between "stack based" and "concatenative". "Concatenative" refers to how the composition of functions is achieved. Consider two functions, f(x) and g(x). To compute g of f of x in say Python we would write g(f(x)). In say Haskell we can use the composition operator "." and write g.f x (note - I'm not a Haskell expert, I googled "function composition in Haskell" so I /hope/ this is correct.) If we make composition the default operation (i.e. it doesn't have an operator, much as in mathematics the default operation is multiplication, so ab implies a multiplied by b) then we get Polish notation - g f x - and read it from right to left "take x, apply f to it, apply g to the result". Flipping that around, we get Reverse Polish notation, which reads from left to right. x f g is "take x, apply f to it, apply g to the result" and this is characteristic of concatenative languages. It is NOT necessary to use a stack to achieve this. Graph reduction or term rewriting also works. So "stack based" describes the implementation method for a concatenative language.
I love this series as an amateur python programmer. I wish there was a class like this at university, where maybe the professor codes the interpreter + compiler in front of the class, they make some decisions together, and some parts (additional operations, etc.) can be homework assignments and the students can do pull requests with their solutions.
@@gusic4529 and what? With enough learning and time he should be capable of doing. Plenty of resources for free to learn, its a matter of taking the time
@@homelikebrick42 he mentioned that the while keyword serves to mark the retern point for the loop right? meaning there should be some jmp assembly instruction. maybe its too complicated to worry about at the moment but once porth is self hosted it might be worth looking into
I never thought I’d watch this much python content, but I can’t get enough of porth, I can’t wait for the next one. Glad to see you dropped the chat overlay. It’s distracting to see side conversation .
Absolutely loving this series Would it be useful for macros to define the types they expect on the stack? That way before a macro is expanded you can throw a compiler error like when you call intrinsics with the wrong arguments on the stack. As this language matures I can see there being a lot of macro usage and making these as powerful and easy to debug as possible would be useful Keep it up Tsoding!
forth automatically prints ."" which would be a nice idea. For null terminated strings you could add a 0 a the end of the string literal like: ""0 or any value for that matter, followed by more string literals, like: ""27"[1;32m"27"[1m"
just noticed that there is very very very quiet music in the bg lmao any particular reason for not showing stream chat? you reference them several times here and, though you repeat their questions for us to know what you're talking abt, i think it'd be nice to actually see the chat. i dunno maybe ill just have to pop in live from now on lol
C has two macros: '__FILE__' and '__LINE__' they use double underscores because 1. its UB to define double underscore variables and 2. its unlikely you will ever define a variable exactly like this. So i suggest you change here to __LOCATION__ or something similar.
Just started tuning in. I subbed when i seen you made a Forth! Bloody incredible language. Did you have a look at Factor before you started, would be great if someone picked up the reins on that project.
Where are you from? I don't think you speak Portuguese, but the word you say at 5:26 as a confirmation is actually something you coukd use in Portuguese, so it got me curious
Concatenative programming vs. not = "does function call require surrounding arguments in braces". Stack-Oriented programming is a paradigm where function calls are expressed with Reverse Polish Notation. I think Groovy is a good example of support for concatenative programming (and enforcing it) while being neither a stack-oriented nor a functional programming language. Stack-Oriented programming implies concatenative programming if it's not limited to one instruction per line like assembly.
Can u please make a videou about llvm, and why some guys (brazilians high ego dev streamers) says that is the **only** way to build a interpreter/compiler on top of a high level language? kinda fun cause u literally didn't use in this series
LLVM allows for compiling for many platforms. Unless one is targeting a VM bytecode like JVM, for production grade cross-platform compilers, LLVM is a must. LLVM has its own intermediate language that your compiler can generate. LLVM can compile or make a JIT compiler for you from there. It is NOT absolutely needed. Tsoding doesn't care if Porth is portable.
A much better implementation of elseif is the on you already have were a second if in the else condition doesn't need to be closed by an end. like the syntax you already have: if else if else if end Note: the single 'end' at the end.
puts actually puts a newline automatically at the end of each string! I highly recommend looking at the musl libc implementation as it is much cleaner than the glibc implementation.
Tscoding, you know several programming languages. If you had to choose a single language to use what would it be? What is your favorite programming language?
Or the convention for such checks to be false (0) or not false. Keeping the false and true to specific values. Do you think those values should be 1 and 0, or -1 and 0?
Hey, as soon as you implement a porth compiler in porth you can just implement it in the porth based compiler. The python based compiler isnt necessary anymore once you have a working porth based compiler
You first have to write it in another language, and then you can write porth programs. Then you rewrite your compiler in porth, use your first compiler to compile that, and then only use your ports compiler from then on. The whole process is called bootstrapping and a lot of modern programming languages do it.
@@janekk_ Oftentimes (not always) you're creating a programming language because it's closer to your ideal language than the existing ones.. so you might enjoy developing the compiler further in this better(?) language.. Also, like Netscape Plugin said, it's a good non-trivial test of the compiler but also dogfooding of your new language.. how does it feel to develop in it.
Ohh you could just write a shell script that sends the file content to std input of porth and saves the output to an asm file and runs nasm and the linker. This is why we have pipes and redirects in *nix systems.
Hi. You wondered about the difference between "stack based" and "concatenative".
"Concatenative" refers to how the composition of functions is achieved. Consider two functions, f(x) and g(x). To compute g of f of x in say Python we would write g(f(x)). In say Haskell we can use the composition operator "." and write g.f x (note - I'm not a Haskell expert, I googled "function composition in Haskell" so I /hope/ this is correct.)
If we make composition the default operation (i.e. it doesn't have an operator, much as in mathematics the default operation is multiplication, so ab implies a multiplied by b) then we get Polish notation - g f x - and read it from right to left "take x, apply f to it, apply g to the result". Flipping that around, we get Reverse Polish notation, which reads from left to right. x f g is "take x, apply f to it, apply g to the result" and this is characteristic of concatenative languages.
It is NOT necessary to use a stack to achieve this. Graph reduction or term rewriting also works. So "stack based" describes the implementation method for a concatenative language.
> and write g.f x
Need parens around g.f, so: (g . f) x
I love this series as an amateur python programmer.
I wish there was a class like this at university, where maybe the professor codes the interpreter + compiler in front of the class, they make some decisions together, and some parts (additional operations, etc.) can be homework assignments and the students can do pull requests with their solutions.
why dont you make it yourself lol
@@jordixboythey literally said they were an amateur
@@gusic4529 and what? With enough learning and time he should be capable of doing. Plenty of resources for free to learn, its a matter of taking the time
@@gusic4529We can't save everyone's brain cells 😅
This is the definition of "Hm yes, the floor is made out of floor"
So it was called porth because it's a python forth, now it's called porth because it's a porth forth.
He needs to now port it to actual forth
Is that how PHP also started...? ;-)
@@landsgevaer not sure if this is a genuine question or not, but assuming it is, PHP originally stood for Personal Home Page.
@@landsgevaer PHP isn't bootstrapped. The interpreter is written in C
Bootstrapping is so confuse
so on and so porth
The video that we needed, but not the one that we deserved. Great content man
Бутсрапер. Неплохо братик
ебать кто тут появился)
Hey Tsoding, these videos are awesome, I've never understood how languages were actually made so thanks :)
There is a great book called “crafting interpreters” which explains the whole process in an accessible way
maybe a switch case that checks the int on the top of the stack, then jumps to the appropriate block depending on the value would be helpful.
There is no jump
Thats why he is using macros for functions
@@homelikebrick42 he mentioned that the while keyword serves to mark the retern point for the loop right? meaning there should be some jmp assembly instruction. maybe its too complicated to worry about at the moment but once porth is self hosted it might be worth looking into
When zozi forget to ping discord after streaming for an hour. KEKW
how can i get permissions on his discord channel?
I never thought I’d watch this much python content, but I can’t get enough of porth, I can’t wait for the next one. Glad to see you dropped the chat overlay. It’s distracting to see side conversation .
Absolutely loving this series
Would it be useful for macros to define the types they expect on the stack? That way before a macro is expanded you can throw a compiler error like when you call intrinsics with the wrong arguments on the stack. As this language matures I can see there being a lot of macro usage and making these as powerful and easy to debug as possible would be useful
Keep it up Tsoding!
You're videos are great, such a fast and slick style
forth automatically prints ."" which would be a nice idea.
For null terminated strings you could add a 0 a the end of the string literal like:
""0 or any value for that matter, followed by more string literals, like:
""27"[1;32m"27"[1m"
I remember seeing a piece of artwork that was a colorful double helix of a DNA molecule. The image was generated by itself and was a Quine.
Nice finally long awaited moment
just noticed that there is very very very quiet music in the bg lmao
any particular reason for not showing stream chat? you reference them several times here and, though you repeat their questions for us to know what you're talking abt, i think it'd be nice to actually see the chat. i dunno maybe ill just have to pop in live from now on lol
C has two macros: '__FILE__' and '__LINE__' they use double underscores because 1. its UB to define double underscore variables and 2. its unlikely you will ever define a variable exactly like this. So i suggest you change here to __LOCATION__ or something similar.
if anyone knows how to escape the formatting in youtube comments let me know!
I dont want half the text to be italic!
@@wChris_ try backspaces before the underscores
@@uwuLegacy how do you type a backspace?
finally what we have been waiting for
This makes my brain hurt, so cool
EDIT: Good explanation of the if/elif block over hashes, thanks ✨
this seems strange but it actually happens to many languages today, practically, every language does that
What keyboard do you have? I liked keyboard sounds.
Hearing the typing is what got me hooked on this channel. It’s so satisfying
what version of pypy do you use?
hi , awsome work
is streq(s1,s2) := strcmp(s1,s2)==0 possible for the last part ?
I swear Alexey Keeps aging backwards.
Just started tuning in. I subbed when i seen you made a Forth! Bloody incredible language.
Did you have a look at Factor before you started, would be great if someone picked up the reins on that project.
I'm
what a lovely video to wake up to
"Is this what everyone means when they talk about Porth Forwarding?"
Porth OS when?
I have a question.. is rust good for OpenGl??
which text editor are you using?
Did you know that GCC (C compiler) actually made with C? Well... as you know, this is something normal
But it definitely used another compiler for bootstrapping
@@stefanalecu9532 actually C was bootstrapped from B
@@wChris_ which was unfortunately not written in A.
@@chri-k and if A existed could be bootstraped from z (since -1 mod 26 = 25 = Z)
Where are you from? I don't think you speak Portuguese, but the word you say at 5:26 as a confirmation is actually something you coukd use in Portuguese, so it got me curious
He is Russian
It will only be a real chicken and egg situation once you rewrite python in porth
Concatenative programming vs. not = "does function call require surrounding arguments in braces".
Stack-Oriented programming is a paradigm where function calls are expressed with Reverse Polish Notation.
I think Groovy is a good example of support for concatenative programming (and enforcing it) while being neither a stack-oriented nor a functional programming language.
Stack-Oriented programming implies concatenative programming if it's not limited to one instruction per line like assembly.
I suppose it's a good start to rewriting porth in porth!
This comment to support this channel
damn i just found you it's like i found a treasure
Love the project. I created a lisp interpreter in Rust once, never thought to write it in itself. Porth is a terrible name. Porth 👄 💦
Can u please make a videou about llvm, and why some guys (brazilians high ego dev streamers) says that is the **only** way to build a interpreter/compiler on top of a high level language?
kinda fun cause u literally didn't use in this series
de quem tu tá falando cara isso literalmente faz sentido algum
quem?
LLVM allows for compiling for many platforms. Unless one is targeting a VM bytecode like JVM, for production grade cross-platform compilers, LLVM is a must.
LLVM has its own intermediate language that your compiler can generate. LLVM can compile or make a JIT compiler for you from there.
It is NOT absolutely needed. Tsoding doesn't care if Porth is portable.
A much better implementation of elseif is the on you already have were a second if in the else condition doesn't need to be closed by an end.
like the syntax you already have:
if else if else if end
Note: the single 'end' at the end.
Then you can't nest if else's, which is really often neccesary.
@@jetison333 I am thinking of ternary style ifs.
Also if you have a nested if in an else block, should already be using an if-else statement
This is awesome
puts actually puts a newline automatically at the end of each string! I highly recommend looking at the musl libc implementation as it is much cleaner than the glibc implementation.
I think I am now inspired to write an editor plugin for this language that will show you what is on the stack as you type… ;)
27:30 lol
"Rewriting My Language in itself"
ah recursion??
*bootstrapping
@@thebirdhasbeencharged 😂
Cool project 👍👍
Tscoding, you know several programming languages. If you had to choose a single language to use what would it be? What is your favorite programming language?
His FAQ says in response to the "favourite programming language" question that he hates them all equally lol
Sooooo, basically porth.porth is to porth what PyPy is to CPython? xD
nice!
you should have considered everything non zero to be Boolean true.
Or the convention for such checks to be false (0) or not false. Keeping the false and true to specific values. Do you think those values should be 1 and 0, or -1 and 0?
Hey, as soon as you implement a porth compiler in porth you can just implement it in the porth based compiler. The python based compiler isnt necessary anymore once you have a working porth based compiler
Finally
you should write a transpiler from python to porth to save you hand porting the compiler :P
I think that's more complicated than what he's doing now
u mean hand porthing?
how is it possible to write a programming language in itself
You first have to write it in another language, and then you can write porth programs. Then you rewrite your compiler in porth, use your first compiler to compile that, and then only use your ports compiler from then on. The whole process is called bootstrapping and a lot of modern programming languages do it.
@@jetison333 thanks, I forgot that all languages are at the end only instructions :p
but why would you do that? rewrite in itself
@@janekk_ It’s a good non-trivial test of the compiler. It can help the developer find bugs.
@@janekk_ Oftentimes (not always) you're creating a programming language because it's closer to your ideal language than the existing ones.. so you might enjoy developing the compiler further in this better(?) language.. Also, like Netscape Plugin said, it's a good non-trivial test of the compiler but also dogfooding of your new language.. how does it feel to develop in it.
Porth: Syntax is simple like Python, with compile errors clarity of Java 😅
nice elif bro
Ohh you could just write a shell script that sends the file content to std input of porth and saves the output to an asm file and runs nasm and the linker. This is why we have pipes and redirects in *nix systems.
pforth
😳 you're codin pro
Please stop talking with that funny voice.