Page 1 of 1

Good Programming Languages To Learn?

Posted: Tue Jun 09, 2020 10:29 pm
by Red
I took a computer programming course last semester and we learned the illegitimate programming language known as MATLAB. I can safely say I walked out of that class remembering exactly nothing.

So this summer, I'm planning on learning Python or C++. Any better ones to learn?

Re: Good Programming Languages To Learn?

Posted: Wed Jun 10, 2020 7:21 pm
by Avskum
Depends on your goal, but I'd say C# or Java. C++ is fine as well, but it's usually considered a harder language. All these languages use the C-style syntax, which is very helpful to learn because it's ubiquitous. Python I think is a bad language to start out with because it's doing too much behind your back, which makes it harder to understand the fundamentals at the lower level. Also Python's syntax deviates significantly from the C-style syntax, so your knowledge of the syntax won't transfer well to other languages (if you care about that)

Re: Good Programming Languages To Learn?

Posted: Wed Jun 10, 2020 8:14 pm
by Red
Avskum wrote: Wed Jun 10, 2020 7:21 pm Depends on your goal, but I'd say C# or Java. C++ is fine as well, but it's usually considered a harder language. All these languages use the C-style syntax, which is very helpful to learn because it's ubiquitous. Python I think is a bad language to start out with because it's doing too much behind your back, which makes it harder to understand the fundamentals at the lower level. Also Python's syntax deviates significantly from the C-style syntax, so your knowledge of the syntax won't transfer well to other languages (if you care about that)
Well I wanna learn something easy to get started. I hear Python is good for beginners though, I guess I'll experiment with both and see which I like better.

I think in about 100-1000 years not being able to program would be akin to being illiterate, so I wanna learn it now if I'm not dead by then. Plus being competent in these languages looks good on a resume.

Re: Good Programming Languages To Learn?

Posted: Wed Jun 10, 2020 9:31 pm
by Avskum
Python is fine to start with. It's what I started with before branching out to C/C++ and Java, though I wouldn't choose it as my starting language if I did it all over again, but in the end it doesn't matter a ton. If you can use one language well, it'll be relatively easy to learn another. In Python you can get a lot of things done quick as a beginner, which is appealing

Re: Good Programming Languages To Learn?

Posted: Wed Jun 10, 2020 9:55 pm
by Red
Relevant Meme:
yi58mfw8ltq41.jpg
I'll give both a try and let you know.

Re: Good Programming Languages To Learn?

Posted: Sat Jun 20, 2020 1:11 pm
by teo123
Red wrote: Tue Jun 09, 2020 10:29 pm I took a computer programming course last semester and we learned the illegitimate programming language known as MATLAB. I can safely say I walked out of that class remembering exactly nothing.

So this summer, I'm planning on learning Python or C++. Any better ones to learn?
I'd recommend you to learn JavaScript. Learning JavaScript is incredibly rewarding. After three weeks of learning JavaScript, I was able to build a PacMan game in it. After years of learning C++, I was able to build precisely nothing.

Re: Good Programming Languages To Learn?

Posted: Sat Jun 20, 2020 3:29 pm
by teo123
Avskum wrote: Wed Jun 10, 2020 7:21 pm Depends on your goal, but I'd say C# or Java. C++ is fine as well, but it's usually considered a harder language. All these languages use the C-style syntax, which is very helpful to learn because it's ubiquitous. Python I think is a bad language to start out with because it's doing too much behind your back, which makes it harder to understand the fundamentals at the lower level. Also Python's syntax deviates significantly from the C-style syntax, so your knowledge of the syntax won't transfer well to other languages (if you care about that)
And why not JavaScript? If you ask me, it may be the only programming language worth learning. It's incredibly rewarding to learn. After years of studying C++, I was able to build precisely nothing. And I once tried to learn Java and I soon gave up, all those terms from object-oriented programming thrown at me right at the beginning, it was just terrifying (it's not so bad now that I understand that stuff, now I have even used it in building a GUI of one of my programs, but it was horrifying back then). But after studying JavaScript for just a few weeks, I was able to build stuff.
The compiler I've written for my programming language, AEC, is also written in JavaScript. I started developing it after studying JavaScript for around 6 months.
While I was banned, I made another program in my programming language. This time it's targeting Linux and GNU Assembler (until now, I was always targeting Windows and FlatAssembler). It's an analog clock. Here is its source code.

Code: Select all

