CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: iconmaster on January 21, 2015, 10:24:59 PM

Title: [HP Prime/PC] Source - It's a programming language.
Post by: iconmaster on January 21, 2015, 10:24:59 PM
Once upon a time, I was writing programs for the HP Prime in HPPL. The more I worked in HPPL, the more I became dissatisfied with the language. I mean, it was usable, but I wanted better.

So I decided to make something better. I started work on Source. It's a programming language.

Source is a procedural, statically-typed bytecode-compiled language that can either compile to whatever platform you need or interpret directly on your computer. Currently, it compiles to HPPL.

Source gives you control. It's statically typed, so you can read your code more easily. It can assume types, so it's not needlessly verbose. You can control how it compiles through directives.

Source is flexible. It provides data structures and user types. You can define methods for data types anywhere. You can organise your code into packages. Source even can handle cyclic dependencies!

Source has tools. Compile it into HPPL from the command line, or use SourceBench to write and compile code on the fly. Use SourceBox to run your code on your PC. Run SourceLine to interactively execute Source code.

Source isn't done yet. The core libraries still need implemented, not to mention a bunch of features such as custom structs and classes. In the future, it will be able to compile to a bunch of places, not just HPPL. I wouldn't describe it as 'usable' yet. But stay tuned!

Anyways, the important bit: The link. Check out the source code at:

https://github.com/iconmaster5326/Source (https://github.com/iconmaster5326/Source)

Want to download Source? Want to learn more? Check out the wiki at:

https://github.com/iconmaster5326/Source/wiki (https://github.com/iconmaster5326/Source/wiki)

The wiki has downloads, documentation, and tutorials.
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: Dream of Omnimaga on January 22, 2015, 04:05:00 AM
This is definitively something I'll need to try to learn when I am done with Supersonic Ball HP and Super Walrii Land. :) I'm also glad that you are still planning PC support. It would be nice to be able to make games for both calcs and the computer simultaneously. Maybe eventually you could also compile to Ndless C?
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: iconmaster on January 23, 2015, 09:19:10 PM
I'm creating tutorials for those who want to get up to date on the syntax of Source on the wiki here (https://github.com/iconmaster5326/Source/wiki). I suggest you check it out!

Quote from: DJ Omnimaga on January 22, 2015, 04:05:00 AM
I'm also glad that you are still planning PC support. It would be nice to be able to make games for both calcs and the computer simultaneously. Maybe eventually you could also compile to Ndless C?

If LLVM can be compiled to ARM assembly, I'd assume you could get something working on the NSpire in short order. It'd take some work, though, but its quite possible.
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: Dream of Omnimaga on January 24, 2015, 12:22:50 AM
Cool to hear about the tutorials. In the past, some people made new languages for various calculators, but they would remain undocumented for the most part, which prevented many people from using them.

And thanks for the info about LLVM.
Title: Re: Source - It's a programming language.
Post by: Dream of Omnimaga on March 11, 2015, 11:03:27 AM
Btw have you worked on this recently?
Title: Re: Source - It's a programming language.
Post by: iconmaster on March 11, 2015, 12:41:45 PM
Quote from: DJ Omnimaga on March 11, 2015, 11:03:27 AM
Btw have you worked on this recently?

In the past few weeks, I've done some minor changes to the compiler, yes. Mostly, though, I've had to take time to deal with other obligations.

When I have time, I need to rewrite the HPPL output platform, so expect large changes when they do happen...
Title: Re: Source - It's a programming language.
Post by: Dream of Omnimaga on March 11, 2015, 01:47:01 PM
Aah ok no problem. Glad this is still worked on :). Keep us updated when there are big updates :)
Title: Re: Source - It's a programming language.
Post by: alexgt on March 25, 2015, 12:10:08 AM
Wow when I get my prime I will definitly use this!
Title: Re: Source - It's a programming language.
Post by: Yuki on March 25, 2015, 05:20:07 AM
Yep, shoulda try it out. By the way, is there any way to use it with LLVM (since you mentioned it in the thread)?
Title: Re: Source - It's a programming language.
Post by: Duke "Tape" Eiyeron on March 25, 2015, 08:10:39 AM
Making llvm work on calc would be rad as it'd open so much things for the calc. Each langugae that would compile into LLVM could be run on the Nspire. Imagine the feats one could do!
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: Snektron on March 25, 2015, 11:10:36 AM
isnt there already a LLVM to Z80 compiler? also i did a click google on it some time ago and i saw some Cemetech posts about it
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: iconmaster on March 26, 2015, 08:11:33 PM
Hello, everyone! Glad you've been interested in Source. I updated the OP, so now it describes Source a little better.

Quote from: Juju on March 25, 2015, 05:20:07 AM
Yep, shoulda try it out. By the way, is there any way to use it with LLVM (since you mentioned it in the thread)?

There WILL be a way to, but the LLVM platform for Source is not usable yet. In time, I hope LLVM to be the primary compilation target for Source.

Quote from: Cumred_Snektron on March 25, 2015, 11:10:36 AM
isnt there already a LLVM to Z80 compiler? also i did a click google on it some time ago and i saw some Cemetech posts about it

There is the one LLVM Z80 project I know of, but it hasn't been worked on for several years, apparently. It doesn't look working yet, but I have hopes.

