C language vs Assembly (epic speedrun)

preview_player
Показать описание
Write concise Assembly and enjoy the performance!

free(numarr) was omitted for speedrun purposes.
Music at the end: Future Technologies by MokkaMusic / Pray For Us
Рекомендации по теме
Комментарии
Автор

I feel tempted to send this to my C/C++ professor

katrin
Автор

imagine going to a job interview and tell them that the only language you can code in is assembly

AlexdAviator
Автор

1) you use struct in c for no reason at all, but not in asm
2) you allocate heap memory in c - also for no reason -, while you do not in asm
3) you don't check whether the allocation was successful
4) you don't free allocated heap memory
5) you use multiple methods in c, but not in asm
6) you only read the first byte (or char, but byte is more accurate) of the argument in asm, the same tests you ran in c would not work there
7) neither of them works for negative numbers
8) good luck running that asm code on other architectures
The C code could look like this (complies with whats mentioned above):
#include <stdio.h>

int main(int argc, char *argv[]){
int i;
if(argc < 2 || sscanf(argv[1], "%d", &i) != 1)
fprintf(stderr, "error\n");
else
printf("%i\n", i + 1);
return 0;
}
//this code does not check for overflow on addition nor the validity of the input number

gameman
Автор

1:15 ah yes, my favourite programming language assmembler

roykin
Автор

The asm program doesn’t work with multiple digit numbers

artusartus
Автор

Please do a Assembly vs MachineCode comparison next. Only true gods code in machinecode

FlyingLlamaa
Автор

In C you should use: ++*argv[1]; argv[1][1] = '\n'; just like in assembly, to obtain the same performance.
Edit: Well, i tested and i got 1 milisecond of difference. Actually nasm is faster lol

johnparrot
Автор

C'mon... The malloc'ed memory isn't being freed..

FirstnameLastname-vtoy
Автор

Use assembly language if you are paid hourly 🤝

mallikarjunj
Автор

My assembly propaganda ad blocker didnt on this one

aaronsonnichsen
Автор

god bless the true witnesses of the one and only language, for we have seen the light. Praise the one that assembles, the one that abstracts the unabstractable, the one that increases the one

ebastiancarlo
Автор

Bro you should have done a loop in the assembler to print more than the first character

tremon
Автор

nice, zero-cost abstraction in asm, because there are no abstractions

AgentProvocateur
Автор

All fun and games till the number has more than one digits. Also that C program can increment numbers that are upwards of 1 million digits

k_gold
Автор

i love how he misspelled assembler at the end

sanduchicu
Автор

int main(int argc, char **argv){ printf("%d", atoi(argv[1]) + 1); } // Use C

bunikido
Автор

I'll program in NASM when I find a tutorial for it.

halfhalf
Автор

Your abstractions cant cost if you dont have any 🐿️

jesust
Автор

I was hoping to see this video was uploaded on April Fools... I was a fool for thinking I'd be lucky. You sir, have 0 programming experience.

Drqonic
Автор

Yes I will make sure to use the assmembler

duxoakende