Author Topic: Source: It's a programming language. Now with HPPL support!  (Read 35891 times)

0 Members and 1 Guest are viewing this topic.

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #15 on: October 07, 2014, 09:39:09 pm »
I found this in an old changelog:


Quote
"1234"[n] now works to access a specific character in a string with no memory copy.


Note to self: Accessing from strings are now probably faster than accessing from a list.


EDIT: Did some speed testing. No, it's not faster.
« Last Edit: October 08, 2014, 03:51:35 pm by iconmaster »

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #16 on: October 09, 2014, 01:30:12 pm »
Another interesting dynamic of HPPL is how global variables work. The following program show you a message when the program is compiled:

Code: [Select]
FF()
BEGIN
 MSGBOX("OH MY");
END;

GLOBALVAR=FF();

I have a few ideas about how this might come in handy. ;)

Offline timwessman

  • LV3 Member (Next: 100)
  • ***
  • Posts: 94
  • Rating: +32/-0
    • View Profile
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #17 on: October 09, 2014, 04:38:21 pm »
I have a few ideas about how this might come in handy. ;)

Crap!

That might be quite problematic since the code gets compiled when you send it across... I'll have to check that.

Also, I think storing a char directly also does not require any memory allocations since the size isn't changing.
« Last Edit: October 09, 2014, 06:17:59 pm by timwessman »
TW

Although I work for the HP calculator group, the comments and opinions I post here are my own.

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #18 on: October 09, 2014, 08:42:31 pm »
Crap!

That might be quite problematic since the code gets compiled when you send it across... I'll have to check that.

Also, I think storing a char directly also does not require any memory allocations since the size isn't changing.

Hmm? You can STORE characters using that notation too? Didn't know that.

It's a good thing you hang around here, Tim. We'd never have any documentation otherwise!


EDIT: Speaking of documentation, I was looking at #pragma. Can it accept any other arguments tham mode? In mode, can it only take separator and integer modes?
« Last Edit: October 09, 2014, 08:49:04 pm by iconmaster »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: &lt;UPDATED&gt; Source: A WIP alternate programming language for the Prime
« Reply #19 on: October 10, 2014, 07:22:25 am »
I thought that code got compiled when exiting the editor? Or am I missing something here?

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #20 on: October 10, 2014, 06:35:38 pm »
Guys, I have an announcement. Source is working.

I'm faaaaar from done, but we can now compile this:

Code: [Select]
field x as real = 3

function test() {
   x = 1 + 1
}

into this:

Code: [Select]

#pragma mode( separator(.,;) integer(h32) )


test();
x:=3;




test()
BEGIN
 LOCAL TMP_1:=1;
 LOCAL TMP_2:=1;
 LOCAL TMP_0:=TMP_1+TMP_2;
 x:=TMP_0;
END;

This is a huge step for the Source compiler. Right now, there is a huge lack of minification, as you can see. This will be fixed once the full syntax of Source gets added to the compiler.
« Last Edit: October 10, 2014, 07:36:19 pm by iconmaster »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #21 on: October 11, 2014, 01:11:21 pm »
Ooh that is awesome :D. It seems the code gets smaller, right? How well does it get optimized for particularly complex programs?

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #22 on: October 11, 2014, 03:15:05 pm »
Ooh that is awesome :D . It seems the code gets smaller, right? How well does it get optimized for particularly complex programs?

Thanks!

Well, the Source program is a lot smaller, but that's just because the compiler doesn't inline simple statements yet. The equivalent HPPL program would be a bit smaller if a human did it right now. Eventually, I'll make it replace the TMPs with the statements that the TMPs equal; right now, these temporary variables are created by the Source compiler to allow for statements that can't be inlined in HPPL to be inlined in Source. Also, there isn't optimization yet. But trust me, I have a few ideas.

Also, more progress. Here's a Hello Source program:

Code: [Select]
@export
function hello() {
   print("Hello, Source!")
}

that translates to:

Code: [Select]
#pragma mode( separator(.,;) integer(h32) )

hello();


