Write a compiler. Some possibility?

Everything else that doesn't fall into one of the other PB categories.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Nik wrote:
NetBeans has more Features than the Purebasic IDE
Absolutly true but in fact it doesn't matter because it's horrible to use because its so slow. If you let it run for lets say 3 hours while doing something else and maximize it again it took me 3 minutes to get up on the screen (on a 2.8 ghz PC). That's simply unacceptable Purebasic needs less than a second to come up again. So better a not that feature rich IDE I can work with than this slow crap.
bye Nik
Good point.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Trond wrote:Well, you said it used ten seconds for you too, didn't you?
I said 5. A cold start of Delphi 2005, after a reboot takes 30+ seconds ;)
Closing it and opening it again then takes 10-15 seconds. So it has a MUCH slower startup. But when it runs then its very fast.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

-
Last edited by thefool on Wed Apr 20, 2011 6:44 pm, edited 1 time in total.
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

Trond wrote:
Nik wrote:
NetBeans has more Features than the Purebasic IDE
Absolutly true but in fact it doesn't matter because it's horrible to use because its so slow. If you let it run for lets say 3 hours while doing something else and maximize it again it took me 3 minutes to get up on the screen (on a 2.8 ghz PC). That's simply unacceptable Purebasic needs less than a second to come up again. So better a not that feature rich IDE I can work with than this slow crap.
bye Nik
Good point.
That would be windows virtual memory manager being inefficient, not java.
Mat
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

thefool wrote:
Trond wrote:Well, you said it used ten seconds for you too, didn't you?
I said 5. A cold start of Delphi 2005, after a reboot takes 30+ seconds ;)
Closing it and opening it again then takes 10-15 seconds. So it has a MUCH slower startup. But when it runs then its very fast.
Time for a new computer?
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

thefool wrote:
Joakim Christiansen wrote:You guys are so silly :wink:
And thanks for that very interesting comment.. (btw "so" should be spelled with 2 o's in this case..)
Are you absolutely sure of this, thefool?

Just added another interesting comment to the thread ;)
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

-
Last edited by thefool on Wed Apr 20, 2011 6:45 pm, edited 1 time in total.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

Heh, poor 2Player, seeing his otherwise interesting thread derail so badly.. :lol:

Image
Last edited by utopiomania on Sun Dec 18, 2005 8:34 pm, edited 1 time in total.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

thefool wrote:
Time for a new computer?
Nope, your fag. Mine is way faster than yours. sorry 'bout that..




(i wrote fag as a joke. I have to write this otherwise im pretty sure you would misunderstand me, you maggot... ) :D
Now I don't think yours is way faster, partly because I've got an Athlon 2400+ but most of all because I measure in seconds and not clock cycles and since you speak so warmly of all those slow programs I assume you use them, and since you use slow programs, your computer will appear slower than mine, since I use faster programs, unless you've got a Cray superprocessor of course.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

i got an 64 bit 3800+ ;)
1 gbyte ram too. fast!

And i dont use slow programs, i use fast programs. Firefox, total commander, winamp, only a few running processes when system is idle, 1 antivirus wich holds the firewall too.. Pelle's C, etc you know.

Mine is way faster. At least I think this is way faster.
However some programs loadtime may not depend on processor and memory clock speed only, as the harddisk speed is also important. There both my 200 gbyte discs has 8 mbyte cache, and 9200 rpm (not 100% sure on that RPM speed though).

So i try to use the fastest programs i can, and always clean out what i dont use. Registry, temp files etc is cleaned on a weekly basis.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

thefool wrote:i got an 64 bit 3800+ ;)
1 gbyte ram too. fast!

And i dont use slow programs, i use fast programs. Firefox, total commander, winamp, only a few running processes when system is idle, 1 antivirus wich holds the firewall too.. Pelle's C, etc you know.

Mine is way faster. At least I think this is way faster.
However some programs loadtime may not depend on processor and memory clock speed only, as the harddisk speed is also important. There both my 200 gbyte discs has 8 mbyte cache, and 9200 rpm (not 100% sure on that RPM speed though).

So i try to use the fastest programs i can, and always clean out what i dont use. Registry, temp files etc is cleaned on a weekly basis.
Ok, but Java is still too slow for those of us who has a budget.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Its not WAY faster, but still a bit.
Anyway i agree java IS much slower than compiled code, but still fast enough for many things.

For a virus scanner for example, i wouldnt like java. But for smaller utils and a bit larger utils like netbeans, imho it works okay.

Of course i would prefer Delphi as it IS faster when loaded.


btw i did not mean the fag thingy hehe :)
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

This was not a discussion about java...
I like logic, hence I dislike humans but love computers.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

now it is :D
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

thefool wrote:Its not WAY faster, but still a bit.
Anyway i agree java IS much slower than compiled code, but still fast enough for many things.

For a virus scanner for example, i wouldnt like java. But for smaller utils and a bit larger utils like netbeans, imho it works okay.

Of course i would prefer Delphi as it IS faster when loaded.


btw i did not mean the fag thingy hehe :)
By the way, I've setup my virus scanner to scan files only on creation and not on run as is the usual setup. That really boosts the speed without sacrificing too much security. That being said, I haven't had virus (neither (fake) alarms) for years.

Just to bring the topic back on track I thought I could post an example that is a bit more advanced with variable=expression parsing. Type in the assignment on the prompt. Example: orange = apple * (5 + orange * apple).

Code: Select all

OpenConsole()

#Ind = "    "
#QUOTE$ = "'"
Global Look.s
Global Stream.s

;Logical not on 1 and 0 _only_
Procedure Not(b.b)
  ProcedureReturn -b+1
EndProcedure

;Cleanup then end
Procedure Finish()
  Input()
  End
EndProcedure

