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 3

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
  • Funny 1

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
Posted (edited)

i personally think x86 Assembly (i think thats what it is, im pretty sure its not machine language) is the best language.

Spoiler
LC0:
.string "When "
.zero 58
.string "ya "
.zero 60
.string "just "
.zero 58
.string "wa"
.zero 61
.string "nna "
.zero 59
.string "dance, "
.zero 56
.string "but"
.zero 60
.string "chya "
.zero 58
.string "can't,\n"
.zero 56
.string "ya "
.zero 60
.string "got"
.zero 60
.string "ta "
.zero 60
.string "be"
.zero 61
.string "lieve "
.zero 57
.string "that"
.zero 59
.string "chya "
.zero 58
.string "can.\n"
.zero 58
main:
push rbp
mov rbp, rsp
sub rsp, 1168
lea rax, [rbp-1088]
mov esi, OFFSET FLAT:.LC0
mov edx, 136
mov rdi, rax
mov rcx, rdx
rep movsq
movss xmm0, DWORD PTR .LC1[rip]
movss DWORD PTR [rbp-1168], xmm0
movss xmm0, DWORD PTR .LC2[rip]
movss DWORD PTR [rbp-1164], xmm0
movss xmm0, DWORD PTR .LC3[rip]
movss DWORD PTR [rbp-1160], xmm0
movss xmm0, DWORD PTR .LC2[rip]
movss DWORD PTR [rbp-1156], xmm0
movss xmm0, DWORD PTR .LC2[rip]
movss DWORD PTR [rbp-1152], xmm0
movss xmm0, DWORD PTR .LC4[rip]
movss DWORD PTR [rbp-1148], xmm0
movss xmm0, DWORD PTR .LC5[rip]
movss DWORD PTR [rbp-1144], xmm0
movss xmm0, DWORD PTR .LC5[rip]
movss DWORD PTR [rbp-1140], xmm0
movss xmm0, DWORD PTR .LC6[rip]
movss DWORD PTR [rbp-1136], xmm0
movss xmm0, DWORD PTR .LC2[rip]
movss DWORD PTR [rbp-1132], xmm0
movss xmm0, DWORD PTR .LC2[rip]
movss DWORD PTR [rbp-1128], xmm0
movss xmm0, DWORD PTR .LC2[rip]
movss DWORD PTR [rbp-1124], xmm0
movss xmm0, DWORD PTR .LC7[rip]
movss DWORD PTR [rbp-1120], xmm0
movss xmm0, DWORD PTR .LC8[rip]
movss DWORD PTR [rbp-1116], xmm0
movss xmm0, DWORD PTR .LC5[rip]
movss DWORD PTR [rbp-1112], xmm0
movss xmm0, DWORD PTR .LC1[rip]
movss DWORD PTR [rbp-1108], xmm0
movss xmm0, DWORD PTR .LC9[rip]
movss DWORD PTR [rbp-1104], xmm0
lea rcx, [rbp-1168]
lea rax, [rbp-1088]
mov edx, 17
mov rsi, rcx
mov rdi, rax
call sing
mov eax, 0
leave
ret
sing:
push rbp
mov rbp, rsp
sub rsp, 48
mov QWORD PTR [rbp-24], rdi
mov QWORD PTR [rbp-32], rsi
mov DWORD PTR [rbp-36], edx
mov DWORD PTR [rbp-4], 0
jmp .L4
.L5:
mov eax, DWORD PTR [rbp-4]
cdqe
sal rax, 6
mov rdx, rax
mov rax, QWORD PTR [rbp-24]
add rax, rdx
mov rdi, rax
mov eax, 0
call printf
mov eax, DWORD PTR [rbp-4]
cdqe
lea rdx, [0+rax*4]
mov rax, QWORD PTR [rbp-32]
add rax, rdx
movss xmm0, DWORD PTR [rax]
pxor xmm1, xmm1
cvtss2sd xmm1, xmm0
movsd xmm0, QWORD PTR .LC10[rip]
mulsd xmm0, xmm1
cvttsd2si eax, xmm0
mov edi, eax
call usleep
add DWORD PTR [rbp-4], 1
.L4:
mov eax, DWORD PTR [rbp-4]
cmp eax, DWORD PTR [rbp-36]
jl .L5
nop
nop
leave
ret
.LC1:
.long 1048576000
.LC2:
.long 1041865114
.LC3:
.long 1051931443
.LC4:
.long 1059481190
.LC5:
.long 1045220557
.LC6:
.long 1066192077
.LC7:
.long 1036831949
.LC8:
.long 1050253722
.LC9:
.long 1065353216
.LC10:
.long 0
.long 1093567616

 

Edited by epic_man89
fixing a fuckup
  • cube 1

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...