[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]

/dpt/ - Daily Programming Thread

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: 324
Thread images: 29

File: dpt.png (554KB, 934x1000px) Image search: [Google]
dpt.png
554KB, 934x1000px
What are you working on, /g/?

Previous thread: >>59382347
>>
>>59387221
First for C
>>
>>59387238
Second for C
>>
>>59387238
C is a disservice to intelligent programmers. It has almost 0 features that a modern and intelligent programmer uses to be productive. Since C is such a timesink, it's popularity is falling more than any other languages in the market.
C is dying and it should die ASAP
>>
>>59387260
Third for C
>>
>>59387273
Fourth for C
>>
>>59387177
>>
Fifth for C
>>
SELECT * FROM a where a.x != a.y;
This returns 0 rows. 
SELECT * FROM a where a.x IS NULL AND a.y IS NOT NULL;
This returns many rows.

What the fuck?
>>
>>59387271
You're a retard. kys

>>59387287
Sixth for C
>>
>>59387286
>Get sizes
>Allocate new string with appropriate size
>Call sprintf
????
>>
Anyone here use javafx before?

I am trying to get an ArrayList that stores objects into a listview. I looked up all the standard ways to do this but all the examples are just arraylist with strings and not objects.
>>
>>59387302
Because you cannot use arithmetic comparision on NULL values.
>>
>>59387307
C programmers are actually retards in general. C is a small language to grasp, exactly the kind of shit that makes things retard friendly.
C has no advanced features like C++ does.
>>
>>59387306
>>59387271
You jelly because C is a better programming language than whatever the shit you use
Stay jello prancing la-la homo man
>>
>>59387307
Seventh for C
>>
Is all the anti-C shilling just a big elaborate ruse or is it just assblasted rustniggers?
>>
>>59387271
t. lazy Javascript shill who hates memory management
>>
>>59387348
>C is a better programming language
C is just as bad as brainfuck garbage.


Last time I checked C doesn't even have generics. What a joke!
>>
>>59387286
Here you go.
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>

char *concat(size_t n, ...)
{
va_list args;
va_start(args, n);

// Find total length of output string

size_t len = 0;
va_list iter;
va_copy(iter, args);

for (size_t i = 0; i < n; ++i) {
const char *str = va_arg(iter, const char *);
size_t n = strlen(str);

// Overflow. Only sensible option is to fail.
if (len >= SIZE_MAX - n)
return NULL;

len += n;
}

va_end(iter);

// Null terminator
++len;

char *res = malloc(len);
if (!res)
return NULL;

char *ptr = res;
for (size_t i = 0; i < n; ++i) {
const char *str = va_arg(args, const char *);

// Using the non-standard (but POSIX standard) stpcpy,
// so we aren't constantly rescanning over the string
ptr = stpcpy(ptr, str);
}

va_end(args);
return res;
}

int main()
{
char *ptr = concat(4, "Hel", "lo, ", "Wor", "ld!");

printf("%s\n", ptr);

free(ptr);
}

I actually wrote this in reply to another anon a few threads ago.
>>
>>59387351
We've known C is shit for 30 years now
>>
>>59387380
Eww what an ugly piece of code. No wonder C is a timesink
>>
>>59387333
Thank you. The expression I was looking for is
 SELECT * FROM a where a.x IS DISTINCT FROM a.y;
>>
>>59387348
Yeah, better as a languagelet.
Call me when you C toddlers have learnt to use lazy evaluations
>>
>>59387380
def concat(*s): return ''.join(s)
>>
>>59387374
>generics
Useless bloat.
>>
>>59387380
Is this a satire? Or C is truly this shit
>>
>>59387435
>generics
>useless
hahaha spotted the fizzbuzz master
>>
>>59387351
It's probably the same buttblasted baboon posting it over and over again as if it made its stupid uneducated opinion true, my dear.
His primitive brain cannot grasp the simplicity and elegance of such a beautiful language, hence he has to resort to name calling and low tier shitposting.
A pity really.
>>
File: 0fcc926d577166f9b297ed4e061b9813.jpg (661KB, 1003x1417px) Image search: [Google]
0fcc926d577166f9b297ed4e061b9813.jpg
661KB, 1003x1417px
Is this correct?
;; applicative order
(sum (+ 1 2) (+ 3 4))
(sum 3 7)
(+ 3 7)
(10)

;; normal order
(sum (+ 1 2) (+ 3 4))
(+ (+ 1 2) (+ 3 4))
(+ 3 7)
(10)
>>
>>59387374
>generics in C
Are you fucking retarded? It's like asking for garbage collection in asm.
>>
>>59387514
Brainfuck is more simple than C. C is, in your logic, is shittier than Brainfuck


dumb cartoon toddler
>>
>>59387554
>Double reddit spacing
Double kill yourself.
>>
>>59387569
What if I don't?
>>
>>59387435
>generics are useless
?
>>
>>59387554
You fail at logic.
>>
>>59387554
Brainfuck is not as elegant as C, you dumb redditor
>>
>>59387621
Simplicity is elegance
>>
>>59387641
That's why lambda calculus is da future.
>>
>>59387554
>C is, in your logic, is shittier than Brainfuck
How do you deduce that from what he posted?
>>
File: 1486249145922.jpg (55KB, 957x621px) Image search: [Google]
1486249145922.jpg
55KB, 957x621px
>>59387641
dis not true..
not true at all mr froddo
>>
>>59387641
"Everything Should Be Made as Simple as Possible, But Not Simpler"
~Famous meme master
>>
>>59387678
Stay in denial. Simplicity and elegance are side effects of each other
>>
Does C have strings?
>>
>>59387678
Fuck off dumb frogposter
>>
>>59387748
Of course it does idiot.
It just doesn't have a dedicated string type.
>>
>>59387678
Frogposters deserve the death penalty
>>
File: map.png (39KB, 1920x1080px) Image search: [Google]
map.png
39KB, 1920x1080px
Doing some test for map generator.
>>
>>59387757
That's like saying "oh the language doesn't have chars, we use ints to represent chars from the ASCII table"
>>
Does C have lexical and dynamic closures?
>>
>>59387757
No it doesn't you tiny, little man.
>>
>>59387789
A string in C is a null terminated array of chars. However, there is no type which can guarantee that it is, or points to, a valid string.
A char * often points to a valid string, but it doesn't _have_ to.