Right now, I discovered some mechanics in the core Source engine that need rewritten, so I'm seriously considering rewriting the Source compiler from scratch. If I do this, it might be a while before Source becomes usable. It would be for the better, however; my old code can be a bit hard to follow.
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: Snektron on March 26, 2015, 08:27:19 PM
Wait- this is a language on a virtual machine? wouldn't it be possible to port it to other calculators and make a common programming language? O.O
i've always wanted to code a higher virtual machine than my brainc compiler... though i don't have mcuh experience and don't really get some of the opcodes...
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: iconmaster on March 26, 2015, 10:21:56 PM
Quote from: Cumred_Snektron on March 26, 2015, 08:27:19 PM
Wait- this is a language on a virtual machine? wouldn't it be possible to port it to other calculators and make a common programming language? O.O
i've always wanted to code a higher virtual machine than my brainbleep compiler... though i don't have mcuh experience and don't really get some of the opcodes...

The name of LLVM is a misnomer. It is not a virtual machine; is compiles code using LLVM IR, a virtual language, as an intermediate. When Source compiles to LLVM, it will be a fully compiled language.

In other news, I'm finalizing pointer operations in Source. What syntax looks better to you guys?

one() is a function that returns a pointer to a local. two() returns the value inside that pointer, dereferencing it.


//idea 1
function one() as ptr[int] {
local a = 2
return a.ptr
}

function two(b as ptr[int]) as int {
return b.value
}



//idea 2
function one() as $[int] {
local a = 2
return $a
}

function two(b as $[int]) as int {
return b$
}
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: Snektron on March 26, 2015, 10:50:20 PM
Yes but since there's not really a good z80 backend a seperate compiler/virtual machine for z80 would still be cool :)
Title: Re: Source - It's a programming language.
Post by: Dream of Omnimaga on March 27, 2015, 03:35:59 AM
Given that HP PPL intended to be user-friendly, I would go with the first syntax, since it looks more English-like. But of course, if the second syntax is more common among other languages, then go with that one instead. Glad to see pointers in Source. :D
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: Snektron on March 27, 2015, 10:23:32 AM
hey i wanted to download it, but there seems to be no working link :(
anyway im really impressed with this language! :D

EDIT: i can download it now, though i have java7 due to the stupid 'medium security' removal, so i can't un it :(
EDIT2: i installed jdk 8u40, so i can run it but jre7 is still my standard runtime :)
EDIT3: out of curiosity, i've been looking at the asm, but i don't get why function a() and b() are both compiled to r?()
Title: Re: Source - It's a programming language.
Post by: Dream of Omnimaga on March 28, 2015, 04:19:08 PM
The Github repo is where the latest code is, I think. Also I didn't know you could install two java versions at once? ??? That would be handy for me because of this. (http://codewalr.us/index.php?topic=296.0)
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: Snektron on March 28, 2015, 04:23:31 PM
you can intsall two at once, b only one can be your default runtime
Title: Re: Source - It's a programming language.
Post by: Dream of Omnimaga on March 28, 2015, 04:27:29 PM
Ok, but can you easily change your settings so you can swap between both?
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: Snektron on March 28, 2015, 04:45:09 PM
Well to run java 8 programs i now just use the full java 8 path instead of just "java -jar program.jar"
but i only installed the sdk and not the jre, so it won't run web things (not that theyre really used anymore, except i
sometimes like to lurk on openprocessing)
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: iconmaster on March 28, 2015, 07:03:06 PM
I fixed the drone.io to give you the old Source. Currently, I'm working on the new Source compiler (you can see it on the "v2" branch on GitHub). Source 2 is even less done than Source 1, so yeah.

Quote from: Cumred_Snektron on March 27, 2015, 10:23:32 AM
EDIT3: out of curiosity, i've been looking at the asm, but i don't get why function a() and b() are both compiled to r?()

That's the HPPL obfuscator at work! The ?s are high-codepage Unicode characters. a and b compiled to functions beginning with an r, but ending with two different characters. You should be seeing characters other than ?s; that's your text viewer not seeing the Unicode encoding properly.

Quote from: DJ Omnimaga on March 28, 2015, 04:27:29 PM
Ok, but can you easily change your settings so you can swap between both?

Yes! I, myself, have something to alter my %JAVA_HOME% when I need to use Java 7.
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: Snektron on March 28, 2015, 10:42:34 PM
Quote from: iconmaster on March 28, 2015, 07:03:06 PM
I fixed the drone.io to give you the old Source. Currently, I'm working on the new Source compiler (you can see it on the "v2" branch on GitHub). Source 2 is even less done than Source 1, so yeah.

Quote from: Cumred_Snektron on March 27, 2015, 10:23:32 AM
EDIT3: out of curiosity, i've been looking at the asm, but i don't get why function a() and b() are both compiled to r?()

That's the HPPL obfuscator at work! The ?s are high-codepage Unicode characters. a and b compiled to functions beginning with an r, but ending with two different characters. You should be seeing characters other than ?s; that's your text viewer not seeing the Unicode encoding properly.

When i view it in hex it still says '3f' though
Title: Re: Source - It's a programming language.
Post by: Dream of Omnimaga on March 29, 2015, 05:02:33 AM
Quote from: iconmaster on March 28, 2015, 07:03:06 PM

Quote from: DJ Omnimaga on March 28, 2015, 04:27:29 PM
Ok, but can you easily change your settings so you can swap between both?

Yes! I, myself, have something to alter my %JAVA_HOME% when I need to use Java 7.
Cool. I might have to Google it, unless it's not something common (in which case, would you mind sharing?)
Title: Re: [HP Prime/PC] Source - It's a programming language.
Post by: Snektron on March 29, 2015, 10:19:44 AM
%JAVA_HOME% points to the java compiler you use with the "java" console command
i've just noticed i didn't set it up properly too, i don't even have the variable
Title: Re: Source - It's a programming language.
Post by: Dream of Omnimaga on March 30, 2015, 03:34:59 AM
Yeah, I just need to find out where to set that stuff up. :P Not a big hurry, though, but this will definitively become one if I ever decide to use Source.