• Source: It's a programming language. Now with HPPL support! 5 1
Currently:  

Author Topic: Source: It's a programming language. Now with HPPL support!  (Read 35885 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 #30 on: October 20, 2014, 03:28:45 pm »
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.

In Source, lists use [] instead. A deviance from the HPPL, sure, but one that works.

Even if I make {} the list delimiters, I believe my parsing system could handle it given some slight changes.

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #31 on: October 21, 2014, 05:45:26 pm »
Good news! I fixed the optimization routines.


Now, this:


Code: [Select]

@export
function hello() {
local a,b = 1,2
a,b = b,a
print(a+" "+b)
}


compiles into this:


Code: [Select]

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


hello();


EXPORT hello()
BEGIN
 LOCAL a:=1;
 LOCAL b:=2;
 LOCAL %TMP2:=b;
 LOCAL %TMP3:=a;
 a:=%TMP2;
 b:=%TMP3;
 print(a+" "+b);
END;


Which is both optimized and correctly prints out 2,1. However, it still could be more efficient.

Offline bb010g

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 428
  • Rating: +22/-1
  • I do stuff
    • View Profile
    • elsewhere on the net
Re: Source: A WIP alternate programming language for the Prime
« Reply #32 on: October 22, 2014, 01:12:50 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.

In Source, lists use [] instead. A deviance from the HPPL, sure, but one that works.

Even if I make {} the list delimiters, I believe my parsing system could handle it given some slight changes.
Vectors?
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: Source: A WIP alternate programming language for the Prime
« Reply #33 on: October 22, 2014, 11:50:40 am »
Vectors?

Matrices (and thus, vectors) will have thier own instantiation syntax.

While vectors are used in math a lot, [] are list deliminators in some programming languages; this is a more programmer-oriented language rather than HPPL, which is more math-oriented. Don't wory, though, in due time there will be an interface for all of HPPL's math functions.

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: Source: A WIP alternate programming language for the Prime
« Reply #34 on: October 22, 2014, 11:53:58 am »
Glad to see more optimizing being done :). Now if only ASM/C was possible on the Prime so that such program could be compiled directly on-calc or even in actual ASM code. In its current form it's still promising, though, especially considering how fast HP PPL is.

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #35 on: October 22, 2014, 01:09:15 pm »
Glad to see more optimizing being done :) . Now if only ASM/C was possible on the Prime so that such program could be compiled directly on-calc or even in actual ASM code. In its current form it's still promising, though, especially considering how fast HP PPL is.
Well, do DO have a way to run native code, it's just that we would have to write a LOT to get a basic framework for anything going. Actually getting reliable ASM execution is far beyond my ability, I believe.


About on-calc execution: In retrospect, perhaps I should have made the Source compiler in C and not Java. :P

But trust me, the minute we have a framework for native code, Source will be able to compile to it. Source is designed so it can compile to multiple platforms.

In other Source news, Source now has ifs and while loops. They're kind of important, I've heard.

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: Source: A WIP alternate programming language for the Prime
« Reply #36 on: October 22, 2014, 04:30:01 pm »
Oh yeah I meant if somebody made the stuff required to run native code. It's possible but the question is if anybody will ever bother, considering how powerful HP PPL already is. You can already have SNES-like graphics without much slowdowns and even 3D polygons now, so if somebody decides to make a game in native code then it will most likely be a port of Doom or emulators.


And yeah glad you added If/while lol, but again I once made a game on a calculator that lacks While/For/Repeat so I guess they're not that essential, after all. :P (I had to use Lbl, Goto, IS>() and DS<())

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #37 on: October 22, 2014, 05:44:43 pm »
Oh yeah I meant if somebody made the stuff required to run native code. It's possible but the question is if anybody will ever bother, considering how powerful HP PPL already is. You can already have SNES-like graphics without much slowdowns and even 3D polygons now, so if somebody decides to make a game in native code then it will most likely be a port of Doom or emulators.


