

Switch to another language in the middle of a project? - sangguine

Hi,<p>My friends and I have been developing a website in PHP on weekends for almost a year now. From what I have read, PHP is not as good as Python or Ruby. I am wondering if we should switch to one of the two. If so, what's the best way to switch?<p>If not, I am also thinking about implementing a PHP framework. We have been developing without a framework. Do you think we should? Doesn't the implementation mean rewriting the code?
======
breily
I find python a lot more enjoyable/productive than PHP, but unless you're
having major problems with your current code, it seems like porting it would
just be a lot of extra work.

I would guess it mostly depends on how much code you have written now (if most
of your time has been design/planning, then it might be worth it), and whether
or not the people you work with have experience with python/ruby.

Whichever way you go, learning python (or ruby, I suppose) will serve you well
in the future.

~~~
sangguine
Yes. It's quiet a lot of code now. And, my friends are not familiar with
python/ruby.

Thank you for your advice.

------
vaksel
finish your project in PHP, throw it up, start making money. Then in your
spare time if you feel like it, switch to another language. Or if you are
starting to have some performance issues.

If you are going to change your language every time some new language gets
hyped you'll never finish.

~~~
jawngee
I'm with Vaskel, plus I'd chime in that if you switch now you totally are
never going to get it done. You should eventually switch to a php framework,
but only after you've finished what you've got now and have proven your idea
viable and workable.

Your experiencing a fairly common mid-project crisis. It's almost exactly like
a mid-life crisis. You're at the point that you can see the end coming and are
wondering if you haven't totally fucked yourself up to this point. You see all
the things you could have done better or differently. The key at that point is
to try to refocus on the finish line and get yourselves there. Take notes on
your mistakes, but always move forward.

Plus you've already sunk a year into it, why set yourself back?

Remember a shitty solution to a problem is better than no solution at all.

------
xirium
I believe that in the book The Mythical Man-Month: Essays on Software
Engineering ( <http://en.wikipedia.org/wiki/The_Mythical_Man-Month> ), Fred
Brooks suggests that you "build one to throw away". I don't recall him
suggesting that you change programming language.

If you are having performance problems or you code has become spaghetti and
your team is most comfortable with the current language then you could start
again in the same language. This has the advantage that you could use good
sections of the current implementation with the least effort.

------
Hexstream
If you want to implement a web framework, keep in mind that it will be a slow
and iterative process. And don't expect to create it in a vacuum (1. make
super great framework 2. use it). It will be more like, you notice some
patterns of repetition in the code of your existing project(s), and then you
devise a way to factor that into a library. Try to implement your web
framework as libraries instead of a monolithic pile of spaghetti. There are
tons of design decisions you'll have to take and it's better if you can use
different parts of the web framework (and perhaps write new ones) for
different projects. At first your web framework will be pretty specific to
your project, and you'll hit walls whenever you want to go in a direction you
hadn't thought of yet. You'll see what is truly general and what's really
project/section/page-specific once you have a good corpus of samples.

That's how it goes for my slowly-evolving will-release-it-someday-when-
it's-ready CL web framework anyway.

------
mooneater
I've heard the suggestion to use Cake PHP as intermediate step from
frameworkless (or "custom framework") PHP, to Rails/Django. Basically it will
result in organizing your code by model/view/controller, so the structure will
be more similar to what you would have in a Ruby or Python framework.

I'd love to hear from anyone who's tried this approach.

------
swombat
I was in almost the same situation as you, and I decided, for the very
reasonable reasons explained in the other responses, to stay with PHP.

In summary:

\- I know PHP, don't know Rails

\- I could be a victim of the "grass is greener" effect

\- I'm already too far into the project to make such a drastic change

\- I made the decision to use PHP in the first place - I'd look like an idiot
for making such a big mistake (even to just myself and my business partner)
And so on.

All very good reasons, and I still think my decision was highly defensible,
and I stand by it.

However, it was a mistake - the deadly kind. There's no telling what could
have happened if I'd switched to Rails at the time (I had a _strong_ hunch
that Rails was way better). But here's what happened:

\- Turns out we weren't so far into the project after all (a typical mistake)
- it was another 8 months before we released

\- I've since learned Rails, and reckon I could probably have redone the whole
site in less time than that with Rails (probably 3-5 months with better
functionality as a result)

\- PHP and the framework I used (custom) were not adequate for our long-term
aims. The viscosity ( [http://www.inter-sections.net/2007/12/01/comparing-
pieces-of...](http://www.inter-sections.net/2007/12/01/comparing-pieces-of-
string-part-1/) ) of the whole thing increased to the point where after we
finally went live, making further changes was too expensive/difficult/error-
prone to be worth our while

Basically, this decision killed this product that I spent about a year working
on.

