Author Topic: It is possible to convert lua to c, and vice versa!  (Read 6662 times)

0 Members and 1 Guest are viewing this topic.

Offline njaddison

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 176
  • Rating: +24/-27
    • View Profile
It is possible to convert lua to c, and vice versa!
« on: January 03, 2012, 06:52:59 pm »
I was surfing the internet, and I found a lua to c converter, and a c to lua converter. It would be possible to convert standard lua scripts to c, so we can run them with ndless, but we would need to create a c to lua converter. This would be awesome because we would be able to play c games without ndless because of the nspire's 3.x lua capabilities.
-Nelson

« Last Edit: January 03, 2012, 06:53:37 pm by njaddison »
<a href="http://www.nerdtests.com/ft_nt2.php">
<img src="http://www.nerdtests.com/images/badge/nt2/5f42ec78e054645d.png" alt="NerdTests.com says I'm a Highly Dorky Nerd God.  Click here to take the Nerd Test, get geeky images and jokes, and talk to others on the nerd forum!">
</a>


Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: It is possible to convert lua to c, and vice versa!
« Reply #1 on: January 03, 2012, 06:56:03 pm »
Wouldn't it be slower in lua if C was converted?

Offline njaddison

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 176
  • Rating: +24/-27
    • View Profile
Re: It is possible to convert lua to c, and vice versa!
« Reply #2 on: January 03, 2012, 07:00:53 pm »
Well, yeah. But it would originally be c, and I can be patient when using a lua script that was originally c.


« Last Edit: January 03, 2012, 07:01:24 pm by njaddison »
<a href="http://www.nerdtests.com/ft_nt2.php">
<img src="http://www.nerdtests.com/images/badge/nt2/5f42ec78e054645d.png" alt="NerdTests.com says I'm a Highly Dorky Nerd God.  Click here to take the Nerd Test, get geeky images and jokes, and talk to others on the nerd forum!">
</a>


Offline cyanophycean314

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 363
  • Rating: +43/-1
  • It's You!
    • View Profile
Re: It is possible to convert lua to c, and vice versa!
« Reply #3 on: January 03, 2012, 07:38:27 pm »
I think C being converted to Lua would have many problems. Speed would probably be an issue, but there are so many features that Lua could not support. I'm not too familiar with either C or Lua, but it seems this wouldn't work.

Secondly, njaddison. You should put that userbar into your signature. That way it's attached to every post, so you don't need to copy and paste it every post.

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: It is possible to convert lua to c, and vice versa!
« Reply #4 on: January 03, 2012, 07:47:26 pm »
you could probably run a lua script indirectly through ndless any way scince there is a lua interpreter, of course i could be wrong
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: It is possible to convert lua to c, and vice versa!
« Reply #5 on: January 03, 2012, 10:05:03 pm »
It also depends. Although the converter may work, it is a matter of how efficient the code it produces is. Also, what may be good design in one language may not be good coding practice in the other, thus producing overly bloated code. Just some things to keep in mind. :)
« Last Edit: January 03, 2012, 10:05:27 pm by Art_of_camelot »

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: It is possible to convert lua to c, and vice versa!
« Reply #6 on: January 04, 2012, 01:31:51 pm »
i'm afraid it won't work.. switching between languages is already hard to do manually, than how are you supposed to do it automatically?

it won't work by just replacing all the commands, you really need to dig into the syntax and structure to make it useable, and how're you supposed to do that?

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: It is possible to convert lua to c, and vice versa!
« Reply #7 on: January 04, 2012, 03:09:14 pm »
Converting lua to C is pretty easy as Lua is programmed to be easily intergrated with C.
Converting C to Lua however is a much bigger task, because:
1. It has many different types of variables which are not available in Lua.
2. Most programs access specific stuff (screen, timers, etc) which you can not do from Lua.
3. If you can bypass these limitations, speed would be a very big issue. My logo interpreter just runs at ok speeds, but C is a billion times more complex.

So in short : C to Lua is not possible.
Of course, you can convert some programs manually, but thats another case :P