This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
cmurtheepic's profile picture

programming language help (CUBIT)

Started by cmurtheepic, 03 December 2012 - 01:55 PM
cmurtheepic #1
Posted 03 December 2012 - 02:55 PM
i am trying to create a programming language called "CUBIT" but it is pronounced "cuhbit"
and i don't know really how to get started :(/>
i am going to write it in lua but i need help
if anyone would like to join in with me on the project PM me or comment on the post :)/>
oh and this is a ask a pro question :)/>
Bubba #2
Posted 03 December 2012 - 02:59 PM
Step 1) Make an interpreter
Step 2) Have fun

Not exactly sure what you want but this is not the place ask people to join your project. As for helping you with your problem, well honestly if you can't be bothered to just go and look up the information you need why should anybody help you? I'll give you a hint: string manipulation will be of vital importance. Go learn some regex and then come back with some code if you are having issues.
cmurtheepic #3
Posted 03 December 2012 - 03:20 PM
i did.
I have been looking for HOURS! trying to find any information that would help me on how to create a programming language in lua and in other languages to help me get a idea on how to do this.
and on your comment

but this is not the place ask people to join your project.
i asked if anyone would LIKE to join in on the project with me.
my intention was not to recruit people to work on the project, or ask them to join. that was not the intention of this post.
and i don't really know what a interpreter is.
and if anyone did want or would like to join in on the project send me a message. and it would be nice to have some help on the project.
oh and i almost forgot I am a intermediate to semi-advanced lua programmer.
I still don't know everything about the context and syntax of LUA but I have a pretty good idea.
Bubba #4
Posted 03 December 2012 - 03:30 PM
An interpreter is basically just a program that interprets some bit of code and translates it into native code, or in this case Lua. Using string regex to find patterns in whatever the user inputs, you can define how you want different patterns/syntax to behave. If you don't know what regex is, then there are plenty of great tutorials out there on the internet. It's just a matter of patience and using your head. If you don't have the patience to go out there and look for stuff, or if you don't use your head before asking questions, anything that people tell you is just going to fly straight over you and will never have a full appreciation of it.

TL;DR? Google "lua string regex" or "lua string manipulation" and find what you're looking for. Or better yet go and look for "how to make a language interpreter" on google - it doesn't have to be in Lua. You can probably make sense of just about any scripting language and apply that to your own interpreter.

