5 ms·
As a PHP developer, I'm less than enamored by this because it seems as though it increases spaghetti code. - Embedded sql in the fashion of php.reboot is dirty
by josegonzalez 15y ago
As a PHP developer, I'm less than enamored by this because it seems as though it increases spaghetti code.
- Embedded sql in the fashion of php.reboot is dirty.
- No open/close tags and using brackets sounds error prone.
- I'm also personally a fan of the dollar sign.
It appears as though what you really want is Ruby.
- notJim 15y agoThey didn't make it very clear, but I think the embedded SQL idea is meant to be for things like querying against collections, similar to LINQ[1]. Even it's meant for databases, it's still up to you where in the app you put it. That being said, my initial reaction is to wonder why, when designing a new language, one would model after PHP of all things. 1: http://en.wikipedia.org/wiki/Language_Integrated_Query http://en.wikipedia.org/wiki/Language_Integrated_Query
- josegonzalez 15y agoYeah I'm also not a fan of linq. Or at least not in my PHP. I think something like underscore.js[1] would be much more in the style of PHP - I always thought PHP and JS were similary in their wackiness - and I would much prefer it to LINQ. As far as modeling after PHP, there are things I'd leave/take, but really the biggest issue is the standard library. 1: http://brianhaveri.github.com/Underscore.php/ http://brianhaveri.github.com/Underscore.php/
- jond3k 15y ago+1. wish I'd seen underscore.php sooner!
- gbaygon 15y ago"- I'm also personally a fan of the dollar sign." May i ask why? i think that this makes the languaje very ugly.
- gburt 15y agoI like it as well, it makes it very clear what is a variable and what is some other sort of identifier.
- etfb 15y agoHere's a contrived example to demonstrate the value of sigils: /* in version x of SFL (Sigil-Free Language) */ school = get_school("Saint Fred's School For Girls"); class = get_class(school, "Agricultural Studies", 12); yield = get_agricultural_yield(class, "Turnips", 2011); printf("The Year 12 Ag Studies class produced %d turnips in 2011", yield); Now we try upgrading to version x+1 of SFL, which adds object-orientation and concurrency (it was a BIG upgrade!). Now three of the lines in that four-line program contain errors, because "class" and "yield" are no longer valid variable names, having been turned into keywords. In a language with sigils, that's no problem. It also makes it easier (therefore faster) for syntax highlighting to spot where variables are used, without needing a full dictionary and an exact version number - that makes a difference for me as an Emacs user especially.
- josegonzalez 15y agoetfb is on the right path, but for me it just feels right. I guess that's just a personal preference, but the dollar sign is a visual indicator that a particular string is a variable, and not a function call. For me, it makes a big difference in languages like ruby where you could either be calling a method, a monkey-patched method_missing callable, or a property in some scope.
- encoderer 15y agoReally? It's cleaner to have queries represented as strings than as a language-integrated syntax that can throw errors at compile time? To each their own, but if I had to guess, I'd say you've got a minority opinion there.
- ceejayoz 15y agoI doubt it's a minority opinion, at the very least amongst PHP devs. Having it as a string allows me to pass it to a logging function, or output it in a debug console, or send it to a query pre-processor that adds the right database prefix for the current app, etc.
- encoderer 15y agoYou're making the assumption that you'd lose that functionality if you moved to a language integrated query? Not so. Take a look at the Linq implementation for a good example. Or, look at something like JSON in javascript.
- dbattaglia 15y agoAs encoderer said, you can definitely do that in Linq. The query operators basically just map to methods, which are overridden by the different providers... The SQL ones basically create SQL statements for you behind the scenes (as log gable strings). I thought it was all kind of weird and wrong at first too but now it's probably my favorite c# feature next to the (very much related) lambda expressions, especially for non-SQL collection queries. Of course this doesn't mean PHP needs integrated queries or anything, but it is a very nice feature to have if done right. XML/json literals, on the other hand, do feel kind of wrong to me though (although I bet they are handy still, as many vb.net devs will probably attest to). [Edited for spelling - damn ipad keyboard!]
- scott_s 15y agoYou never lose capabilities by adding semantic structure. It's trivial to flatten that out with a toString of some kind.