Lex Fridman on PHP programming

preview_player
Показать описание
Please support this podcast by checking out our sponsors:

GUEST BIO:
Guido van Rossum is the creator of Python programming language.

PODCAST INFO:

SOCIAL:
Рекомендации по теме
Комментарии
Автор

Guest bio: Guido van Rossum is the creator of Python programming language.

LexClips
Автор

I like the dollar sign. It’s quick visual reference and when you type it into the editor you immediately get a list of all variables in scope.

evilcultleader
Автор

using PHP for 25 years.. working on large scale applications (current on on which i'm working has prolly 500k lines of code).. $ sign at the start of variable looks totally intuitive and handy.. i like it

raysubject
Автор

PHP is actually ahead of python in terms of how usable the type annotations are, and they are also enforced in PHP (not in python, see other clip of Lex and Guido for discussion about that). Yes, the syntax is very dated but I love how fast PHP currently is improving and modernizing. Also code written with the Laravel framework is very testable, highly structured code and I have seen other frameworks in more “mature” languages (e.g. Java) that cant stand up to it in terms of testability and quality.

jantuitman
Автор

I’m not as bothered with the $ as having to type -> for a method call. A simple period is just so much better imo

jaredbouwer
Автор

I still like the $ in php. It helps me identify variables quickly. When I started learning Javascript I missed this feature it a lot.
Over the years I don't write a lot of code, I simply reuse a lot of my old functions that I copy and paste. Laravel also makes my life a lot easier with a lot of build in functionality.

netsudro
Автор

I love the $. I think it helps a lot for code readiability.

minor
Автор

I felt at home with dollar sign variables because I came from BASIC. In PHP, constants don't have a dollar sign. So it's easy to tell when something is a constant and when something is a variable.

Many of the quirks in PHP like floating point math and parameter order come from the underlying C.

I think the biggest source of bugs with the dollar sign is when people use $$ for variable variables. PHP lets you code like a fool which is good for the hiring team. They can see which coders do things that make life difficult just because they can and "it works" and not hire them. Good PHP coding comes from developers learning how to code properly through experience and guidance, not the language.

bkucenski
Автор

I wish PHP had adopted dot syntax for object to property vs the -> syntax. And used + for concat instead of the "." but it is what it is. I'm really happy with how far PHP has come; especially in the last 10 years with Laravel.

ChrisHorneVL
Автор

For me the dollar sign is very helpful to notice variables. In JS, variables can be mistaken for in-built properties.

Sergeant_Camacho
Автор

I was using PHP for some time and I can't remember any bugs that occured because if $ sign.

volvoxpl
Автор

either everything is a string and you have to mark variables explicitly (e.g. with a dollar sign) or everything is a variable and you have to mark strings explicitly (with quote characters)....

ichanmich
Автор

I have found that most people complain when they learn a second language because they have a first language to compare against. The $ in PHP is a bit odd, but doesn't bother me at all. Neither does the arrow. What bothers me the most is the arrays with the => due to bad keyboard ergonomics for those two keystrokes.

xbmcme
Автор

i like the dollar sign for readability. Not a deal breaker, but very visible.

colinm
Автор

as someone who learnt coding by learning PHP I had the opposite problem: "how do I know if it's a variable if there is no $ before that? :D"
Now I don't use php anymore but it would just annoy me. Even more because I use the US keyboard layout instead of the hungarian and it's really unconforable to use the $ sign in my opinion.

SzaboB
Автор

Came here to listen to Lex talk about PHP, left with a CS degree in CLI

jasontfrom
Автор

It is interesting noting how these choices at the birth of computing still influence things so far down the road, similar to the evolution of languages themselves. All the French, Latin, Greek, and German packed into English placed in strange sharp corners, or in math where Delta is used idiomatically to represent rates of change. The protocols and practices we come up with take on a life of their own and spread mimetically-- the descendants of the shell interpreters live on.

davidpham
Автор

I understand that for you, the dollar sign is a PITA, but error prone and source of a lot of bugs? If you program in PHP you'll simply not forget to use the $... can't see your point on that argument...

GonzaloMassa
Автор

Lex should interview Rasmus some time.

There are some interesting things to say about Php, especially about some of the new programming styles outside standard platforms (apache, fpm etc), like libuv paradigms which have completely different programming styles than traditional php and huge performance boosts with the JIT.

Sometimes I wonder if php-apache and fpm were really good inventions all things considered.
Rasmus famously said in an interview that that's php's strength because it allowed providers to lease out portions of servers instead of whole dedicated servers... but I wonder if that's really still a strength in a world with docker and wasi.

It would be an interesting interview, and you should really push a bit on the libuv stuff since so many people just don't know about it (and probably will never find out about it) simply because it's not being taught as standard php at all, instead young programmers are being shoved into CMS stuff just because at this moment in time it offers better jobs.

Would be an interesting interview to say the least.

PS: the "$" syntax is annoying in most cases, but there are some quite unique things you can do with it, like referencing a dynamic variable name. like this: $$myVariable, using "$$".
In other languages you would need and actual pointer reference, or you straight up can't do it without some middleman logic.
It looks like reflection, but it's not, it actually getting JITed on the spot.

Another example would be: $myInstance->$methodName()
Really bad practice in most use cases, but you can do it, and it's still not using actual reflection, which makes it fast.

razt
Автор

I'm not sure I follow on the dollar sign being a source of a lot of bugs. It's always provided me a very quick and readable way of visually parsing code. It seems that help rather than hurt. Typing an extra character isn't any more onerous than using semicolons or using tabs for scoped code.

alivenumber