4 ms·
Since I'm sure this will quickly be a debate about PHP, these are the reasons I liked PHP at the time: 1. Ubiquity across web hosts. 2. Native support for JSON
by TallGuyShort 9y ago
Since I'm sure this will quickly be a debate about PHP, these are the reasons I liked PHP at the time:
1. Ubiquity across web hosts.
2. Native support for JSON-esque associative arrays.
3. Integration with HTTP seemed amazing compared to other languages used for CGI.
1's not an issue anymore thanks to the cloud and other improvements in hosting services. 3's not an issue either thanks for good web frameworks in better languages. But 2?
Flex / JavaScript / PHP really are a pleasure to write some things in because of the flexibility of those data structures. Working with JSON, etc. in Java and friends is really painful and boiler-platey. Anyone aware of really good implementations that feel like PHP / JS in more widely respected languages?
- Avshalom 9y agoIt's not the ubiquity of php per se so much as mod_php meaning deployment is literally 'drop in' there's no setting paths or configs or even a little friction it's just write and save your php file.
- WaxProlix 9y agoRuby, Python, etc all do this fairly well if you're talking about dict/assoc.array literals and ease of serialization/deserialization.
- TallGuyShort 9y agoYeah Python does well, but boy I wish dynamic properties were smoother sometimes, e.g.: a[b][c] == a.b.c. But I'd rather Python be Python than compromise correctness for PHP-like flexibility :)
- int_19h 9y agoYou could implement an object that does it this way - it would basically implement __getitem__ and __getattr__ identically.
- WaxProlix 9y agoThis causes all sorts of problems, though. If you conflate the language's symbol table with a data structure managed by the language (ie, a hash or dict) then suddenly you have the same problems as JS did for ages. I can't put a '__init__' or ' ' in my key names anymore, or any of the other special cases. Best to leave them as hash keys.
- Joeri 9y agoAfter a long stint on php I'm now using jackson inside of play framework to work with json from java. It's quite easy to use. https://www.playframework.com/documentation/2.5.x/JavaJsonActions https://www.playframework.com/documentation/2.5.x/JavaJsonAc... I don't miss php much. I'd like to have instant browser reloads back. Play's incremental compilation does give you an edit-reload cycle, but it can be sluggish. (Incidentally, the reason I use java now is because this web app is the front-end to a hadoop platform, and php's hadoop integration is less than ideal.)
- int_19h 9y agoOther dynamically typed languages have already been pointed out, but one that might surprise you is C#. For starters, because it supports [] overloading, you can do: foo["bar"]["baz"] unlike Java's .get(). But more interestingly, it has opt-in dynamic typing, and the most popular JSON library actually makes use of that. Thus, you can do something like: dynamic obj = JObject.Parse(json); int x = obj[0].foo["bar"].baz; With [] and dot notation both accessing by key, the only difference being quoting.