News for hackers. Stuff that matters.
Re:Terra: A low-level counterpart to Lua by djent on Saturday August 24, 2013 @11:07AM (#6268824)
Re:Terra: A low-level counterpart to Lua by jamii on Saturday August 24, 2013 @11:31AM (#6268897)
Huh, searching for "site:news.ycombinator.com terra lua" did not turn up any discussion at all. Thanks.
Re:Terra: A low-level counterpart to Lua by greenyoda on Saturday August 24, 2013 @03:36PM (#6269558)
HNSearch seems to be better at finding previously posted content than Google is:

https://www.hnsearch.com/search#request/submissions&q=terra+...

Still, it's interesting and relevant, and I hadn't seen it before, so thanks for posting.

Re:Terra: A low-level counterpart to Lua by Bootvis on Saturday August 24, 2013 @02:23PM (#6269343)
Don't feel sorry. I hadn't seen Terra before and now I have, so thanks for submitting!
Re:Terra: A low-level counterpart to Lua by djent on Saturday August 24, 2013 @11:41AM (#6268920)
There's a search field at the bottom of the HN page that searches all of HN.
Re:Terra: A low-level counterpart to Lua by HCIdivision17 on Saturday August 24, 2013 @03:29PM (#6269538)
Any reason we should expect the two to return different results, other than one is less comprehensive crawling? (I have wondered how thorough the web crawling engines are.)
Re:Terra: A low-level counterpart to Lua by denzquix on Saturday August 24, 2013 @05:31PM (#6269861)
It bugs me that the numerical for-loop in Terra has identical syntax to Lua's, but different semantics. Especially since you are encouraged to mix Lua and Terra code in the same file. Even something like:

for i = 0, < 10 do --[[ ... ]] end

...and throwing a compile error if you omit the <, though arguably ugly and weird, would still have been preferable I think.

Re:Terra: A low-level counterpart to Lua by omaranto on Saturday August 24, 2013 @09:34PM (#6270526)
I couldn't find a description of the Terra for loop in a few minutes of poking through the website and the paper. How is it different from the numeric Lua for loop?
Re:Terra: A low-level counterpart to Lua by tekacs on Saturday August 24, 2013 @11:18PM (#6270753)
From http://terralang.org/getting-started.html#control_flow

     Terra also includes for loop. This example counts from 0 up to but not including 10:  
       
     for i = 0,10 do  
         C.printf("%d\n",i)  
     end  
       
     This is different from Lua’s behavior (which is inclusive of 10) since Terra uses 0-based indexing and pointer arithmetic in contrast with Lua’s 1-based indexing. Ideally, Lua and Terra would use the same indexing rules. However, Terra code needs to frequently do pointer arithmetic and interface with C code both of which are cumbersome with 1-based indexing. Alternatively, patching Lua to make it 0-based would make the flavor of Lua bundled with Terra incompatible with existing Lua code.  
       
     Lua also has a for loop that operates using iterators. This is not yet implemented (NYI) in Terra, but a version will be added eventually.  
       
     The loop may also specify an option step parameter:  
       
     for i = 0,10,2 do  
         c.printf("%d\n",i) --0, 2, 4, ...  
     end
Re:Terra: A low-level counterpart to Lua by aray on Saturday August 24, 2013 @08:43PM (#6270393)
ARM support, sweet! This is one of the advantages of just using llvm for code-gen -- architectures just work right out of the box, and the library handles all of the specifics.

I think this is a good example of what the llvm code generation libraries enable (as opposed to gcc).

(In addition to being a pretty cool project on it's own!)

Re:Terra: A low-level counterpart to Lua by atrilumen on Saturday August 24, 2013 @01:51PM (#6269268)
I haven't taken the time to play with it yet, but I think it would be nice to write a little sugar language that compiles to Terra, with inline macros that compile to Lua.

In the meantime, I'm watching Terra.

Re:Terra: A low-level counterpart to Lua by jnbiche on Saturday August 24, 2013 @03:48PM (#6269586)
Moonscript could be easily modified to accomodate Terra:

http://moonscript.org/

Personally, through, Lua is sugary enough for me, particularly if I use Penlight.

Re:Terra: A low-level counterpart to Lua by atrilumen on Sunday August 25, 2013 @10:34AM (#6272122)
Sure, I considered using Moonscript as a starting point. It looks pretty neat.

But what I have in mind is just a little different. I want explicit type declaration, and I don't want to type "->".

So, something more of this character:

    void chant( string thing, int times ):
        for int i in range( times ):
            print( "$thing $i" )

Also, I'd like to write the compiler in Terra.

I'm pretty fond of Lua just the way it is as well, but I'm picky and stubborn and idealistic. I keep telling myself not to think about it, but I can't help but daydream about writing a language. I think Terra presents a fair opportunity to get it out of my system.

Re:Terra: A low-level counterpart to Lua by trentmb on Saturday August 24, 2013 @05:55PM (#6269940)
Then you can compile it to C++, which, thanks to asm.js/emscripten, can be compiled to JS!