I still stand by it, but I've learned from my mistake. I even wrote an article
about it (though I didn't mention this specific product, the argument
applies): [http://www.inter-sections.net/2008/01/22/fundamental-
mistake...](http://www.inter-sections.net/2008/01/22/fundamental-mistakes/)

What would I have done differently? How about take a 2 week break and give
Rails a really good try to see how well I liked it and if it was just an
impression. I would then probably have made the decision to switch, and I
believe it would have been the right one. I suggest you do the same with your
product. Building a product that's painful to evolve is a deadlier mistake
than wasting a bit of work. Also, it's not all wasted - you've still learnt
about the business domain.

Anyway, good luck!

Daniel

------
underscore
I think the answer kind of depends on the nature of the project.

Re-writing something you have now in another language/framework can be (in
addition to fun) a great way to learn the new language/framework. If this is
just a fun project, well, cool - best of luck to you. If this is a business,
something that you'd like to start making money (or at least getting press)
from, then maybe the delay will hurt you more than the fun will help you.

In my case, the website was the online component of a small university
department. I inherited a PHP codebase that worked, but that I really didn't
like, and opted to re-write it in Python/Django. I'm really happy with the
decision: I think it was a great way to learn the framework, and the result is
a lot better than the PHP site that it replaced, but I don't think I would
have done it if I hadn't had a working PHP site to placate students while I
was working on it.

Good luck with whatever route you choose to go.

------
Kaizyn
The answer depends on the purpose of the project. If you're building something
to make money, you should not spend the time now to switch languages unless
your NEW language has some library or feature which your current project
simply cannot work without. However, if this is a learning exercise only or
just a fun project, there would be no harm in spending the time to explore
both the Python and Ruby options.

The key to your decision here should be how much time and effort it would
require to duplicate a feature you want to use in your existing system as
compared to what comes out of the box with either a new language or an
existing PHP framework. If it's a pain to do and the functionality is critical
to your project's success, then you should port. Otherwise, I'd recommend you
keep doing what you're doing.

------
maxklein
Very big mistake if you are serious about bussiness. Django and Ruby are very
tough to find cheap programmers for, but there is no shortage of cheap PHP
programmers. Expect a language change to throw you back 3 months or more.

And there are many PHP frameworks, don't implement a new one.

~~~
swombat
Cheap programmers are expensive. I'd rather have 1 great rails programmer than
10 cheap rails programmers. The single great programmer will be more
productive than all 10 of the cheap ones, and far easier to communicate with
and manage.

------
donal
Oh how apt your timing is, Jeff Atwood just wrote a nice article on his Coding
Horror block titled:

"PHP Sucks, But It Doesn't Matter"
(<http://www.codinghorror.com/blog/archives/001119.html>)

Why introduce regressions and headache by switching to another language that
I'm guessing you don't know as well as PHP.

Jeff says it best in that article: "building a compelling application is far
more important than choice of language."

Personally, I'd just keep plugging away in PHP. It isn't my favorite language,
but it has yet to fail me. It is like the farmers rusty pickup truck. Not very
flashy, but it gets the job done.

------
thorax
I've said this a lot, but I can't recommend Code Igniter enough when working
with PHP. Quite fast, almost feels like an entirely different "real" language
with so much library support from the framework.

Even when I work with Django (being a huge Python man myself), I miss having
some of the better aspects of Code Igniter (and definitely CI's user guide is
stellar).

Don't switch languages mid-way unless you have a great reason. PHP blog-flak
isn't a good enough reason (IMHO) unless your team is fluent in another
language they can code more securely.

~~~
sangguine
Thanks. We already use PHPTAL. Will Code Igniter work with PHPTAL?

------
asnyder
I wouldn't say PHP is not as good as Python or Ruby, it's simply different.
For instance you could use a development platform/framework that lives on top
of PHP that might make your life easier. You'll have the same issues with
Python and Ruby and will eventually implement a framework or platform that
lives on top of them.

I also recommend you check out NOLOH (shameless self plug), there will be a
limited developer release at the end of this month.

------
sah
I'd say stick with PHP for this project, and try doing the next one in Python
or Ruby.

If you feel like you need a framework, slowly build it up one piece at a time
as you need it. Don't re-write your whole app before you're making money. You
can spend a lot of time doing that, and there are so many other things that
can potentially go wrong, you don't need to add "it took us too long to get it
working" to the list.

------
iamnirav
I was recently halfway through a project that was going strong in PHP, but I
started reading about Django and Python and decided to port everything over:
turned out to be a very good decision. Django keeps my code clean and Python
keeps me inspired. While PHP is a good language, I would argue that it takes
more self-control to program well in it.

~~~
mattdennewitz
interesting point - when you have it majority of components ready-made for
you, are you really as disciplined a programmer? im going to say "yes," on the
assumption that you had the self-control to go to the hardware store and buy a
hammer instead of making a set of tools to make a hammer, as the metaphor
goes.

------
smanek
Well, I think you should start learning Python or Ruby.

Learning enough to make an informed decision (heresay doesn't count) should
only take a few weekends.

After that you can decide for yourselves if it would be worthwhile.

------
lakeeffect
We switched from PHP to phython after six months of working on the project, it
has made all the difference. I would do it again 9 month or even a year into a
project. Django is the best.

------
jdavid
i think you should go where your passion is.if you are board with php, you
might be willing to put more hours in to another language.

you will find that the more languages you know the easier it is to switch.

i also think you should keep in mind on how you plan to progress in your
company, the further you are from writing the code, the more you will want to
be able to recognize a broad set of patterns.

------
craigbellot
I am also contemplating a switch from php to RoR. After developing another
site in RoR and loving it, php just doesn't inspire me anymore.