;Make sure a character is a visible one
Procedure.s VisibleToken(s.s)
  Select s.s
    Case #CR$
      s.s = "newline"
    Default
      s.s = #QUOTE$ + s.s + #QUOTE$
  EndSelect
  ProcedureReturn s.s
EndProcedure

;Report an error
Procedure Error(s.s)
  PrintN("Error: "+s+".")
EndProcedure

;Report an error then abort
Procedure Abort(s.s)
  Error(s.s)
  Finish()
EndProcedure

;Report what was expected and abort
Procedure Expected(expected.s)
  Abort("Expected: '" + expected + "', got " + VisibleToken(Look))
EndProcedure

;Output a tabbed string
Procedure Emit(s.s)
  Print(#Ind + s.s)
EndProcedure

;Output a tabbed line with linefeed
Procedure EmitLn(s.s)
  SetClipboardText(GetClipboardText()+s.s+Chr(13)+Chr(10))
  Emit(s.s)
  PrintN("")
EndProcedure

;Read a character into Look
Procedure GetChar()
  Look = Left(Stream,1)
  Stream = Right(Stream, Len(Stream)-1)
EndProcedure

;Match a specific input character
Declare EatWhite() ;forward
Procedure Match(s.s)
  If Look = s
    GetChar()
    EatWhite()
  Else
    Expected(s)
  EndIf
EndProcedure

;Recognize an alpha character
Procedure.b IsAlpha(s.s)
  ProcedureReturn (Asc(UCase(s.s)) > 64 And Asc(UCase(s.s)) < 91)
EndProcedure

;Recognize an addop
Procedure.b IsAddop(s.s)
  ProcedureReturn (s.s = "+" Or s.s = "-")
EndProcedure

;Recognize a decimal digit
Procedure.b IsDigit(s.s)
  ProcedureReturn (Asc(UCase(s.s)) > 47 And Asc(UCase(s.s)) < 58)
EndProcedure

;Recognize an alphanumeric
Procedure.b IsAlphaNumeric(s.s)
  ProcedureReturn (IsAlpha(s.s) Or IsDigit(s.s))
EndProcedure

;Recognize whitespace
Procedure.b IsWhiteSpace(s.s)
  Select s.s
    Case " "
    Case #TAB$
    Default
      ProcedureReturn 0
  EndSelect
  ProcedureReturn 1
EndProcedure

;Get an identifier
Procedure.s GetName()
  temp.s = ""
  If Not(IsAlpha(Look))
    Expected("Name")
  EndIf
  While IsAlphaNumeric(Look)
    temp + UCase(Look)
    GetChar()
  Wend
  EatWhite()
  ProcedureReturn temp
EndProcedure

;Get a number
Procedure.s GetNum()
  temp.s = ""
  If Not(IsDigit(Look))
    Expected("Integer")
  EndIf
  While IsDigit(Look)
    temp + Look
    GetChar()
  Wend
  EatWhite()
  ProcedureReturn temp
EndProcedure

;Skip whitespace
Procedure EatWhite()
  While IsWhiteSpace(Look)
    GetChar()
  Wend
EndProcedure

;Init
Procedure Init()
  SetClipboardText("")
  Stream = Input()+#CR$ : PrintN("")
  GetChar()
  EatWhite()
EndProcedure

;------------------------------
;D0 D1 = edx, ecx

Declare Expression() ;forward declaration for factor

;Parse and translate an identifier
Procedure Identifier()
  Name.s
  Name = GetName()
  If Look = "("
    Match("(")
    Match(")")
    EmitLn("call [f_" + Name + "]")
    EmitLn("mov edx, eax")
  Else
    EmitLn("mov edx, [v_" + Name + "]")
  EndIf
EndProcedure

;Parse and translate a math factor
Procedure Factor()
  If Look = "("
    Match("(")
    Expression()
    Match(")")
  ElseIf IsAlpha(Look)
    Identifier()
  Else
    EmitLn("mov edx, " + GetNum())
  EndIf
EndProcedure

;Recognize and translate a multiply
Procedure Multiply()
  Match("*")
  Factor()
  EmitLn("pop ecx")
  EmitLn("imul edx, ecx")
EndProcedure

;Recognize and translate a divide
Procedure Divide()
  Match("/")
  Factor()
  EmitLn("pop eax")
  EmitLn("mov ecx, edx")
  EmitLn("xor edx, edx")
  EmitLn("idiv ecx")
  EmitLn("mov edx, eax")
EndProcedure

;Parse and translate a math term
Procedure Term()
  Factor()
  While Look = "*" Or Look = "/"
    EmitLn("push edx")
    Select Look
      Case "*" : Multiply()
      Case "/" : Divide()
    EndSelect
  Wend 
EndProcedure

;Parse and translate an add
Procedure Add()
  Match("+")
  Term()
  EmitLn("pop ecx")
  EmitLn("add edx, ecx")
EndProcedure

;Parse and translate a subtract
Procedure Subtract()
  Match("-")
  Term()
  EmitLn("pop ecx")
  EmitLn("sub edx, ecx")
  EmitLn("neg edx")
EndProcedure

;Parse and translate an expression
Procedure Expression()
  If IsAddop(Look)
    EmitLn("xor edx,edx")
  Else
    Term()
  EndIf
  While IsAddop(Look)
    EmitLn("push edx")
    Select Look
      Case "+" : Add()
      Case "-" : Subtract()
    EndSelect
  Wend
EndProcedure

;Parse and translate an assignment statement
Procedure Assignment()
  Name.s = GetName()
  Match("=")
  Expression()
  EmitLn("mov v_[" + Name.s + "], edx")
EndProcedure

Init()
Assignment()
If Look <> #CR$ : Expected("Newline") : EndIf

Print(Stream)
Finish()
Post Reply