• 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 40422 times)

0 Members and 2 Guests are viewing this topic.

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #45 on: October 31, 2014, 03:17:24 pm »

Some news!

First of all, I gave a presentation on my language to my peers this week! My presentation included all presently implemented features of Source. Get the slides here!


Second of all, here's an example of how the type system works:


Code: [Select]

function types() {
local a as real //a is of type real
local b as string //b is of type string


//a = "" //real!=string, ERROR!
b = "" //string==string, fine

a = 1 //fine
//b = 1 //ERROR!


local c //c is ??, which is the base type (?) weakly typed


c = 1 //fine, c is now of type real?, again weakly typed
c = "" //fine, c is now type string?


local d = 44 //d is of type real?
a = d //real==real?, fine
//b = d //string!=real?, ERROR!
d = "" //real?==string?, fine


local e as ? //e is ?, the base type, but strongly typed


e = "" //you can set anything to e
//... But the reverse is not true.
//b = e //string!=?, ERROR!
d = e //??==?, fine
}

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Source: A WIP alternate programming language for the Prime
« Reply #46 on: November 03, 2014, 02:39:21 am »
I still plan on buying  a Prime one day. This will be one of the first programs to run on it.

Once I buy it. <_<
I'm not a nerd but I pretend:

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • 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 #47 on: November 05, 2014, 02:56:59 am »
I'll definitively have to try Source at one point too, although since I prefer to not learn multiple languages at once I'll most likely stick to PPL at first, but if I keep running into roadblocks or can't stand it, I might attempt a switch to Source.

Anyway keep the good work on this. If this do come to fruition this is definitively front page material I'll be suggesting to staff.

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #48 on: November 06, 2014, 06:38:48 pm »
I still plan on buying  a Prime one day. This will be one of the first programs to run on it.

Once I buy it. <_<

I'll definitively have to try Source at one point too, although since I prefer to not learn multiple languages at once I'll most likely stick to PPL at first, but if I keep running into roadblocks or can't stand it, I might attempt a switch to Source.

Anyway keep the good work on this. If this do come to fruition this is definitively front page material I'll be suggesting to staff.

I'm flattered. Thanks for all your support!

Speaking of support, Source now allows you to write your own custom compiling targets! Source can compile into any language you write a Java plugin for. To show off this system, I made SourceBox, a Source interpreter. Get all 3 needed jars at:

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

Put Source and SourceBench in the same directory, as usual. Run Bench once, and close it. There is now a folder called BenchData, and a subfolder called libs. Put SourceBox in there, and restart Bench.

Now, try to use that 'Platform' drop-down box.

With SourceBox, you should be able to run this directly on your computer:

Code: [Select]
@export
function powers() {
@inline
local end = 10
print("The first "~end~" powers of 2 are:")
local i,a,b = 0,0,1
while i<end {
a = a + b
b = a
print(b)
i+=1
}
print("Done!")
}

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • 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 #49 on: November 06, 2014, 06:41:49 pm »
Wait, so basically if I want to make a game for both the HP Prime and the computer at once then I now can if the computer language is available for Source? O.O

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #50 on: November 06, 2014, 07:25:58 pm »
Wait, so basically if I want to make a game for both the HP Prime and the computer at once then I now can if the computer language is available for Source? O.O

Yes.

Of course, Source still needs a library for drawing...

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Source: A WIP alternate programming language for the Prime
« Reply #51 on: November 06, 2014, 07:28:09 pm »
That's amazing. O.O

Someone, create this for Axe please!
I'm not a nerd but I pretend:

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • 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 #52 on: November 06, 2014, 07:29:54 pm »
Wait, so basically if I want to make a game for both the HP Prime and the computer at once then I now can if the computer language is available for Source? O.O

Yes.

Of course, Source still needs a library for drawing...
That's amazing. I wonder if PC programs will run as they do on the Prime, especially for compiled languages? It would definitively make things even easier (although you would need of course good support for the TICKS and WAIT commands so we can make our games run at constant speed.


And yeah drawing will definitively be a must, especially with how much freedom HP PPL offers already.

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #53 on: November 06, 2014, 07:40:22 pm »
That's amazing. I wonder if PC programs will run as they do on the Prime, especially for compiled languages? It would definitively make things even easier (although you would need of course good support for the TICKS and WAIT commands so we can make our games run at constant speed.

And yeah drawing will definitively be a must, especially with how much freedom HP PPL offers already.

Well, right now, SourceBox is a rather... Naive implementation. For one, in SourceBox, lists start at 0 and are passed by reference...