>>59387800
There is a proposal for closures in the next C standard.
Clang already supports them, because Apple uses it for their API. You may need some extra runtime libraries though.
>>
>>59387823
>There is a proposal
Hopefully it gets implemented within this decade.
Does C have dynamic function creation
>>
>>59387823
KEEP THE BLOAT OUT OF C
KEEP THKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CE BLOAT OUT OF C
>>
>>59387846
>within this decade
The C2X standard is aiming to be done in 2021 or 2022, so you're out of luck with that.
>>
>>59387823
>Clang already supports them, because Apple uses it for their API. You may need some extra runtime libraries though.

The new proposal isn't like Apple's Blocks though, is it?
>>
>>59387880
Don't worry C89 is immutable.
>>
File: Screenshot_6.png (11KB, 428x448px) Image search: [Google]
Screenshot_6.png
11KB, 428x448px
im new to this board, so i hope i dont get too much shitposting for asking, but i have a question or two...

first, how do i post text the way everyone else does?

and second is pic related.
im trying to make my first game. its a basic oregon trail kinda idea, i get a bunch of events that can happen and choices for them.

im stuck at the random selection part. i want it to shuffle the events every time i start a playsession (i guess 5 events untill the game is over, even though i would put in like double the amount...)

ive tried a couple of ways of going about achieving the randomness thingy, but it always bugs out on me when printing it out or something...

anyone have any suggestions? would be greatly appreciated

im working in C, btw...
>>
Okay, since I bet on the wrong horse.

>>59387335
Having to do that just to get declarations closer to statements that use them may well be the symptom of a function body that is getting too large. You can avoid that by splitting the function body into shorter functions.

I have the same problem in C++, because I don't want to get too many methods in my classes, but then I end up with gigantic methods with declarations all over the place. Eventually, while refactoring, I split the code inside public methods into shorter private methods. This way, it's even easier to define constant references at the start of the private methods to get more concise code afterwards.
>>
>>59387884
What about dynamic function creation?
Does C have reflection? Instrospection?


I'm under the impression that C is for people from the stoneage, primitive and an insult to ingelligence of a human brain?
Does C even have mixins?
>>
>>59387905
>scanf
Aaaaaaaye ;)
>>
>>59387899
>The new proposal isn't like Apple's Blocks though, is it?
They basically are Apple's blocks. The proposal straight up says it's based on them.
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2030.pdf
>>
>>59387925
Trolling too hard.
>>
File: 1c2.jpg (49KB, 559x389px) Image search: [Google]
1c2.jpg
49KB, 559x389px
>>59387935

Oh, neat. I hadn't got around to reading the proposal yet, and needed the quick rundown.
>>
>>59387934
cout, whatever suits your boat...
>>
>>59387925
I get the feeling that you don't understand C and what it's all about in the slightest.
>>
>>59387925
>Can't program without his 1000 layers of abstraction
Kill yourself senpai
>>
File: hoffman.jpg (476KB, 500x500px) Image search: [Google]
hoffman.jpg
476KB, 500x500px
>>59387925
One does not need all this bloat when one talks the language of the machine.
>>
File: 1487974409142.jpg (79KB, 640x640px) Image search: [Google]
1487974409142.jpg
79KB, 640x640px
>>59387925
C is for newbies. Think of it this way:
During ancient times, counting to 10 was a big deal and a person who could count to 10 was considered to be "wise".

Fast forward a few century counting to 10 is so trivial we teach this to toddlers. Now toddlers appreciate the vast "knowledge" of counting to 10 while matured brains are busy with modern technologies.

C is from stone age and the people who still preach it is like overgrown toddlers that can't learn advanced things.
>>
>>59388014
(You)
>>
>>59387998
One does not need anything but assembly, C itself is a bloat
>>
>>59387380
I just want to say that if you need a function to like sprintf() but which allocates its own memory, there is the GNU asprintf:
#define _GNU_SOURCE
feature_test_macros(7) */
#include <stdio.h>

int asprintf(char **strp, const char *fmt, ...);


https://linux.die.net/man/3/asprintf
>>
>>59388014
I agree. Doing trivial tasks in C feels like living in the stoneage (see >>59387380) while matured people have moved on and left those small tasks to primitive brains of average c tards
>>
>>59388036
asprintf is actually really easy to implement yourself with just malloc and snprintf.
>>
>>59388014
true. that explains why c defence force are so immature
>>
>>59387962
Even worse
>>
>>59387569
Not him, but that was for readability. You leave a blank line between paragraphs, and this has nothing to do with reddit. Also, Markdown != reddit.
>>
>>59388049
Typical haskel faggots to be honest.
God I hate you retards, you fuckwads literally abstract for the sake of it in the most shitfaced retarded ways. PLEASE kill yourself before you write another line of production code.
P L E A S E.
>>
>>59387970
>abstraction
These are necessary tools. Technically you can solve any problem in a basic turing complete language and anything other than what brainfuck has to offer is what you call "abstractions" or "bloat"
>>
File: 152886240.jpg (357KB, 1024x679px) Image search: [Google]
152886240.jpg
357KB, 1024x679px
I literally CAN'T stomach weakly typed shit after years of C

CAN'T
>>
Implementing God's fourth temple in HolyC.
>>
>>59387748
typedef char * string;

Happy now?
>>
>>59388092
It's not hard, idiot. No seriously. C is so simple and void of functionalities it feels like an insult to write C programs
>>
>>59387905
You do code with code tags, you find them under /g/'s rules in the rules page.

