5 ms·
I find the timing odd [0] that php since v5 ressembles more and more Java very explicit type system, while Java is going backward to more implicit and infered.
by agumonkey 7y ago
I find the timing odd [0] that php since v5 ressembles more and more Java very explicit type system, while Java is going backward to more implicit and infered.
All in all in 20 years we'll all be writing ml ?
[0] technological waves diffuse differently across cultures
- Ayesh 7y agoPHP gained a lot of good feedback from scalar typing in version 7.0, and a lot of improvements are towards more OOP. I think it's a brilliant move because it's still backwards compatible with PHP 5, and even sometimes with PHP 4!
- Piskvorrr 7y agoHaven't seen PHP4 code in a decade (and even then, it was a desperate last stand of an Anfient Monftrofity), and I'm immensely glad I didn't.
- Ayesh 7y agoI still have one client with a 2010 code base. Tools like PHPComptibity and IDE scans can easily batch-fix most of them, but some PHP 4 code never needed any changes.
- Piskvorrr 7y agoOh, it runs, all right. But it's rarely well done (pardon the pun): still fit for a computer, but harder for a human to read and understand.
- jillesvangurp 7y agoType inference does not compromise on static typing. It simply makes it less verbose. IMHO type inference has removed a lot of the arguments against statically compiled languages. Which is why things like Typescript are becoming popular. Even Python has type annotations now.
- minxomat 7y agoAlthough some devs (and style guides) do tend to resist inference in favor of verbosity (C#). Subjectively, I love inference (like in F# or Crystal). I'm not sure if an objective winner exists for best strategy, or how to even measure that.
- Crinus 7y agoIt is certainly subjective, but i am one of those developers who dislike inference in languages where it has them and prefer explicit typing out types - in fact i also go as far as to avoid type aliases (e.g. i prefer something like "const std::vector<some_template<some_foo>>" to "a_foo_vector" typedef for the former). The reason is that i want to know "on site" what exactly is going on when reading and debugging code, especially outside a "smart" IDE, like when diffing changes via the command line, a web-based VCS frontend or some code review tool - especially since these tend to not show the entire code, meaning i need to switch back and forth. But even with an IDE that can show me the inferred types, it is almost always (while i say "almost always" i really mean "always" since i haven't seen any other, but there might be some IDE i haven't tried) done through some popup under the mouse cursor, meaning it is transient and slow. For similar reasons i dislike features like operator overloading, placing non-self-initializing logic in constructors (and the equivalent in destructors), properties for anything that involves complex calculations (unless the language uses special syntax for properties that make them stand out when used) especially for getters, i prefer to use names that hint to what the code does (e.g. i'd use something like "get_foo" only if it doesn't do any calculations and give you a precomputed or cached "foo", otherwise i'd use an "action" verb like "calc_foo" or "find_foo" or whatever to hint that there is some calculation going on and isn't just a dumb getter), i avoid exceptions as they create hidden exit points for functions (and if the IDE/editor allows, i use a more visible - like bold red - font for "return" or the language equivalent so that explicit exit points are obvious), etc. Yeah, these make code more verbose and you need to type more, but IMO the negatives are grossly overwhined against and while the positives way too overlooked.
- viraptor 7y ago> who dislike inference in languages where it has them and prefer explicit typing out types So you prefer std::vector<some_template<some_foo>> foo = new std::vector<some_template<some_foo>>(); Rather than replace the first one with var / let / auto / whatever your language does? Why? The type is already there.
- stunt 7y agoJava adding type inference is similar to PHP which has initially been dynamically typed adding static type features in a sense that both are trying to improve their type system gradually by adding more features. The tooling around has also improved so they can do it now. I like the idea of language to support more type features because there is no one ultimate type of solution for everything and in every situation. Moreover, these are all safe changes. There is less possibility for developers to abuse these features compared to what they can do with implicit conversion, for instance.
- ragnese 7y agoI've been saying for a while that the best PHP code you can write today is basically Java that you were writing 10 years ago. The trade-off between Java 7 and PHP 7.x is that Java has generics, but PHP's treatment of nullable variables is better/safer.
- james-mcelwain 7y agoType inference isn't "going backwards."
- agumonkey 7y agoDon't interpret it as a negative.
- leshow 7y agoType inference is going forwards not backwards. Languages with "modern" type systems (Haskell, Ocaml, Rust, Swift, etc) have had inference from the start and it doesn't compromise type safety. There's a big difference between dynamically typed and type inferred. Haskell, for instance, was designed to have globally decideable inference (you don't have to write any type signatures if you don't want to), while still being completely type safe. Type inference is a wonderful thing, and I'm glad 'maintstream' languages are getting it. Albeit 30 years later...
- bjoli 7y agoI don't think the parent disagrees. Type inference is great for just about everything except dependant types which are all kinds of undecidable unless you help the compiler.
- weberc2 7y agoCould have been a lot sooner if the languages that first implemented type inference also focused on the more pragmatic aspects of programming. 'Type inference' is a small consolation if the tooling and ecosystem are impoverished and you can't find affordable developers. :)
- jesseschalken 7y ago> All in all in 20 years we'll all be writing ml ? If everything goes well, yes. Everything is moving towards static typing with local inference.