4 ms·
By that example, I meant to highlight the DRY aspect of programming and how I realized, as an early beginner at the age of 15, that frameworks and libraries pro
by sgacka 17y ago
By that example, I meant to highlight the DRY aspect of programming and how I realized, as an early beginner at the age of 15, that frameworks and libraries provide a good foundation so you can focus on more complex issues.
The SQL I kept repeating in that application was simple CRUD functions on MySQL tables. I know that SQL is so much more than that.
- marshallp 17y agoSql isn't more than that. That's the whole beauty of relational programming, you only have to write queries and views, and this simple abstraction does most of the work that you need to do (with pl/sql or t-sql it is turing complete and you don't even need to leave the rdbms).
- wlievens 17y agoI don't get why some people keep praising SQL like this. SQL is great for complex queries that contain valuable logic, but it's not expressive at all when you want to do something trivial. Getting all the attributes of user X is so much more work, and harder to maintain, in SQL than it is in any ORM. "select name, pass, hash, email, realname from user where id = ?" versus session.get("User", x)
- jrockway 17y agoSQL is not particularly nice for complex queries, either. The underlying model is good, but the particular syntax they chose is verbose, confusing, and non-portable.
- wlievens 17y agoI kind of agree, but I was conceding the most reasonable argument to the parent.
- james2vegas 17y ago'SELECT * FROM user WHERE id = ?' OR 'SELECT getUser(?)' presuming you have a stored procedure/function getUser that returns the data you need, and you should (or a view, at least)
- mattmanser 17y agoSELECT *? A function in the SELECT statment? Oh dear god, a blasphemer! The former can cause performance problems if you have blobs as well as being an unnecessary security hole, the latter can cause performance problems over large datasets as it often forces the execution plan away from a set based solution.
- wlievens 17y agoThe fact that using the most trivial of examples triggers a discussion in on itself helps to prove my point. Nobody debates session.getUser(id)
- ewjordan 17y agoRelational programming may be beautiful, sure, I guess in some ideal world. But SQL syntax is a dog. Especially when it's sitting next to real code, wrapped up inside strings and making everything feel dirty. If you're using an SQL database from within another language primarily just to dump objects and pull them out, and especially if you're doing a lot of it, I have trouble thinking of a situation where you wouldn't prefer to abstract away the SQL bits. Maybe if you're working in a language with built in SQL syntax support? Even then, it's not exactly compact, and you've got quite a bit to do even after you get your results back from the database...