>i want it to shuffle the events every time i start a playsession
Sounds like you need to place the events in an array and shuffle the array at the start of the session.

Also
>if(choice=='a' || choice=='A')
Surely C has a toLower function.
>if(choice.toLower() == 'a')
>>
File: 1329591174686.gif (688KB, 286x310px) Image search: [Google]
1329591174686.gif
688KB, 286x310px
>>59388115
Please just end yourself you fat fuck...
>>
>>59388121
>Surely C has a toLower function.
tolower() in <ctype.h>.

>>59388115
>1GB/s
>>
>>59388121
thank you for non shitposting answer
>>
>>59388139
>toLower
bloat
>>
my body is ready, now how should i go about teaching myself python? what are some of the best resources available?
>>
>>59388155
The C Programming Language
>>
>>59388115
This so fucking much.

Every single time,
Every single fucking time I see C codes I cringe visibly and I feel disgusted enough to puke.
D fag here
>>
>>59388171
>D fag here
AHAHAHAHAHAHAHAHAHAHHAHAHA
>>
>>59388160
haha
"no."
>>
>>59388171
>D fag here
How does it feel going extinct
>>
>>59388171
>tfw too intelligent for C
>>
>>59388115
Simplicity is the ultimate sophistication.
>>
>>59388171
>D fag here
Literally the same as C.
>>
>>59388193
Do you happen to be one of those /v/ toddler? I dualboot GNU/Linux and freeBSD; marketshare is pretty irrelevant to me

>>59388205
No
>>
>>59388115
>C is so simple and void of functionalities it feels like an insult to write C programs
>mfw to intellagent to use C
this is too much anon
>>
>>59388171
I have literally never seen anyone mention the D programming language outside of this board.
It literally doesn't exist.
>>
>>59387905
>first, how do i post text the way everyone else does?
put it inside [ code ] and [ /code ] tags (no spaces).

About the randomness thingy, here's a trick you can use:
1. add
#include <stdlib.h>
and
#include <time.h>
to the top of your file.
2. Generate the random seed:
srand(time(NULL));

3. Then, to get a random integer between 0 and n, do
int random_number, n = 10;
random_number = rand() % n;


For more information, see the rand() manpage
man 3 rand
, or online here https://linux.die.net/man/3/rand
>>
>>59388219
>he dual boots linux and freebsd
>not templeos and openbsd
Enjoy getting owned by the CIA.
>>
>>59388219
>No
Same shitty syntax and way of writing programs.
You're still a baby.
>>
>>59387962
scanf() reads user input, cout outputs text to stdout.
>>
>>59388244
thank you very much, anon.
appreciated.
>>
>>59387905
Newlines should be inside the string
Use puts() instead of printf() if you are not displaying variables, you don't need the newline with puts().
Use getchar instead of scanf for getting a single character.
>>
>>59387380
*PUKE*.jpg
God I hate C SO FUCKING MUCH
import std.stdio;

void main(string[] args){
string result;
foreach(arg; args[1 .. $]){
result~=arg;
}
writeln(&result);
}
>>
>>59388286
>>59388268
yeah, noticed it too, wasn't really thinking there...
>>
>>59388115
C doesn't even keep track of array sizes does it?
That's just seems so stupid.
>>
>>59388227
I'm being 100% honest. C lacks SO.MANY.THINGS I feel like being insulted. It doesn't even have generic programming
>>
>>59388287
>tfw to intelligent for C
>foxandthegrapes.jpg
>>
Friendly reminder that if your computer has ACPI and/or UEFI, your computer is mentally retarded
>>
>>59388323
>>tfw to intelligent for C
I am. C doesn't have mona- oh wait

It doesn't even have delegates and function pointers
>>
File: 1451842303902.jpg (16KB, 281x349px) Image search: [Google]
1451842303902.jpg
16KB, 281x349px
>>59388345
>it doesn't even have function pointers
>>
>>59388287
here, not going to like I actually puked a little bit and I had to wash my mouth at seing that cringe inducing C code
>>
>>59388287
>It doesn't even have function pointers
Good job demonstrating that you know fuck all about C.
>>
>>59388345
int (*foo)( int a, int b );
?
>>
>>59388345
>C doesn't have function pointers
Are you literally retarded?
>>
>>59388374
>>59388375
>>59388376
trolled
>>
>>59388374
Replied to the wrong post: >>59388345
>>
>>59388366
like*
>>
>>59388381
>it's okay guys I was just pretending to be retarded xdd
ok
>>
>>59388381
>I-I WAS JUST TROLLING I SWEAR!
>>
>>59387522
Yes. Also your results won't be in a list.
>>
>>59388381
>I was just pretending to be retarded
>>
>>59388374
Delegates?
>>
>>59388307
Why? It you are not retarded it's not difficult to keep track of your buffer sizes.
It's like Terry says, it's like a motorcycle, if you lean too far the side you fall off, so don't do that.
>>
>>59388408
>>59388406
>>59388404
>>59388382
>>59388376
Ah, you got me.

Now give me some example of standard delegates in C
>>
>>59388436
First explain what a delegate is.
>>
>>59388410
You can typedef function pointers so yes
>>
>>59388407
Forgot about that.
>>
>>59388428
>Terry
Who the fuck is that?
>>
File: camera_girl.jpg (153KB, 1024x943px) Image search: [Google]
camera_girl.jpg
153KB, 1024x943px
Redpill me on C /g/? How can it be better than Rust when Rust is more memory safe and just as fast?
>>
>>59388428
>it's not difficult so you should be forced to do it
'no'
>>
>>59388448
A delegate is a combination of a function pointer and the context that it should be
executed in.

