Email or username:

Password:

Forgot your password?
Top-level
Gina Peter Banyard

@oschonrock @ramsey @woozle @cptwtf @IceWolf there is still a runtime in Go, C, C++, etc.
You can have data races and other bugs that those languages won't prevent via their static type system.

To get more of that benefit you need a language that supports dependent types and/or effect types. Which is _far_ from mainstream.

PHP is definitely not statically types by default, you can _kinda_ make it with SA tools and using a subset of the language.

17 comments
Gina Peter Banyard replied to Gina Peter Banyard

@oschonrock @ramsey @woozle @cptwtf @IceWolf C's type system is omega jank, and you do have type juggling via integer promotion.

Oliver Schönrock replied to Gina Peter Banyard

@Girgias @ramsey @woozle @cptwtf @IceWolf

I did mention integer promotions elsewhere already..

and yes they suck and modern tools warn when you use that.

but C's type system is lightyears ahead of php's which was the comparison here.

There are other languages with more advanced type systems, but they are less widespread.

Oliver Schönrock replied to Gina Peter Banyard

@Girgias @ramsey @woozle @cptwtf @IceWolf

yes, go and scala definitely have a runtime. (at different levels)

c and c++ dont' really.... (and don't have to or bare metal)

and yes their type system is not perfect with respect to lifetime and thread safety, but it's reasonably advanced and lightyears ahead of php which was the comparison here..

Gina Peter Banyard replied to Oliver

@oschonrock @ramsey @woozle @cptwtf @IceWolf C and C++ has a runtime, it not an interpreter, but there is still a runtime. Literally, C compiler will call various aspects as the CRT (e.g; MSVC learn.microsoft.com/en-us/cpp/)

Everything has a "runtime" as it needs to be ... running a program. Except if you do proof assistant stuff, where "it compiles" means you are done.

And I will respectfully disagree on C's type system being better than PHP's, I can't get a NULL pointer in PHP.

@oschonrock @ramsey @woozle @cptwtf @IceWolf C and C++ has a runtime, it not an interpreter, but there is still a runtime. Literally, C compiler will call various aspects as the CRT (e.g; MSVC learn.microsoft.com/en-us/cpp/)

Everything has a "runtime" as it needs to be ... running a program. Except if you do proof assistant stuff, where "it compiles" means you are done.

Gina Peter Banyard replied to Gina Peter Banyard

@oschonrock @ramsey @woozle @cptwtf @IceWolf PHP doing runtime coercions is related, but different, to its type system. And C pointer aliasing rules are a *thing* (and this ignoring type punning and void* hell).

Oliver Schönrock replied to Gina Peter Banyard

@Girgias @ramsey @woozle @cptwtf @IceWolf

Please refer to my list above.

in php a variable can change it's type, even without conversion. So the IDE/compiler/interpreter never knows the type at compile time.

that is basically a non-existent type system in my book. And that's from 20yrs of practical experience using the language v4->v8.

Oliver Schönrock replied to Oliver

@Girgias @ramsey @woozle @cptwtf @IceWolf

With regards to "nullptr" and "void*"...

php just doesn't have an equivalent, because php does not allow manual memory management.

Really this is a pointless discussion from my point of view. php and C or C++ are not comparable languages in almost every conceivable way.

A more useful questions might be: When would using either language make sense:

Would I write a server side webapp in C or C++? Prob not. Like using a tank to squash an ant.

Woozle Hypertwin replied to Oliver

@oschonrock @Girgias @ramsey @cptwtf @IceWolf

Well... I'd say "usually" or "by default", not "never". You can set the type for a member in a class, and get an error if you try to assign it a value of an incompatible type.

...but that's a pretty new feature.

Oliver Schönrock replied to Woozle

@woozle @Girgias @ramsey @cptwtf @IceWolf

yeah.. and it's also "shallow"... because the type information is "lost" as soon as you call a method on that type and chain a few more calls.

I have continued to try to use LSPs in php over the last 2 decades, they have very slowly got better, but as soon as you switch to what I call a "compile time statically typed language" the experience is night and day.

Oliver Schönrock replied to Gina Peter Banyard

@Girgias @ramsey @woozle @cptwtf @IceWolf

the C "runtime"... is a misnomer...

there is nothing "running" while a C-program is running.

there is crt0 which runs *before* the c-program runs..

and the other stdlibs are "not required".. and in fact people write c -programs ion embedded systems without them all the time.

They are libraries which are C-programs that you didn't write.

You are clearly taking a pedantic approach. We don't need to agree.

Woozle Hypertwin replied to Oliver

@oschonrock @Girgias @ramsey @cptwtf @IceWolf

I think we're using the word "runtime" in two different ways. Both statements are right, but they're talking about somewhat different things.

Oliver Schönrock replied to Woozle

@woozle @Girgias @ramsey @cptwtf @IceWolf

maybe... I mean "runtime" as in... there is something that my programme is "running on top of or through", without which it could not work..

That is not the case for systems languages like C,C++ or Rust.

php/js/python/ruby and also JVM and .Net languages and to a lesser extent Go ... are just a different category of language.

The php interpreter/runtime, call it what you like, is written in C/C++. So is the JVM. Could you write it in php?

Gina Peter Banyard replied to Oliver

@oschonrock @woozle @ramsey @cptwtf @IceWolf I mean, someone did it for funsies: github.com/ircmaxell/PHPPHP

Like nothing prevents it from being done.

Oliver Schönrock replied to Gina Peter Banyard

@Girgias @woozle @ramsey @cptwtf @IceWolf

there goes the pedantic approach again....

"This requires that php be in your system path."

you still need the php interpreter which is written in C/C++ in order to run the php vm to run the php programme..

have you ever heard of chickens and eggs?

so.... "no"... basically.

not to mention it would be prob be stupidly slow..

Gina Peter Banyard replied to Oliver

@oschonrock @woozle @ramsey @cptwtf @IceWolf You asked if the PHP VM could be written in PHP, I gave you a repo where someone did this 13 years ago. I didn't say it was a good idea nor that it would be fast. Nor is this even fully fleshed out. People have written a Python interpreter in Python and use it to run Python. There is nothing fundamentally *preventing* you from doing it.

Chickens and Eggs exists with statically compiled languages when you need to boostrap it the first time too....

Oliver Schönrock replied to Gina Peter Banyard

@Girgias @woozle @ramsey @cptwtf @IceWolf

This is totally not the same... because you are still running a php interpreter at the outer layer in every case. In a systems language there is only the hardware.

You are apparently unable/unwilling to understand the fundamental difference, or just really stubborn and pedantic.

And with that I conclude the one thing that always irritated me more than anything else in php: The quality of understanding and discussion.

I am out. Have a nice day.

Woozle Hypertwin replied to Gina Peter Banyard

@Girgias @oschonrock @ramsey @cptwtf @IceWolf

Wasn't there even a PHP compiler at one point? I can't quite remember the name... closest I can find is this, but that wasn't it.

Go Up