While using PHP you have to keep in mind that it is a language mainly developed for web pages, can run together with html and so. It evolved alot and has become a real backend language with great oops features. It is not a compiled language and meant to run as long as possible with interference. To prevent type conversion etc you can use strict types. Then you need to tell what kind of a variable it is
Finding myself working with php is exactly like this video. Everything has its own set of rules compared to oop and type structure. Love seeing your problem solving and frustration at the sametime!
This is so nice. Just watching a man discover something new for himself, just a pure stream of curiosity. Makes me wanna go out and learn a random language
It seems you can use type-hinting in PHP now. It's been possible since 7.4. That would make code a bit more readable. You can do something like: class A { public string $my_str; public __construct (string $str) { $this->my_str = $str; } }
@@yyny0 I never understood that, why use a language like PHP or Python to later force Types? the whole point of these languages is exactly that: "If it walks like a duck, quacks like a duck, then probably its a duck". If you want type-safety use a language that comes with type-safety like rust
Awesome! Simple really like it! The whole processe of thinking and how to use even an almost unknown language and build something from scratch! This video teach me a lot of things, not of PHP but how to really code thinking! Thank you so much!
Of course PHP has associative arrays as first-class citizens, and classes only added later, so idiomatic PHP would have used associative arrays for most of the data structures.. what you've written is a very C-style PHP with structs as classes... I do like what you've done tho - very entertaining
arrays are really weird in php, out of all the languages I use, it's the only one that copies the array when you pass it to another variable or to a function argument. If you don't want to copy the array, you have to explicitly put a "&" in the function parameter so that it's passed by reference.
Re: remembering syntax. I noticed once I started understanding multiple languages, there's a separate layer in my brain that translates syntax into the abstract concepts of the programming language represent. It took awhile to decouple the syntax from the brains abstract syntax tree.
I understand your frustration with the auto evaluation compare operator == but I would like to point out that the string from md5 is not a string like the hex that is printed when you echo it. It is a literal ByteString, not a string like ascii or utf8 or another. Think of it as a ByteArray but works with almost all the str functions. Nowhere have I seen this explained, but in my DFA parser library in PHP it tripped me a few times. Thanks for the good development streams. I watch all of them that make it to UA-cam.
Sorry, I misspoke on the md5 that one is actually a string. It is the sodium_* functions which return the raw bytes in a string. How is my sympathy of the frustration of the eval comparator operator beside the point?
in php, regular string are actually byte arrays. $emoji = "😀"; echo strlen($emoji) // returns 4 echo $emoji[0]; // returns "�" because it's not a valid utf8 byte sequence echo $emoji[0] . $emoji[1] . $emoji[2] . $emoji[3]; //returns "😀" because it's the utf8 byte sequence of this emoji It makes sense since PHP is heavily inspired by C
@@soniablanche5672 This has bitten me many times in the past. Thankfully, they have all of the `mb*` functions. I am a little curious why those are not just the default, but instead need to be enabled as an extension.
Feeling grateful that you didn't ditch the Debian in favour of Hanna Montana Linux. Vim is pushing it. Windows would have been a joke too far, though, for sure.
Thanks. I was thinking "why is this guy calling, actual, the devil doing this so weird thing? Maybe he couldn't find a recent corpse and a crossroad with a hang tree?"... But, guy, it's amazing! 👍
W3C is about the worst way to learn about PHP. Not just aren't constructors not mentioned - it lacks all typing and modern features, like readonly properties, (backed) enums, constructor property promotion, annotations. PHP is pretty close to most other OO-languages with first-class functions by now with the omission of generics and typed instance variables (though there are plugins supported by most IDEs where you can add generic type-checking via docblocks or annotation). Even has a few things that are more convenient for writing good OO-code than e.g. C# or Java. Old built-in function sometimes have inconsistent parameter order, but that's not really a problem in an IDE. For the last 4-5 years, it's been pretty clean, performant (has a JIT compiler since 8) and comfortable. It's mixin-handling and package-management are some of the most convenient I know. You also have a strict-typing option, which prevents accidental typecasting. Anf if you then type your functions, you also get an error when you try to pass/return something not matching the signature. I still much prefer languages with generics - but most have their own problems. TypeScript has a great type-system, but its got node/deno/bun for server-side programming and the entailed suboptimal package-management. Scala has a superb type-system, but JVM has such a big footprint, and native compilation is limited and a hassle - only Coq, Idris 2 and Agda have a nicer type-system for me, but you don't build applications with those. Rust is also nice, but too inconvenient for higher-level stuff. Python's typing has matured a great deal, and I quite like it, even though generics are a bit cumbersome. If one can live with design-time generics via annotations or docblocks, PHP is actually a decent choice for quite a few situations, because for all the increased expressive power and ability to write clean OO-code, it hasn't lost its convenience, low footprint and high velocity. Far less cumbersome than C or C++, far more lightweight than C# or Java. I didn't understand the problem with the stack trace... it exactly traces the callstack in inside-out order, nothing random about it.
I know a lot of people hate on php and it has its faults, but it’s annoying to see someone constantly complain when they are trying to blow through the process so fast they don’t bother to actually read up on anything for more than 3 seconds and don’t try to understand what’s right in front on them. Re the stack trace at the start, it very clearly threw at line 4. The trace shows that it was called via the todo function (#0), from the Lexer method call (#1), called from main (#3). There’s absolutely nothing wrong with it.
isn't better to make C compiler in C in case of compilation speed? I am impressed by the way of what you achieved. Cheers! P.S> If no more challenges waiting for you then make C compiler in MS Excel ;)
strings in php are actually just bytes, that's why we have strlen() and mb_strlen(), the first one gives you the number of bytes, the second one gives you the number of characters with utf8 as default encoding
and u can use struct mode to avoid alot of convertion issues for variables types u have type hinting system and for constructors u have property promotion for avoids a lot of boiler plate and u did gj
I don't think he's saying it's not valid syntax, I think he's saying the type in the function prototype is only there as documentation for the programmer and doesn't have any meaning to the interpreter
i mean a c compiler in brainfuck would be theoretically possible right? so what about a python to brainfuck transpiler, which then gets fed a c compiler XD
Python is my favorite kind of assembly
Ah yes pyasm
pasm
pasthmatic
oh god the title is so cursed
Exactly my thoughts haha
I said: "Oh god..."
I obviously clicked, then saw the video length... 3 hours
"OOohhhh Goddddd"...
You shall burn in hell for such evil!
I love php, like c but less verbose
watching this as a php dev has taught me that the internet is awful at teaching PHP
they hate it just to hate it.
Yep, most suggestions are outdated,docs lack type hints, missing shorthand versions of stuff.
is it true that php devs drive lambos?
@@Alguem387 i dont
Yes, somehow pretty much all advice is stalled at PHP5 at best..
Next challenge is to make a c compiler in MySQL
Why you embed this idea as a fact of our immutable reality?
@@happyfase if its immutable js add mut
you mean in Visual Basic
go for asm
@@soniablanche5672 you mean in whitespace?
Ahh PHP, a language perfect for the implementation of the UnHolyC language.
Ah yes, the CIA's programming language
Lol
So is Terry Davis' HolyC okay?
Finally the content that we are all deserve.🔥
Didn't watch the whole video yet, but i'll it definetly.
And btw, welcome to the PHP club!
While using PHP you have to keep in mind that it is a language mainly developed for web pages, can run together with html and so. It evolved alot and has become a real backend language with great oops features. It is not a compiled language and meant to run as long as possible with interference.
To prevent type conversion etc you can use strict types. Then you need to tell what kind of a variable it is
18:13 I have been waiting for the phrase "Can your Emacs do that?"
56:22 that iota idea for enums is actually a 200IQ move 🧠
He did it already:
Making Programming Language in Python - Porth Ep.1: ua-cam.com/video/8QP2fDBIxjM/v-deo.html
It comes from Go
i just started to learn compiler design hope so this video will help me in some way
I guess Porth development series has to be quite relevant for you
don't he is so powerfull
Finding myself working with php is exactly like this video. Everything has its own set of rules compared to oop and type structure. Love seeing your problem solving and frustration at the sametime!
This is so nice. Just watching a man discover something new for himself, just a pure stream of curiosity. Makes me wanna go out and learn a random language
It seems you can use type-hinting in PHP now.
It's been possible since 7.4. That would make code a bit more readable.
You can do something like:
class A {
public string $my_str;
public __construct (string $str) {
$this->my_str = $str;
}
}
This is the only thing we allow at work, no more dynamic typing.
@@yyny0
Yeah, dynamic typing is a bane.
You can even do something like this since php8:
class A {
public function __construct(public string $str){}
}
@@project-lu3qv
That is a bit too.... Un-verbose for my taste. Lol.
@@yyny0 I never understood that, why use a language like PHP or Python to later force Types? the whole point of these languages is exactly that: "If it walks like a duck, quacks like a duck, then probably its a duck". If you want type-safety use a language that comes with type-safety like rust
Awesome! Simple really like it! The whole processe of thinking and how to use even an almost unknown language and build something from scratch! This video teach me a lot of things, not of PHP but how to really code thinking! Thank you so much!
Of course PHP has associative arrays as first-class citizens, and classes only added later, so idiomatic PHP would have used associative arrays for most of the data structures.. what you've written is a very C-style PHP with structs as classes... I do like what you've done tho - very entertaining
arrays are really weird in php, out of all the languages I use, it's the only one that copies the array when you pass it to another variable or to a function argument. If you don't want to copy the array, you have to explicitly put a "&" in the function parameter so that it's passed by reference.
what a php rollercoaster ride from insanity of comparison to "as safe as rust" out of bounds checks :D
Parser Combinators would be a reasonable thing to implement in php
My God, he is the chosen one! The divine intellect, may saint terry protect you from glovies tsoding.
20:18 watching some man editing text files is my favourite thing to do, btw
Bravo! at 15:49, the best 20 seconds ever! I love your channel. Keep it up, that was epic.
Ohn man, there is so much good stuff in this video! 16:50
Re: remembering syntax. I noticed once I started understanding multiple languages, there's a separate layer in my brain that translates syntax into the abstract concepts of the programming language represent. It took awhile to decouple the syntax from the brains abstract syntax tree.
I understand your frustration with the auto evaluation compare operator == but I would like to point out that the string from md5 is not a string like the hex that is printed when you echo it. It is a literal ByteString, not a string like ascii or utf8 or another. Think of it as a ByteArray but works with almost all the str functions. Nowhere have I seen this explained, but in my DFA parser library in PHP it tripped me a few times. Thanks for the good development streams. I watch all of them that make it to UA-cam.
This fact is besides my point twitter.com/tsoding/status/1643464258192015360
Sorry, I misspoke on the md5 that one is actually a string. It is the sodium_* functions which return the raw bytes in a string.
How is my sympathy of the frustration of the eval comparator operator beside the point?
in php, regular string are actually byte arrays.
$emoji = "😀";
echo strlen($emoji) // returns 4
echo $emoji[0]; // returns "�" because it's not a valid utf8 byte sequence
echo $emoji[0] . $emoji[1] . $emoji[2] . $emoji[3]; //returns "😀" because it's the utf8 byte sequence of this emoji
It makes sense since PHP is heavily inspired by C
@@soniablanche5672 This has bitten me many times in the past. Thankfully, they have all of the `mb*` functions. I am a little curious why those are not just the default, but instead need to be enabled as an extension.
This is undoubtedly the greatest atrocity of the 21st century
I had no idea implementing cat was so easy tbh
jokes aside, thank you for the lexer algorithm. This is super useful!
Let this be a lesson, just because you can do it, doesn't mean you should
Feeling grateful that you didn't ditch the Debian in favour of Hanna Montana Linux.
Vim is pushing it.
Windows would have been a joke too far, though, for sure.
General Tso only codes in PHP ironically
I love this guy
Thanks. I was thinking "why is this guy calling, actual, the devil doing this so weird thing? Maybe he couldn't find a recent corpse and a crossroad with a hang tree?"... But, guy, it's amazing! 👍
UnholyC
That was awesome (including your neighbors "moving furniture" lol), really cool to watch!
W3C is about the worst way to learn about PHP. Not just aren't constructors not mentioned - it lacks all typing and modern features, like readonly properties, (backed) enums, constructor property promotion, annotations. PHP is pretty close to most other OO-languages with first-class functions by now with the omission of generics and typed instance variables (though there are plugins supported by most IDEs where you can add generic type-checking via docblocks or annotation). Even has a few things that are more convenient for writing good OO-code than e.g. C# or Java. Old built-in function sometimes have inconsistent parameter order, but that's not really a problem in an IDE. For the last 4-5 years, it's been pretty clean, performant (has a JIT compiler since 8) and comfortable. It's mixin-handling and package-management are some of the most convenient I know. You also have a strict-typing option, which prevents accidental typecasting. Anf if you then type your functions, you also get an error when you try to pass/return something not matching the signature.
I still much prefer languages with generics - but most have their own problems. TypeScript has a great type-system, but its got node/deno/bun for server-side programming and the entailed suboptimal package-management. Scala has a superb type-system, but JVM has such a big footprint, and native compilation is limited and a hassle - only Coq, Idris 2 and Agda have a nicer type-system for me, but you don't build applications with those. Rust is also nice, but too inconvenient for higher-level stuff. Python's typing has matured a great deal, and I quite like it, even though generics are a bit cumbersome. If one can live with design-time generics via annotations or docblocks, PHP is actually a decent choice for quite a few situations, because for all the increased expressive power and ability to write clean OO-code, it hasn't lost its convenience, low footprint and high velocity. Far less cumbersome than C or C++, far more lightweight than C# or Java.
I didn't understand the problem with the stack trace... it exactly traces the callstack in inside-out order, nothing random about it.
Hi there!
Where would you suggest learning php instead?
Like getting to know the inside outs of the langage, not only the surface parts...?
a C programmer forgetting to add a semicolon at the end of lines very suspicious.
My favourite coder on twitch and youtube!.
Therapist: A C compiler made in PHP doesn't exhist it can't hurt you...
Meanwhile, a C compiler made in PHP:
The main reason why php devs don't close the
I know a lot of people hate on php and it has its faults, but it’s annoying to see someone constantly complain when they are trying to blow through the process so fast they don’t bother to actually read up on anything for more than 3 seconds and don’t try to understand what’s right in front on them. Re the stack trace at the start, it very clearly threw at line 4. The trace shows that it was called via the todo function (#0), from the Lexer method call (#1), called from main (#3). There’s absolutely nothing wrong with it.
Okay but you carefully read things and have not written a C compiler in PHP in 3 hours, so who's the real winner here?
Don't know how you pull up these themes. It's absolutely crazy. I would like to see a video centered around V(lang)
I'm Pretty sure the scientific notation problem is fixed with the introductian of type hinting.
isn't better to make C compiler in C in case of compilation speed? I am impressed by the way of what you achieved. Cheers!
P.S> If no more challenges waiting for you then make C compiler in MS Excel ;)
19:05 Yea, PHP is some kind of "Web Java" xD
Any plans to bring back some porth content?
I want to believe
Man fights with PHP for 3 hours
Dude I love your content.
"I know that PHP doesn't yest have native Enumerations"
*Asked 14 years ago*
"Ah so they were introduced relatively recently..."
Lol 😂
Alternative title : bullying PHP for three hours straight
you have some pretty amazing project ideas 🤣
I wish I had been able to watch you live. It hurts watching you stumble through PHP, having to rely on bad docs and posts Google shows you.
Not sure if April Fool or cursed
April Fools but the vod is late
How you become so good in programming? damn!
Next video: C compiler en HTML OMEGALUL
Tsoding talking good about javascript
Imagine if for next april fools, he makes "php.js" a Javascript php runtime, this could be so cursed
Imagine comparing strings and on some input it will convert to 0 integer (and probably back to '0' but string). Funny
Sounds like another day on javascript island
that's why you use === instead of == in both php and javascript
@@soniablanche5672 correction: that's why strings should be just an array of bytes and converting them is the matter of functions like atoi or strtol
@@soniablanche5672 that's why those languages are for soggy people
strings in php are actually just bytes, that's why we have strlen() and mb_strlen(), the first one gives you the number of bytes, the second one gives you the number of characters with utf8 as default encoding
16:05 "we build applications that allows people to build applications"
What's the story behind your tshirt ? How can i get one , I like it
That 7gb porn folder 😂
lmao
cursed
no PHP was harmed in this video
Not even one line of code.
Can you implement sed in sed?
The longest April Fool's joke I've ever seen!
tsoding uses vim before gta 6
2:11 Vim is not weird and quirky, I feel personally attacked.
not weird and quirky enough
Why not C compiler in HTML?
People hate PHP for sake of hating
Nice text file editing session.
Thinking of being php at summer.
Why do u use the better editor only on April fools?
What in god's name have you unleashed upon this earth... 🙈
Hi Mr T, great video again 💪, please Can you finish it with assembler generation 🙏🙏🙏. Regards
Absolute madman lmao
"even JavaScript doesn't do shit like this"
Next challenge, write a compiler in PHP to compile PHP
Do you mean "interpreter" ?
Every programmer should have a tab for chatgpt, faster than docs ktself
Well, very good opinion, but Russia
and u can use struct mode to avoid alot of convertion issues
for variables types u have type hinting system
and for constructors u have property promotion for avoids a lot of boiler plate
and u did gj
17:33 thats actually real PHP syntax, not just something made up for the docs
I don't think he's saying it's not valid syntax, I think he's saying the type in the function prototype is only there as documentation for the programmer and doesn't have any meaning to the interpreter
C to Python Compiler In PHP 😂😂
Is Tsoding Daily the real engine behind ChatGPT?
Yes.
Using vim huh! That's good to see!
emacs too
- Why?
- Yes
next challenge make a php compiler where you don't need to use $ for variable
Next challenge is to make a c compiler in scratch
подвинь окно камеры немного вверх, чтобы можно было видеть строку состояния vim
bro has never touched grass.
I saw the title and almost fainted
And he used vim lord help me
PHP is as safe as Rust.
Rustaceans: 💀
Why was I not subscribed??? I fixed it at once...
Now I've seen everything.
Wasn't php written in C/C++?
Bro, code a C compiler in MOO.
Btw, wtf, i hope someday have that knowledge!
Can you do the same, but with 1c language?
Epic
i mean a c compiler in brainfuck would be theoretically possible right? so what about a python to brainfuck transpiler, which then gets fed a c compiler XD
there is a knocking sound in the bg
Next up: Python interpreter in PHP
In the foreach you are passing a reference by doing this &$value, it would be like this
foreach($array as $value) {}
Emacs can do ligatures now
vim has support for gigachads?
гигачад это я
Хорош,мужик
now make python with c php!! it would be super fast!
In Emacs 28 you can