[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Javascript is not superior to C. Period. >>59377395 Ok

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 8
Thread images: 1

File: programming-languages.jpg (518KB, 2500x1443px) Image search: [Google]
programming-languages.jpg
518KB, 2500x1443px
Javascript is not superior to C. Period.

>>59377395
Ok first of all:

/* str_concat.c */
#include <stddef.h>
#include <stdlib.h>
char* str_concat(char const* s1, char const* s2, char* dest) {
size_t tot_size = 0;
char* siter;
for (siter = s1; *siter; siter++) tot_size++;
for (siter = s2; *siter; siter++) tot_size++;
dest = realloc(dest, tot_size + 1);
tot_size = 0;
for (siter = s1; dest[tot_size] = *siter; siter++) tot_size++;
for (siter = s2; dest[tot_size] = *siter; siter++) tot_size++;
return dest;
}

/* your_program.c */
#include <stdio.h>
#include <stdlib.h>
#include "str_concat.h"
int main() {
char const* h = "Hello ";
char const* w = "world";
char* r = malloc(0); /* this is allowed */
printf(str_concat(h, w, r));
free(r);
return 0;
}

Was that so hard?

Second of all, if you think javascript is doing anything less under the hood, you're wrong.

Thirdly, string concatenation is unnecessary. If you want concatenated output, just use printf with %s. If you want strings concatenated for any other purpose, just use fprintf with %s and direct it to the relevant stream pointer for your purpose.

Fourthly, please, like string concatenation is any easier in raw electrical engineering, as you seem to suggest it is.

Fifthly, engineering is a bad programming language either way, else programming languages would not have been invented.

Sixthly, if your obsession with transistors is meant as a rhetorical device for comparison with the perceived fallacy of saying we should still program in C when javascript is available -- as I suspect it is -- then that's a false analogy. Javascript is useful for cross platform GUI software. C is a better choice for:
>writing platforms themselves
>cross platform CLI software
>native GUI software from cross platform source code
Hard-wiring computational procedures is a better choice for:
>programming embedded machines that won't be programmable after manufacturing, e.g. toy car brains, non-algebraic calculators
>building processors
>>
>>59380512
Sure, ECMAScript7 is shit.
>>
>>59380512
kys javascript are better
>>
>>59380512
>tot_size
>dest
>sites
>single letter variables
Ishygiddy
>>
>>59380648
In the case of str_concat: it's appropriate
In the case of main: it's an example function, not an API function, so readability for purpose doesn't matter because there is no purpose
>>
>>59380742
>implying all C code isn't this bad
>>
>>59380757
>implying all C code is that bad
>>
>>59380648
Also, it's siter, not sites, and it's name is an obvious indication of its function to anyone with two brain cells.
Thread posts: 8
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.