DescriptionThe N# Compiler is a compiler that reads N# code and outputs legal SmileBasic code. Its intention is to be an optional COMPLETE replacement for SmileBasic, as it contains the ability to do all that SB can do, plus more, easier.
N# is a multi-paradigm (Object-Oriented, Functional) language with extra capabilities that SB does not have (such as classes, lazy evaluation, higher-order functions, etc.). The compiler eliminates need for variable and function suffixes (the compiler handles them automatically) and improves syntax of existing commands (for example, C-style "for," "while," "if," etc). N# is not an extension of SB, but rather a total replacement. It is not the same language by any means.
All code must be in a function, and all functions should be in a class. If a function is not in a class, it will assume inheritance by the next occurring class. The compiler automatically runs "entry.main" at program start.
Here's the official discussion/help thread: http://smilebasicsource.com/forum?fpid=5814Instructions[N# manual has not been published]
1: Set PRG:N_SHARP as your SmileTool.
2: Write your N# program in slot 0 of the editor.
3: When you're ready to compile, press the Smile button. Your program will compile and will appear in slot 1 of the editor. This new PRG file is in pure SB, so it can be loaded, saved, and published independent of any N# tools.
N# "Hello World" example:
use "Console"
static class entry
def public void main()
Console.Println "Hello World!"
end
end static
As this is Beta, there are a few glitches I am aware of. However, almost all of these are crunched, and so the development should hopefully come out of beta soon.
Update List:
Beta v1.0:
*Original publication
Beta v1.1:
*Private functions
*Changed array declaration syntax
*Fixed calculator example
*Bug fixes
Beta 1.2
*Revamped objects
*Assigning objects class references
*Bug fixes
Beta 1.3
*Library importing
*Completed object functionality
*MML and Graphics classes
*Class variables (private keyword doesn't work yet with these)
*Passing an object's value as a parameter works now
*Inline SB editor using [SB] tag in front of a line
*Bug fixes
Beta 1.4
* += and -= operators to work on objects
* /=, %=, *=, <<=, and >>= operators added
* % instead of MOD
*Console and Hardware class
*Class variables
*Immutable value types
*Foreach blocks
*Basic array comprehension using [| and |]
*Compile code to a standalone PRG! (No more mandatory runtime compilation)
*Bug fixes
Beta 1.5
*Changed syntax of switch blocks ("end" is no longer required after each case, only at the very end)
*Changed compilation process of +=, -=, *=, /=, %=, <<=, and >>= (this does not affect the user)
*Removed runtime compiler
*Added progress bar to compilation
*Removed support for labels
*Partial sprite library
*App library
*Resource library
*Bug fixes
Beta 1.6
*By reference parameter passing
*Brace syntax
*Dictionary library
*Wildcard variable (equal to anything)
*Runs as SmileTool (much easier to use)
*Ignore command
*Lambdas and higher-order functions
*Bug Fixes
Beta 1.7
*Getter functions
*Setter functions
*Init functions
*Modified Sprite and MML classes
Beta 1.8
*Lazy evaluation
*eval() function
*BigInt library
Expected Updates:
Beta 1.9
*Completed Sprite Library
*Function overloading
*Bug FixesNotesIntended for use by experienced programmers.
69 Comment(s)the_squat1115Second YearMy account is over 2 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteForum ContributorHiddenAchievementsPersonally I would prefer this one. And it's very neatly structured.the_squat1115Second YearMy account is over 2 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteForum ContributorHiddenAchievementsHow I can use this? I need helpMZ952Intermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthThird YearMy account is over 3 years oldWebsiteReadingI like to read books!Hobbieshttp://smilebasicsource.com/forum?fpid=5814computableeScholarReceived for knowing a great deal about programming topicsAchievementsosu! Is Awesome!I love osu!Express YourselfFirst DayJoined on the very first day of SmileBASIC SourceWebsiteHello! N# was mainly made to introduce some basic object-oriented concepts while also providing a cleaner-looking syntax. It's buggy, and I made it only a couple years after I started programming when I didn't know much about object-oriented design.
I would suggest, personally, if you want to learn an object-oriented language, to learn something like C# or Java. Lowerdash for SmileBasic also has some of these features. If you're simply looking for another language to learn, as much as I dislike it, Python is really good for beginners.spaceturtlesVideo GamesI like to play video games!HobbiesAvatar BlockI didn't change my avatar for 30 days.WebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming Strengthare there any intentions to continue developing this?answerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsiteif he did, it would be a complete remake. also phil_ doesn't work on anything sb anymore reallyErtasIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthVideo GamesI like to play video games!HobbiesZelda Is Awesome!I love The Legend Of Zelda!Express Yourselfn# programmed by basic? wowNateDogg1232Night PersonI like the quiet night and sleep late.Express YourselfAvatar TabooI didn't change my avatar for 180 daysWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthA cool thing would be to have an object have its own local arrays that work on an object's instance, not the object as a whole including all its instances (I hope that made sense)hakkeRNGHiddenEaster EggsQSP Contest 2 Contest ParticipantI participated in the second SmileBASIC Source QSP Contest!Expert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthYou're talking about non-static members?NateDogg1232Night PersonI like the quiet night and sleep late.Express YourselfAvatar TabooI didn't change my avatar for 180 daysWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthYes, I'm talking about non-static arrays. Sorry, the term was blanking my mind.SaladFingers@PhilFish I'm curious, what is SBexecutable? I'm trying to write a python interpreter which, hopefully with your help, will become an interpreter. I'm pretty much down with the graphics, console, and controls libraries. Most control flows are finished except classes :/chemicalexDrawingI like to draw!HobbiesIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming Strengthosu! Is Awesome!I love osu!Express YourselfIf you would like to contact Phil directly, there's a message box built just for this purpose.NateDogg1232Night PersonI like the quiet night and sleep late.Express YourselfAvatar TabooI didn't change my avatar for 180 daysWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthSBExecutable is just SB code. That's all.answerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsitePFFFFFTTTTanswerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsiteI feel as though you should really consider this when making the *I'll just just call them* quick array definitions using [||]
I feel as though constants should only be optional in the matter and that you should be using something like str() to track the variable's values and the constant values
int[] myArr[0]
myArr = [| 23, someNumber, theClass.ThatHasAMember |]
It's a bit irritating that this won't work and will only work with constants because of the way you designed this ._.
hakkeRNGHiddenEaster EggsQSP Contest 2 Contest ParticipantI participated in the second SmileBASIC Source QSP Contest!Expert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming Strengthhow do you make a higher order function?
hakkeRNGHiddenEaster EggsQSP Contest 2 Contest ParticipantI participated in the second SmileBASIC Source QSP Contest!Expert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthA little problem of the compiler is that if you do:
static class meme
public int me 'thats two spaces of indenting
end
Will parse incorrectly.
alsp, lambds are awesomeanswerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsiteWell, think of it like Python, it kinds of depends on using exact spacing in between blocks
Like for example, how blocks require 4 spaces on indentation, every block requires 1 space(only) of indentation.
Pythonclass Hello:
def World():
print "Hello, World"N#class Hello
def public void Main()
end
end classanswerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsiteI'm sorry, but this is so outdated; do you think there will ever be a time where you will basically reset the project, this has a lot of potential, but I've discontinued to use this because it kind of needs an update and needs to be more similar to the syntax of C# if this is where you're trying to go.
I'd really appreciate it if you continue this great language, but its flaws need work
computableeScholarReceived for knowing a great deal about programming topicsAchievementsosu! Is Awesome!I love osu!Express YourselfFirst DayJoined on the very first day of SmileBASIC SourceWebsiteI probably won't redo it, but I can't say for certain I won't. If the demand gets high enough I might.MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfCrowds gather in chatREDO N#! REDO N#! echos through the chatserver.MYCRAFTisbestGood PageHiddenAchievementsVideo GamesI like to play video games!HobbiesDeep SleepHiddenWebsiteN# 2 CONFIRMED!answerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsiteThe only REAL problem is the way objects are designed, like, referencing the object within the class does not work. You should also be able to access object properties with keys as well rather than referencing the object's value
class MyClass
int myInteger
string myString
def public void doSomething()
print this.myString
end
end
static class entry
def public void main()
object it <- MyClass
it.myString = "Hello"
it.doSomething()
end
end
I'd love it if something like this would work12Me21Syntax HighlighterReceived for creating the code syntax highlighter on SBSNight PersonI like the quiet night and sleep late.Express YourselfTurns out the echos were just a bird slamming into the dooranswerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsiteI'm working on a guide:
https://docs.google.com/document/d/1tzDcRIDJpDpERJ5E5xgZH0jOxGylnzawUsPOtcwhZfk/edit?usp=sharinganswerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsiteComments are enabled btwanswerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsiteI feel like N# should still have keys with objects, and with each object(like in Java) should have set variables within it, I cannot add this myself as the code is too obfuscating; is there a less obfuscating source code you have lying around?
answerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsiteWhen will N# be able to support DLCcomputableeScholarReceived for knowing a great deal about programming topicsAchievementsosu! Is Awesome!I love osu!Express YourselfFirst DayJoined on the very first day of SmileBASIC SourceWebsiteJust type the DLC commands directly into N# and use them as you would SB. They should work.NateDogg1232Night PersonI like the quiet night and sleep late.Express YourselfAvatar TabooI didn't change my avatar for 180 daysWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthI believe you still need to use the [SB] notation. Just a heads upcomputableeScholarReceived for knowing a great deal about programming topicsAchievementsosu! Is Awesome!I love osu!Express YourselfFirst DayJoined on the very first day of SmileBASIC SourceWebsite[SB] tells the compiler to not parse ANYTHING on the line, including possible variables, function suffixes, etc. However, if a command is unknown to the compiler, it will pass it directly to the output. Often times, [SB] actually isn't needed at all where you might use it.NateDogg1232Night PersonI like the quiet night and sleep late.Express YourselfAvatar TabooI didn't change my avatar for 180 daysWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthMay I ask the origins of the name "N#" I'm a little curiousMasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfThe original name of the compiler was Nossrec (which was something I thought of: Persson backwards, but instead of starting with P, starting with C, because this was based off of C# and other similar languages), so that's where the N comes from. The # comes from C#, since this is sort of like C# in quite a few ways.GuzzlerFirst WeekJoined in the very first week of SmileBASIC SourceWebsiteDrawingI like to draw!HobbiesIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthCool.plinkopenguinThanks for the info again!computableeScholarReceived for knowing a great deal about programming topicsAchievementsosu! Is Awesome!I love osu!Express YourselfFirst DayJoined on the very first day of SmileBASIC SourceWebsiteTo initialize sprites (untested code, may need tweaking)
use "Sprite"
static class entry
def public void main()
object mysprite <- Sprite
mysprite = Sprite.Init(0)
'Now "mysprite" represents the sprite that appears on screen. You can do stuff like mtsprite.Move to move it.
delete mysprite 'memory handling
end
end static
EDIT: In the new version Beta 1.7, initializing sprites has been changed.
use "Sprite"
static class entry
def public void main()
object mysprite <- Sprite = 0
'Now "mysprite" represents the strawberry on the screen.
'You can change the number to change the sprite, but once created, it cannot be changed
mysprite = [| 100, 100 |]
'Assigning coordinates via array notation will automatically change the location of the sprite, so now "mysprite" appears at location 100,100
mysprite.Clear
delete mysprite
end
end staticplinkopenguinSorry to bother again but I can't seem to figure out how to initialize sprites! I keep trying Sprite.Init(0) but I'm very clearly doing it wrong. I should probably wait for the manual but I thought I might ask anyways. Also C# would be the best reference for now right? Thanks for any info.NateDogg1232Night PersonI like the quiet night and sleep late.Express YourselfAvatar TabooI didn't change my avatar for 180 daysWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthI know this is a bit late but you can do this:
use "Sprite"
static class entry
def public void main()
object mySprite <- Sprite = 0
'Rest of your code
end
end static
16bitcoderThanks for the insperation for the title of basiccode2 (#AC) which is an interpreter so that is why I mistyped! My codinng is based off of BasicTron and Python!computableeScholarReceived for knowing a great deal about programming topicsAchievementsosu! Is Awesome!I love osu!Express YourselfFirst DayJoined on the very first day of SmileBASIC SourceWebsite@16bitcoder
An interpreter is an engine that reads a line of code, executes it, and then continues to read the next line, the one after that, etc.
A compiler reads all of the lines of code at once, parses them, and outputs a format that can be read by the computer.
The reason N# is a compiler is that it compiles (or converts) N# into SB, which is then converted into SBExecutable. Because it converts into pure SB, it runs faster and does not require the compiler to run. This also means code does not have to be open-source.16bitcoderI'm sorry, I mistyped... :(16bitcoderFacinating! Another coding language interpreter on SmileBasicMinxrodThird YearMy account is over 3 years oldWebsiteExpert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthQSP Contest 2 Contest ParticipantI participated in the second SmileBASIC Source QSP Contest!It's a compiler, not an interpreter :)
It's actually kind of a big difference I think16bitcoderI mistyped? Sorry for my mistype.MinxrodThird YearMy account is over 3 years oldWebsiteExpert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthQSP Contest 2 Contest ParticipantI participated in the second SmileBASIC Source QSP Contest!Ok.
Sorry to bug you then ;)16bitcoderDon't worry Minxrod, it is quite all right.
1
2
int[] myArr[0] myArr = [| 23, someNumber, theClass.ThatHasAMember |]
It's a bit irritating that this won't work and will only work with constants because of the way you designed this ._.class Hello: def World(): print "Hello, World"
class Hello def public void Main() end end class
class MyClass int myInteger string myString def public void doSomething() print this.myString end end static class entry def public void main() object it <- MyClass it.myString = "Hello" it.doSomething() end end
I'd love it if something like this would workuse "Sprite" static class entry def public void main() object mysprite <- Sprite mysprite = Sprite.Init(0) 'Now "mysprite" represents the sprite that appears on screen. You can do stuff like mtsprite.Move to move it. delete mysprite 'memory handling end end static
EDIT: In the new version Beta 1.7, initializing sprites has been changed.use "Sprite" static class entry def public void main() object mysprite <- Sprite = 0 'Now "mysprite" represents the strawberry on the screen. 'You can change the number to change the sprite, but once created, it cannot be changed mysprite = [| 100, 100 |] 'Assigning coordinates via array notation will automatically change the location of the sprite, so now "mysprite" appears at location 100,100 mysprite.Clear delete mysprite end end static
use "Sprite" static class entry def public void main() object mySprite <- Sprite = 0 'Rest of your code end end static