Syntax GAS
;This is yet another example of how to target Linux using GNU Assembler.
;The first line of code needs to be "syntax gas" (case insensitive).
;This one can be compiled and run as follows (from the terminal):
;   gcc -o aec.elf aec.c duktape.c -lm #Assuming you've downloaded "Duktape.zip" rather than "ArithmeticExpressionCompiler.zip".
;   ./aec.elf analogClock.aec
;   gcc -o analogClock.elf analogClock.s #Or, on a 64-bit Linux: gcc -m32 -o analogClock.elf analogClock.s
;   ./analogClock.elf
;If you don't have "gcc" on your Linux machine, you can as well use "clang".
AsmStart ;What follows is code produced by GCC 9.3.0 on Linux, I don't understand much of it either, and it's not important.
    .file   "analogClock.c"
    .text
    .comm   result,4,4
    .comm   i,4,4
    .comm   x,4,4
    .comm   y,4,4
    .comm   currentSign,4,4
    .comm   centerX,4,4
    .comm   centerY,4,4
    .comm   distance,4,4
    .comm   clockRadius,4,4
    .comm   output,7360,32
    .comm   hour,4,4
    .comm   minute,4,4
    .comm   second,4,4
    .comm   angle,4,4
    .comm   endOfTheHandX,4,4
    .comm   endOfTheHandY,4,4
    .comm   coefficientOfTheDirection,4,4
    .comm   windowWidth,4,4
    .comm   windowHeight,4,4
    .comm   lowerBoundX,4,4
    .comm   upperBoundX,4,4
    .comm   lowerBoundY,4,4
    .comm   upperBoundY,4,4
    .comm   isXWithinBounds,4,4
    .comm   isYWithinBounds,4,4
    .comm   expectedY,4,4
    .comm   expectedX,4,4
    .comm   j,4,4
    .comm   ASCIIofSpaceAsFloat32,4,4
    .globl  main
    .type   main, @function
main:
.LFB0:
    .cfi_startproc
    leal    4(%esp), %ecx
    .cfi_def_cfa 1, 0
    andl    $-16, %esp
    pushl   -4(%ecx)
    pushl   %ebp
    .cfi_escape 0x10,0x5,0x2,0x75,0
    movl    %esp, %ebp
    pushl   %ecx
    .cfi_escape 0xf,0x3,0x75,0x7c,0x6
    subl    $36, %esp
    subl    $12, %esp
    leal    -20(%ebp), %eax
    pushl   %eax
    call    time
    addl    $16, %esp
    subl    $12, %esp
    leal    -20(%ebp), %eax
    pushl   %eax
    call    localtime
    addl    $16, %esp
    movl    %eax, -16(%ebp)
    movl    -16(%ebp), %eax
    movl    8(%eax), %eax
    movl    %eax, -28(%ebp)
    fildl   -28(%ebp)
    fstps   hour
    movl    -16(%ebp), %eax
    movl    4(%eax), %eax
    movl    %eax, -28(%ebp)
    fildl   -28(%ebp)
    fstps   minute
    movl    -16(%ebp), %eax
    movl    (%eax), %eax
    movl    %eax, -28(%ebp)
    fildl   -28(%ebp)
    fstps   second
    #APP
AsmEnd ;And now finally follows a program written in AEC.
windowWidth:=80
windowHeight:=23
ASCIIofSpace<=" \0\0\0" ;As integer. We know we are dealing with a...
ASCIIofNewLine<="\n\0\0\0" ;32-bit low-endian machine.
ASCIIofStar<="*\0\0\0"
i:=0
While i<windowWidth*windowHeight ;First, fill the window with spaces and newlines.
    If mod(i,windowWidth)=windowWidth-1
        AsmStart
            .intel_syntax noprefix
            fild dword ptr ASCIIofNewLine
            fstp dword ptr currentSign
            .att_syntax
        AsmEnd
    Else
        AsmStart
            .intel_syntax noprefix
            fild dword ptr ASCIIofSpace
            fstp dword ptr currentSign
            fld dword ptr currentSign
            fstp dword ptr ASCIIofSpaceAsFloat32
            .att_syntax
        AsmEnd
    EndIf
    output[i]:=currentSign
    i:=i+1
