What is the best scala-like persistence framework available right now? - database

What is the best scala-like persistence framework available right now?
Hibernate works, but it's not very scala-like. It insists on using annotations, no-arg constructors, doesn't work with anonymous class instances, doesn't work with scala collections, has an outdated string-based query model, etc.
I'm looking for something that really fits Scala. Does it exist? Or do I have to make it?

Squeryl is a strongly typed, LINQ like persistence framework written entirely in Scala.
In any case, it looks very promising. There's also ScalaQuery by Stephan Zeiger, which has a similar approach.
I haven't tried these two out yet, but will likely do so in the very near future.

Old question and that's probably why no one mentioned Slick at the time, but that's a good choice nowadays. It's developed by Typesafe, so there's some assurance of quality and continuous development that other frameworks might not have.
Anyway, this link might be a good source for anyone looking for other options: http://manuel.bernhardt.io/2014/02/04/a-quick-tour-of-relational-database-access-with-scala/.

Lift has a persistence framework in scala, but it's integrated with the web framework and is a bit specialized.

I've not gotten a chance to evaluate it personally, but it looks like eBean is very Scala friendly. It even supports Scala types (as of Release 2.6.1).

Related

Codename One ORM

Is the ORM in Codename One similar to hibernate?
I can't find any detailed examples.
I have seen one tutorial to persist objects. But i'm more interested in populating the database with XML during install and then retrieve data on query.
Or, would it be possible to use hibernate with Codename one?
Codename One doesn't have an ORM. It has an Externalizable implementation similar to Java serialization and manual SQL support but no ORM and nothing like Hibernate.
The reason why that is missing is pretty simple, ORM's require either reflection or bytecode manipulation. Codename One translates code to C for iOS thus discarding reflection meta-data, on Android the code is obfuscated to comply with Googles guidelines (again breaking ORM). So a traditional ORM would be problematic to integrate.

