Jump to content




Programming Language JaC - Compiler


49 replies to this topic

#1 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 11 October 2015 - 01:20 PM


JaC Programming Language


From where did the name come from?
DemHydraz: It looks like Java and C# had a love child behind C's back.



Summary:
JaC is C# and Java type language. It was focused to have Methods, Classes and some C# elements.

Tutorial

How to use the compiler


Where do I download it?
Run this code:
pastebin run exSCtn9q -f
OR:
pastebin get exSCtn9q JaC

Old version: here


To run it [ Type in your Computercraft computer ]:
JaC -f [ -p ... ]


If you found any bugs, paste them here, THANKS!


Edited by LeDark Lua, 28 November 2015 - 11:49 AM.


#2 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 11 October 2015 - 04:22 PM

Can you write a more detailed tutorial, because it is kinda confusing.

#3 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 11 October 2015 - 06:41 PM

Tutorial section updated. Hope this helps more now.

EDIT: Did you try it?

Edited by LeDark Lua, 11 October 2015 - 06:42 PM.


#4 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 11 October 2015 - 07:07 PM

I still don't see why packages'd be useful.

#5 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 11 October 2015 - 07:07 PM

Well packages are like API's.

In future I will add so that it will compile the packages to like:

JaC -f file -p package1 package2

Edited by LeDark Lua, 11 October 2015 - 07:08 PM.


#6 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 11 October 2015 - 07:09 PM

What does JaC add to standard Lua?

#7 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 11 October 2015 - 08:03 PM

With JaC you can code like in Java, object orriented programming.

#8 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 11 October 2015 - 08:15 PM

It is possible with lua:

--Class Neuron
function Neuron(args)
--private
local one = 1
local two = 2

--public
local self = {}
self.a = "A is public"
function self.b()
print(one+two)
end
--constructor
blob = args
return self
end

That is the class Neuron.

Edited by Creator, 11 October 2015 - 08:15 PM.


#9 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 11 October 2015 - 08:58 PM

View PostCreator, on 11 October 2015 - 08:15 PM, said:

It is possible with lua:

Whilst everything here is possible with normal Lua, it often is nicer/more fun to have a custom syntax for creating classes. Another project which has tried this was LuaLua, which had a far more ugly odd syntax than this. I'm also currently working on a Lua compiler with the aim of adding types to it. Also: since when has anything written in CC really had a point to it :).

I would question the Java-esq (and C# truth be told) requirement for packages/classes - I feel they should be an additional feature rather than a requirement - as in you can write programs in JaC without having to wrap everything in a class. I'm also not sure about the idea of private variables within functions - people are used to using local and I'd try to follow the Principal of Least Astonishment: what do people expect. I know you are trying to go for an OOP style of code, and for class members private makes sense, but for variables it doesn't. For this reason, I'd also suggest removing the semicolon requirement - you should be able to parse without it.

Other than that though: I'm pretty impressed! Speaking of C# features though: if you could get lambdas that would be awesome!

#10 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 11 October 2015 - 09:25 PM

Impressed by what?
What are lambdas?

#11 ElvishJerricco

  • Members
  • 803 posts

Posted 11 October 2015 - 11:01 PM

View PostCreator, on 11 October 2015 - 09:25 PM, said:

Impressed by what?
What are lambdas?

Making a language is impressive. I've made a few and it's always really interesting. This language is useful because packages encapsulate your code, and in-language classes serve as an infinitely more elegant solution to OOP than the hacky, manual, strange OOP system you have to construct in ordinary Lua. Yes all of this is possible in Lua, but it's clunky and annoying in Lua.

Lambdas are anonymous functions.

doSomethingWithCallback(function() ... end) -- pass a lambda as a parameter

Anyway, about this project: It looks really good. Is it possible to use the "using" syntax to import packages from other files? Also, I took a look at your parser. You might want to do some reading on abstract syntax trees (ASTs) and their construction. It makes defining the language a lot easier and eliminates potential bugs.

#12 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 12 October 2015 - 12:14 PM

Thanks for the great response guys.

Today I will add a feature of adding packages from files,
Lambdas, I will add them but not today :D, this will need a bit more work to be done,

The semicolon and private variables, when compiling to Lua I make private to local, semicolon is needed to check for a end-of-possible-(function variable etc...).

Edited by LeDark Lua, 12 October 2015 - 12:14 PM.


#13 ardera

  • Members
  • 503 posts
  • LocationGermany

Posted 12 October 2015 - 12:41 PM

Looks awesome!

View PostCreator, on 11 October 2015 - 08:15 PM, said:

It is possible with lua:
It is possible to write reallife Operating Systems in assembly - but they're coded in highlevel languages like C++. Why? Because it's a lot easier, it looks better, and you don't lose track. (and it's easy to compile to other processor architectures)
Same goes with this: Of course you can use Lua to achieve object-orientation, but this (JaC) makes your OOP coding a lot easier, it looks better, and you don't lose track. Also, Lua is not really made for object-orientation, JaC is.

