I care a little bit about function, but I care mostly about the looks. I've got a program which sings "When you just wanna dance, butchya can't, ya gotta believe thatchya can.", written in four different languages. C# looks nicer than Java even though they're similar. Python seems too basic for me and C too complicated. However, I can't do much C# without admin rights on my computer (and I hate that). These programs are filtered using the default filtering algorithms Visual Studio Code uses with its extensions. Here's the code:
C#:
Spoiler
usingSystem;usingSystem.Threading;namespaceCodeComparison{publicclassSong{private string[] words;privatedouble[] intervals;public string[]Words{
get {return words;}set{ words = value.Length== intervals.Length? value :thrownewArrayTypeMismatchException();}}publicdouble[]Intervals{
get {return intervals;}set{ intervals = value.Length== words.Length? value :thrownewArrayTypeMismatchException();}}publicSong(string[] wordsVal,double[] intervalsVal){if(wordsVal.Length== intervalsVal.Length){
words = wordsVal;
intervals = intervalsVal;}else{thrownewArrayTypeMismatchException();}}publicvoidSing(){for(int i =0; i <Math.Min(Words.Length,Intervals.Length); i++){Console.Write(Words[i]);Thread.Sleep((int)(Intervals[i]*1000));}}}classProgram{staticvoidMain(string[] args){SongMySong=newSong(new string[]{"When ","ya ","just ","wa","nna ","dance,"," but","chya ","can't,\n","ya ","got","ta ","be","lieve ","that","chya ","can.\n"},newdouble[]{0.25,0.15,0.35,0.15,0.15,0.65,0.2,0.2,1.1,0.15,0.15,0.15,0.1,0.3,0.2,0.25,1});MySong.Sing();}}}
publicclassJavaSong{publicString[] words;publicdouble[] intervals;publicJavaSong(String[]Words,double[]Intervals){
words =Words;
intervals =Intervals;}publicvoid sing(){for(int i =0; i <Math.min(words.length, intervals.length); i++){System.out.print(words[i]);try{Thread.sleep(Math.round(intervals[i]*1000));}catch(InterruptedException e){}}}}
from time import sleep
classSong:def __init__(self, words, intervals):
self._words = words
self._intervals = intervals
def sing(self):for i in range(min(len(self._words), len(self._intervals))):print(self._words[i])
sleep(self._intervals[i])@propertydef words(self):return self._words
@words.setter
def words(self, value):if len(value)== len(self._words):
self._words = value
else:raise(TypeError())@propertydef intervals(self):return self._intervals
@words.setter
def intervals(self, value):if len(value)== len(self._intervals):
self._intervals = value
else:raise(TypeError())if __name__ =="__main__":
mySong =Song(["When","ya","just","wa","nna","dance,","but","chya","can't,","ya","got","ta","be","lieve","that","chya","can."],[0.25,0.15,0.35,0.15,0.15,0.65,0.2,0.2,1.1,0.15,0.15,0.15,0.1,0.3,0.2,0.25,1])
mySong.sing()
Another thing is that I want to make a game with one of these languages, so C is already out the window because it's hard to set up FreeGlut and other OpenGL stuff.
Which looks nicest? I want to know your opinions. I might ask for admin permissions too and start making C# games, probably with FNA, which uses .NET 4 so I might try Unity.
Featured Replies
Archived
This topic is now archived and is closed to further replies.
I care a little bit about function, but I care mostly about the looks. I've got a program which sings "When you just wanna dance, butchya can't, ya gotta believe thatchya can.", written in four different languages. C# looks nicer than Java even though they're similar. Python seems too basic for me and C too complicated. However, I can't do much C# without admin rights on my computer (and I hate that). These programs are filtered using the default filtering algorithms Visual Studio Code uses with its extensions. Here's the code:
C#:
Java:
JavaMain.java
JavaSong.java
C :
Python:
Another thing is that I want to make a game with one of these languages, so C is already out the window because it's hard to set up FreeGlut and other OpenGL stuff.
Which looks nicest? I want to know your opinions. I might ask for admin permissions too and start making C# games, probably with FNA, which uses .NET 4 so I might try Unity.