Fucking c tard
>>
>>59388467
>just as fast
Don't delude yourself.
>>
Working on quarternions http://pastebin.com/sFcGDJvt
>>
>>59388467
Rust is not as fast as C.
>>
>>59388481
Nobody calls this a delegate except Microshills.
>>
>>59388481
so... a vtable?
>>
File: reddit_is_that_way.jpg (94KB, 478x487px) Image search: [Google]
reddit_is_that_way.jpg
94KB, 478x487px
>>59388461
If you don't know who Terry is you should just leave /g/
>>
>>59388428
You do have variadic parameters, as far as I recall.

Why do you need variable length parameters? Are you too retarded to keep track of the number of parameters?
>>
>>59388481
Considering C doesn't have "methods" and other OOP garbage, delegates make absolutely no sense.
In C, a function is a function.
>>
>>59388508
No I don't; who the fuck is terry
>>
>>59388501
He's referring to typedef'ing function pointers basically
I've used C# plenty of times
>>
>>59388056
That's what I actually did a while ago because I was bored.
asprintf.c:
/* Feature test macros */
#ifdef _POSIX_C_SOURCE
# undef _POSIX_C_SOURCE
#endif /* _POSIX_C_SOURCE */
#ifdef _POSIX_SOURCE
# undef _POSIX_SOURCE
#endif /* _POSIX_SOURCE */
#ifdef _POSIX_SOURCE
# undef _POSIX_SOURCE
#endif /* _POSIX_SOURCE */
#ifdef _XOPEN_SOURCE
# undef _XOPEN_SOURCE
#endif /* _XOPEN_SOURCE */
#ifdef _GNU_SOURCE
# undef _GNU_SOURCE
#endif /* _GNU_SOURCE */
#ifdef _BSD_SOURCE
# undef _BSD_SOURCE
#endif /* _BSD_SOURCE */
#ifdef _ISOC99_SOURCE
# undef _ISOC99_SOURCE
#endif /* _ISOC99_SOURCE */
#ifdef _ISOC11_SOURCE
# undef _ISOC11_SOURCE
#endif /* _ISOC11_SOURCE */
#ifdef _DEFAULT_SOURCE
# undef _DEFAULT_SOURCE
#endif /* _DEFAULT_SOURCE */
#ifdef _SVID_SOURCE
# undef _SVID_SOURCE
#endif /* _SVID_SOURCE */
#ifdef _FORTIFY_SOURCE
# undef _FORTIFY_SOURCE
#endif /* _FORTIFY_SOURCE */
#ifdef __STRICT_ANSI__
# undef __STRICT_ANSI__
#endif /* __STRICT_ANSI__ */

#ifndef _ISOC99_SOURCE
# define _ISOC99_SOURCE
#endif /* _ISOC99_SOURCE */
/* End of feature test macros */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "asprintf.h"

/*
* asprintf
* arguments: Just like a call to printf
* return:
* a pointer to allocated memory large enough to hold what printf would have
* printed, containing what it would have printed.
* It's like sprintf, but you don't have to worry about memory allocation
* yourself.
* Just remember to free() any string you got this way.
*/
char *asprintf(char *fmt, ...)
{
int len;
va_list argp, argp_copy;
char *str;

va_start(argp, fmt);
va_copy(argp_copy, argp);
len = (size_t) vsnprintf(NULL, 0, fmt, argp);
va_end(argp);

if (len < 0) {
return NULL;
}

/* The + 1 is for the terminating null byte */
str = malloc((size_t) (++len));

vsnprintf(str, len, fmt, argp_copy);
va_end(argp_copy);

return str;
}


