Jump to content

Compiler

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Firebird_38

Firebird_38

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
Hey I wanna make a compiler that compiles pascal (preferable delphi flavor, with some added stuffs) into PHP and Java (depending on whether it'll run on a client or a server, of course...).

So, instead of making a scanner and a parser and so forth, is therew any code available that'll spit out an AST? That'd be nice.

I know that there's the FreePascal source (handy dandy!), but I see no AST being produced there...

Th reason I want this is because, well, I'm sick and tired of having to program in languages that don't have compile time type checking (like PHP and Java, where you don't know anything is wrong until you've installed it and are testing it).

Besides, it'd be nice if you could write:


 
 
procedure TMyWebApp.Init; [client]
begin
...
UserNameEdit.OnExit:=CheckAvail;
...
end;
 
procedure TMyWebApp.CheckAvail; [client]
begin
 if not UserAvail(UserNameEdit.Text) then
  begin
   ShowMessage('That username you can''t have!');
   UserNameEdit.Focus;
  end;
end;
 
function TMyWebApp.UserAvail(name:String):Boolean; [server]
begin
 result:=dbquery('SELECT Count(*) FROM users WHERE name=%1',[name])[0].value=0;
end;

Seems pretty cool, don't it?

This would be translated for you... with AJAX and stuff. (Yay!)

Client:
<script language="javascript">
function Init() {
 
 GetObj("UserNameEdit").OnExit=CheckAvail;
 
}
 
function CheckAvail() {
 if (AjaxCall("UserAvail",GetObj("UserNameEdit").Text)) {
   window.alert('That username you can''t have!');
   GetObj("UserNameEdit").Focus;
  }
}
</script>

Or something like that...

And the server:

function TMyWebApp_UserAvail($name) {
 return=(dbquery('SELECT Count(*) FROM users WHERE name=%1',[$name])[0]->value==0);
end;

Something like this...

But details need to be worked out... Anyone else see the benefits? 1 unified language to work with... built in database access framework in OODBMS style (preferable anyway), security (preferred also), and support for a host of environments (flash actionscript, html, java, cell phones and EVEN win32 apps!) all in one language, one environment, from 1 source.

Compile for target (here it's the LAMP target :)) and go!

Debugging support would be nice too... Yeah, it all needs some work (10000 man-hours worth) but it would be great! YOU would want a copy!

I think...

And please don't say I should go with C++ as the source language. That will be a target, not a source (as C++ is notoriously hard to read (and write) and produces the buggiest programs (ie windows) ever (with buffer overrun vulnerabilities, any1 hear that before?).

So, pascal it is.

Anyway, I figured I'd put it out there if someone has some input or comments...

Posted Image


#2
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
Hi,

Unfortunately I never have the chance to try Delphi Prism, but isn't this what Delphi Prism does?

#3
Firebird_38

Firebird_38

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
No, Prism is for .NET. I'd like to be able to leverage the cheap LAMP in combination with JavaScript, but in a language that supports "compile" time type checking. Also, 1 language please. Not 7, with the addition of a bunch of "standards" like JQuery or Ajax. (PHP, JavaScript, HTML, SQL, etc)

It's annoying that one has to program the page generation, page parsing, ajax responses, layout, and so forth. The CMS becomes the platform. PHP will crash your site if you made a typo (no compile-time syntax or anything check, as there is no compile-time).

Loosy goosy PHP and JavaScript isn't "well suited" to enterprise class application development. Not to mention the object-relational mismatch hurdle.

Would be nice if this "stuff" were solved with a unified, readable language that provides compile-time checks (with the loss of some flexibility perhaps), a unified, extensible library (like the RTL and VCL for instance), and cross platform, cross page-load/render operation. It would be nice to finally have a language that regards the user session as the application state, with global vars and such to automatically be preserved (a-la TApplication). The url of a page could then simply be trivial, instead of the call entry point, the start of a script run that finishes when the page has been rendered.

Well, it still needs some thought... :)

Posted Image


#4
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
Yes I am aware that Prism was for .NET. But (note I am really never use or seriously learn about Prism) from what I have read in the end Prism produces javascript stuff to link the client side dynamic stuff. doesn't that sound like AJAX screaming? Well, at least the idea was similar, i.e. write in language A, compile to B (in X format), run B.

Actually this idea hit me when hearing Borland was working on .NET version of Delphi (beta version included in Delphi 8 released). Come on, with the greatness of VCL why is it so hard to transform TForm into a web pages and split the UI rendering codes into client side javascript? Or at least that's what I was thinking. :)

Quote

Loosy goosy PHP and JavaScript isn't "well suited" to enterprise class application development.
Totally agree.

But again if we only inspecting the final goal, I think Delphi Prism is already capable of this. I.e. one language to rule them all :)
Just hit me, what about Morfik? I think it's not tied to .NET