I'm researching several web frameworks in order to create a web application that I need to, that also should work as a web site on the Internet, and will have API to integrate things into other web-sites, if clients does not want to use that site.
For the task I started with two frameworks:
I do not want to try Rails, because I find the logic behind it very disturbing. The Rails framework rewrite the language, rather then adding libraries to use. I think that it is not the proper way to write libraries. So I decided not to try it at all, even though I really love the Ruby language itself.
So I started testing fpWeb, and I must say that it takes a while to get used to it and the way it does things, but once I figured out the basics, I find it really enjoyable to write a CGI (I always hate to write html/css stuff though, and that's regardless of the language for the server side) application.
fpWeb works in very different mindset then most modern web frameworks I have ever worked with so far. On one hand it appears that everything chosen for you, that is the template engine, session engine etc.. But on the other hand, you can actually use what ever you want, just decide on something and go for it.
Unlike most frameworks, it does not arrive bundled with all of the required tool. It allows you to use the tools that you want to use by just using what arrives with FPC and Lazarus. But also with 3rd party tools and libraries. Just like any other application. So instead of looking for a chart tool for fpWeb, you can use taChart, and create an image of the charts. You can use the bgra tools to make it look prettier and use DataSet based non gui component for database access, or direct API, or whatever you want to… It's all up to you !
The template structure is a bit different then what we know from erb, and even from django's templates. No logic and no code on the view side ! only tags that will be replaced in our CGI code ! We choose how the tags looks like and how we work with them. And if no code is set for a specific tag ? well, the engine will remove it anyway for the rendering.
That approach took me half a day to understand. Not the design of templates, but how to create sub templates that the variables there will also be parsed, but it wasn't hard to understand, once you realized the mindset of the engine.
Another big advantage of fpWeb, is that it is really easy to convert the application between CGI, FastCGI and Apache's module. It takes something like 4-6 lines of code to do so.
And like with other applications, you can share your code with many other applications or several modules of your CGI, and even use the same code for more then one CGI application.
I never understood Python too much. It have few unreadable issues, in my mind at least.
class Example : def __unicode__() : return 'bla' class SubExample : def say_hello : return null # not really needed I know def do_something() : # ....
I find this issue unreadable. Do you have a bug here ? does it work like you wanted ? You can not really tell here. Most Pyhthon developers will say now "huh?"
When you wrote do_something, have you meant to see it belong to SubExample, but have a bug with your spaces ? Does SubExample should be a sub class or should it be a standalone class ? And the questions just keep on popping into my head on this short code.
The indentation as a way to set code blocks that explain what belongs to where is very unreadable (for me at least) as a syntax. On "normal" languages, even if my indentation is wrong, it will not effect the code logic or flow. And it's really simple to fix btw… But on Python you never really fully understand if things are intentional, or if that is a bug. I know that some people will say that you can always document it, but that just misses the point of readable code. Comments should arrive to explain why, or what, or "the way of". Not the language itself. Code with variable assignment of a value with a comment of "adding this value to the variable", well that's a noise, not a comment.
But it's not the only unreadable thingy that the language have. Here is another example:
What will happen ? Does it a string or a Regex ? should I escape it or not ? Why will it translate as a Regex ? Or why will it not ? (I found it in django's route translate it into a regex …) On Ruby for example, regex code is belong to the Regexp class. You understand that it's not a string due to syntax. If django had something like regex("/^hello.*$/") then I would have known that it will have some sort of regex translation. But a string that in a magical way translate as a regex, well, that's unreadable, for me at least. There are many other issues with the language itself.
Unlike Rails, it make sure that you understand from where things comes from (yes, you can do the same in Ruby, but people that arrive from Rails, usually does not do that 😦 ).
But like with Rails, some tools, that was not written specifically for django, will remove efficiency and will bite you somewhere, and you will loose something on the way because of that.
The admin interface support of django is really cool, and save a lot of time and effort for the developers. I think that if you require administration interface for a product/website it makes much better choice then "clean" rails (rails does have plugins that add such support as well).
I need to play more with django. I really dislike Python way of doing things as you understand, but I can accept that evil, like the way I accept coding with C when I have no choice but something to gain.
fpWeb is more or less like PHP before the usage of any other framework, but more readable, maintainable and flexible. It will take more time to implement things over fpWeb then django, but I will enjoy more working with fpWeb then with django.
So if this was not a work related decision, I would go with fpWeb, but time is very important, so I think I'll go with django 😦