Old thread: What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
Other urls found in this thread:
arstechnica.com
xorcatt.wordpress.com
gigaom.com
zedwood.com
templeos.org
cvsweb.netbsd.org
twitter.com
TRAPPOSTER WHERE WERE YOU
arstechnica.com
xorcatt.wordpress.com
Once again, a buffer overflow has lead to new vulnerabilities in C land. This time all pre-2013 Cisco routers are affected.
It does indeed feel there is a gaping hole in our software stack as these buffer overflows are only increasing in rapidity. It is time we take a serious look at the epidemic of exploits in C land, and begin to implement real solutions; they are out there.
It’s hard to deny that easy access to stack, especially unprivileged access, plays a serious role in creating computer crime. How many buffer overflows happen in languages with access checks on stacks? How many buffer overflows are discovered in the Ada each year? None. How many in Haskell? None. How many in Java?
None. The list could go on. And yet, mass exploitation in the C-land continue to increase. There is certainly a correlation. But there are other important causes at play as well: the language is an ill-designed clusterfuck of hacks upon hacks.
Of course, mass buffer overflows are only one indication of the security nightmare that plagues the language — the whole language is built on unsafe and insecure code. In the C-land, memory rules are much more lax than that of other popular languages, on par with the assembly and lacking even basic safety features: unless explicitly requested by the programmer.
Nearly 70% pre-2013 routers are Cisco and are vulnerable to being hacked during the %CurrentYear%.
gigaom.com
These are a only a few of the indicators of what may feed into the hopelessness and despair that causes so much distrust in C and its derivatives. The bugs cost real money and real work-hours to be wasted on correcting and debugging the garbage that was compiled by compilers which don't value anything but speed and memory use
>tfw hardcore C fizzbuzzer
>tfw to intelligent to be employed
Nice you copy-pasted an earlier Sup Forums thread's OP
@59064471
>ada
>haskell
>java
>speed and memory use is not important anyway guise
bwahahahahaha
Rust doesn't have that problem
I have about $4000 and 6 months
Options:
a) CS degree somehow (unlikely in the near future)
b) Code bootcamp
c) learn on my own using resources from a + b
Which is the best?
Spend it on drugs and hookers.
d) Get a job and use that money for a)
>wild rust shill appears
ding! ding! ding!
how can you resolve a circular dependency without relying on function pointers?
like if you have a static library and you want the static library to call back to one of your functions
>It's another episode of a C toddler can't accept the truth episode
i have a datastream. i load data coming from this stream into a buffer and then i have a couple of threads run over this buffer byte per byte and do some math on each byte. after that, i erase the buffer and fill it with fresh data. i do this mainly because if i load in a lot of data all at once, around 300mb, my program crashes. i don't know why my program crashes and the only way i could fix it was by buffering the data instead.
is there some science to how big those buffers should be? should they be as big as possible? small as possible? can i calculate a sweetspot?
doesn't have the power either :^)
What are good resources to start with r?
what power do you want?
Weak symbols.
Go get some unpopular STEM degree, CS is overhyped.
all of them
done
What's a simple crypto method/library for C/C++ if I just want to hash some passwords?
upvoted
lies
Post your best C fizzbuzz and explain why it's the best.
Surely C ucks are just in denial when it comes to the fact that Rust is objectively better than C?
>objectively
literally?
Not mine but
Terry Davis wrote the perfect Fizzbuzz in AMD64 Assembler. It doesn't use division or modulo and stores the strings in registers instead of the stack or, God forbid, the heap. (8 characters per register).
Hey gee, how can I coq muh hasklel in rust?
get some plumber job or something and then learn programming in the meantime. trust me on that one.
top memester
>perfect Fizzbuzz in AMD64 Assembler
pff, back in the day I did it in amd32 asm in half the space requirements
link me nig***
That's easy, but how do we Sqoop the Hadoop into Oraoop using OOP?
templeos.org
#define RANGE_START 1
#define RANGE_END 100
#define FIZZ_SPAN 6
#define BUZZ_SPAN 7
asm {
_BUZZ_FIZZ::
PUSH RBP
MOV RBP,RSP //Always set-up stk frame. (Stack Gets Traced)
PUSH RSI //See REGG_LOCAL_VARS & REGG_LOCAL_NON_PTR_VARS
PUSH RDI
MOV RSI,FIZZ_SPAN-RANGE_START%FIZZ_SPAN+1
MOV RDI,BUZZ_SPAN-RANGE_START%BUZZ_SPAN+1
MOV RAX,RANGE_START
@@05: CALL PUT_HEX_U64
PUSH RAX
MOV RAX,CH_SPACE
CALL PUT_CHARS
DEC RSI
JNZ @@10
MOV RAX,'FIZZ '
CALL PUT_CHARS
MOV RSI,FIZZ_SPAN
@@10: DEC RDI
JNZ @@15
MOV RAX,'BUZZ '
CALL PUT_CHARS
MOV RDI,BUZZ_SPAN
@@15: MOV RAX,'\n'
CALL PUT_CHARS
POP RAX
INC RAX
CMP RAX,RANGE_END //Actually only a 32-bit inst.
JBE @@05
POP RDI
POP RSI
POP RBP
RET
}
Note how he uses general-purpose registers for string processing, not pointers to memory.
MUH DICK!
>doesn't use division or modulo
>RANGE_START%FIZZ_SPAN
lad...
fuck
not in the main loop, just in the initialization
>Ada is isn't fast
faster than python, slower than C
i'm 4 years into a software engineering uni and i still fucking hate programming
what the fuck do i do
That folder name is stupid and could have been said in less words.
>4 years into
bite the bullet.
lube and take it up the ass.
So i dropped highschool and having nothing to do at home, I decided to learn C++ because my brother wanted someone who can help him for a project.
I'm stuck there, pic related, it cannot recognize the class Guerrier (warrior in french) despite recognizing the mother class Personnage (character in french)
What did I fuck up ?
Always program in English, regardless of your native tongue.
>backpedaling
please
why is so /comfy/ in C, Sup Forums?
@59065208
why do you jerk it to cartoon kids, mentally ill fag?
Did you try refreshing intellisense
Either shoot yourself in the head because you should have swiched 3,5 years ago or suck it up.
wat
Did it work?
How long do I have to work to write C at this level? It's just the ifconfig source
I also looked at the wpa_supplicant source. In both, they seem to use C structs like classes, which is strange to read as a C++ programmer
#include "stdio.h"
int main(){
f=fopen("E:/program.c", "w+");
int limit = 100;
char iff[] = "\tif(i ";
char eliff[] = "\telse if(i ";
char mod15[] = "% 15 == 0)\n";
char mod5[] = "% 5 == 0)\n";
char mod3[] = "% 3 == 0)\n";
char fizz[] = "\t\tprintf(\"fizz\");\n";
char buzz[] = "\t\tprintf(\"buzz\");\n";
char fizzbuzz[] = "\t\tprintf(\"fizzbuzz\");\n";
char i[] = "\tint i = 0;\n";
char incl[] = "#include \"stdio.h\"\n";
char beg[] = "int main(){\n";
char end[] = "}";
fprintf(f, "%s\n", incl);
fprintf(f, "%s\n", beg);
fprintf(f, "%s\n", i);
for(int i = 0; i < (limit - 1); ++i){
fprintf(f, "%s", iff);
fprintf(f, "%s", mod15);
fprintf(f, "%s", fizzbuzz);
fprintf(f, "%s", eliff);
fprintf(f, "%s", mod5);
fprintf(f, "%s", fizz);
fprintf(f, "%s", eliff);
fprintf(f, "%s", mod3);
fprintf(f, "%s", buzz);
fprintf(f, "\n", 0);
fprintf(f, "\ti = %d;\n", (i + 1));
}
fprintf(f, "%s", end);
fclose(f);
}
Those are all pretty fast languages, bro. You should have gone for Python or something.
>didn't explain why it's the best
not portable
>pretty fast
not fast enough
Can I get a TL;DR on this disgusting fizzbuzz?
>metaprogramming
needs to compile twice
GOTTA GO FAST
>Not calling GCC in the program and running it
Fucked it, tbqh
GOTTA!
It outputs the source code for a fizzbuzz program.
...
Not portable, doesn't meet the requirements of FizzBuzz.
It's shit.
GOTTA
O
T
T
A
#ifndef HFILE_H
#define HFILE_H
#endif
or
#pragma once
?
> pretty fast
pleb
Why is Python SO SLOW?
Because everything in Python is object.
Because you're not using Cython
This. Why can't Python be as fast as Assembly?
Most languages are shit in that way.
First one is more portable
>they think neural networks won't be able to translate spoken human language into optimized machine code
fools
we will have human friendly language running maximally efficient soon and there's nothing you can do about it
the first if you ship your code to others
the first if you only use it for yourself and don't mind changing it when compilers drop support for it
>reddit spacing
I'm 5 years into pharmacy school and want to switch to CS.
Thankfully I have no student debt but this fucking opportunity cost is killing me.
Stick it out for another year for a job I hate, will be gone in 10 years.
Or rush through a degree in three years and get into the workforce at 25/26.
Just fucking end me.
I have no idea what I want to do but fuck pharmacy.
I want to die.
Get the degree, it's just a year.
>he thinks human language is precise enough to specify a program
baka, the specs will be as complicated as the program itself
That's what I think I'm going to ultimately do.
The future of this profession is terrifying though.
> The future of this profession is terrifying though.
CS or pharmacy?
Yes
In the UK, the vast majority of secondary care pharmacists spend their time on medicine reconciliation.
As soon as the NHS gets its shit together enough to centralise patient records two thirds of them will be out of a job.
Why is cython not popular yet? How much is it missing?
If I could get compiled speeds from python, I don't think I'd use anything else.
Earn easy $$$ as a pharmacist
Then study CS for fun
I need some help in C
I'm doing this excersize from a book and I'm having trouble with the if part
#include
#include
main(){
int answernum, inputnum;
inputnum = 0;
answernum =(rand() %10)+1;
printf("\nGuess the number");
printf("\nWrite your answer: ");
scanf ("%d inputnum");
if (isdigit(inputnum)){
if (inputnum == answernum);
printf("\nYou guessed right");
else \* my compiler says it expects an expression before this, I add a } but then it gives me the same error on the 'else' below*\
printf("\nYou guessed wrong \n the answer was %d" answernum);
}
else \* and if I add a } before this it gives me more errors in other lines*\
printf("\nThat is not a number");
}
Pharmacy.
I'm likely going to get a job in retail since I'm not competitive for a residency.
Retail is seeing a huge downward shift due to reimbursement, huge number of grads coming out, and automation.
I just fucking wish I was 18 and never even heard of this shit.
>Will be gone in 10 years
If anything, there will be more people needing drugs. Just finish the Pharma.
become a pharmacist and sell drugs illegally, possibly in collaboration with a crooked doctor
>if (inputnum == answernum);
why do you have a ; after an if statement
>"onee-chan ai, write a fizzbuzz program"
>"yes master"
>nanosecond later
#define RANGE_START 1
#define RANGE_END 100
#define FIZZ_SPAN 6
#define BUZZ_SPAN 7
asm {
_BUZZ_FIZZ::
PUSH RBP
MOV RBP,RSP //Always set-up stk frame. (Stack Gets Traced)
PUSH RSI //See REGG_LOCAL_VARS & REGG_LOCAL_NON_PTR_VARS
PUSH RDI
MOV RSI,FIZZ_SPAN-RANGE_START%FIZZ_SPAN+1
MOV RDI,BUZZ_SPAN-RANGE_START%BUZZ_SPAN+1
MOV RAX,RANGE_START
@@05: CALL PUT_HEX_U64
PUSH RAX
MOV RAX,CH_SPACE
CALL PUT_CHARS
DEC RSI
JNZ @@10
MOV RAX,'FIZZ '
CALL PUT_CHARS
MOV RSI,FIZZ_SPAN
@@10: DEC RDI
JNZ @@15
MOV RAX,'BUZZ '
CALL PUT_CHARS
MOV RDI,BUZZ_SPAN
@@15: MOV RAX,'\n'
CALL PUT_CHARS
POP RAX
INC RAX
CMP RAX,RANGE_END //Actually only a 32-bit inst.
JBE @@05
POP RDI
POP RSI
POP RBP
RET
}
this is how it's gonna go in the future, programmers will be obsolete
>if (inputnum == answernum);
can you make it more enterprise?
that'd be great
>if (inputnum == answernum);
>not a syntax error
Cfags WILL defend this
I know that feeling, I study twice as hard for my cs classes simply because I want to get it over with.
It's got a niche in scientific computing, but other than that I'm not sure why. Might just be a marketing thing if anything.
> if (inputnum == answernum);
remove that semicolon. This is what your code means
if (inputnum == answernum)
{ //do nothing }
printf("right");
else //the printf above means the if clause ended so this else is not owned by an if
printf("wrong");