symfony vs cakephp [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
What is conceptually the difference between symfony and cakephp?
Just to balance out this thread, this is why I like symfony:
uses PHP5
it runs some really big sites like Yahoo! Answers, delicious, and Daily Motion.
good documentation. the jobeet tutorial on the website is awesome. walks you straight through all of the features, and after you are done you feel like you can build anything.
is highly modular; many of the symfony components work on their own.
allows you to choose either Propel or Doctrine as your ORM. Doctrine is really great and easy to use.
you can define your models with YAML or in PHP, its up to you. Some people don't like configuration files, and you can really limit their use if you want to steer clear of YAML.
the updated symfony cli (as of 1.2) is awesome. I agree with abales, before this version it was a little wonky, but now it is very well documented and follows a predictable format.
there are a lot, and i mean a lot, of similarities with ruby on rails, except that of course PHP isn't quite as pretty or flexible as Ruby(!). But, if you talk to a cake developer, they will probably say the opposite :)
the symfony admin generator, which is a step up from CRUD (which also exists in symfony), is a huge time saver. Using your data model it will generate customizable admin interfaces complete with list views (index), create, and edit pages. It's not like basic crud where it generates the source and you go in and modify it... You actually can define how each field looks, which fields you want to include, what additional actions you can perform on each object, and so on.
Conceptually, I'd say the difference is this:
CakePHP has a smaller learning curve. If you have never used a MVC framework, Cake will be easier to pick up and run with in a short amount of time.
Symfony feels bit "bigger," not to say that it is slow, but that there is a lot of code back there that will let you do a lot of really advanced things when you need to.
The best advice I can give is to quickly try to set up a your own simple data model in both, and experiment with some basic interfaces, and just see which fits your own coding style the best. I think both frameworks have very active and passionate user communities and you won't regret your decision either way.
CakePHP philosophy is similar to Ruby on Rails.
CakePHP is better for medium projects.
CakePHP is faster to learn.
CakePHP is lighter than symfony.
CakePHP's Database Interaction uses CRUD.
CakePHP uses the test system PHPUnit.
Is interesting in CakePHP Bake and scaffolding.
Symfony's philosophy is each version is different.
Symfony's is slower to learn.
Symfony's is best for large projects.
Symfony's Database Interaction uses Doctrine.
Symfony's uses the test system PHPUnit.
Is interesting in Symfony's Bundles and templates.
A big difference is in how models are created: CakePHP models are written in PHP, and Symfony models are written in YAML and powered by Propel. CakePHP's approach is more similar to ROR's ActiveRecord (although it isn't exactly an AR implementation). CakePHP, in general, is more rails-esque.
CakePHP's documentation and tools, in my opinion, have a wider target audience and the syntax and helpers are easier, but thy have yet to embrace PHP5 as their exclusive target (to autoloading isn't really there). In general, I prefer CakePHP's approach because it sort of follows an established standard, and I applaude it's organization. I'd also recommend Kohana for it's PHP5 goodness.
There's another post on stack overflow about this question, although its a bit different in focus.
Edit: I revisted Symfony to find the reasons I said 'no' and came up with these — your opinions and mileage may vary:
CakePHP also offers dead simple scaffolding and easy to understand CLI tools. Symfony's CLI syntax is a bit wonky to me, and 'CRUD' in Symfony just isn't the same. Combine that with Symfony's (awkard) action syntax and throw in Symfony's poorly designed (and challenging to understand) website, and preference for 3rd-party paid documentation (books on Amazon) and you have more ticks in the cons column.
Some of the claims about CakePHP and limitations above simply isn't true. The query is possible. You just have to know how to make it. The "automagic" of CakePHP is SUPER nice so you can hit the ground running FAST. It is BY FAR the FASTEST framework to development (hence why it's so closely modelled after RoR which obviously was a big success and buzz). There are more advanced behaviors to get data returned differently and make some of those more complex queries with a few short method calls and array parameters specified.
However. As far as I can tell, no other framework has as many "automagic" methods and classes. Cake takes the most common of tasks and provides an easy way to get it done. If you're really clever, you'll do most of your coding at the model level and make use of the app_model and app_controller file and have an extremely efficient application.
The console is great and always expanding. The community is truly amazing and there are many many contributions to help you get things rolling even faster. You can literally architect and then move "pieces" into place to build an app very quickly because most of what you'll need is available. You do not get that with any other framework. You have to spend a LOT more time coding usually.
Lastly. While the documentation was lagging, it is much better now and while Cake also got some harsh reviews during this lack of documentation and version 1.1 period...It was STILL good, just severely overlooked. With 1.2 and now Cake2 and Cake3 on the horizon...You're going to see a lot of opinions changing.
I have used CakePHP since 1.1. I'm a firm believer in it. I have used it for huge corporate sites. That receive millions and millions of hits per day...We're out of the realm of things like WordPress and Drupal for solutions. When you get to that level for a CMS type site, I am super glad to have CakePHP on it. Likewise, Symfony and CodeIgniter will help you with the scaling. I can't say anything bad about either of those frameworks either. I can only say that you will spend less time coding and find a larger community (and a super friendly IRC channel) with CakePHP.
I'm going through and documenting some of my responses to the above comments about CakePHP and some of it's (in some cases rightly) perceived faults.
Big websites are run using CakePHP, some being Mozilla Addons, Scratch by MIT, and Hot Scripts. There is a bigger list right at the bottom of the CakePHP website (http://cakephp.org). Regardless, any good developer should be able to build a scalable website using a framework as long as the framework isn't completely silly (CakePHP isn't too silly :D ).
It is true that there isn't one very good (free) CakePHP tutorial that goes through every feature of the framework, but the documentation is extremely well laid out and verbose. Anything that isn't clear can be cleared up through the Google Group and on IRC, and we welcome any and all changes/corrections to the documentation. Documentation is not just a core developer issue, as many things are application specific and people come up with interesting tips and tricks, and so thusly everyone is invited to contribute (Not just comment!). Of course it is all moderated, so most of the cruft/spam is not added.
The code is modular in that you can add in new code that supercedes core functionality. Much of the code is simply PHP classes. It is true that writing such functionality may be a burden, and I have not tried using alternate classes as fillins. Yes, it does not handle other ORMs, so you are stuck with the default, but this should be fixed in Cake3, which will be able to mix and match any other PHP classes at will (that includes Propel and Doctrine support).
The CLI is very good, and it is easy to extend for App-specific support. One example is that I recently developed a shell plugin that would automatically install any other CakePHP plugin that I have indexed from github. Took about 5 hours to build something extremely usable and flexible. I'm sure such functionality exists for Symfony, and it DOES exist for RoR :)
As for being Rails-like, it is and it isn't. Many things are similar, they are MVC frameworks after all, and CakePHP goes for the "Conventions vs Configuration" approach. PHP4 support mucks with a nicer syntax, which Symfony doubtless has because of PHP5-only support, but it is still extremely usable and intuitive. The framework does not provide EVERY feature of Rails out of the box as it isn't a straight clone. CakePHP is a framework, not a library (hi Zend), so it won't provide everything out of the box.
Generation of views is, I agree, a bit wonky in CakePHP. It is being greatly enhanced in CakePHP 1.3 and 2.0. It will support custom templates for each and every Model, View and Controller (as opposed to just a type of view as it does now). Also, there exists a set of shell tasks on github by a user going by neilcrookes that auto-bakes only certain types of views (including only admin views) which can be used in combination with custom templates to produce exactly what you want. CSS styling also helps :) but this is definitely something that can be improved.
CakePHP takes many varied parameters in it's Model::find methods, although in certain cases it may be useful to use raw SQL queries. The Model::find() method is very flexible and has not failed me insofar as creating complex finds. I suppose that is related to being comfortable with the ORM, which inevitably always takes time.
Form validation should logically be in the model layer, as that is where any action related to the database is being performed. You can specify alternate validation in a specific view I believe, or swap validations (there is a behavior for this but it wouldn't be hard to do so without it).
Multidimensional arrays are a bit silly, but you'd still likely have multidimensional objects. PHP4 had a broken Object Model and so that is why CakePHP does not use objects. This is being corrected in a future version of CakePHP (as I pointed out above in a previous comment), but it is useful to have a framework that supports PHP4 in some cases. Again, YMMV and I agree that full PHP5 will be a great boon, both in speed of the application and of development.
Databases can be swapped out at will. CakePHP does not allow functionality that is inherent in only one type of DB (hence the dropped support of ENUMs that are only in MySQL), so that the ORM is always supported and can always build valid queries. You can have multiple databases in an application, one per each Model if you wanted, and can swap them at will or even not use a database at all for a specific model. So no, it is not tied to a specific database.
In the end, your choice is your own, and I wholeheartedly suggest looking into both and reading through the documentation, checking out the Groups, IRC channels, blogs and any forums for both and seeing which framework suits your development style the best. Reader beware, I'm a CakePHP developer so my post has some bias.
Further to the existing answers, you should try both if possible. I use both quite a bit, and over some time, have come to prefer symfony.
but I'm fairly convinced that its not because one or other is better, but because symfony happens to suit the way my mind works better, its closer to what I do when I write software outside a framework, so feels more intuitive. I expect that others may find their mind fits the paradigm of another framework.
Having said that, I do think that cakephp's objects are a weakness, through the use of arrays rather than objects. (This is something that periodically develops into an intense hatred inside me whenever I need to do something that it makes hard ... ! ) They could do exactly the same, but return objects rather than arrays to represent data, and I think most of the issues I have would go away - you'd be able to add extra functionality into the data objects to achieve the things I want to do, rather than writing functions in the existing model class and passing them an array.
The model layer of CakePHP is a mess. Try doing simple things like a many-to-many relationship between a Category and an Item object and then retrieve all the Items in a Category that have a specific property set.
Like:
SELECT items.* FROM items, categories, item_categories WHERE item.available=1 AND category.id=1 AND item_categories.category_id = category.id
Something so trivial is not possible in one statement in cake with the find() method of a model.
There is also no way in the core API to add a single many-to-many relationship as in one item to the item_category table above. There are a couple solutions online including a behavior that someone posted in the bakery (http://bakery.cakephp.org/articles/view/add-delete-habtm-behavior), but that's just stuff that any good ORM framework like Propel, Torque(Java), Hibernate(Java), SQLObject(Python), SQLAlchemy(Python) support right out of the box. Basically you're either going to have to write a lot of PHP code to add those missing features or use raw SQL queries but the main purpose of a framework is to avoid doing those things so that you can focus on the application that you're writing so you're not really gaining much with CakePHP.
There are a bunch of other problems and they all really have to do with the model layer including the form validation being tied into the model layer, having to deal with messy multidimensional arrays, having to use raw sql and tying your app to a specific database.
I would say use symfony. It's a bigger framework might take a few days longer to learn but it will be well worth it. I was going to use CakePHP for a project that I am working on, after running to too many of those types of issues I switched to symfony and it's been smooth sailing.
One difference more is: Symfony separated to 3 environments: Development, Production and Testing - CakePHP can not!
It's easy to develop and test product at same time
Cake 2.0 nicely autoloads most of the classes you need, whereas I found in Symfony 2 that every class had to have numerous imports at the top of the script. Attempting to memorize all those imports is near-impossible, so you always need a reference handy.
eg. Symfony 2 controller code...
namespace Acme\HelloBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
// bunch of other imports accumulate here...
class HelloController {
...
Argh, yuck. While that may be good OO technique for the purists, it lengthens development time (bye bye RAD). At least with Cake I can code most of the simple stuff quickly from memory now.

What is better CakePHP or pure PHP for a huge Project?

I just know pure PHP, never worked with a framework before, but my boss wants me to create our next project, which will be a lot bigger than everything we did before (means bigger than a page that needs only 5 scripts to work, more like 100 or something like that).
But I'm not sure if I can realise it with pure PHP, now I heard that CakePHP could be helpful for that (structure etc.).
Should I learn this or just use my pure PHP way?
As noted, your definition of the scope and complexity of this project is a little vague, but I'll respond with the general observation that larger projects benefit from more "top-down" structure than smaller ones. I suspect that pretty much every PHP developer on the planet started by hacking straight into index.php, then wrote some code for guestbook.php, and so on. Then you realise how much you're repeating yourself and start refactoring to classes and libraries.
Frameworks are the natural next step up from that. The term covers quite a range of products; some that tie you very closely to a specific way of working, and some that are more a library with some loose front control.
I'd advise you to choose a loose MVC framework, which gives you a good structure to work within, but doesn't overly constrain you, and should allow you to use existing libraries. I've not used CakePHP - my experience is with Zend Framework, which I like a lot (not that it's flawless). However, I have worked with another developer to compare the functionality of Cake and ZF, and from what I've seen Cake has many of the strong points that ZF displays. In fact, in many places it almost seems you could convert code from one to another by changing a few classnames.
I suspect Cake's not a bad choice at all, but I can't recommend it as I don't know enough about it. ZF I do know, pretty well now, so I can recommend it - and the docs are now pretty good.
Before you dive into either Cake or ZF, you'll need some understanding of the MVC design pattern. Jason Sweat's book is a good, if slightly dated introduction, and the ZF manual is also pretty strong.
By the way, it's not a choice between "Cake and Pure PHP". Cake (and ZF) are both "Pure PHP". The difference is between "PHP I wrote", and "PHP someone else wrote" (so I didn't have to). From this, the important bit is that you trust the quality of that "someone else's code", which in this case you'll have to do by recommendation and reputation.
But don't just go asking "What's the best PHP framework?" - that's like asking for the best text editor ;) And I'm sure this response (or question) will get tagged 'subjective' in mere moments.
I've been using Cake for a couple of years. I'd say if you haven't used any MVC framework before, you should definitely learn one to expand your horizon.
It's not really about using the framework for your convenience. It's about seeing how things are done in the framework-land. You'd really gain some insights that you can carry over even if you later decide not to use a framework.
Your description of the project didn't sound too huge. However, learning an MVC framework is some serious learning curve there. Basically you'll feel like you're learning a whole new programming language. So for your situation if you really do decide to try a framework, you might want to factor that in your schedule.
To get you started, I personally think CakePHP has a more elegant solution and has tighter design philosophies. CodeIgniter, on the other hand, seems more natural to "pure PHP-ist" because it's less abstract so it might be easier to pick up.
To answer the titled question though, I'd think any huge project should roll their own from the start instead of using a framework. The whole point of using a framework is because you want to leverage some of the stuffs they have built in for you. But for really huge projects, many of the parts should be customized anyway, so you might found yourself restricted by the framework more than leveraging it.
But then again, I really don't think your project (by your description) is anything near huge. As a ballpark estimate I'd say any project under 50k - 100k hits a day can safely benefit from using a framework.
I do not say CakePHP. But any framework will do. The major benifit will be you will get a default folder structure, skin, language framework (oscommerce etc. do). You will be customizing this framework. Most features will/may there be by default, like email sending, page creation, Menu generation etc.
You did not say what kind of application you plan (may be because of NDA). More details, more accurate answers.
I agree that it shouldn't be a decision whether to use CakePHP, but whether to use a framework at all. There are a multitude of PHP frameworks out there (Cake, Symfony, Codeigniter, Zend, etc.) and each has it's advantages and disadvantages.
If it was me, I'd use a framework just to strictly enforce some MVC rules... with a large project, keeping things structured helps down the road when someone else inherits the system.
The key here, is don't get lulled in by the "code generation" aspects. If you don't know the framework (or don't know the language as well as you could) down the road, the code generation could be more of a headache than it's worth.
Using a PHP framework like cakephp will reduce the amount of code you need to write. In cakephp there are many things that will save time like using elements to display snippets of code that you use often. If the project is really big, it will help tremendously because your code will be shorter and much more clean and organized. It will be much more easy to maintain as well.
I think that pure php would be the best option because if you use a framework you are restricted to their boundaries,
whereas without framework you are free to design anything, if you think that you have the best capability of solving problems and making algorithms then you must go with php not any kind of framework
and if you just want work to be done then you must go with framework i haven't worked on framework by have some knowledge of cake php i didn't liked it as i think i am tied with some rules, i prefer writing my own code and in case you want to do less work in future just write you own rules (its like making your own framework) just save every thing you created in small files and then use them in you other project just like one of the benefit of OOP(Object Oriented Programing)
If you know PHP, you'll learn more about how to implement common design patters if you start reading other peoples code. The more you read, the more you'll get perspective on what good code looks like, and what bad code looks like.
It is tempting to "code-your-own" because you will understand it more fully, but remember, you're not going to be the only one working on this, and one day, you might actually want to work on something else, and having a system which is widely implemented and understood can make it easier to move on.
As far as whether cakePHP a good choice for your particular project, it's hard to say without knowing more than it's going to be "bigger".
Everything depends on the project and the project stake holder. If there is going to be a lot of modification, either during development or after the project goes live, a framework can be pretty limiting to someone without a strong grasp of the theories behind the framework (not a judgement on the programmer, just a statement.)

Rhino Mocks vs Moq for Silverlight

We are Silverlight Unit Test Framework for testing.
Which one will be better for my team? Rhino Mocks or Moq. No one has any experience with using a framework like this.
What are the pros and cons of using each framework in this environment?
Take a look at both, and see which syntax suites you and your teams skillset.
Rhino Mocks has been around for nearly 4 years, and supports a couple different symantics. The record/playback is the oldest, and the Arrange Act Assert (AAA) is the newest. I would say that in the community, Rhino Mocks is the standard framework due to how long it has been around, and how easy it is to find examples, documentation, and help with.
Moq is really about 1 year old, and relies heavily on .Net 3.5 syntax, like lambdas. I think because of how new it is, it might be harder to find people who have used it, and get help with it.
More important than the framework you choose, is getting an understanding of how mocks help you test, and also how they can change the way you think about designing systems for testability. In the end, the framework doesn't matter, the experience and knowledge matters.
There's not much impact of Silverlight itself on the frameworks, and using them is not much different than doing so in full .NET
RM is said to have steeper learning curve, and MoQ allegedly has cleaner API, but RM on the other hand, has been around for much longer, and probably supports more corner-case scenarios.
I'd suggest to spike with both, and choose whichever you find suits you better.
I prefer Moq for its lamba-like syntax.
I find it very difficult to use Moq with ref/out parameters in functions setup's... Switched to Rhino because of this

Querying like Linq when you don't have Linq

I have a project that I'm currently working on but it currently only supports the .net framework 2.0. I love linq, but because of the framework version I can't use it. What I want isn't so much the ORM side of things, but the "queryability" (is that even a word?) of Linq.
So far the closest is llblgen but if there was something even lighter weight that could just do the querying for me that would be even better.
I've also looked at NHibernate which looks like it could go close to doing what I want, but it has a pretty steep learning curve and the mapping files don't get me overly excited.
If anyone is aware of something that will give me a similar query interface to Linq (or even better, how to get Linq to work on the .net 2.0 framework) I'd really like to hear about it.
Have a look at this:
http://www.albahari.com/nutshell/linqbridge.html
Linq is several different things, and I'm not 100% sure which bits you want, but the above might be useful in some way. If you don't already have a book on Linq (I guess you don't), then I found "Linq In Action" to be be good.
You might want to check out Subsonic. It is an ORM that uses an ActiveRecord pattern. I'm pretty sure most of its features work with the .NET Framework 2.0.
To echo what Lance said - the SubSonic query language has a fluent interface which isn't as pretty as LINQ, but gives you some of the benefits (compile time checking, intellisense, etc.).
LinqBridge works fine under .NET 2.0, and you get all the Linq extensions and query language. You need VS 2008 in order to use it, but you already knew that.
However, Linq it not an ORM. It's a query syntax. If you want to use Linq to query a database, you will need .NET 3.5. That's because 2.0 does not provide the mechanism needed to convert Linq code to your favorite database query language.
In other words, if an ORM is what you need, LinqBridge will not help you. You need to check out some of the other suggestions provided.
There's a way to reference LINQ in the .NET 2.0 Framework, but I have to warn you that it might be against the terms of use/EULA of the framework:
LINQ on the .NET 2.0 Runtime
First of all. Getting linq itself to work on 2.0 is out of the question. Its possible, but really not something to do outside a testing environment.
The closest you can get in terms of the ORM/Dynamic Querying part of it, is imho SubSonic, which I'll recommend for anyone stuck in C# 2.0
LinqBridge looks like a pretty nice place to start since I have VS2008, I just need to compile and deploy to a .net 2.0 server.
I've looked at SubSonic and it's also an interesting alternative, but linqbridge seems to provide a much closer fit so I'm not going to have to go and learn a new ORM / query syntax.

Resources