For one, I plan on having other compiling platforms; platforms where things are passed by reference and where arrays are indexed by different things.
I have plans to alleviate this divide; for example, I plan on making Source a language where the first list index is irrelevant. Wait and see to find out how!

In other news, you can insert HPPL code directly into Source programs:

Code: [Select]
@export
@!optimize
function hax() {
   local a="HAX"
   @lang=hppl "msgbox(a)"
}

Also, you can use custom HPPL functions as Source functions:

Code: [Select]
@native=MAX
function wow(a,b) {
   
}

@export
function getmax() {
   return wow(1,2)
}

Code: [Select]
@native
function MAX(a,b) {
   
}

@export
function getmax() {
   return MAX(1,2)
}


You can also use @lang to comment your compiled output:


Code: [Select]

@export
function stuff() {
@lang=comment "This function does stuff."
print("Stuff done!")
}
« Last Edit: November 06, 2014, 07:48:15 pm by iconmaster »

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 #54 on: November 06, 2014, 11:54:53 pm »
I'm guessing the FFI is not going to be platform independent. Am I sensing compile-time code selection?
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 #55 on: November 07, 2014, 03:50:51 pm »
I'm guessing the FFI is not going to be platform independent. Am I sensing compile-time code selection?

Yes, the @lang strings are platform-dependant, as well as @native. However, I plan on making a few @langs that are independent, such as ones for Source internal bytecode.

Basically, there is a bytecode operation called NATIVE which contains the @lang string. The platform assembles this operation however it wishes; in this case, the HPPL platform takes @lang=hppl blocks and inserts the contents directly into the HPPL output.


Moving on...


Today, I have for you more progress! We now have function overloading. Now you can have two functions with the same name and different arguments, like so:


Code: [Select]

@export
function overloadTest() {
print(func())
print(func("an argument"));
}


function func() {
return "Got no arguments!"
}


function func(a) {
return "Got "~a
}


Overloading via data type will be supported soon. Right now, however, I have made directive-based overloading, too.


So, in SourceBox, you have an output panel where calling print is like the standard println. Well, what if you want a newline-less print? Well, in SourceBox, there are two versions of print. They both take 1 argument, but one of them is tagged with the @append directive. Because of this fact, you can target the print-like one instead of the println-like one as so:


Code: [Select]

@main
function printTest() {
print("This ends with a newline.")
@append print("This one ")
@append print("does not.")
}


If you tag your function call with a directive, it will try to match the directives up between functions. This way, you can have a very fine way to control function call overloading.
« Last Edit: November 07, 2014, 04:02:00 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 #56 on: November 07, 2014, 08:00:20 pm »
I implemented the libraries for drawing in HPPL.

Code: [Select]

import prime.draw
import prime.io


@export
function main() {
local a = [rgb(255,0,0),rgb(0,255,0),rgb(0,0,255),rgb(255,0,255),rgb(0,255,255),rgb(255,255,0)]
screen.clear()
screen.drawString("Press any key to begin.",20,10)
waitForInput()
local i = 1
while not isKeyDown(4) {
screen.fill(a[i] as real)
screen.drawString("Source",125,40,7)
wait(.5)


i+=1
if i>a.size() {
i = 1
}
}
msgbox("Source. It's a programming language.")
}
« Last Edit: November 07, 2014, 08:02:21 pm by iconmaster »

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 #57 on: November 08, 2014, 02:15:50 am »
Multiple dispatch?
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 #58 on: November 08, 2014, 07:16:44 pm »
Multiple dispatch?

Source uses static dispatch, but yes, it does dispatch now.

Anyways, I've been working for HPPL drawing emulation in SourceBox. It's limited, but for now you can run this program in both the Prime and on your PC:

Code: [Select]
import prime.draw
import prime.io

@export
function main() {
   local a = [rgb(255,0,0),rgb(0,255,0),rgb(0,0,255),rgb(255,0,255),rgb(0,255,255),rgb(255,255,0)]
   screen.clear()
   screen.drawString("Press any key to begin.",20,10)
   waitForInput()
   local i = list.start
   while not isKeyDown(key.esc) {
      screen.fill(a[i] as int)
      screen.drawString("Source",125,40,7)
      wait(.5)

      if a[i]==a.last() {
         i = list.start
      } else {
         i+=1
      }
   }
   msgbox("Source. It's a programming language.")
}
« Last Edit: November 09, 2014, 06:12:04 pm by iconmaster »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • 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 #59 on: November 08, 2014, 07:37:32 pm »
inline HP PPL support is definitively a good idea. Also if the calc ever supports ASM maybe Source could allow inline ASM opcodes?