>>59388103
Same.
>>
>>59388538
Function pointers aren't the whole picture. To have a closure you need a function pointer (or equivalent) as well as storage for the captured free variables.
>>
>>59388520
You just don't have 'em. Denial is not taking your trash lang anywhere.
I don't expect a limited IQ c tard to understand the need of features like those
>>
>>59387533
>garbage collection in asm
That's exactly what web devs are asking for in WASM.
>>
File: angry_doggo_noises.png (766KB, 843x1034px) Image search: [Google]
angry_doggo_noises.png
766KB, 843x1034px
>>59388537
Leave.
>>
>>59388541
>if (len < 0) {
You cast vsnprintf to an unsigned type, so this check with always fail. You should do this check before you cast to size_t.
>>
Does C even have function overloading?

>>59388591
no u
>>
>>59388541
asprintf.h:
#ifndef _ASPRINTF_H
# define _ASPRINTF_H

/*
* asprintf
* arguments: Just like a call to printf
* return:
* a pointer to allocated memory large enough to hold what printf would have
* printed, containing what it would have printed.
* It's like sprintf, but you don't have to worry about memory allocation
* yourself.
* Just remember to free() any string you got this way.
*/
char *asprintf(char *fmt, ...);

#endif /* _ASPRINTF_H */

Makefile:
CC=gcc
CFLAGS=-Wall -g -Wextra -Werror -ansi -std=c90 -pedantic -pedantic-errors -O3
PROGNAME=asprintf_test
LIBS=-lc
OBJS=asprintf.o main.o

.PHONY: all clean clean-all asprintf

all: $(PROGNAME)

asprintf: asprintf.o

$(PROGNAME): $(OBJS)
$(CC) -o '$@' $^ $(LIBS)

main: main.o
$(CC) -x c $(CFLAGS) -c -o '$@' '$<'

asprintf.o: asprintf.c asprintf.h
$(CC) -x c $(CFLAGS) -c -o '$@' '$<'

clean:
-@rm ./*.o ./*~ ./.*~
clean-all: clean
-@rm ./$(PROGNAME)


main.c:
#include <stdio.h>
#include <stdlib.h>
#include "asprintf.h"

int main(int argc, char **argv)
{
char *string;
int i;

for (i = 1; i < argc; ++i) {
string = asprintf("Arg %d: %s\n", i, argv[i]);
printf("%s", string);
free(string);
}

exit(EXIT_SUCCESS);
}


I hereby license it under the GNU General Public License, either version 2 of the license, or (at your option) any later version.
>>
>>59388591
memes just rule your whole life, right?
i bet you also post that programmer sock meme
>>
>>59388602
>Does C even have function overloading?
Sort of. _Generic can do the job.
>>
>>59388556
>Closures
Useless fucking bloat
>>
>>59388461
>>59388537
You need to go back.
>>59388471
Then don't use C nigger.
Manual buffer management is faster.
It's more time consuming (not by that much though), but it's faster.
If you don't care about faster, then don't use C.
>>59388515
That's comparing apples and oranges. There is no runtime cost for varadic args
>>
>>59388613
see >>59388095
>>
>>59388604
Stop, nobody wants your shit code.
>>
>>59388595
Right. Thanks for letting me know.
>>
>>59388564
Does Haslel or whatever useless language you like even have pointers?
>>
>>59388508
Terry is a pretty cool guy; eh makes TempleOS and doesn't afraid of anything.
>>
>>59388635
D has pointers
C++ has pointers
Rust has smart pointers

>Haskell
Does C even have monads?
>>
>>59388623
>faster in exchange for extremely basic features
'no'
>>
>>59388623
Who
the
fuck
is
torry?
>>
>>59388654
>Does C even have monads?
I know this is probably bait, by why on earth would an imperative language need monads?
Using a monad is basically saying "FP is too hard for me, so I'll write imperatively instead".
>>
>>59388632
You hurt my feelings, anon.
But I posted it anyway, if you were paying attention, you'd have known that that's all there is.
>>
>>59388613
"Unboxed" closures used with monomorphized templates is about as lightweight as you can get. You don't even use a function pointer because the code is dependent on the type, and if it doesn't get inlined (though most of the time that's what you would do) the only cost involved is passing the captured variables, which is the bare minimum.
>>
>>59388541
>ifdef
>undef
>ifdef
>undef
>ifdef
>undef
>ifdef
>undef
>ifdef
>undef
What the fuck are you even doing?
>>
>>59388682
That only shows the flexibility of Haskel
>>
>>59388672
See >>59388649
then see >>59388591
>>
i came here for anime pictures
where are the anime pictures
>>
>>59388672
Fucking lurk moar you faggot.
>>59388662
Then use Python you retard.
Don't complain about C if you don't want what it has to offer.
>extremely basic
No, bounds checking has an implicit run time cost.
If you want languages with an implicit run time cost than use something other than C.
The people who use C use it BECAUSE it doesn't have these things.
It's use case is NOT catering to retards.
>>
>>59388690
I read feature_test_macros(7) and got a little bit too excited.
>>
>>59388690
>>59388541
Yeah, that's really fucking stupid.
For starters, you can #undef unconditionally, because doing that on a macro that wasn't defined is perfectly valid.
Secondly, you shouldn't do feature test shit in the program itself like that: it should be done with compiler command line options.
If you want to use C99, just fucking use -std=c99.
>>
>>59388697
what the fuck is that tempolos? Looks like a pretty shitty year 4 assignment work

I looked up torry and apperently he is an autistic youtube vlogger
>>
File: anime_pointing_dance.gif (483KB, 243x270px) Image search: [Google]
anime_pointing_dance.gif
483KB, 243x270px
>>59388699
Here!
>>
>>59388708
>what it has to offer.
so..
Nothing except for loops and functions(some of them)?
>>
>>59388721
Kill yourself.
That is the most efficient OS I have ever seen on x86.
You fucking reek of CIA nigger.
>>
>>59388721
>4 assignment work
it's a sunday schol that went wrong
>>
I'm having a trash class about decision/repetition structures in Java.
>>
File: laughingloli.png (2MB, 1065x1480px) Image search: [Google]
laughingloli.png
2MB, 1065x1480px
>>59388654
>Haskell doesn't even have pointers
>>
>>59388742
post pics?
>>
>>59388736
>That is the most efficient OS
yeah, apperently it doesn't have any user privilage restriction
You meant the most unstable or vulnerable OS made by an autistic manchild living in his mom's basement
>>
>>59388732
If you weren't retarded you would see why implicit run-time costs are not useful when writing something like a kernel, or low level crypto libraries, or anything else that requires efficiency.
There are other languages for when you don't want efficiency above all else.
Use those and stop bothering anyone else with your lack of intelligence.
>>
>>59388771
Why would I write a kernel in C? There is ASM

?
>>
>>59388682
I'm gonna assume you are willing to learn.

Normally, sequencing in a declarative fashion is simply done by passing results of functions into other functions. What monads (and algebraic effects) do is generalize this a lot so that you can do things like error propagation and non deterministic choice. It's based on continuation passing style, which is the functional equivalent to single static assignment in an imperative setting. Monads have the additional property of being roughly equivalent to linear types, so they are also used for type state and turning side effects into first class effects.
>>
>>59388748
https://hackage.haskell.org/package/base-4.9.1.0/docs/Foreign-Ptr.html
https://hackage.haskell.org/package/base-4.9.1.0/docs/Data-IORef.html
>>
>>59388787
I don't think your average c tard has the capacity to fathom what you just posted
>>
>>59388708
>it's not an extremely basic function because I say so
m8...
Next you'll say not having loops is alright because you have GOTO's.
>>
>>59388791
pedo BTFO
>>
>>59388768
>implying privilege restriction matters with no networking and a single user
Why the fuck would you waste time on privilege checking?
>unstable
t's stable as fuck it you aren't stupid (you).
>>
>>59388791
>Haskell can only have pointers to foreign memory
useless
>>
>>59388837
>no networking
Great, an unfinished year 4 assignment it is. How pathetic.

Considering his autism I'd say he did a good job. Just like I would applaud a female student for being able to complete a fizzbuzz
>>
>>59388782
Low level parts of most kernels are written in ASM.
>>59388809
>because I say so
No because that's how C is, and always has, been.
Just because you just learned JavaScript in your Code Bootcamp doesn't mean people haven't been writing C since 1977.
Those people have been getting by without language imposed bounds checking.
Of course since then other languages that provide bounds checking at the cost of run time have been created.
Use those.
>>
>>59388787
>>59388807
I know what a monad actually is; I actually know Haskell, although I'm not balls-deep in it.
Yes, without getting to mired in the details, they're effects as values.
That doesn't explain why they would be useful in an imperative programming language, as all you would be doing is providing a duplicate facility.
>>
>>59388853
It's no networking because God says you fucking CIA nigger.
What OS did you write faggot? I won't bother waiting.
>>
>>59388718
That program is pure C89.

>>59388768
>CURRENT_YEAR
>No networking

>>59388467
>and just as fast?
I disagree with that, but real life girls are so much better than anime girls.
>>
>pure cs students wrote their first fizzbuzz in haskell and started hating c
like pottery, happens every year

now be good boys and either get a job and we'll talk in a year again or kindly fuck off proving p != np
>>
>>59388899
>That program is pure C89.
Sure, but they explicitly define _ISOC99_SOURCE at the end of all of that shit, despite undefining it earlier.
>>
>>59388885
What's this "CIA nigger" meme?
>>
>>59388882
Monads have a dual purpose. People mainly know them as a way to sanely do I/O in Haskell, which is the part I mentioned about turning side effects into first class effects. Their other purpose is to generalize the act of "doing X and passing its result into Y", which is a way they could still be useful in an imperative language.

There are imperative languages that do have monads in a sense, like C#'s LINQ. However, C# doesn't have higher kinded types and thus you cannot write code that works for ALL monads, which is the real killer feature.
>>
>>59388920
Lurk more or fuck off, preferably the latter.
>>
>>59388875
>Low level parts of most kernels are written in ASM.
No, if I had to write a kernel I would write it completely in ASM with no trace of C

See menuetOS

>>59388885
>It's no networking because God says you fucking CIA nigger.
Can you give me god's snapcha id?
>What OS did you write faggot?
I wrote a kernel while I was doing masters, it's not really special. Other people have done it and it didn't give them autism.

Maybe if he stopped his attention whore-vloggin youtube catering to autistic brainlet trash like yourself he would get the time to implement the networks stack and stopped blaming "god"
>>
>>59388899
vsnprintf isn't C89
>>
>>59388926
why are you so angry? Do you have autism?
>>
>>59388875
Just because C's been around since the 1970s doesn't mean it was perfect when it was created, it has flaws.
>>
>>59388932
Then do that.
No one is forcing you to use C.
Good luck when it gets over 100,000 lines though.
>gods snapchat id
He has a space alien you nigger cattle.
>i wrote a kernel
Post it or it didn't happen CIA nigger.
>>
>>59388950
C is full of flaws
>>
>>59387338
>C has no advanced features like C++ does.
those "advanced features" don't make your code run faster one bit, they are alien features to CPUs
>>
>>59388936
Then gcc should've given me some warnings at least. I used
-Wall -g -Wextra -Werror -ansi -std=c90 -pedantic -pedantic-errors -O3
>>
>>59388950
Of course, but not having bounds checking isn't one of those.
>>
>>59388957
>He has a space alien
what other fairy tale do you believe in? One that turns wooden sticks into snakes? Or the wone that rides on flying deers in christmas eve?
>>
>>59388932
>Can you give me god's snapcha id?
God doesn't use proprietary software.
>>
>>59388967
Well tough shit, (v)snprintf is c99.
>>
>>59388975
*tips fedora*
>>
>>59388966
C itself is an alient to the CPU, only machine code is native
>>
>>59388923
>"doing X and passing its result into Y"
And how is this sufficiently different than normal function application?

>>59388967
You fucked with the feature test macros, so it's not going to give correct results.
That's the only way that stdio.h is actually able to determine which functions it defines.

>>59388950
I'm an advocate for C, and I will happily admit it has its flaws. Most of them are just because of its history, and how it came to be now.
That doesn't mean that it's not damn good at what it does.
>>
>>59388990
*fucks cousin*
>>
>>59389002
>he doesn't fuck his cousin
Should we tell him guys?
>>
>>59389008
Someone who's not an autistic redneck
>>
Reminder to ignore the language-war trolls.
>>
Can i do a paid app that shows a celebrity face?
>>
>>59388995
>I'm an advocate for C, and I will happily admit it has its flaws. Most of them are just because of its history, and how it came to be now.
>That doesn't mean that it's not damn good at what it does.
This.
I would even argue that most (read: >60%) of good usable software nowadays is still written in C.
>>
>>59388995
>And how is this sufficiently different than normal function application?
Because depending on the monad you can do things a little differently. For example, error propagation. If it's successful, you pass on the result. If not, it's just the same error. Or you could do non determinism using a set of outcomes, and you run the function for each outcome and collate the results.
>>
>>59388932
>>59388957
>he hasn't posted his kernel yet
Just as I thought, fucking CIA nigger.
>>
>>59389035
Have you ever been taken a CS course?
>>
>>59389035
https://kernel.org/
>>
>>59389045
>>59389046
>no kernel yet
"ok"
>>
>>59389035
>No network
>"kernel"
LMAO
>>
>>59389061
What are you trying to prove here, autistic trash?
>>
>>59389061
Don't quote me, I'm not him. I'm still skilled enough to make my own kernel yet.
>>
>>59389080
s/still/not/g
>>
>>59389062
>>59389080
>>59389078
see >>59389061
CIA nigger trash
Peace.
>>
Does C even have contract programming

>>59389089
EPIC VIM SKILLZ BRO
>>
>>59389026
4chan is not written in C
Google's search engine is not written in C
Google Chrome is not written in C
Firefox is not written in C
Notepad++ is not written in C
GCC is not written in C

What programs exactly are you talking about?
>>
>>59389092
see >>59389078
>>
>>59389098
>vim
You mean ed?
>>
>>59389106
My browser is larger than my kernel and it's mostly written in C++
>>
>>59389098
>VIM
sed uses that syntax, though.

>>59389106
>GCC is not written in C
Sure, "technically" GCC is written in C++, but have you ever read the source code?
Excluding the C++-specific shit like the C++ parser and libstdc++, that shit is C. Most of the files even still end with a .c extension.
>>
>>59388995
>I'm an advocate for C
How's that unemployment treating you?
>>
Does C have static construction order?
>>
>>59389187
Why would C even need that?
>>
>>59389098
>new
>>
>>59389383
who are you quoting?
>>
File: 1481816509906.jpg (8KB, 251x242px) Image search: [Google]
1481816509906.jpg
8KB, 251x242px
>project claims to be written in 1k LoC
>relies on libraries like libc
>>
Hey /dpt/, brainlet here.

I'm studying C++ and was looking at a piece of code that is showing nested loops. It's a small program that gives you the prime numbers up to 100.

#include <iostream>
using namespace std;

int main () {
int i, j;

for(i = 2; i<100; i++) {
for(j = 2; j <= (i/j); j++)
if(!(i%j)) break; // if factor found, not prime
if(j > (i/j)) cout << i << " is prime\n";
}

return 0;
}


I've tested it on 2 different IDE's, and both times the results are starting with "2 is a prime number". My problem here is that 2%2 gives 0. And !(0) is 1. And since if(1) means the condition is true, then why isn't the break; activating and terminating the loop before reaching the next check? What am I missing here. Pls respond!
>>
>>59389429
because it breaks nested for, not the first one
>>
>>59389429
Put curly brackets around the statements in the for loop, idiot.
Your code is being compiled as
for(i = 2; i<100; i++) {
for(j = 2; j <= (i/j); j++) {
if(!(i%j)) break; // if factor found, not prime
}
if(j > (i/j)) cout << i << " is prime\n";
}

If you were using a modern version of GCC, -Wmisleading-indentation (enabled by -Wall) would warn about that.
>>
>>59389454
>>59389477
Fuck, I knew I was missing something obvious. Thanks.
>>
>>59389421
>libraries like libc
Complaining about the standard library in a hosted program is fucking stupid.
Although, stupidity is to be expected from a fucking frogposter.
>>
is code complete worth reading in 201x?
>>
>>59389791
>reading
>201x
>>
>>59389804
>
>
>>
>>59389902
>>
>>59389804
>>59389902
>>59389932
>>59389958
xD
>>
>>59389328
Why would C need anything? It's not meant to be used anymore these days. Use C# and stop being autistic
>>
>>59390293
>Use C# and stop being autistic
Oh the ironing.
>>
>>59390293
C# isn't really useful for the low level stuff, since it requires a managed environment.
>>
>>59390452
yeah, I'm not writing a kernel, like you do twice a week, dear autist
>>
File: 1466606457116.jpg (41KB, 380x358px) Image search: [Google]
1466606457116.jpg
41KB, 380x358px
>>59390476
>insulting someone for writing a kernel twice a week
>>
>>59390452
>not using managed C
>>
>>59390565
At least I don't have autism
>>
>>59390629
Yeah, neither do I. :^)
>>
>>59390629
You need to be at least bit autistic to be a good programmer. git gud
>>
>>59390651
I'm not the one who creates imaginary kernels in ANSII C twice a week.

>>59390665
no
>>
File: 1466532967522.jpg (41KB, 394x353px) Image search: [Google]
1466532967522.jpg
41KB, 394x353px
>>59390676
>no
t. mediocre programmer
>>
>>59390676
But I can't make a kernel in ANSII C because ANSII C doesn't exist. :^)
>>
>>59388582
Webdevs are retarded in general.
The ones using electron definitely are.
>>
>>59390693
t. dumb weeaboo

I also noticed if you share anything from buzzfeed, program in c or if you are posting anime you are not the brightest person in the world
>>
>>59390676
>not having managed autism
>>
Does GCC work on Bash on Ubuntu on Windows pretty well? I've been using ubuntu for about 10 months, and gcc is pretty much the only pro that Linux has given me. Think I'm going to go back to windows.
>>
>>59390773
MinGW works decently for getting GCC on windows if that's what you need.
>>
File: 1428182712023.jpg (72KB, 440x406px) Image search: [Google]
1428182712023.jpg
72KB, 440x406px
>>59390764
Haha, you know jackshit, if you take a look of great programmers all of them used and mastered C. I bet you don't even know how to use pointers.
>>
>>59390805
is pointer supposed to be a milestone to anime watching c toddlers?
>>
>>59390773
Even Cygwin works better than this piece of crap.
>>
File: goodbye world.png (21KB, 803x321px) Image search: [Google]
goodbye world.png
21KB, 803x321px
I'm trying to run this java code on Netbeans but its not working, can you guys help me? i have no idea whats going on, because yesterday it was working
>>
>>59390816
Yes.
>>
>>59390827
>void
Did you mean null?
>>
Do you like soundtracks /g/? https://www.youtube.com/watch?v=sNPUOoQoukk
>>
>>59390852
fuck me, i'm a retard

thank you anon!
>>
>>59390695
>ANSII C doesn't exist
It does now :^)
>>
>>59390787
>>59390824
>Even Cygwin works better than this piece of crap.
kek. I'll check both out.
>>
>>59390867
Okay :^)
>>
>>59390880
Do keep in mind that Cygwin might need cygwin1.dll to run your C/C++ programs.
There is a dll replacement for it which is more adapted to Windows and with a more permissive license but I dont remember the project name
>>
>>59387221

how the fuck do you install openCL on ubuntu 14.04
>>
>>59390980
>google "opencl on ubuntu"
>install opencl-icd under mesa
>install opencl-nvidia under nvidia
>>
>>59390880
Cygwin's pretty gud, you'll probably have to make it run as admin though.
>>
>>59391001

Been there done that under like 2 different installs

I'm not even gonna worry about my GPU right now. I just want to get clinfo to return my fucking CPU and I'll be happy for now
>>
> Feggets not belonging to the actor/process master race

erlang/elixir are fun. Enjoy your shared mem bugs and pajeet jobs.
>>
File: 1489289786057.png (63KB, 268x268px) Image search: [Google]
1489289786057.png
63KB, 268x268px
So I did simple/toy dfs as practice and just wrote it like my rough pseudocode. Is there some better way to write it?
Because it's recursive I have to throw stuff onto tree object which I'm already passing to function or make extra arguments like the t1,t2,t3 so I can keep track of state.
What's the slick way?
class Tree(object):
def __init__(self, adj_list):
self.n = len(adj_list)
self.adj_list = adj_list
self.V = list(range(self.n))
self.E = [[u,v] for u in range(self.n) for v in adj_list[u]]
self.children = self.adj_list

def dfs(T, root):
T.preorder = [None for _ in range(T.n)]
T.inorder = list(T.preorder)
T.postorder = list(T.preorder)
dfs_recurse(T, root, 0, 0, 0)

def dfs_recurse(T, v, t1, t2, t3):
T.preorder[v] = t1
t1 += 1
flag = True
for c in T.children[v]:
t1, t2, t3 = dfs_recurse(T, c, t1, t2, t3)
if flag:
T.inorder[v] = t2
t2 += 1
flag = False
if flag:
T.inorder[v] = t2
t2 += 1
T.postorder[v] = t3
t3 += 1
return t1, t2, t3
>>
How do I git gud?
>>
>>59391404
At what?
Usually, practicing helps.
>>
>>59391404
Just fukken git ur gud up
>>
Can I call myself a codewarrior IRL?
>>
does c have anything nice besides messing with pointers and function pointers?
>>
>>59391435
I barely understand this thread. I want to be as good as you guys.
>>
>>59391580
No one understands this thread, it's all shitposting.
In all seriousness though it's a field where "practice makes perfect" definitely applies. Think of a project you want to do, do it then repeat.
>>
>>59391580
https://www.youtube.com/watch?v=SlCRfTmBSGs
>>
>>59391548
No, the preferred term is code artisan.
>>
>>59391580
Your level of understanding /dpt/ threads isn't really a good metric, but I would say I understand a lot more than I used to.
Just study, make things, etc.
>>
File: whatamdoingwrong.png (105KB, 1548x851px) Image search: [Google]
whatamdoingwrong.png
105KB, 1548x851px
I need to access this array from another class

I've initialised and defined the array like pic related

What am I doing wrong? I am new to C++
>>
>>59391659
Please learn C++ before you learn libraries for C++.
Try "Absolute C++" or "C++ Primer."
This is beginner stuff.
>>
>>59391603
I could make a program that downloads all of the images in a thread. It could help me build up my shitposting folders too. Would that be challenging?

I think it would be cool if it sorted it into folders too, like a smug folder, a sad folder, angry folder etc. That would probably be too hard though.
>>
>>59391692
Practice doing what you want to get better at. What is something that would want to make in the future? Something that would be really challenging and take a lot of time perhaps.
>>
>>59391691
Okay, I've download a .pdf of A Tour of C++
Will start reading
>>
>>59391659
using namespace cubes;

Cube* cube = new Cube();
>>
>>59391691
>"C++ Primer."
that's no beginner
>>
C++ is only good if your time is worthless.
>>
>>59391707
A robot waifu.
>>
>>59391847
Not him, but the guy he's replying to

I can program in Java, but I know almost nothing about C++.
But C++ Primer is over 1,000 pages, so fuck that
>>
>>59391867
You mean "C is only good if your time is worthless", right?
>>
>>59391896
You mean "JavaScript is only good if your time is worthless", right?
>>
>>59391692
I doubt you'd be able to sort them like that, that'd require image recognition or analysing the post.
>>
>>59391939
No I meant
C is only good if your time is worthless. Why are c tards so insecure about JS?
>>
C requires MUCH less time to learn than JS - unless you're a brainlet that doesn't understand pointers.
>>
>>59392015
C is a beginner friendly newbie language. It's small and easy to learn because it only has like if, else, while and for statements.
Play group stuff
>>
>>59390476
Is that supposed to be an insult or something?
>>
File: images.duckduckgo.com.jpg (58KB, 414x414px) Image search: [Google]
images.duckduckgo.com.jpg
58KB, 414x414px
>>59392104
No, I'm just saying C is entry level stuff. Like the elementary schools that only has "a b c d e f" or "1 2 3" etc to teach. C is like elementary stuff, it only teaches you "if while for else * **" etc and nothing too advanced. It's not a bad thing
>>
>>59392153
Does using complex languages make you feel more grown up and mature?
For me, I just like to keep things simple
>>
>>59392153
The language has simple syntactic constructs, but with it, you can create very complex systems. Concepts of complex systems can be learned through C. The language itself, of course, is easy.
>>
File: Untitled.png (740KB, 1834x1200px) Image search: [Google]
Untitled.png
740KB, 1834x1200px
>>59392230
>>59392233
Nothing wrong with it
>>
>>59390880
Grap MSYS2 and forget Cygwin shit.
>>
Hey /g/, I'm learning myself JS for a game development project that I'm working on with a friend.

Anyway I know Python pretty well but I'm getting a little tripped up converting what I know of that syntax to JS. In this particular instance. I'm trying to do something pretty simple. In Python it would be:

for int in Array:
if int = "X"
do something


So plainly said, I'm trying to iterate through an ordered array of unknown elements and do something depending on what the elements are. What's the syntax for this in JS? The sources I'm reading are telling me not to use (for x in y) in JS for arrays, so I'm curious how exactly I should handle it. Specifically what's the syntax used to refer to the iterables in the for loop?
Thread posts: 324
Thread images: 29


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