And yeah glad you added If/while lol, but again I once made a game on a calculator that lacks While/For/Repeat so I guess they're not that essential, after all. :P (I had to use Lbl, Goto, IS>() and DS<())

Yeah, I don't suppose native execution will come soon; I mean, there's like 3 or 4 willing Prime fans total :P

Well, if only we had GOTOs. I would actually like a GOTO; Source could really take advantage of GOTO-based optimizations.

I'm trying to make for loops now. Speaking of that, Source probably won't optimize FORs to MAKELISTs right off the bat; I'm still implementing anonymous functions, which that would depend on internally.

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: Source: A WIP alternate programming language for the Prime
« Reply #38 on: October 22, 2014, 05:47:37 pm »
Indeed. After the small craze last Fall and Winter I think only 1 game came out. Of course tho it doesn't help that calculator programmers is an endangered species and that the few dedicated ones that remains are too busy with school and work. HP marketing the calc more outside USA and fixing the bugs would help, though.


As for Gotos I'm not a big fan of them anymore since they often cause memory leaks in certain languages or are slower, but they can be handy in some cases if you use and name them properly.

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #39 on: October 22, 2014, 08:11:03 pm »
As for Gotos I'm not a big fan of them anymore since they often cause memory leaks in certain languages or are slower, but they can be handy in some cases if you use and name them properly.

I'm not usually the best fan of them, myself; however, I would believe using nothing but GOTOs would be faster than most loop constructs currently available. If I was programming directly in HPPL, that would be a pain. However, I'm writing in Source. :)

Anyways, I whipped up a little interactive Source application to let you guys see how Source is coming along. You'll need the following 2 files:

https://drone.io/github.com/iconmaster5326/Source/files
https://drone.io/github.com/iconmaster5326/SourceBench/files

Put them both in the same directory, and then run SourceBench.

Here's what SourceBench looks like:
Spoiler For Spoiler:


You put Source code in the input box, hit compile, and see your HPPL output. I suggest trying examples from earlier in the thread!
« Last Edit: October 22, 2014, 08:17:50 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: Source: A WIP alternate programming language for the Prime
« Reply #40 on: October 22, 2014, 08:14:46 pm »
A Java exception has occured D:

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #41 on: October 22, 2014, 08:18:23 pm »
A Java exception has occured D:
It was compiled in Java 8. Do you have Java 8 installed?

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: Source: A WIP alternate programming language for the Prime
« Reply #42 on: October 22, 2014, 09:17:18 pm »
Ok I just realized that my version (7) was 2 months old. I updated and it starts fine now (although with a Windows 7-like theme rather than the Windows 95-like theme in your screenshot :P)

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #43 on: October 23, 2014, 04:29:20 pm »
Now you can inline variables, too!

Code: [Select]
@export
function hello() {
   @inline
   local x="Source"
   print("Hello, "+x)
}

Compiles to:

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

EXPORT hello()
BEGIN
 print("Hello, "+"Source");
END;

You can make inlined stuff equal to non-constant pieces of code, so they're a little like a macro. You can even redefine constants!

Here's a program showing off everything I've implemented recently:

Code: [Select]
@export
function test() {
 @inline
 local end=10
 local a,i=range(1,end),1
 while i<=end {
  print(a[i])
  a[i]*=2
  i+=1
 }
 print(a)
}
« Last Edit: October 25, 2014, 05:06:59 pm by iconmaster »

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #44 on: October 27, 2014, 09:06:37 pm »
Data types are (mostly) working. I'll talk more about how they work in Source, but for now, have an example of how data type methods work:


Code: [Select]

function list.test(a as list) {
local i = a.size()
print("The list is "~i~" elements long.")
while i>0 {
print("Element "~i~" contains "~a[i]~".")
i-=1
}
print("Interesting!")
}


@export
function main() {
local l as list = range(1,10)
l.test()
}