EndWhile
centerX:=windowWidth/2-mod(windowWidth/2,1)
centerY:=windowHeight/2-mod(windowHeight/2,1)
clockRadius:=(centerX<centerY)?(centerX):(centerY)-1
i:=0
While i<windowWidth*windowHeight ;Next, draw the circle which represents the clock.
    y:=i/windowWidth-mod(i/windowWidth,1) ;When I didn't put "floor" into my programming language...
    x:=mod(i,windowWidth)
    distance:=sqrt((x-centerX)*(x-centerX)+(y-centerY)*(y-centerY)) ;Pythagorean Theorem.
    If abs(distance-clockRadius)<3/4
        AsmStart
            .intel_syntax noprefix
            fild dword ptr ASCIIofStar
            fstp dword ptr currentSign
            .att_syntax
        AsmEnd
        output[i]:=currentSign
    EndIf
    i:=i+1
EndWhile
AsmStart
    .intel_syntax noprefix
    jmp ASCIIofDigits$
    ASCIIofDigits:
    .macro writeDigits startingWith=0
        .byte '0'+\startingWith,0,0,0 #".byte" is to GNU Assembler about the same as "db" is to FlatAssembler.
        .if \startingWith < 9
            writeDigits \startingWith+1
        .endif
    .endm
    writeDigits #The goal is to make Assembler output the ASCII of "0\0\0\01\0\0\02\0\0\0...9\0\0\0" inside the executable (if the instruction pointer points to it, it will, of course, be an invalid instruction).
    ASCIIofDigits$:
    .att_syntax
