Come-from-Beyond
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
February 04, 2014, 10:18:35 PM |
|
We need some kind of a competition. The goal is to find a language with min number of opcodes.
|
|
|
|
ChuckOne
Sr. Member
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
|
February 04, 2014, 10:19:59 PM |
|
Once we have a low-level language we'll be able to use any high-level language to translate it into low-level one.
If you use the abstract syntax tree based approach of Franz, your code would be platform neutral and any high-level language would only need to target the AST. Nxt is simple. Let's follow KISS principle as long as possible. If that's the way to go, then we shall use something already tested and bullet-proof instead of inventing the wheel anew. What about ARM aka RISC? As in accordance of NXT power efficiency.
|
|
|
|
Come-from-Beyond
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
February 04, 2014, 10:22:03 PM |
|
Is there something that you would need me to code up as a proof-of-concept in order to consider the AST approach?
The problem is not with AST approach. The problem is that Nxt should be as simple as possible to become wide-spread as much as possible. By mentioning "AST" word u increase entry barrier for programmers.
|
|
|
|
freigeist
|
|
February 04, 2014, 10:22:34 PM |
|
We need some kind of a competition. The goal is to find a language with min number of opcodes.
by this you mean instructions?!
|
|
|
|
xyzzyx
Sr. Member
Offline
Activity: 490
Merit: 250
I don't really come from outer space.
|
|
February 04, 2014, 10:23:12 PM |
|
Is there something that you would need me to code up as a proof-of-concept in order to consider the AST approach?
The problem is not with AST approach. The problem is that Nxt should be as simple as possible to become wide-spread as much as possible. By mentioning "AST" word u increase entry barrier for programmers. Ok. I understand now. What about the VM outlined in N. Wirth's Compiler Construction?
|
"An awful lot of code is being written ... in languages that aren't very good by people who don't know what they're doing." -- Barbara Liskov
|
|
|
Come-from-Beyond
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
February 04, 2014, 10:23:43 PM |
|
What about ARM aka RISC? As in accordance of NXT power efficiency.
We can't use ARM without virtualization. Current Nxt cores (Java and .NET versions) can't support virtualization.
|
|
|
|
ChuckOne
Sr. Member
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
|
February 04, 2014, 10:23:54 PM |
|
We need some kind of a competition. The goal is to find a language with min number of opcodes.
Don't know if turing complete is too much of a RISC (no pun intented; hoho). I know, you never, if you ever gonna need a feature. One problem with that is for instance the halting problem.
|
|
|
|
jl777
Legendary
Offline
Activity: 1176
Merit: 1134
|
|
February 04, 2014, 10:24:24 PM |
|
Will the Turing code be able to invoke higher level functions like "escrow NXT from acct to acct", "release escrow txid", "send DOGE", etc.
I think it's a bad idea. The language should have simple operations with near-equal consumption of resources. In this case it will be easy to assess fee required for contract execution. Time used should be the key, maybe adjust it for CPU speed of forging node. Current swap state would need to be put into blockchain so next forging node can pick up where it left off, but we can limit memory space. I am envisioning services provided by code running on the hub servers, so it is feasible to have 20 different altcoind's running and ready to be called. Also, anything else we can think of can be encapsulated into a function call. Need to be able to suspend a script after time limit anyway, otherwise infinite loop will be bad problem James Resource/fee consumption must be forger-agnostic. OK, 1 NXT per runtime context where it actually does anything. Getting context just to check status and not do anything could be free, if there was an initial cost to cover this overhead. Maybe part of submitting a script to the network could include frequency or other global variables, not all scripts need to run every block. I realize this contaminates the purity of the language, but I am just trying to make it easy for people to write scripts. Look at metatrader. They made global variables out of all the commonly needed data, eg. recent prices at various resolutions. That made it so thousands of EA (expert advisors they are called) were written. I want to support direct blockchain trading for all the other coins, so triggers to activate a script could reference any of the other blockchains. If there was a way to interconnect different scripts, then there could be a master script that runs and then conditionally triggers other scripts only when needed. We are behind etherium, so we need to leap past them by implementing low level primitives that allow immediate implementation of actually useful functionality. Decentralized trustless trading of any crypto against any other crypto. That I am sure will be big. James
|
|
|
|
Come-from-Beyond
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
February 04, 2014, 10:24:40 PM |
|
What about the VM outlined in N. Wirth's Compiler Construction?
I haven't heard about it so I can't answer.
|
|
|
|
|
Come-from-Beyond
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
February 04, 2014, 10:26:13 PM |
|
One problem with that is for instance the halting problem.
Halt is a legit way to terminate contract execution. At least Ethereum creators say so.
|
|
|
|
ChuckOne
Sr. Member
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
|
February 04, 2014, 10:26:23 PM |
|
What about ARM aka RISC? As in accordance of NXT power efficiency.
We can't use ARM without virtualization. Current Nxt cores (Java and .NET versions) can't support virtualization. What exactly do you mean by virtualization? How else do you want to execute it on my machine? On real metal? No way! You have to have an environment anyway.
|
|
|
|
Damelon
Legendary
Offline
Activity: 1092
Merit: 1010
|
|
February 04, 2014, 10:27:41 PM |
|
Nxt chocolate cookies!
|
|
|
|
Come-from-Beyond
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
February 04, 2014, 10:29:07 PM |
|
Maybe part of submitting a script to the network could include frequency or other global variables, not all scripts need to run every block.
Transactions should be processed only upon including into a block. If u need an algo that "wakes up" every 5 minutes then ur algo has to send a new transaction each time.
|
|
|
|
ChuckOne
Sr. Member
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
|
February 04, 2014, 10:30:06 PM |
|
One problem with that is for instance the halting problem.
Halt is a legit way to terminate contract execution. At least Ethereum creators say so. Well, okay. You could pay per operation.
|
|
|
|
Come-from-Beyond
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
February 04, 2014, 10:30:29 PM |
|
What about ARM aka RISC? As in accordance of NXT power efficiency.
We can't use ARM without virtualization. Current Nxt cores (Java and .NET versions) can't support virtualization. What exactly do you mean by virtualization? How else do you want to execute it on my machine? On real metal? No way! You have to have an environment anyway. That's why I mentioned virtualization.
|
|
|
|
Come-from-Beyond
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
February 04, 2014, 10:31:26 PM |
|
Well, okay. You could pay per operation.
Yes, I like it too.
|
|
|
|
ChuckOne
Sr. Member
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
|
February 04, 2014, 10:31:34 PM |
|
One problem with that is for instance the halting problem.
Halt is a legit way to terminate contract execution. At least Ethereum creators say so. Well, okay. You could pay per operation. The operator of the program gains the operation fees, I guess.
|
|
|
|
ChuckOne
Sr. Member
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
|
February 04, 2014, 10:32:41 PM |
|
What about ARM aka RISC? As in accordance of NXT power efficiency.
We can't use ARM without virtualization. Current Nxt cores (Java and .NET versions) can't support virtualization. What exactly do you mean by virtualization? How else do you want to execute it on my machine? On real metal? No way! You have to have an environment anyway. That's why I mentioned virtualization. Yes, and RISC is already tested in production almost everywhere. Just need a virt. env for that in J, C#, Python etc.
|
|
|
|
xyzzyx
Sr. Member
Offline
Activity: 490
Merit: 250
I don't really come from outer space.
|
|
February 04, 2014, 10:34:33 PM |
|
What about the VM outlined in N. Wirth's Compiler Construction?
I haven't heard about it so I can't answer. This is it: MODULE RISC; (*NW 27. 11. 05*) IMPORT SYSTEM, Texts; CONST MemSize* = 4096; ProgOrg = 2048; (*in bytes*) MOV = 0; MVN = 1; ADD = 2; SUB = 3; MUL = 4; Div = 5; Mod = 6; CMP = 7; MOVI = 16; MVNI = 17; ADDI = 18; SUBI = 19; MULI = 20; DIVI = 21; MODI = 22; CMPI = 23; CHKI = 24; LDW = 32; LDB = 33; POP = 34; STW = 36; STB = 37; PSH = 38; RD = 40; WRD= 41; WRH = 42; WRL = 43; BEQ = 48; BNE = 49; BLT = 50; BGE = 51; BLE = 52; BGT = 53; BR = 56; BSR = 57; RET = 58; VAR IR: LONGINT; N, Z: BOOLEAN; R*: ARRAY 16 OF LONGINT; M*: ARRAY MemSize DIV 4 OF LONGINT; W: Texts.Writer; (* R15] is PC, R[14] used as link register by BSR instruction*) PROCEDURE Execute*(start: LONGINT; VAR in: Texts.Scanner; out: Texts.Text); VAR opc, a, b, c, nxt: LONGINT; BEGIN R[14] := 0; R[15] := start + ProgOrg; LOOP (*interpretation cycle*) nxt := R[15] + 4; IR := M[R[15] DIV 4]; opc := IR DIV 4000000H MOD 40H; a := IR DIV 400000H MOD 10H; b := IR DIV 40000H MOD 10H; c := IR MOD 40000H; IF opc < MOVI THEN (*F0*) c := R[IR MOD 10H] ELSIF opc < BEQ THEN (*F1, F2*) c := IR MOD 40000H; IF c >= 20000H THEN DEC(c, 40000H) END (*sign extension*) ELSE (*F3*) c := IR MOD 4000000H; IF c >= 2000000H THEN DEC(c, 4000000H) END (*sign extension*) END ; CASE opc OF MOV, MOVI: R[a] := ASH(c, b) (*arithmetic shift*) | MVN, MVNI: R[a] := -ASH(c, b) | ADD, ADDI: R[a] := R[b] + c | SUB, SUBI: R[a] := R[b] - c | MUL, MULI: R[a] := R[b] * c | Div, DIVI: R[a] := R[b] DIV c | Mod, MODI: R[a] := R[b] MOD c | CMP, CMPI: Z := R[b] = c; N := R[b] < c | CHKI: IF (R[a] < 0) OR (R[a] >= c) THEN R[a] := 0 END | LDW: R[a] := M[(R[b] + c) DIV 4] | LDB: (*not implemented*) | POP: R[a] := M[(R[b]) DIV 4]; INC(R[b], c) | STW: M[(R[b] + c) DIV 4] := R[a] | STB: (*not implemented*) | PSH: DEC(R[b], c); M[(R[b]) DIV 4] := R[a] | RD: Texts.Scan(in); R[a] := in.i | WRD: Texts.Write(W, " "); Texts.WriteInt(W, R[c], 1) | WRH: Texts.WriteHex(W, R[c]) | WRL: Texts.WriteLn(W); Texts.Append(out, W.buf) | BEQ: IF Z THEN nxt := R[15] + c*4 END | BNE: IF ~Z THEN nxt := R[15] + c*4 END | BLT: IF N THEN nxt := R[15] + c*4 END | BGE: IF ~N THEN nxt := R[15] + c*4 END | BLE: IF Z OR N THEN nxt := R[15] + c*4 END | BGT: IF ~Z & ~N THEN nxt := R[15] + c*4 END | BR: nxt := R[15] + c*4 | BSR: nxt := R[15] + c*4; R[14] := R[15] + 4 | RET: nxt := R[c MOD 10H]; IF nxt = 0 THEN EXIT END END ; R[15] := nxt END END Execute; PROCEDURE Load*(VAR code: ARRAY OF LONGINT; len: LONGINT); VAR i: INTEGER; BEGIN i := 0; WHILE i < len DO M[i + ProgOrg DIV 4] := code[i]; INC(i) END END Load; BEGIN Texts.OpenWriter(W) END RISC.
Sorry about the formatting. Whitespace didn't copy clean.
|
"An awful lot of code is being written ... in languages that aren't very good by people who don't know what they're doing." -- Barbara Liskov
|
|
|
|