Edited by ardera, 12 October 2015 - 12:50 PM.


#14 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 12 October 2015 - 01:18 PM

View Postardera, on 12 October 2015 - 12:41 PM, said:

Looks awesome!
...
Thanks!

#15 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 12 October 2015 - 01:35 PM

JaC Update

Added: adding packages from other files: JaC -f file -p pack1 pack2 ...

Added: Multiline comments.


Updated: Tutorial section!


Download: pastebin get G4eFAiSf JaC



#16 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 15 November 2015 - 04:19 PM

I'm remaking this compiler and I will use It in my OS for creating APP's and stuff :)

#17 Awe2K

  • Members
  • 38 posts
  • LocationSomewhere near keyboard

Posted 15 November 2015 - 06:59 PM

Wow, that's, maybe, the most amazing thing I've ever seen for CC:
You can code in Java/C-like syntax, easily use objects/classes (lua is pain for me after using Java), thanks guy!
Keep it up.

#18 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 15 November 2015 - 07:20 PM

View PostAwe2K, on 15 November 2015 - 06:59 PM, said:

Wow, that's, maybe, the most amazing thing I've ever seen for CC:
You can code in Java/C-like syntax, easily use objects/classes (lua is pain for me after using Java), thanks guy!
Keep it up.
Thanks.

Little update and point out:
The classes and packages in this version work a bit buggy. So I created new ones and I will release it with the new compiler that works better than this one!

Packages are replaced with methods!

In the new version you can create classes outside the methods:
class System {
 //System class
}

Ohh, one thing, the Compiler will be done tomorrow or next this Friday because it's coming along nicely and working better than this version.

#19 クデル

  • Members
  • 349 posts

Posted 16 November 2015 - 10:17 AM

View Postardera, on 12 October 2015 - 12:41 PM, said:

Looks awesome!

View PostCreator, on 11 October 2015 - 08:15 PM, said:

It is possible with lua:
It is possible to write reallife Operating Systems in assembly - but they're coded in highlevel languages like C++. Why? Because it's a lot easier, it looks better, and you don't lose track. (and it's easy to compile to other processor architectures)
Same goes with this: Of course you can use Lua to achieve object-orientation, but this (JaC) makes your OOP coding a lot easier, it looks better, and you don't lose track. Also, Lua is not really made for object-orientation, JaC is.

Kinda off-topic, but its really interesting to write systems in assembly. I wrote a basic system with assembly, and even wrote a small portion of it in machine code, which was really only for testing purposes.

Also, this language is hella awesome. :D

#20 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 16 November 2015 - 02:10 PM

View PostEsKreme, on 16 November 2015 - 10:17 AM, said:

View Postardera, on 12 October 2015 - 12:41 PM, said:

Looks awesome!

View PostCreator, on 11 October 2015 - 08:15 PM, said:

It is possible with lua:
It is possible to write reallife Operating Systems in assembly - but they're coded in highlevel languages like C++. Why? Because it's a lot easier, it looks better, and you don't lose track. (and it's easy to compile to other processor architectures)
Same goes with this: Of course you can use Lua to achieve object-orientation, but this (JaC) makes your OOP coding a lot easier, it looks better, and you don't lose track. Also, Lua is not really made for object-orientation, JaC is.

Kinda off-topic, but its really interesting to write systems in assembly. I wrote a basic system with assembly, and even wrote a small portion of it in machine code, which was really only for testing purposes.

Also, this language is hella awesome. :D
Thanks, and thank you all for this kind of support, this really makes me more and more motivated to work on this project.
And I'm happy to say that the new and better compiler is 50% DONE!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users