AsmEnd
;Label of "12"...
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+1*4] #The ASCII of '1'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
output[(centerY-clockRadius+1)*windowWidth+centerX]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+2*4] #The ASCII of '2'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
output[(centerY-clockRadius+1)*windowWidth+centerX+1]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+6*4] #The ASCII of '6'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
output[(centerY+clockRadius-1)*windowWidth+centerX]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+3*4] #The ASCII of '3'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
output[centerY*windowWidth+centerX+clockRadius-1]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+9*4] #The ASCII of '9'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
output[centerY*windowWidth+centerX-clockRadius+1]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+1*4] #The ASCII of '1'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
y:=centerY-(clockRadius-1)*cos(360/12)
y:=y-mod(y,1)
output[y*windowWidth+centerX+sin(360/12)*(clockRadius-1)]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+2*4] #The ASCII of '2'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
y:=centerY-(clockRadius-1.5)*cos(2*360/12)
y:=y-mod(y,1)
output[y*windowWidth+centerX+sin(2*360/12)*(clockRadius-1.5)]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+4*4] #The ASCII of '4'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
y:=centerY-(clockRadius-1)*cos(4*360/12)
y:=y-mod(y,1)
output[y*windowWidth+centerX+sin(4*360/12)*(clockRadius-1)]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+5*4] #The ASCII of '5'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
y:=centerY-(clockRadius-1)*cos(5*360/12)
y:=y-mod(y,1)
output[y*windowWidth+centerX+sin(5*360/12)*(clockRadius-1)]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+7*4] #The ASCII of '7'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
y:=centerY-(clockRadius-1)*cos(7*360/12)
y:=y-mod(y,1)
output[y*windowWidth+centerX+sin(7*360/12)*(clockRadius-1)]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+8*4] #The ASCII of '8'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
y:=centerY-(clockRadius-1)*cos(8*360/12)
y:=y-mod(y,1)
output[y*windowWidth+centerX+sin(8*360/12)*(clockRadius-1)]:=currentSign
;Label "10"...
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+1*4] #The ASCII of '1'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
y:=centerY-(clockRadius-1.5)*cos(10*360/12)
y:=y-mod(y,1)
output[y*windowWidth+centerX+sin(10*360/12)*(clockRadius-1.5)]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+0*4] #The ASCII of '0'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
y:=centerY-(clockRadius-1.5)*cos(10*360/12)
y:=y-mod(y,1)
output[y*windowWidth+centerX+sin(10*360/12)*(clockRadius-1.5)+1]:=currentSign
;Label "11"...
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+1*4] #The ASCII of '1'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
y:=centerY-(clockRadius-1.5)*cos(11*360/12)
y:=y-mod(y,1)
output[y*windowWidth+centerX+sin(11*360/12)*(clockRadius-1.5)]:=currentSign
AsmStart
    .intel_syntax noprefix
    fild dword ptr [ASCIIofDigits+1*4] #The ASCII of '1'.
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
y:=centerY-(clockRadius-1.5)*cos(11*360/12)
y:=y-mod(y,1)
output[y*windowWidth+centerX+sin(11*360/12)*(clockRadius-1.5)+1] := currentSign
j:=0
While j<3
    If j=0
        angle:=(mod(hour+minute/60,12))*(360/12)
    ElseIf j=1
        angle:=minute*(360/60)
    Else
        angle:=second*(360/60)
    EndIf
    endOfTheHandX:=centerX+sin(angle)*clockRadius/(j=0?2:j=1?3/2:4/3) ;Hour hand will be the shortest, and the hand that shows the seconds will be the longest.
    endOfTheHandY:=centerY-cos(angle)*clockRadius/(j=0?2:j=1?3/2:4/3)
    coefficientOfTheDirection:=(endOfTheHandY-centerY)/(endOfTheHandX-centerX)
    debugString <= "Drawing line between (%d,%d) and (%d,%d).\n\0"
    AsmStart
        .intel_syntax noprefix
        .ifdef DEBUG #Conditional assembly, this will only be assembled if you tell GNU Assembler (by modifying the file or using command line) that you want to enable debugging.
            fld dword ptr endOfTheHandY
            fistp dword ptr result
            push dword ptr result #This (pushing a "dword" onto the system stack) breaks the compatibility with 64-bit Linux (but you can still enable it by disabling debugging)!
            fld dword ptr endOfTheHandX
            fistp dword ptr result
            push dword ptr result
            fld dword ptr centerY
            fistp dword ptr result
            push dword ptr result
            fld dword ptr centerX
            fistp dword ptr result
            push dword ptr result
            lea ebx,debugString
            push ebx
            call printf
        .endif #End of the conditional assembly.
        .att_syntax
    AsmEnd
    i:=0
    While i<windowWidth*windowHeight
        lowerBoundX:=(endOfTheHandX<centerX)?(endOfTheHandX):(centerX)
        upperBoundX:=(endOfTheHandX>centerX)?(endOfTheHandX):(centerX)
        lowerBoundY:=(endOfTheHandY<centerY)?(endOfTheHandY):(centerY)
        upperBoundY:=(endOfTheHandY>centerY)?(endOfTheHandY):(centerY)
        y:=i/windowWidth-mod(i/windowWidth,1)
        x:=mod(i,windowWidth)
        isXWithinBounds:=(x>lowerBoundX | x=lowerBoundX) & (x<upperBoundX | x=upperBoundX) ;Damn... Now I understand why almost every programming language supports the "<=" and ">=" operators, no matter how much harder they make the language to tokenize.
        isYWithinBounds:=(y>lowerBoundY | y=lowerBoundY) & (y<upperBoundY | y=upperBoundY)
        If isXWithinBounds=1 & isYWithinBounds=1
            expectedY:=(x-centerX)*coefficientOfTheDirection+centerY
            expectedX:=(y-centerY)*(1/coefficientOfTheDirection)+centerX
            debugString1 <= "The point (%d,%d) is within bounds, expectedY is %d and expectedX is %d.\n\0"
            AsmStart
                .intel_syntax noprefix
                .ifdef DEBUG
                    fld dword ptr expectedX
                    fistp dword ptr result
                    push dword ptr result
                    fld dword ptr expectedY
                    fistp dword ptr result
                    push dword ptr result
                    fld dword ptr y
                    fistp dword ptr result
                    push dword ptr result
                    fld dword ptr x
                    fistp dword ptr result
                    push dword ptr result
                    lea ebx,debugString1
                    push ebx
                    call printf
                .endif
                .att_syntax
            AsmEnd
            ASCIIofLetterH<="h\0\0\0"
            ASCIIofLetterM<="m\0\0\0"
            ASCIIofLetterS<="s\0\0\0"
            If j=0
                AsmStart
                    .intel_syntax noprefix
                    fild dword ptr ASCIIofLetterH
                    fstp dword ptr currentSign
                    .att_syntax
                AsmEnd
            ElseIf j=1
                AsmStart
                    .intel_syntax noprefix
                    fild dword ptr ASCIIofLetterM
                    fstp dword ptr currentSign
                    .att_syntax
                AsmEnd
            Else
                AsmStart
                    .intel_syntax noprefix
                    fild dword ptr ASCIIofLetterS
                    fstp dword ptr currentSign
                    .att_syntax
                AsmEnd
            EndIf
            If (upperBoundX=lowerBoundX | upperBoundY=lowerBoundY) & output[i]=ASCIIofSpaceAsFloat32
                output[i]:=currentSign
            EndIf
            If (abs(expectedY-y)<3/4 | abs(expectedX-x)<3/4) & output[i]=ASCIIofSpaceAsFloat32
                output[i]:=currentSign
            EndIf
        EndIf
        i:=i+1
    EndWhile
    j:=j+1
