Recent

Author Topic: Hi, would like some direction, web development  (Read 9909 times)

puffy

  • Newbie
  • Posts: 3
Hi, would like some direction, web development
« on: October 18, 2010, 05:18:00 pm »
Hi,

So I am a long time web developer. Things like PHP have been the norm for about 7 years now. I also have used python(django, turbogears) and ruby on rails and many other similar frameworks as well. I was really wanting to get a "little" closer to the "system" now? I hope you can get the point. I would like to try and make some web apps in pascal and hopefully there is a solid way of doing that? I can't find much but some out of date things that are not worked on anymore and not sure if they would even work with the current freepascal?

As I said I am new, I am really not even an ide fan (emacs) so I am not sure if I really want to use lazarus for web dev or anything but I would really like to give this a go and possibly use it in a work environment if I can actually get stuff done. I have worked with C quite a bit and objective C. Pascal is fairly straight forward to me so this should be a good learning experience as well.

If anyone thinks I'm crazy that's ok, I already know I am  8)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Hi, would like some direction, web development
« Reply #1 on: October 18, 2010, 05:49:59 pm »
If you've worked with ObjC, that probably means you have a Mac. If so, you might want to look at Dashcode, the other IDE that comes with Apple's Xcode tools. You can create the JS frontend with Dashcode, with full support for HTML5 too. Then maybe write your server app in Pascal and communicate with it using normal Ajax calls.

The thing that's interesting about Dashcode is that it provides a "dual-app" capability, where you design one frontend optimized for a big screen browser and the other frontend for a small screen browser (mobile devices running Webkit browers - i.e., almost all mobile devices) - both in the same Dashcode project.

My feeling is that any new Web app that does not provide an optimized experience for mobile devices is probably a mistake, maybe a fatal one.

Thanks.

-Phil

Edited: Original post omitted the "not" in last sentence.
« Last Edit: October 19, 2010, 01:30:23 am by Phil »

michaelthuma

  • Jr. Member
  • **
  • Posts: 51
Re: Hi, would like some direction, web development
« Reply #2 on: October 18, 2010, 06:15:02 pm »
Hi!

Wondering little. Just programming the website can be done in PHP lot easier.

What you usually can do is CGI or Fastcgi via Gate. Check Leonardo's blog - you will get an impression.
http://leonardorame.blogspot.com/

Honestly don't start with web apps. This is a very special case. What I think can be very helpfull in a first is command line utilites maybe using the internet units.

I personally use fpc under Linux for CGI scripts ... consider in this case the moment you deploy it to recompile without debug info and line info.

  • You can use FPC/Lazarus webservices, this still makes sense. Hope this works - never tried.
    You can read the response from a webservice written in PHP and parse it using the XML Document component....
    ...
    Live in the first steps with connecting to a DB, execute query, fetch result and close connection.

Here is how to write a webserver:
http://wiki.lazarus.freepascal.org/Networking

Things like these. Just to give an idea.

Regards
Mike

List of links:

http://wiki.freepascal.org/CGI_Web_Programming
http://www.freepascal.org/packages/inet.html
http://www.freepascal.org/packages/uncgi.html

Web Service Toolkit
http://wiki.lazarus.freepascal.org/Web_Service_Toolkit

http://z505.com/powtils/idx.shtml --> Seem to be good
http://code.google.com/p/extpascal/ --> ExtJS + Pascal bindings
http://code.sd/ --> Freespider

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Hi, would like some direction, web development
« Reply #3 on: October 18, 2010, 06:26:47 pm »
Mike,

You raise an interesting question: What is a Web app?

For a number of years now when someone says "Web app" that usually means an "in-browser" app consisting of an HTML/Javascript frontend that communicates via Ajax calls to a server backend that can be written in virtually anything. However, this now strikes me as too limiting. If you look at apps available for mobile devices, very few of these fit this description, yet many communicate with the server and many aren't even functional without an Internet connection. Shouldn't these "out-of-browser" native apps also be considered Web apps? To the user there isn't much difference other than the ugly, clunky browser has been eliminated.

