Jump to content
  • Sign Up
ClassiCool

Which programming language looks best to you?

Recommended Posts

Posted (edited)

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
using System;
using System.Threading;

namespace CodeComparison
{
    public class Song
    {
        private string[] words;
        private double[] intervals;

        public string[] Words
        {
            get { return words; }
            set { words = value.Length == intervals.Length ? value : throw new ArrayTypeMismatchException(); }
        }

        public double[] Intervals
        {
            get { return intervals; }
            set { intervals = value.Length == words.Length ? value : throw new ArrayTypeMismatchException(); }
        }

        public Song(string[] wordsVal, double[] intervalsVal)
        {
            if (wordsVal.Length == intervalsVal.Length)
            {
                words = wordsVal;
                intervals = intervalsVal;
            }
            else
            {
                throw new ArrayTypeMismatchException();
            }
        }

        public void Sing()
        {
            for (int i = 0; i < Math.Min(Words.Length, Intervals.Length); i++)
            {
                Console.Write(Words[i]);
                Thread.Sleep((int)(Intervals[i] * 1000));
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Song MySong = new Song(
                new string[] {"When ", "ya ", "just ", "wa", "nna ", "dance,", " but", "chya ", "can't,\n",
                              "ya ", "got", "ta ", "be", "lieve ", "that", "chya ", "can.\n"},
                new double[] {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();
        }
    }
}

 

Java:

Spoiler

JavaMain.java

Spoiler

public class JavaMain {
    public static void main(String[] args) {
        JavaSong mySong = new JavaSong(
            new String[] {"When ", "ya ", "just ", "wa", "nna ", "dance,", " but", "chya ", "can't,\n",
                          "ya ", "got", "ta ", "be", "lieve ", "that", "chya ", "can.\n"},
            new double[] {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();
    } 
}

 

JavaSong.java

Spoiler

public class JavaSong {
    public String[] words;
    public double[] intervals;

    public JavaSong(String[] Words, double[] Intervals) {
        words = Words;
        intervals = Intervals;
    }

    public void 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) {
            }
        }
    }
}

 

 

C :

Spoiler
#include <stdio.h>
#include <unistd.h>

void sing(char words[][64], float intervals[], int length);

int main()
{
    char words[][64] = {"When ", "ya ", "just ", "wa", "nna ", "dance, ", "but", "chya ", "can't,\n",
                        "ya ", "got", "ta ", "be", "lieve ", "that", "chya ", "can.\n"};
    float intervals[] = {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};
    sing(words, intervals, 17);
}

void sing(char words[][64], float intervals[], int length)
{
    int i;
    for (i = 0; i < length; ++i)
    {
        printf(words[i]);
        usleep((int)(intervals[i] * 1e6));
    }
}

 

Python:

Spoiler
from time import sleep


class Song:
    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])

    @property
    def words(self):
        return self._words

    @words.setter
    def words(self, value):
        if len(value) == len(self._words):
            self._words = value
        else:
            raise(TypeError())

    @property
    def 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.

Edited by ClassiCool
*sigh* auto emoji

Share this post


Link to post
2 hours ago, lashednova said:

i like java script you should do that

That is Java... Not JavaScript, those are 2 different things.

  • Winner 1

Share this post


Link to post

java script is what made java editon and the words you see in windows and more is all in java script

  • Dumb 2

Share this post


Link to post
Just now, lashednova said:

java script is what made java editon and the words you see in windows and more is all in java script

almost none of that is true, minecraft java edition was made in java and windows uses a lot of different languages throughout different elements of itself. 

Share this post


Link to post
2 minutes ago, lashednova said:

thats what my DAD told me java edition is in java script

Wikipedia will tell you otherwise image.thumb.png.6122cb95ec9fb623927918476fa1d51f.png

  • cube 1

Share this post


Link to post
51 minutes ago, lashednova said:

thats what my DAD told me java edition is in java script

Your dad is wrong then.

  • Winner 4

Share this post


Link to post
2 hours ago, aleksb385 said:

Wikipedia will tell you otherwise image.thumb.png.6122cb95ec9fb623927918476fa1d51f.png

I'd like to add on to this:

Quote

Alongside HTML and CSS, JavaScript is one of the core technologies of the World Wide Web.[10] JavaScript enables interactive web pages and is an essential part of web applications. The vast majority of websites use it for client-side page behavior,[11] and all major web browsers have a dedicated JavaScript engine to execute it.

Source: Wikipedia, 2nd paragraph. Minecraft was available online, however it used a Java applet, which is a very different breed compared to JavaScript.

Share this post


Link to post
Posted (edited)
11 hours ago, Panda said:

Just gonna put this here...

 

https://en.wikipedia.org/wiki/Brainfuck

 

I challenge you programmers to write "Hello World" in bf, good luck!

+++++++++[>++++++++<-]>.>++++++++++[>++++++++++<-]>+.>++++++++++[>++++++++++<-]>++++++++..>+++++++++++[>++++++++++<-]>+.>++++[>++++++++<-]>.>+++++++++++[>++++++++<-]>-.<<<<.+++.<<.--------.>>>>+.

Below is some annotated code:

Spoiler
2 = H
4 = e
6 = l / d
8 = o / r
10 = space / !
12 = W

1 +++++++++
[
  2 > ++++++++
  1 < -
]
2 >
2 . H
3 >

3 ++++++++++
[
  4 > ++++++++++
  3 < -
]
4 > +
4 . e
5 >

5 ++++++++++
[
  6 > ++++++++++
  5 < -
]
6 > ++++++++
6 .. ll
7 >

7 +++++++++++
[
  8 > ++++++++++
  7 < -
]
8 > +
8 . o
9 >

9 ++++
[
  10 > ++++++++
  9 < -
]
10 >
10 . space
11 >

11 +++++++++++
[
  12 > ++++++++
  11 < -
]
12 > -
12 . w

8 <<<<
8 . o

8 +++
8 . r

6 <<
6 . l

6 --------
6 . d

10 >>>>
10 +
10 . !

 

 

Edited by ClassiCool
More annotation!
  • Agree 1

Share this post


Link to post
Posted (edited)

Hello. I am from the future. Was it really 2 months ago since I left? Anyways, I want to let everybody know how I got on. I found out about SDL, and that's great. I didn't really like Java in the end, so I dropped that off. I don't use Unity, I use MonoGame and occasionally Godot with C#. I've tried out JavaScript (more specifically TypeScript) and I like the syntax. However, creating a game project is a hassle, because I have to set up a web server and stuff. Anyways, I was bored. I may come on ClassiCube for a few days, including today.

Note: This post contains the 5000th comment, which is the one right at the top. How lucky of me!

Edit: Why am I up and coming?

Edited by ClassiCool

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...