Email or username:

Password:

Forgot your password?
Top-level
Oliver Schönrock

@ramsey @woozle @cptwtf @Girgias @IceWolf

I can tell this is going to be very boring already...

If you use a statically typed language you will know about it. It will get in your way, the types will be pain, but when you get them right, then you can have a high degree of confidence that the code is already free of entire classes of error.

This kind of '==' BS cannot happen. No type juggling. Not everything is a pointer under the hood. Objects have a size. ...

TBC

22 comments
Oliver Schönrock replied to Oliver

@ramsey @woozle @cptwtf @Girgias @IceWolf

There is no runtime or interpreter. Non-existent variables in if branches don't compile. Your IDE/LSP can give you meaningful autocompletion and full syntax/type checking..... etc etc etc

I used php for 20yrs. It is "not statically typed".. whether you like that term or not... it has a completely different feel to any of those languages I listed above on all of those dimensions.

I have decided that for most things, I prefer the above languages.

Woozle Hypertwin replied to Ben

@ramsey @oschonrock @cptwtf @Girgias @IceWolf

To put it another way (from my experience with C++ and Object Pascal): type-conversion doesn't happen except when explicitly specified in the code; you always(ish) get an error if you try to assign data of one type to a variable of another type.

The conversion method is pretty much always specified explicitly, too (as few assumptions as possible), though sometimes it can be hidden under the hood of an overloaded operator. (Operator overloading is both fun and a source of technical debt, so I try to avoid it.)

@ramsey @oschonrock @cptwtf @Girgias @IceWolf

To put it another way (from my experience with C++ and Object Pascal): type-conversion doesn't happen except when explicitly specified in the code; you always(ish) get an error if you try to assign data of one type to a variable of another type.

The conversion method is pretty much always specified explicitly, too (as few assumptions as possible), though sometimes it can be hidden under the hood of an overloaded operator. (Operator overloading is both...

Oliver Schönrock replied to Woozle

@woozle @ramsey @cptwtf @Girgias @IceWolf

yes, the only exceptions to this are the implicit conversions available in c++ via "standard numeric promotions" and "implicitly converting constructors"...

and in fact, both of these are mostly considered a "legacy anti-feature", and modern compilers and linters will warn against them..

(they can't be removed for backward compatbility reasons).

Gina Peter Banyard replied to Oliver

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

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