I assume many mobile apps communicate with the server via a Web service or some other kind of programmatic API. I've used Web Service Toolkit extensively and it works well with many kinds of Web services, so yes that's another good starting point.

Thanks.

-Phil

bobo

  • Full Member
  • ***
  • Posts: 171
Re: Hi, would like some direction, web development
« Reply #4 on: October 18, 2010, 06:32:16 pm »
Quote
http://z505.com/powtils/idx.shtml --> Seem to be good
http://code.google.com/p/extpascal/ --> ExtJS + Pascal bindings
http://code.sd/ --> Freespider

FPC now can work with ExtJS JSON calls directly (including Ajax calls) as of 2.5.1
basic demos are at
.../fpc/packages/fcl-web/examples/...

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Hi, would like some direction, web development
« Reply #5 on: October 18, 2010, 06:40:37 pm »
Now that ExtPascal has been refactored (in SVN, I believe), you can use the FCGIApp.pas unit to create FCGI apps that don't depend on the ExtJS Pascal units or the ExtJS Javascript framework. I've tested an FCGI Web app like this by calling it via Ajax from Dashcode JS and it works fine.

Thanks.

-Phil

puffy

  • Newbie
  • Posts: 3
Re: Hi, would like some direction, web development
« Reply #6 on: October 18, 2010, 11:02:53 pm »
Still no one told me what that LazWeb is  :D

Also if there is one thing I like about web development and one thing I hate is the build your site from javascript. At the firm I work at they give psd's and they want that in a site. For some web "applications" if you want to call it sproutcore and extjs is cool.

I just want something similar to traditional web dev. Maybe an mvc perspective where I can just have controllers and views. Does lazarus have anything to help me here? I don't want to write cgi I would like to write fcgi, I dont know much about them except cgi is bad for performance.

If I have to code my own framework I will, I just need a base.

anyone else with any ideas? I would be really interested if laz has stuff to help me here.

Thanks.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Hi, would like some direction, web development
« Reply #7 on: October 19, 2010, 01:53:24 am »
I'm not familiar with LazWeb. (Nor am I familiar with "psd's".) However, I believe there are at least a couple ways to program FCGI with Free Pascal. Here's a very simple FCGI app that can be compiled with either FPC or Delphi and runs on either a Web server or standalone with an embedded Indy Web server if WebServer is defined:

program DashcodeTest;

uses
{$IFNDEF WebServer}
  FCGIApp,
{$ELSE}
 {$IFNDEF MSWINDOWS}
  CThreads,
 {$ENDIF}
  IdExtHTTPServer,
{$ENDIF}
  AppThread;

{$IFNDEF FPC}
 {$IFNDEF WebServer}
  {$APPTYPE CONSOLE}
 {$ENDIF}
{$ENDIF}

const
  AppTitle = 'Dashcode Test';
  Port = 2014;
  MaxIdleMinutes = 30;

begin
{$IFNDEF WebServer}
  Application := TFCGIApplication.Create(AppTitle, TAppThread, Port, MaxIdleMinutes);
{$ELSE}
  Application := TIdExtApplication.Create(AppTitle, TAppThread, 80, MaxIdleMinutes);
{$ENDIF}
  Application.Run;
end.


unit AppThread;

interface

uses
  FCGIApp;

type
  TAppThread = class(TWebSession)
  published
    procedure Home; override;
  end;

implementation

procedure TAppThread.Home;
begin
  Response := 'document.getElementById("' + Query['Name'] + '").innerText = "Hello, again";';
end;

end.


This was a test of making an Ajax call, passing the name of a control (e.g. Name=text1) - app sends back Javascript that changes the control's text when eval-ed.

I used ExtPascal's FCGIApp unit.

Thanks.

-Phil

puffy

  • Newbie
  • Posts: 3
Re: Hi, would like some direction, web development
« Reply #8 on: October 19, 2010, 02:15:28 am »
psd is a photoshop file.

I will just stick with PHP :)

I guess I am a bit crazy sometimes wanting to use things that are just not made for it.


 

TinyPortal © 2005-2018