EndWhile
;Draw some ornament...
ASCIIofLetterX<="x\0\0\0"
AsmStart
    .intel_syntax noprefix
    fild dword ptr ASCIIofLetterX
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
i:=0
While i<windowWidth*windowHeight
    y:=i/windowWidth-mod(i/windowWidth,1)
    x:=mod(i,windowWidth)
    If abs(windowHeight-2*ln(1+abs((x-centerX)/2))-y)<1-abs(x-centerX)/(centerX*95/112) & x>1/2*centerX & x<3/2*centerX & output[i]=ASCIIofSpaceAsFloat32 ;The logarithmic curve looks somewhat like a lemma of a flower.
        output[i]:=currentSign
    EndIf
    i:=i+1
EndWhile
AsmStart
    .intel_syntax noprefix
    fild dword ptr ASCIIofLetterX
    fstp dword ptr currentSign
    .att_syntax
AsmEnd
;Let's try to make it look like the bottom of the lemma isn't floating in the air.
j:=0
While j<3
    i:=windowWidth*(windowHeight-1) ;So, the last line.
    While i<windowWidth*windowHeight
        If j<2 & (output[i-windowWidth]=currentSign & (output[i+1]=currentSign | output[i-1]=currentSign))
            output[i]:=currentSign
        ElseIf j=2 & (output[i+1]=ASCIIofSpaceAsFloat32 & output[i-windowWidth]=currentSign)
            output[i]:=ASCIIofSpaceAsFloat32
        EndIf
        i:=i+1
    EndWhile
    j:=j+1
EndWhile
AsmStart ;And here goes how, according to GCC 9.3.0, you print the table and finish an Assembly program on 32-bit Linux (I don't understand that either, and it's not important).
#NO_APP
    movl    $0, -12(%ebp)
    jmp .L2
.L3:
    movl    -12(%ebp), %eax
    movss   output(,%eax,4), %xmm0
    cvttss2sil  %xmm0, %eax
    subl    $12, %esp
    pushl   %eax
    call    putchar
    addl    $16, %esp
    addl    $1, -12(%ebp)
.L2:
    cmpl    $1839, -12(%ebp)
    jle .L3
    movl    $0, %eax
    movl    -4(%ebp), %ecx
    .cfi_def_cfa 1, 0
    leave
    .cfi_restore 5
    leal    -4(%ecx), %esp
    .cfi_def_cfa 4, 4
    ret
    .cfi_endproc
.LFE0:
    .size   main, .-main
    .ident  "GCC: (GNU) 9.3.0"
    .section    .note.GNU-stack,"",@progbits
AsmEnd
Here is what it outputs right now (at 19:56):

Code: Select all

                                                                               
                                     *******                                   
                                   ***  12 ***                                 
                                 ***11      1***                               
                                **             **                              
                                *     m         *                              
                               **10   m        2**                             
                               *      m          *                             
                              **      mm         **                            
                              *        m          *                            
                              *        mm         *                            
                              *9       hh        3*                            
                              *       hhs         *                            
                              *     hh  s         *                            
                              **        s        **                            
                               *8       s       4*                             
                               **       s       **                             
                                *       s       *                              
                     xxx        **  7   s    5 **        xxx                   
                        xxxxxxxx ***         *** xxxxxxxx                      
                              xxxxx***  6  ***xxxxx                            
                                  xxx*******xxx                                
                                   xxxxx xxxxx                                 
The source code of my compiler and a few examples of programs in my language is available here, the executable files are (if you are willing to risk infecting your computer) available here. Maybe somebody would prefer to use my compiler that way, the version of my compiler runnable in NodeJS is available here.
It's a bit weird that, in order to effectively work in your own programming language, you need to insert tons of assembly code which you yourself don't fully understand. It's also interesting that, to somebody who doesn't know programming, the version I've made a few years ago in JavaScript probably looks more impressive, even though it takes far more knowledge to build a terminal-based analog clock in the programming language you've made than to build a nice-looking analog clock in JavaScript.

Re: Good Programming Languages To Learn?

Posted: Sun Jun 21, 2020 2:18 pm
by teo123
By the way, @Red, I also hate MatLab.

Re: Good Programming Languages To Learn?

Posted: Thu Oct 15, 2020 2:28 pm
by Peppesq
Start with something simple like HTML,CSS, Javascript.