EXPORT hello()
BEGIN
 LOCAL TMP_1:="Hello, Source!";
 LOCAL TMP_0:=print(TMP_1);
END;



As a bonus, some inner workings- here's the Source Intermediary Language (SIL) output for the Source program that compiles into HPPL:


Code: [Select]
FUNC hello [] []:
MOVS   TMP_1   Hello, Source!
CALL   TMP_0   print   TMP_1
END
« Last Edit: October 11, 2014, 03:20:40 pm by iconmaster »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #23 on: October 14, 2014, 02:28:37 am »
I see, thanks for the example :D

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #24 on: October 15, 2014, 06:39:00 pm »
Some more progress. This time, we have inlining!


Code: [Select]

@inline
function test() {
   local a = 1
   return a + 1
}


@export
function hello() {
   print(test()+1)
}


In Source, the @inline directive tells the compiler to directly insert the code of the function test() into hello().


Here's what it compiles to:


Code: [Select]

#pragma mode( separator(.,;) integer(h32) )


hello();


EXPORT hello()
BEGIN
 LOCAL %TMP0:=1;
 LOCAL a:=%TMP0;
 LOCAL %TMP2:=a;
 LOCAL %TMP3:=1;
 LOCAL %TMP1:=%TMP2+%TMP3;
 LOCAL %TMP6:=%TMP1;
 LOCAL %TMP7:=1;
 LOCAL %TMP5:=%TMP6+%TMP7;
 LOCAL %TMP4:=print(%TMP5);
END;


Notice the non-existence of test(). It was inlined!

EDIT: Also, some work on simplifying compiled code is being done. However, it doesn't work perfectly yet:

Code: [Select]
@export
function hello() {
local a,b = 1,2
b,a = a,b
print(a+" "+b)
}
Code: [Select]
#pragma mode( separator(.,;) integer(h32) )

hello();
EXPORT hello()
BEGIN
 LOCAL a:=1;
 LOCAL b:=2;
 b:=a;
 a:=b;
 print(a+" "+b);
END;
« Last Edit: October 15, 2014, 08:12:08 pm by iconmaster »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #25 on: October 17, 2014, 12:42:42 am »
Nice so far. By the way at one point you should try to make an example program, such as a port of the "famed" Wacky Fun Random Numbar Generator v1.000069. Perhaps a graphical demo too to showcase the speed and size.

Offline bb010g

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 428
  • Rating: +22/-1
  • I do stuff
    • View Profile
    • elsewhere on the net
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #26 on: October 17, 2014, 01:18:56 am »
Nice. Would you mind pull requests in the future? :)
Arch Linux user
Haskell newbie | Warming up to Lua | Being dragged into C++
Calculators: HP 50g, HP 35s, Casio Prizm, TI-Nspire CX CAS, HP 28s, HP Prime, Mathematica 9 (if that counts)
π: 3.14...; l: 108; i: 105; e: 101; l+i+e: 314
THE CAKE IS A LIE IS A PIE

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #27 on: October 17, 2014, 06:49:12 am »
Nice so far. By the way at one point you should try to make an example program, such as a port of the "famed" Wacky Fun Random Numbar Generator v1.000069. Perhaps a graphical demo too to showcase the speed and size.

That's a good idea. Right now, the language is about 90% stable; some things might change before final release, but not many. The big thing that's in the air right now is the functions I'll be providing. Even if these two things are true, I probably should work on making actual programs in Source.

Nice. Would you mind pull requests in the future? :)

I would love some collaboration!

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #28 on: October 19, 2014, 08:34:54 am »
I just saw this, nice work so far!

Offline timwessman

  • LV3 Member (Next: 100)
  • ***
  • Posts: 94
  • Rating: +32/-0
    • View Profile
Re: <UPDATED> Source: A WIP alternate programming language for the Prime
« Reply #29 on: October 20, 2014, 09:01:53 am »
So how do you plan to distinguish lists from block braces? The primary reason we decided to go with the begin/end instead of { } was due to confusion and potential conflicts.
TW

Although I work for the HP calculator group, the comments and opinions I post here are my own.