You probably think I'm trying to be a dickhead or just an asshole but I'm not. I want to help people who help themselves. In all of my time programming (and I've been programming a looong time), I've only asked a few questions and all of them were on somewhat or extremely obscure issues. So what I'm trying to say is that you just need to look harder - it's all out there.
cmurtheepic #5
Posted 03 December 2012 - 03:53 PM
right now lua is the only programming language that i understand and (like)
I absolutley refuse to use C, C#, or C++ becuase they are non-usable programming language. and I get this from experiance. it comes up with errors from nothing.
and I don't think you are a "dickhead" or a "asshole" :)/>
I try todo the same thing i get called to help my brother and parents all the time to help them with their computers. and believe me it gets anoying pretty much 89% of the time.
cmurtheepic #6
Posted 03 December 2012 - 03:54 PM
oh and I don't get python or java or even javascript.
and i have looked at other programming languages to learn.
Bubba #7
Posted 03 December 2012 - 03:57 PM
right now lua is the only programming language that i understand and (like)
I absolutley refuse to use C, C#, or C++ becuase they are non-usable programming language. and I get this from experiance. it comes up with errors from nothing.
and I don't think you are a "dickhead" or a "asshole" :)/>
I try todo the same thing i get called to help my brother and parents all the time to help them with their computers. and believe me it gets anoying pretty much 89% of the time.

Well calling C, C#, or C++ "non-usable" because they "come up with errors from nothing" is ignorant, because C, C#, and C++ are probably some of the most refined programming languages to date. Any errors you get are not because of the language, but because of something you did. But back on subject, I'm not suggesting you go and take a look at anything like C++ for an example. Almost every scripting language follows very similar syntax, so Python, Ruby, Javascript, or any of those would be completely understandable for you excepting perhaps a few things and therefore you could implement it into your own script. You don't have to understand every aspect of the language, just get the general idea of what the person is trying to do. Here's a small example:

Python code

def sayHi(name):
  print("Hi " + name)

sayHi("Michael")
–This will output "Hi Michael"

Lua code

local function sayHi(name)
  print("Hi "..name)
end

sayHi("Michael")
– Outputs the same as above

As you can see in the incredibly simple example, they follow very similar syntax. If you understand Lua then I'm sure you can figure out what people are doing in other scripting languages just by just looking at their code. It only took me a few days to adapt myself to Lua after learning all the other scripting languages that I have.
Bubba #8
Posted 03 December 2012 - 04:04 PM
oh and I don't get python or java or even javascript.
and i have looked at other programming languages to learn.

Well seeing as how their syntax is so similar to Lua I don't see why not. Can explain why you don't understand them?
cmurtheepic #9
Posted 03 December 2012 - 04:15 PM
the reason I don't understand python or javascript or java is because I have comprehension issues and I can't make the similarity connections that most people can :(/>
but I did buy a beginners guide to python book. I didn't get far into it :(/>
and if you have any ideas on programming languages that the coding and syntax is near exact or similar to lua and that i could look at it and either understand it and know how to use it but with some learning on the programming language itself. or where I can make the connections quite a bit easier that what you have shown above, to the similarities. that will be great :)/>

but I will be making my own research too on the matter so I am trying to help myself too :)/>
Kingdaro #10
Posted 03 December 2012 - 04:17 PM
So you want to make a programming language. Do you actually have the basic premise of how it's going to work planned out?

It's also good to understand how string functions like match and gmatch work, too, because you'll be using those often, I'd imagine.
cmurtheepic #11
Posted 03 December 2012 - 04:23 PM
yes I have gotten most of the syntax and the layout thought up.
but it is going to be somewhat quite similar to lua
Bubba #12
Posted 03 December 2012 - 04:29 PM
yes I have gotten most of the syntax and the layout thought up.
but it is going to be somewhat quite similar to lua

In that case you may be able to just use loadstring() on a lot of the code, and use the mentioned string manipulation methods to do the rest.
Orwell #13
Posted 03 December 2012 - 04:29 PM
If you're actually going to create a programming language with a proper syntax, I believe you should have quite some knowledge about Context Free Grammars. Maybe I'm wrong, but that's what I've been thought at school. :P/> Anyway, I do have a suggestion for you. You could start out with a stack-oriented programming language. Those have rather weird syntaxes, but they are quite simple to understand and it would really teach you a lot about the working of programming languages and interpreters. I believe that you'd have a good base knowledge after create such a stack-oriented language. I have 2 3 4 links here for you to start out with:

The principle of a 'Stack' on Wikipedia: https://en.wikipedia...ct_data_type%29
Stack-oriented programming languages on Wikipedia: https://en.wikipedia...amming_language
Lua Stack snippet: http://snippets.luac...ippets/stack_97
A maybe easier to understand Lua Stack snippet: http://lua-users.org/wiki/SimpleStack
cmurtheepic #14
Posted 03 December 2012 - 06:01 PM
thanks i'll see if this helps :)/>
cmurtheepic #15
Posted 03 December 2012 - 06:05 PM
OMF–FABULOUS AMAZING–G
this is just like using for instance

local function commandname(arguments)
  what it should do
end
like
local function printCentered(str, ypos)
  term.setCursorPos(w/2 - #str/2, ypos)
  term.write(str)
end
PERFECT!!!!
:)/>
thanks orwell this really helped
but I probably am still going to need some help
cmurtheepic #16
Posted 03 December 2012 - 06:15 PM
OH and i forgot to mention if you want to see the book on python that i bought. just look up "Beginning Python From Novice to Professional Second Edition" "by Magnus Lie Hetland"