Posts: 2020
Threads: 133
Joined: July 26, 2017
Reputation:
5
WebAssembly
August 3, 2020 at 12:08 pm
Hey, guys!
So, I came to an idea that I could make money by making an alternative to AssemblyScript, by making a compiler which compiles AEC (the programming language I designed) to WebAssembly. Until now, AEC targetted only x86 Assembly, so I've been writing a new compiler. I've actually rewritten everything (including the tokenizer and the parser) from JavaScript to C++, because most experienced programmers think C++ is a better language than JavaScript is for those kinds of stuff. After I've written more than 3'000 lines of code, I've managed to compile a simple AEC program to run in a browser.
So, what do you guys think, is it worth to continue developing it? Do you think it's worth to drop out of university to try to make money of that idea? I am not doing well at the university, and most things we learn there seem absolutely pointless to me. I want honest answers.
Posts: 3989
Threads: 79
Joined: June 30, 2009
Reputation:
41
RE: WebAssembly
August 3, 2020 at 12:40 pm
I don't really know what your language brings to the table that is new because I haven't done extensive coding. I've only dabbled a bit. I would say throw free time at your language and compiler and try to find a market to make money while you keep chopping that wood at school.
Posts: 2020
Threads: 133
Joined: July 26, 2017
Reputation:
5
RE: WebAssembly
August 4, 2020 at 2:09 pm
Rhizomorph13 Wrote:I've only dabbled a bit. I would say throw free time at your language and compiler and try to find a market to make money while you keep chopping that wood at school. I have 5 F's at the university. The only way I can finish the university is maybe if I dedicate all my time to it. So, I can't both develop my programming language and finish the university. By the way, today I've managed to compile some simple algorithms written in my programming language to WebAssembly.
Posts: 2020
Threads: 133
Joined: July 26, 2017
Reputation:
5
RE: WebAssembly
August 9, 2020 at 3:06 pm
I've just managed to compile the Analog Clock in AEC, previously runnable on Linux and DOS (using DJGPP), to be runnable on the web. I had to write a math library for that, because WebAssembly doesn't provide you with "fsin", "fcos" and "fsqrt" like x86 assembly does.
Posts: 2020
Threads: 133
Joined: July 26, 2017
Reputation:
5
RE: WebAssembly
August 19, 2020 at 3:36 pm
I've implemented a Dragon Curve in AEC:
Code: /*
* This will be my attempt to build a graphical application with AEC.
*/
//Let's import some JavaScript functions...
Function drawLine(Integer32 x1,
Integer32 y1,
Integer32 x2,
Integer32 y2,
CharacterPointer color,
Integer32 lineWidth) Which Returns Nothing Is External;
Function applyTurtleTransformation(Integer32 translateX,
Integer32 translateY,
Integer32 rotateDegrees)
Which Returns Nothing Is External; //We won't use the turtle for actual
//drawing, but we will move it and
//rotate it.
Integer32 directionX[4] := { 0, 1, 0, -1},
directionY[4] := {-1, 0, 1, 0},
currentX := 15,
currentY := 250,
currentDirection := 0,
lineLength := 5,
lineWidth := 2,
currentStep := 0;
Character path[16384], reversedPath[16384];
//Again, we need to implement string manipulation functions. Like I've said,
//even though this program will be running on JavaScript Virtual Machine, it
//can't call the methods of the JavaScript "String" class.
Function strlen(CharacterPointer str) Which Returns Integer32 Does
//We can't implement this recursively, like we did in earlier AEC
//programs, because we will be dealing with large strings which will
//cause stack overflow.
Integer32 length := 0;
While ValueAt(str + length) Loop
length := length + 1;
EndWhile
Return length;
EndFunction
Function strcpy(CharacterPointer dest,
CharacterPointer src) Which Returns Nothing Does
While ValueAt(src) Loop
ValueAt(dest) := ValueAt(src);
dest := dest + 1;
src := src + 1;
EndWhile
ValueAt(dest) := 0;
EndFunction
Function reverseString(CharacterPointer string) Which Returns Nothing Does
CharacterPointer pointerToLastCharacter := string + strlen(string) - 1;
While pointerToLastCharacter - string > 1 Loop
Character tmp := ValueAt(string);
ValueAt(string) := ValueAt(pointerToLastCharacter);
ValueAt(pointerToLastCharacter) := tmp;
string := string + 1;
pointerToLastCharacter := pointerToLastCharacter - 1;
EndWhile
EndFunction
Function strcat(CharacterPointer dest,
CharacterPointer src) Which Returns Nothing Does
strcpy(dest + strlen(dest), src);
EndFunction
//This is the function that's supposed to be called by JavaScript as soon
//as it is ready.
Function init() Which Returns Nothing Does
CharacterPointer path := AddressOf(path[0]);
CharacterPointer reversedPath := AddressOf(reversedPath[0]);
strcpy(path,"R");
Integer32 counter := 0;
While strlen(path) < 8192 Loop
strcpy(reversedPath, path);
If mod(counter, 4) = 0 Then
reverseString(reversedPath);
EndIf
strcat(path, reversedPath);
strcat(path, not(mod(counter,4))?"L":"LLL");
counter := counter + 1;
EndWhile
EndFunction
//This function is supposed to be periodically called by JavaScript:
Function step() Which Returns Nothing Does
If currentStep < 8192 and currentX > 0 and currentX < 500
and currentY > 0 and currentY < 500 Then
Integer32 nextX := currentX + directionX[currentDirection] * lineLength,
nextY := currentY + directionY[currentDirection] * lineLength;
drawLine(currentX, currentY, nextX, nextY,
currentStep=0?
"lightYellow"
:path[currentStep]='R'?
"red"
:path[currentStep]='L'?
"lightGreen"
: "lightBlue",
lineWidth);
currentX := nextX;
currentY := nextY;
If path[currentStep]='R' Then
currentDirection := mod(currentDirection + 1, 4);
ElseIf not(currentDirection=0) and path[currentStep]='L' Then
currentDirection := currentDirection - 1;
ElseIf path[currentStep]='L' Then
currentDirection := 3;
EndIf
currentStep := currentStep + 1;
applyTurtleTransformation(currentX, currentY, currentDirection*90);
EndIf
EndFunction
To accomplish that, I needed to fix a few bugs in the compiler.
|