Ok, I made C compiler in PHP (c.php Ep.01)

Поділитися
Вставка
  • Опубліковано 18 жов 2024

КОМЕНТАРІ • 263

  • @Phytolizer
    @Phytolizer Рік тому +239

    Python is my favorite kind of assembly

  • @__gadonk__
    @__gadonk__ Рік тому +264

    oh god the title is so cursed

    • @gabriellevesque2185
      @gabriellevesque2185 Рік тому +18

      Exactly my thoughts haha
      I said: "Oh god..."
      I obviously clicked, then saw the video length... 3 hours
      "OOohhhh Goddddd"...

    • @vladinosky
      @vladinosky Рік тому

      You shall burn in hell for such evil!

    • @eboubaker3722
      @eboubaker3722 Рік тому +1

      I love php, like c but less verbose

  • @asthmaticpathic
    @asthmaticpathic Рік тому +242

    watching this as a php dev has taught me that the internet is awful at teaching PHP

    • @eboubaker3722
      @eboubaker3722 Рік тому +30

      they hate it just to hate it.

    • @narkocat
      @narkocat Рік тому +37

      Yep, most suggestions are outdated,docs lack type hints, missing shorthand versions of stuff.

    • @Alguem387
      @Alguem387 Рік тому +22

      is it true that php devs drive lambos?

    • @nctrn07
      @nctrn07 Рік тому +11

      @@Alguem387 i dont

    • @crrodriguez
      @crrodriguez Рік тому +18

      Yes, somehow pretty much all advice is stalled at PHP5 at best..

  • @manacht2727
    @manacht2727 Рік тому +627

    Next challenge is to make a c compiler in MySQL

    • @happyfase
      @happyfase Рік тому +25

      Why you embed this idea as a fact of our immutable reality?

    • @wuxxy
      @wuxxy Рік тому +29

      @@happyfase if its immutable js add mut

    • @soniablanche5672
      @soniablanche5672 Рік тому +4

      you mean in Visual Basic

    • @LabhamJain
      @LabhamJain Рік тому +1

      go for asm

    • @_lenn.box_
      @_lenn.box_ Рік тому +1

      @@soniablanche5672 you mean in whitespace?

  • @xravenx24fe
    @xravenx24fe Рік тому +296

    Ahh PHP, a language perfect for the implementation of the UnHolyC language.

  • @byterbrodTV
    @byterbrodTV Рік тому +12

    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!

  • @keremardicli4013
    @keremardicli4013 Рік тому +22

    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

  • @RenderDragon
    @RenderDragon Рік тому +18

    18:13 I have been waiting for the phrase "Can your Emacs do that?"

  • @MaxCoplan
    @MaxCoplan Рік тому +13

    56:22 that iota idea for enums is actually a 200IQ move 🧠

    • @two-spikes
      @two-spikes Рік тому +3

      He did it already:
      Making Programming Language in Python - Porth Ep.1: ua-cam.com/video/8QP2fDBIxjM/v-deo.html

    • @sebastiangudino9377
      @sebastiangudino9377 Рік тому +2

      It comes from Go

  • @yuyi-hao
    @yuyi-hao Рік тому +23

    i just started to learn compiler design hope so this video will help me in some way

    • @mazZZzilaplayer
      @mazZZzilaplayer Рік тому +6

      I guess Porth development series has to be quite relevant for you

    • @jackgame8841
      @jackgame8841 Рік тому

      don't he is so powerfull

  • @bradley1995
    @bradley1995 5 місяців тому

    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!

  • @lowlight1063
    @lowlight1063 5 місяців тому

    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

  • @GegoXaren
    @GegoXaren Рік тому +30

    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
      @yyny0 Рік тому +21

      This is the only thing we allow at work, no more dynamic typing.

    • @GegoXaren
      @GegoXaren Рік тому +3

      ​@@yyny0
      Yeah, dynamic typing is a bane.

    • @project-lu3qv
      @project-lu3qv Рік тому +11

      You can even do something like this since php8:
      class A {
      public function __construct(public string $str){}
      }

    • @GegoXaren
      @GegoXaren Рік тому +4

      @@project-lu3qv
      That is a bit too.... Un-verbose for my taste. Lol.

    • @jordixboy
      @jordixboy Рік тому +2

      @@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

  • @daviddwq4513
    @daviddwq4513 10 місяців тому +1

    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!

  • @thedreadedgman
    @thedreadedgman Рік тому +12

    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

    • @soniablanche5672
      @soniablanche5672 Рік тому +1

      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.

  • @_dnL
    @_dnL Рік тому +3

    what a php rollercoaster ride from insanity of comparison to "as safe as rust" out of bounds checks :D

  • @kraftwerk28
    @kraftwerk28 Рік тому +7

    Parser Combinators would be a reasonable thing to implement in php

  • @ilyasabi8920
    @ilyasabi8920 Рік тому +2

    My God, he is the chosen one! The divine intellect, may saint terry protect you from glovies tsoding.

  • @RenderDragon
    @RenderDragon Рік тому +5

    20:18 watching some man editing text files is my favourite thing to do, btw

  • @johnbeeckler
    @johnbeeckler Рік тому +2

    Bravo! at 15:49, the best 20 seconds ever! I love your channel. Keep it up, that was epic.

    • @johnbeeckler
      @johnbeeckler Рік тому

      Ohn man, there is so much good stuff in this video! 16:50

  • @Mozartenhimer
    @Mozartenhimer Рік тому +7

    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.

  • @DonaldDuvall
    @DonaldDuvall Рік тому +7

    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.

    • @TsodingDaily
      @TsodingDaily  Рік тому +4

      This fact is besides my point twitter.com/tsoding/status/1643464258192015360

    • @DonaldDuvall
      @DonaldDuvall Рік тому +2

      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?

    • @soniablanche5672
      @soniablanche5672 Рік тому

      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

    • @DonaldDuvall
      @DonaldDuvall Рік тому

      @@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.

  • @Lemon_Inspector
    @Lemon_Inspector Рік тому +3

    This is undoubtedly the greatest atrocity of the 21st century

  • @cheebadigga4092
    @cheebadigga4092 10 місяців тому

    I had no idea implementing cat was so easy tbh
    jokes aside, thank you for the lexer algorithm. This is super useful!

  • @notarandom7
    @notarandom7 Рік тому +1

    Let this be a lesson, just because you can do it, doesn't mean you should

  • @auntiecarol
    @auntiecarol Рік тому +2

    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.

  • @nekoill
    @nekoill Рік тому

    General Tso only codes in PHP ironically
    I love this guy

  • @FranFuentesR
    @FranFuentesR Рік тому

    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! 👍

  • @ChickenFingers42
    @ChickenFingers42 Рік тому +14

    UnholyC

  • @fer.barrios
    @fer.barrios Рік тому

    That was awesome (including your neighbors "moving furniture" lol), really cool to watch!

  • @DumblyDorr
    @DumblyDorr Рік тому +3

    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.

    • @enriquejosemunozavellan5517
      @enriquejosemunozavellan5517 Рік тому

      Hi there!
      Where would you suggest learning php instead?
      Like getting to know the inside outs of the langage, not only the surface parts...?

  • @ayoubbelatrous9914
    @ayoubbelatrous9914 Рік тому +6

    a C programmer forgetting to add a semicolon at the end of lines very suspicious.

  • @AndrewTSq
    @AndrewTSq Рік тому

    My favourite coder on twitch and youtube!.

  • @Franky_PT
    @Franky_PT Рік тому +6

    Therapist: A C compiler made in PHP doesn't exhist it can't hurt you...
    Meanwhile, a C compiler made in PHP:

  • @the_primal_instinct
    @the_primal_instinct 3 місяці тому

    The main reason why php devs don't close the

  • @churchers
    @churchers Рік тому +3

    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.

    • @robmckennie4203
      @robmckennie4203 10 місяців тому +1

      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?

  • @georgecop9538
    @georgecop9538 Рік тому +15

    Don't know how you pull up these themes. It's absolutely crazy. I would like to see a video centered around V(lang)

  • @GegoXaren
    @GegoXaren Рік тому +2

    I'm Pretty sure the scientific notation problem is fixed with the introductian of type hinting.

  • @GoWithAndy-cp8tz
    @GoWithAndy-cp8tz 8 місяців тому

    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 ;)

  • @RenderDragon
    @RenderDragon Рік тому +4

    19:05 Yea, PHP is some kind of "Web Java" xD

  • @Pi7on
    @Pi7on Рік тому +7

    Any plans to bring back some porth content?

  • @markmckenzie5343
    @markmckenzie5343 Рік тому +1

    Man fights with PHP for 3 hours

  • @ggoadmusic
    @ggoadmusic 9 місяців тому

    Dude I love your content.

  • @mattetis
    @mattetis Рік тому +3

    "I know that PHP doesn't yest have native Enumerations"
    *Asked 14 years ago*
    "Ah so they were introduced relatively recently..."
    Lol 😂

  • @PetaPelikan
    @PetaPelikan Рік тому

    Alternative title : bullying PHP for three hours straight

  • @joaomachado9105
    @joaomachado9105 Рік тому +1

    you have some pretty amazing project ideas 🤣

  • @DonaldDuvall
    @DonaldDuvall Рік тому +1

    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.

  • @arie1906
    @arie1906 Рік тому +6

    Not sure if April Fool or cursed

  • @JohnMurphy-iw2ce
    @JohnMurphy-iw2ce Рік тому +1

    How you become so good in programming? damn!

  • @paolobooker4163
    @paolobooker4163 4 місяці тому

    Next video: C compiler en HTML OMEGALUL

  • @Lars-ce4rd
    @Lars-ce4rd 6 місяців тому

    Tsoding talking good about javascript

  • @makidelille
    @makidelille 7 місяців тому

    Imagine if for next april fools, he makes "php.js" a Javascript php runtime, this could be so cursed

  • @rogo7330
    @rogo7330 Рік тому +6

    Imagine comparing strings and on some input it will convert to 0 integer (and probably back to '0' but string). Funny

    • @morgengabe1
      @morgengabe1 Рік тому +2

      Sounds like another day on javascript island

    • @soniablanche5672
      @soniablanche5672 Рік тому

      that's why you use === instead of == in both php and javascript

    • @rogo7330
      @rogo7330 Рік тому +1

      @@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

    • @morgengabe1
      @morgengabe1 Рік тому

      @@soniablanche5672 that's why those languages are for soggy people

    • @soniablanche5672
      @soniablanche5672 Рік тому

      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

  • @caiocouto3450
    @caiocouto3450 10 місяців тому

    16:05 "we build applications that allows people to build applications"

  • @fasogoss
    @fasogoss Рік тому +1

    What's the story behind your tshirt ? How can i get one , I like it

  • @linux_devs
    @linux_devs Рік тому +2

    That 7gb porn folder 😂

  • @Synthetic_geth
    @Synthetic_geth Рік тому +8

    cursed

  • @shubhamverma1407
    @shubhamverma1407 Рік тому +1

    no PHP was harmed in this video

  • @reverseila
    @reverseila Рік тому +3

    Can you implement sed in sed?

  • @AbdelhakOussaid
    @AbdelhakOussaid Рік тому

    The longest April Fool's joke I've ever seen!

  • @DomenicoPezzullo-ib9bg
    @DomenicoPezzullo-ib9bg 7 днів тому

    tsoding uses vim before gta 6

  • @thaddaeusmarkle1665
    @thaddaeusmarkle1665 Рік тому +3

    2:11 Vim is not weird and quirky, I feel personally attacked.

  • @TheUKofBananas
    @TheUKofBananas Рік тому +1

    Why not C compiler in HTML?

  • @bartech101
    @bartech101 Рік тому +1

    People hate PHP for sake of hating

  • @Lars-ce4rd
    @Lars-ce4rd 6 місяців тому

    Nice text file editing session.

  • @deathlife2414
    @deathlife2414 Рік тому +1

    Thinking of being php at summer.

  • @mariomaliqi184
    @mariomaliqi184 Рік тому +1

    Why do u use the better editor only on April fools?

  • @atrumluminarium
    @atrumluminarium Рік тому

    What in god's name have you unleashed upon this earth... 🙈

  • @tonym5857
    @tonym5857 Рік тому +1

    Hi Mr T, great video again 💪, please Can you finish it with assembler generation 🙏🙏🙏. Regards

  • @ankitpoudel8750
    @ankitpoudel8750 11 місяців тому

    Absolute madman lmao

  • @motbus3
    @motbus3 Рік тому +1

    "even JavaScript doesn't do shit like this"

  • @JabezEmmanuelBorja
    @JabezEmmanuelBorja Рік тому

    Next challenge, write a compiler in PHP to compile PHP

  • @QuickBitMastery
    @QuickBitMastery Рік тому +1

    Every programmer should have a tab for chatgpt, faster than docs ktself

  • @omarkandil1515
    @omarkandil1515 11 місяців тому

    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

  • @ExZeMIP
    @ExZeMIP Рік тому

    17:33 thats actually real PHP syntax, not just something made up for the docs

    • @robmckennie4203
      @robmckennie4203 10 місяців тому

      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

  • @AndrieMinecraft
    @AndrieMinecraft Рік тому +1

    C to Python Compiler In PHP 😂😂

  • @wagsman9999
    @wagsman9999 Рік тому +1

    Is Tsoding Daily the real engine behind ChatGPT?

  • @abrarmasumabir3809
    @abrarmasumabir3809 Рік тому

    Using vim huh! That's good to see!

  • @chiquinhodelidia
    @chiquinhodelidia Рік тому

    - Why?
    - Yes

  • @naive_algorithm
    @naive_algorithm Рік тому

    next challenge make a php compiler where you don't need to use $ for variable

  • @Tefyer
    @Tefyer 6 місяців тому

    Next challenge is to make a c compiler in scratch

  • @two-spikes
    @two-spikes Рік тому +1

    подвинь окно камеры немного вверх, чтобы можно было видеть строку состояния vim

  • @hold4564
    @hold4564 10 місяців тому

    bro has never touched grass.

  • @grutomo1287
    @grutomo1287 Рік тому

    I saw the title and almost fainted

  • @a-rustacean
    @a-rustacean Рік тому

    PHP is as safe as Rust.
    Rustaceans: 💀

  • @gargleblasta
    @gargleblasta Рік тому

    Why was I not subscribed??? I fixed it at once...

  • @b1.7.3
    @b1.7.3 Рік тому

    Now I've seen everything.

  • @cbbcbb6803
    @cbbcbb6803 Рік тому +1

    Wasn't php written in C/C++?

  • @ogprograma
    @ogprograma Рік тому

    Bro, code a C compiler in MOO.
    Btw, wtf, i hope someday have that knowledge!

  • @ВладимирГорячев-ю3э
    @ВладимирГорячев-ю3э 11 місяців тому

    Can you do the same, but with 1c language?

  • @XELER53
    @XELER53 Рік тому

    Epic

  • @beatslist
    @beatslist Рік тому

    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

  • @samjanssens1509
    @samjanssens1509 Рік тому

    there is a knocking sound in the bg

  • @christopherjaya342
    @christopherjaya342 Рік тому

    Next up: Python interpreter in PHP

  • @Lanzelord
    @Lanzelord Рік тому

    In the foreach you are passing a reference by doing this &$value, it would be like this
    foreach($array as $value) {}

  • @codebroker_
    @codebroker_ Рік тому

    Emacs can do ligatures now

  • @two-spikes
    @two-spikes Рік тому +1

    vim has support for gigachads?
    гигачад это я

  • @mierce
    @mierce Рік тому

    Хорош,мужик

  • @teev660
    @teev660 Рік тому

    now make python with c php!! it would be super fast!

  • @КонстантинАнисимов-т2е

    In Emacs 28 you can