Don't get me wrong. I think both projects are fantastic.
But as both php and ruby developer I wonder if there are there any compelling reasons, besides possible language barrier, why would one choose Behat over Cucumber (with cuke4php) for BDD even when working with php or some php framework.
I'm a Behat developer.
Why I've developed Behat instead of Cucumber customization:
Speed. There's no simple way to bootstrap/run PHP from Ruby code. This means that you need to implement wires/proxies and other things, which makes your tests insanely slower. And slower tests is not a test, it's just code that eats your customer's money.
Extensibility. There are very few PHP developers that really know Ruby. It's a hard to use tool, that many don't understand! All examples written for Cucumber are Ruby code and you even can't look at Cucumber sources, because, let's say, you don't know Ruby. It's like buying a submarine when you just need a taxi.
In terms of features, Behat and Cucumber are almost the same (I've worked hard to achieve this). But in terms of speed/extensibility/logic from a PHP developer's perspective - Behat is better, because it's a fast and clean native PHP tool. Behat is not a Cucumber port, as you might think by first, it's built entirely from the ground on PHP 5.3. Behat is trying to simulate Cucumber with its input reading (features) and output formatting (formatters), but it's not a Cucumber port (there are no Ruby syntax constructions in PHP).
Yet another reason why you may need Behat is explained here: https://cucumber.io/blog/bdd/when-cucumbers-go-bad/
If you have PHP project, you may want to create context for internals testing (domain layer, application layer).
I wanted to toss in my two cents on this topic with an answer that addresses various use-cases in a professional setting.
If you are working with other developers on a codebase written primarily in PHP, the advantage boils down to your coworkers.
If your team is more comfortable in PHP because that's what the codebase is written in and people have trouble or are annoyed by context switching to different programming languages (most people are this way in my experience) then it is better to accommodate your team and use Behat. People will complain less and (hopefully) get more done.
If your team is fluent in a variety of languages and most people have no problems switching between using Ruby (cucumber) for acceptance tests and using PHP for everything else, use the language best suited for the job. Ruby is much more expressive than PHP, so cucumber is arguably a better choice.
If your team is more comfortable with PHP than Ruby, then go with Behat. Native compatibility ensures expressiveness and avoids weirdness, besides the fact that it's faster.
Related
I'm looking to develop a Win32 desktop app - a one off, for a personal need. A GUI is not scrictly needed, though would be a bonus.
What is needed:
The ability to monitor the window title of a specific window.
The ability to run DOS commands when this window title changes.
I hope my programming ability is up to this - I feel I'm pretty good with PHP, but I'm not ready to spend time learning OO for this one-off project.
What non OO (or at least not mandatorily OO) languages are there for desktop apps that might be suitable for a beginner on a task like?
Any other, more hacky approaches are welcome too - batch scripts etc.
Many thanks for any advice,
Jack
Whether or not the language supports OO doesn't really matter for your purposes. After all, PHP supports objects and you seem to do just fine with it.
Personally, i'd recommend Java or C# to get started with. The communities for these two languages are huge and there are plenty of tutorials online to help you get started.
It's extremely easy to get starting writing C# with Visual Studio Express. And a good hello world tutorial.
Also, if you stick with C# you can take advantage of WMI which will allow you to do everything you need for this project (and much much more).
Lastly, most windows machines will be able to run your application without having to install anything extra and Visual Studio builds the .exe for you as part of the build process.
You can use PHP for desktop apps if you really want to. Just install the php CLI.
You can even do a gui for your desktop app in php: http://gtk.php.net/
EDIT: I'm not sure how easily you can call win32 api functions from PHP, however. There look to be a few articles about this online and a SO question: How to call winapi functions from PHP?
I would vote for Python using the included TkInter module for GUI. Dead simple to use.
Widgets aren't the prettiest looking, but development is rapid.
EDIT: I mistook "non-OO" in the question for "OO". Python is most definitely not "non-OO", but but is very well suited to doing what you asked.
You could write this in pretty much any mainstream language supported by Windows. C or C++ are obvious choices. C# and Visual Basic .NET are going to require the .NET Framework ... not a bad thing, but perhaps more than you want to tackle for a simple project. Come to think of it, you might be able to do this with JScript or VBScript, although I'm not clear on what API functions you have easy access to. And I have to believe that it's possible to do with PowerShell with just a little work.
Your options are wide open.
F#
It's an awesome piece of work, has access to the Framework class libraries, supports GUI development, really easy parallel programming, compiles to IL (same as C#) but has a really concise functional syntax.
I would like to be able to write database driven applications (i.e. standalone apps that are not web based and don't require a browser or Apache server to run)
I have attempted to do this in Codegear C++ Builder in the past but even though my 'background' is in that (C++ OOP with Borland Builder) it is so far removed from doing the same sort of thing with PHP/mysql and other web technologies that I found that I couldn't get very far for a lot of effort getting it to work. It was a while ago now but I was using the built-in database engine that comes with Builder and I just found it frustrating and difficult.
In other words - Is there something out there that will allow me to make use of web based languages to write standalone applications (specifically PHP/Javascript/mysql)
You can stick with PHP if you want. There are QT bindings, GTK bindings, OSX/Cocoa bindings, and you can call Win32 functions. I don't know how stable all of those are, but you can do GUI in PHP as well as the command line stuff.
As for other languages... PHP is very C like. It started as basically a scripting wrapper around C (IIRC), which is why you have functions named after the C standard library (like strstr). C like languages will feel quite familiar.
I would think Python would probably be the closest to PHP. It's a scripting language, syntax is somewhat close, it has a ton of libraries, and is very well supported and commonly used. I'd imagine it would feel pretty familiar. Using indenting instead of brackets for blocks can throw some people, but it fit the way I already indented my code.
Ruby is quite popular, and is also a scripting language. I think it's farther away, syntax wise, than Python, but I've never really used it so I can't promise that. I know it has at least GTK bindings.
Perl has a lot of resources and bindings, but isn't as easy to read as PHP since you have to learn the special variables like #_. It was never really my cup of tea.
You do have the C/C++ stuff, and Java has it's large library. You may want to go that way since you say you've used C++ before. If you're on a Mac (or willing to use GNUStep) you could go with Objective-C/Cocoa. That's getting rather far from PHP syntax though.
All of these languages have database connections. You don't mention what platform you're on.
But for easy to work with, quick to pick up, works all sorts of places, and can definitely do GUIs... Python would be a good choice to look at.
You could always use PHP. It is a decent command-line / programing application. Other than that all I can say is that you knowledge of database access and storage will be helpful but by the end of the day you are going to need to learn a new language.
Most languages have libraries for database access. Just pick one that you like the feel of. It is also a good idea to choose one that is popular (for the community support) and free libraries are always nice. Also look for good documentation and one that is fairly standard.
A nice thing to know is that javascript and php syntax are very similar to many other languages. (Javascript looks almost identical to C and C++). Just read the main language tutorial then the database API tutorial and you should be good to go
In Java or Ruby, there are many talks about test/TDD/BDD. and there are many tests in Java/Ruby projects.
But I notice that, there are less tests in PHP project, and It seems like PHPer does not like to write tests, I just want to know the reason. thanks
I've used several applications or libraries, in a variety of languages, that did not include unit tests. This is not something isolated to the PHP community.
In fact, PHP has several testing frameworks available. Developers may either choose not to use them for whatever reason, or may be unaware of them. After all, a lot of PHP developers are self-taught with no formal training in computer sciences.
Honestly, most PHP developers I know that do use testing frameworks and other lifecycle tools tend to have been in the field for a long time, or come from another background like Java.
IMO there are multiple contributing factors:
It's a pretty new concept for PHPers. I don't use it myself. Most applications are written without contractual API design, hence code preceedes tests (in practice).
The test frameworks (PHPUnit and SimpleTest) are not natural.
PHP runs in a different environment than Ruby/Java. Moreover application parts are split into include scripts, which have different semantics from packages; sometimes locations variate.
PHP isn't as object-oriented to the core as other languages. Most code is procedural / mixed or hybrid.
I would go so far and ask about the merits of Unit-Testing for PHPs runtime environment. Selenium might be a better choice. But personally I'm looking for a simpler approach: simple (non-unit) test framework, similar to .phpt, should evaluate output/headers/errors/results
Yesterday Facebook launched HipHop, a sourcecode-converter from php to c++. The set of php functions and constructions is more limited than in standard php.
Are the current popular php frameworks (ZF, CakePHP, symfony) compatible with HipHop? If not, which parts of these frameworks are not usable?
If I'm not mistaken, HipHop has not been released yet -- even the wiki page linked from the Facebook annoucement yesterday is not up yet.
So, it's going to be a bit hard to answer, right now.
I suppose it'll all depend on :
The features used by the Frameworks -- like already said here and there, stuff like eval is not supported by HipHop
The PHP extensions used by the Frameworks : only a couple of those have been ported by Facebook to HipHop.
Depending on the Frameworks and your specific needs, maybe/probably some subsets of the Frameworks you are using will be supported, even if not every available components... I suppose time will tell which ;-)
With at least ZF and Symfony being used for Enterprise level applications, chances are pretty good they will run with HipHop. If not now, then sooner or later. However, the question is not so much if they can run with these frameworks, but how your supporting IT architecture looks like.
HipHop is for scaling large multiserver high traffic sites like Facebook. In your regular web application, you will likely get no advantage out of it. Just continue to use memcache and APC.
See these related articles:
http://www.readwriteweb.com/archives/rasmus-lerdorf-php-hiphop-facebook.php
http://ilia.ws/archives/213-My-Thoughts-on-HipHop.html
http://terrychay.com/article/hiphop-for-faster-php.shtml
http://www.brandonsavage.net/hiphop-for-php-who-benefits-who-doesnt/
While I'm sure most of us are curious about what HipHop is going to be, I know it will not be a replacement for PHP - it's very much a niche product: unless you're running a large server farm then the performance benefits vs the maintenance costs just wouldn't justify it.
Perhaps it might be an interesting alternative to use encoded PHP for some people - but again this introduces even greater maintenance overheads. The only low-volume scenario where a compiled PHP would seem to make a lot of sense is for embedded devices (where the software exists to support the hardware and not vice versa) and for very high security installations (where its not a good idea to have a interpreter available).
It's far to early to be able to say what PHP software will work with it. However even once thats established, I'd want to see a solid commitment from any supplier that they were going to explicitly support HipHop in the future before I switched.
C.
I won't repeat what has already been said, I'll just add that as soon as HipHop is released you can count on the opensource community to submit patches for your favorite framework for increased compatibility with HipHop.
Also, one good way to test whether your favorite framework is compatible or not would be to launch the test suite using HPHPi (you then know where to concentrate your patching effort ;).
Searching for 'eval' gives a lot of false positives, as you get hits for the word "evaluate" in comments, or escapeValue if the search isn't case sensitive, etc.
If you search for 'eval(' in ZF 1.11 you'll find in once in Zend/Serializer/Adapter/PhpCode.php on line 59, in a method that unserializes stored PHP code. The method isn't a part of the MVC architecture, db component, and actually isn't used anywhere else in the framework (Zend_Serializer_Adapter_PhpCode isn't instantiated anywhere else in the code base).
So if eval breaks your ZF-Hip Hop app, don't use Zend_Serializer_Adapter_PhpCode, or eval in your consumer code.
Simple answer: I don't think it would.
Just saw this on hiphop page: https://github.com/facebook/hiphop-php/wiki/
"You keep coding in simpler PHP, then HipHop executes your source code in a semantically equivalent manner and sacrifices some rarely used features – such as eval() – in exchange for improved performance."
Did a search for 'eval' on ZF 1.9 and there are over 100 occurrences.
We are about to start a new Web2/AJAX app and are trying to decide if its worth the time and effort learning Ruby/RubyOnRails instead of PHP, CodeIgnitor and JQuery we currently use.
The key issues are clean/fast/modern AJAX UI, robust error handling, ans maintainability.
I would appreciate unbiased (if thats at all possible talking languages/frameworks) comments from experienced PHP and RUBY developers.
I can't say too much about Ruby, but I can say that I often feel like PHP gets a bad rap. PHP is what you make of it. Yes, there is a lot of awful PHP code out there, but you know, it was mostly written by people who would have written awful Ruby, or awful Python. PHP has such a wide audience that programmers of all stripes and abilities are using it, and many of them are writing bad programs.
That said, you can write good programs in PHP. Do you have good developers? If so, you can certainly write good code in PHP.
PHP has a terrible reputation because it is so accessible. Anyone can start writing PHP, and most hosting solutions offer PHP these days, so there are a lot of non-programmer types writing programs in PHP. These programs lack proper computer science discipline.
There is a very widespread movement within the PHP community to move toward readable, well formed code as PHP starts to adopt modern language features. With PHP5, OOP became a practical reality and with that an explosion of books and material written about OOP best practices and development patterns. While PHP is often used to write malformed sloppy spaghetti code, the language facilities are there to allow developers to program in development paradigms like MVC, OOP, and TDD.
Not to mention, PEAR has greatly improved the quality and accessibility of community scripts. PHP's strongest asset is its community, and it has been becoming stronger and more disciplined. In many ways, PHP is very much like JavaScript--it had a very sloppy beginning from which the developers and community have been trying to recover. JavaScript is a very sloppy language, but there are some extremely powerful parts of that language that have brought it some well deserved respect in the age of Ajax and interactive web applications.
Languages like Ruby and Python are chock full of things geared toward computer programmers. If you hire a Python or a Ruby programmer, just by virtue of knowing the language that programmer is many, many times more likely to appreciate clean, well organized code than a PHP developer. That is part of the culture of those languages, and the people who evangelize them.
There is nothing inherently better about Ruby or Ruby on Rails in my opinion. Rails was the first mainstream MVC development framework, but its popularity and success has catalyzed the development of similar frameworks in every language imaginable. The choice to write Rails in Ruby isn't an indication that Ruby is better than PHP, which many could argue. Considering the time in which Rails was written and 37signals' fascination with obscure things, I can understand the move completely. At the time, web scripting languages were pretty lame, and 37signals was looking for a language that catered more to the needs of application programmers, not scripters.
You're not being held back using a PHP framework like Zend Framework, CakePHP, or symfony. CakePHP and symfony are both directly modelled after Rails, even if they aren't direct ports. Akelos is an actual port of Rails to PHP. Zend Framework is the most fully featured framework I've used so far. Don't be afraid to experiment, but jumping ship to a completely different platform isn't necessary and it won't change the way you do business. It's the same business in a different dialect.
The most important feature of a language is how much you enjoy using it. If you enjoy the language that you use, not only will your life be better, you will write better code and be more productive. Of course, this is completely subjective; however, I've never heard any first-class programmers talking about how much they love PHP.
Of course, getting to the level of fluency in a language / framework combination that you really know whether it is going to float your boat takes a big investment of time. In my opinion, the time that you spend will make you a better programmer even if in the end you decide that you like a different tool better, so, go for it!
I think it's not about the language but the disciplines that are used in the community. If you are PHP developer who doesn't unit or functional test his code, nobody cares. There are bunch of PHP developers like that. If you are Rails developer and doesn't test your code automatically you're weird, something must be very wrong with you.
Ruby on Rails seems to me more than a framework, all the tools that come with the community. It is recommended that you use some kind of semiautomatic deployment tool like Capistrano. If you're not, you're weird again. And so on.
I agree with dicroce that you can shoot in your leg with both languages/frameworks. You could go with PHP and try to use some of the tools originally ment to Rails and i believe you get a great result.