[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 41
File: 1334682645405.jpg (475 KB, 1024x1076) Image search: [Google]
1334682645405.jpg
475 KB, 1024x1076
Old /dpt/ at >>51474126

What are you working on?
>>
>>51477701
Is LISP dead?
>>
second for C master race
>>
>>51477701
ThirD
>>
Friendly reminder that OOP is cancer and the only things worse than object-oriented programming are object-oriented languages.
>>
File: 1430853197680.png (331 KB, 474x432) Image search: [Google]
1430853197680.png
331 KB, 474x432
>>51477782
nice meme!
>>
File: jcexceptions.png (40 KB, 623x368) Image search: [Google]
jcexceptions.png
40 KB, 623x368
>>
File: raii.png (41 KB, 649x365) Image search: [Google]
raii.png
41 KB, 649x365
>>
File: 1447124961854.jpg (58 KB, 500x581) Image search: [Google]
1447124961854.jpg
58 KB, 500x581
C is fun to write, but fuck, everything take so much longer.
A simple codeeval solution written in C is more than 100 lines of code.
>>
>>51477934
That's a stupid thing to say.
>>
>>51477893
I try to avoid exceptions altogether
>>
I need to make a json file that is created by a GUI editor.

should I use C# or java?
>>
>>51477959
What platforms does it need to run on?
>>
>>51477893
At least he acknowledges based Scott Meyer.
>>
>>51477939
What kind of codeeval solutions are you writing that are 100 lines of code, anon?
>>
>>51477966
mostly windows and linux.

I'm planning on doing a 2D fighter but I need also to make a character editor and a separated player executable.

Maybe I'll make the player using SFML, but I need an editor that makes a json file.
>>
>>51477939
I don't think I've ever gone over 100 lines with C.
Maybe a few times
>>
>>51477939
Git gud
>>
>>51477939
#include <stdio.h>

#define MAX_BYTE 512
int main (int argc, char *argv[])
{
if (argc == 2)
{
FILE *file;
if ((file = fopen(argv[1], "r")) == NULL)
{
printf("Couldn't open file.\n");
return -1;
}
else
{
char buffer[MAX_BYTE] = {0};
char *ptr;
while(fgets(buffer, MAX_BYTE, file) != 0)
{
ptr = &buffer[MAX_BYTE-1];
while(ptr != buffer)
{
ptr--;
while(*ptr != '\n' && *ptr != ' ')
ptr--;
for(*ptr = 0; (ptr != &buffer[0]) && (*(ptr-1) != ' ');)
ptr--;
printf("%s", ptr);
if(ptr != &buffer[0])
putchar(' ');
}
putchar('\n');
}
fclose(file);
return 0;
}
}
else
{
printf("Incorrect usage. Program takes filename as argument.\n");
return -1;
}
}

r8 my word reverser, anon
>>
>>51478006
Well, cross platform UI is a bit better on Java. But the language and tooling for C# in general is much better.
>>
>>51478064
You could clean up those if-else statements
Just use one if statement for checking argc and one for opening the file
>>
>>51478064
>uses fgets
>still checks for newline
why
>>
>>51478064
I can't even read that.
Mine doesn't look much better.
void reverse_line(char *buf, unsigned len)
{
char array[200][200];
unsigned i = 0;
unsigned trv = 0;
while (sscanf(buf + trv, "%s", array[i]) && trv < len)
{
strncpy(array[i], array[i], strlen(array[i])); /* get rid of newlines */
trv += strlen(array[i]) + 1; /* traverse next word + space */
i++;
}
while (0 < i--)
{
printf("%s", array[i]);
if (i == 0)
printf("%c", '\n');
else
printf(" ");
}
}
>>
>>51478092
fgets leaves the newline in, you know.
>>
>>51478114
BTFO
T
F
O
>>
>>51478064
>>51478103
wait this is code for reversing the line?
>>
>>51478142
Reversing the word order of the line.
>>
>>51477934
I dislike the things Blow says (mostly to do with his dismissal of "big idea" languages and type theory) but at least he is doing something instead of just bitching.
>>
>>51478103
>printf("%c", '\n');
>>
>>51477939
Does codeeval have a score for "programmer time" in addition to "CPU time"? If not, it should.
>>
>>51478159
So why are none of you using strtok?
>>
I'm trying C# and Python
>>
#import math
code = 114688837778579513684337030346042655818
def is_prime(n):
for i in range(2, n):
if n%i == 0:
return False
return True
llimit = 1000000
mlimit = 9999999
while llimit < mlimit:
for i in range(llimit, llimit+999, 2):
if is_prime(i) == True:
if i%code == 0:
print i
break
else:
continue
print 'incremented '+str(llimit)+' to '+str(llimit+999)
llimit = llimit + 999
>>
File: 1428353052866.jpg (282 KB, 1000x1000) Image search: [Google]
1428353052866.jpg
282 KB, 1000x1000
>>51478198
>including anything but stdio.h
>>
Im writing a 4chan thread image downloader. In C.
Fun times.
>>
>>51478189
There's no point in enforcing that because you could just copy paste your solution from your editor and claim it took you 2 seconds to write the code.

Is it bad that that reverse words challenge tooke me like an hour?

>>51478198
I didn't know that was an option, even.
>>
>>51478229
trying to crack a bios password for a sony vaio, no proof of purchase and the s/n last 7 digit thing didn't work.
>>
>>51478229
if n%i == 0

should be
if n%i == 0 && n != i
>>
>>51478226
Why Python?

Do you want to be a shit programmer?
>>
>>51478064
>nested loops
Kek, C programmers are so fucking awful. Why would you make your solution O(n^2) instead of finding a faster way?
>>
>>51478239
don't feel bad, i spent at least that amount of time on a way to find lowest unique number
>>
I understand that Java syntax is retarded and I fully see why, but I am worried because I have an easier time reading Java than most anything else. Does this mean I am retarded?
>>
File: asem.png (66 KB, 1344x658) Image search: [Google]
asem.png
66 KB, 1344x658
I really don't understand. Any ASM tutorials you guys could suggest?
>>
best C# GUI linux library pls?
>>
>>51478346
sometimes instructors take problems from books verbatim, so if you google a unique sentence from the problem, you can find someone's solution
>>
>>51478346
>yfw this indian has been posting his homework on /dpt/ since September
>>
>>51478369
GTK+
>>
>>51478338
No, Java is just the opposite of Perl.
Nice to read but shit to write.
>>
>>51478369
>c# on linux
you should be shot
>>
>>51478270
ty
>>
>>51478346

I can give you details. I'm writing this message to let you know that I'm currently typing up how you would go about doing this. Wait just a bit (I'm finishing up my dinner atm).
>>
>>51478239
>Is it bad that that reverse words challenge tooke me like an hour?

I dunno, how long do you think it would take in Python?
>>
>>51478164
>dismissal of type theory
This I gotta see.
>>
>>51478424
What's wrong anon :^)?
>>
>>51478424
>you should hate a good language because the guys who made it worked at microsoft
full fedora m8

do you also believe in the illoominati and the NWO

top kuck
>>
>>51477934
How does C++ discourage RAII?
>>
>>51478443
It would take me a day, I'm not familiar with python's string libraries.
>>
>>51478443
' '.join(line.split(' ')[::-1])
or something
>>
>>51478424
better than Java. then again Vala exists and it's pretty much the same as C#.
>>51478449
>>51478164
his objection was pretty much
>games aren't academia
>safety doesn't matter in games
>i need speed (apparently he doesn't understand how good use of type theory can improve speed but w/e)
to be fair, his language is a huge improvement over C and it has some ideas worth pursuing in future languages. i'd still probably end up using Rust if i had to pick between the two, though
>>
>>51478452
good goy
>>
>>51478369
this >>51478424 >>51478525
I'd never use your shit in linux.
>>
what is jonathan blow's language called? i hope it's not called "jonathan blow's programming language"
>>
>>51478547
jai
>>
>>51478496
And the rest of the program is `import sys; for line in open(sys.argv[1]): print`
>>
>>51478547
all we know is the compiler is called "JAI" so people have started calling it that. it hasn't been confirmed by him AFAIK
>>
>>51478524
Well, the language I'm developing is based on type theory with dependent and linear types and the prototypical use case is for games/simulators. So we'll see how it fares against Blow's language.
>>
>>51478543
Why? C# is a great language. Why not use it on linux?
>>
>>51478577
cuz mono bad xd
>>
>>51478575
Good luck with that. You basing it on "Dependent types for low level programming"?
>>
>>51478577
why do I care if C# is a great language? it's tied to microsoft, more than enough reason not to, ever, use it.
>>
File: image001.jpg (124 KB, 480x320) Image search: [Google]
image001.jpg
124 KB, 480x320
>C#
>ever
even fucking Swift is better
>>
File: 1201395060095.jpg (7 KB, 158x183) Image search: [Google]
1201395060095.jpg
7 KB, 158x183
>>51478607
>>
>>51478607
Why is that any reason not to use it?
>>
>>51478632
Freetards won't use a language unless it's poorly specified, riddled with undefined behavior, and implemented by several competing organizations.
>>
what would be better, using libgit2 or wrapping process calls to git itself? i know how to use git but libgit2 is alien and confusing. c apis are always fucking garbage too and the api reference for libgit2 is easily the worst i've ever seen. what benefit does it have over just wrapping git processes?
>>
File: 1444987352105s.jpg (3 KB, 125x125) Image search: [Google]
1444987352105s.jpg
3 KB, 125x125
>>51478185
>>
>>51478597
It's mostly based on the material out there about linear capabilities, or rather that's what inspired me to augment your typical dependent type theory with linearity.

As far as I know, the approach I've taken is novel. The only other decent material on combining dependent and linear type theories I've seen just doesn't even make an attempt and does it modally, so you can either be working with dependent types or linear types but not both at the same time.
>>
>>51478575
by the way, is it eager/strict or lazy by default?
>>
Who /Allman/ here?
>>
>>51478663
>calling git from c

Why not write a shell script instead?
>>
>>51478346

Okay, same guy as >>51478431.

This question is asking you to process a single array (dunno if the array is of type SBYTE, SWORD, SDWORD or etc), but I'm going to imagine it's of type sbyte to keep things simple.

When writing this program, there is only ONE question you need to ask yourself (in the program) and depending if it's true, you should perform one loop with written tasks or another to process it. In order to process the array, ask this question: "Is the current number I'm looking at a positive or negative integer?"

IF it is positive, add the value into an array you'll make for yourself (since the question wants you to do so). And if it is NOT positive then it MUST be negative, so add that negative number to a different array. You're basically sorting these numbers into two piles, one being positive and the other negative.

Use a loop to go through the numbers and have it end when you get to the end of the array. Inside the loop you should have the decision structure for if the number is positive or negative. After making a decision, I suggest you write a procedure outside of your main procedure (like a function in C++) to separate the code and make it look a lot more clean and easy to understand.

I hope this helps. If you have any more questions, do ask.
>>
>>51478685
Strict. It's basically got the run time semantics of C, although it's not like ATS in that you have to write both a C program and the verification proofs separately. It's all-in-one.
>>
>>51478700
Sorry, but I have taste.
>>
>>51478660
Well meme'd
>>
>>51478563
b-but python is a shit language!!
>>
>>51478683
>The only other decent material on combining dependent and linear type theories I've seen just doesn't even make an attempt and does it modally, so you can either be working with dependent types or linear types but not both at the same time.
>>
>>51478660
>Freetards won't use a language

>>51478543
>I'd never use your shit in linux.

/dpt/
>>
>>51478703
well my program requires a little more than just calling into git, the git part is only a small part.
>>
>>51478739
It's not as bad as I just made it sound, but there's basically two separate type theories and you have to switch between them with special decorator expressions.

Mine integrates the two seamlessly, though I haven't put any effort into formally proving that it's sound. I'll save that for my masters thesis or something.
>>
>>51478346

Same as this guy >>51478705

One more thing I forgot to mention (dunno if you knew this or not), but the section where it says .DATA is where you list your variables, such as this:

"number1 BYTE 1"

"number1" is just the name of the array. "BYTE" is the type of array, and the 1 after BYTE is the actual content inside the array.

Under "main proc" is where you write your code/instructions.
>>
Can someone please recommend me a good beginners book or some resources on T-SQL?

I am completely overwhelmed trying to figure out where to start.
>>
>>51478543
I'd be careful to use any C# crap on any platform.
99% of software written in it is complete shit by people who just learned how to program.
>>
>>51478771
Good luck anon. I know almost nothing about type theory, but I'm sure there is a HUGE incompatibility here, else it would have been already proven. It would be too sweet to be true
>>
Thinking on buying SICP and 'The C programming language" but god damn they're expensive.

However you can easily find both in pdf version but having the physical book is just better. Is it worth it?
>>
>Get a job
>Alright this should be great
>No documentation to get familar with the system
>No comments in the code
>Code is not self documenting
>Duplicate data fucking everywhere
>Different access methods for every application some with 3 different access methods in the same app
>IIS servers hosted with only self signed certs despite working with important data
>Views with thousands of case statements in them
>Web pages that only work on IE 7-9 and chrome

What's the worst place you ever worked at code wise?

And should I even bother with a resignation letter or just not show back up?
>>
>>51478806
>99% of software written in it is complete shit by people who just learned how to program.
That's the same for pretty much every language.
>>
>>51478834
Read a few chapters of the pdfs to see if it is worth it.
>>
>>51478830
>It would be too sweet to be true
I've been thinking that too. I mean, I'm just an undergrad student, mostly self-taught, especially when it comes to advanced topics like category and type theory. But so far, everything has come together beautifully.
>>
>>51478853
>implying
It is true for other noob languages like VB or Python.
>>
>>51478845
>>IIS servers hosted with only self signed certs despite working with important data
nothing wrong with self-signed certs.
>>
>>51478198
>strtok
Never used it before. So I looked it up,
#include <stdio.h>
#include <string.h>

int main ()
{
char str[] ="- This, a sample string.";
char * pch;
printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str," ,.-");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " ,.-");
}
return 0;
}

Good mother Mary...
>>
>>51478855
A big reason why I want them is because they are THE books.
>>
File: wasd.png (70 KB, 1572x530) Image search: [Google]
wasd.png
70 KB, 1572x530
About to order a custom WASD keyboard. I modified the default german layout to be more programming friendly. (Removed umlauts and moved common programming characters like curly braces onto the free space away from alt-gr)
What do you think?
>>
>>51478862
Intuition is quite important. You might not be able to formally prove the correctness (yet), but nothing is stopping you from "smelling" that there is something there.
>>
>>51478915
Might aswell get TAOCP and Concrete Mathematics too then if you want to fill your bookshelf.
>>
>>51478845
Just update their Adobe Reader and get moneyz.
>>
>>51478834
Used K&R is pretty cheap.
>>
>>51477934
What is the talking about RAII is literally 90% of the reason why it's useful.
>>
>>51478766
Mind explaining? It might be something that git can already do with some obscure command or option.
>>
File: 1367710994437.gif (2 MB, 640x272) Image search: [Google]
1367710994437.gif
2 MB, 640x272
>>51478965
>TFW I don't have permission to update or install anything

>TFW have to test outside of debugging by requesting a promotion to test and then testing my development work in Test

Hahahahaha
>>
File: Space-cadet.jpg (1 MB, 2001x773) Image search: [Google]
Space-cadet.jpg
1 MB, 2001x773
>>51478942
Don't forget the hyper and meta keys.
>>
>>51478969
those are all the nasty made in india international edition printed on literal toilet tissue
>>
>>51479011
Cool, where can I get one?
>>
>>51479011
why doesn't it have dedicated keys for parenthesis?
>>
How do I gain access to a massive distributed network to grow a Skynet AI?
>>
>>51479043
Get hired by Google
>>
>>51479033
Not everyone writes in Lisp anon
>>
>>51478983
i'm just making a dumb github clone for fun (to see if I can ... i probably wont be able to) and i need to do things like initialise new repositories.
>>
>>51479062
But it is for lisp machines
>>
>>51479062
>keyboard from a lisp machine
>not made for writing lisp
>>
>>51479053
I tried, they said I was underqualified and called me a madman.
>>
why is C# wrong?

it's not like you can't use the open source implementations.

if you don't want to use the open source implementations and still use microsoft as a legitimate argument, i pity you.

good goy m8
>>
>>51478229
>calculating all primes every time
>range(2,n) instead of range(2, ceil(sqrt(n)))
del self
>>
>>51479092
why is flash wrong?

it's not like you can't use ope source implementations

if you don't want to use the open source implementations and still use adobe as a legitimate argument, i pity you.

good goy m8
>>
>>51479080
>>51479082
Well don't I just look dumb now
>>
>>51479114
what's wrong with using the open source clone of propietary software?

you can't go full free software on non free hardware.

this is why ideologies are fucking stupid.

I'm sure you're using some non free software on your broswer or other shit on some server just to post that.

hypocrit
>>
>>51479138
>what's wrong with using the open source clone of propietary software?
have you used them? they're shit
>>
>>51479043
amazon gives you "free" credit for going to their conferences
>>
>>51479114
>why is flash wrong?
because you need a shitty plugin

>>51479146
mono is not bad desu senpai
>>
>>51479015
Not all of them. You just have to be careful.
>>
the actionscript virtual machine is open-source, though
>>
>>51479033
What do you mean? They're right beside the p and they don't need the shift key unlike normal keyboards (sadly).
>>
>>51479146
It's a waste of time to go full freetard today, just to use the internet I'm sure you'll need to use a non propietary software.
>>
>>51479160
The only good thing about mono is that it let's a kissless virgin like myself feel what it's like to have mono.
>>
>>51479162
Is it worth having a physical copy even?
I know I'm just gonna keep it on my shelf and I've already read through it like 3 times now.
>>
>>51479186
Oh indeed, the additional parenthesis in the usual place confused me.
>>
>>51478023
My average per file is also pretty low
$ for i in $(find -name "*.c" | grep -v 'pregen\|lodepng\|out.c'); do wc -l $i; done | awk 'BEGIN {sum = 0; n = 0} {sum += $1; n+=1} END {print "Average: ", sum/n, "Total: ", sum, "Items: ", n}'
Average: 122.503 Total: 18743 Items: 153

excluded some autogenerated files and lodepng
>>
>>51479206
That's up to you. If you have the money then it might be worth the $15 for a reference book.
>>
what do i put in my PATH variable to get mingw-w64 and g++ working in cmd prompt? I've tried mingw-w64/some bullshit/mingw64/bin but it's not working.
>>
>>51478232
>stdint
>stdlib
>string
>>
>>51478780

I appreciate it, but I'm still confused.

        .orig    x3000
and r2,r2,0
lea r3,file
in
ldr r1,r3,0
loop
add r4,r1,-4
brz enddata
not r1,r1
add r1,r1,1
add r1,r1,r0
brnp next
add r2,r2,1
next
add r3,r3,1
ldr r1,r3,0
br loop
enddata
ld r0,char
add r0,r0,r2
out
halt

char .fill x0030
x .blkw 1
file .stringz "abcxdefabef"
eot .fill x0004
.end


Here's a program I found that counts the number of instances of "x" in a string. I'm working around this for my application, but beyond the first few and last few lines, I'm lost.

        .orig    x3000 ;starting address
and r2,r2,0 ;init r2 = 0, used to count instances
lea r3,file ;init r3 = the string
in
ldr r1,r3,0
loop
add r4,r1,-4
brz enddata
not r1,r1
add r1,r1,1
add r1,r1,r0
brnp next
add r2,r2,1 ;increment r2
next
add r3,r3,1
ldr r1,r3,0
br loop
enddata
ld r0,char
add r0,r0,r2
out
halt

char .fill x0030
x .blkw 1 ;char x
file .stringz "abcxdefabef" ;string to check
eot .fill x0004
.end


Besides commented code, ???
>>
>>51478232
>being unable to malloc
>>
>>51479336
C:\Mingw64\bin does it for me. Make sure you got the right path.
>>
>>51479375
>using malloc
>codeeval

but your score will be shit
>>
>>51478845
>everything in PHP or Perl
>no test coverage
>dev servers were in Sydney, I had to ssh and use vi to edit the code
>100+ ms latency on every keystroke
>no comments
>unreadable perl, thankfully most of the app was in php
>every PHP class extended "General"
>no one knew what "General" actually did
>70% of the engineers were offshore in India and were very poor communicators
>no QA, no code reviews, developers pushed code straight to production
>>
>>51479381
Yeah that was working for me before but I've had to switch to mingw-w64 due to a bug with string conversions, I'll keep trying though. They provide a .bat file that works but i'm trying to get it working for convenience's sake.
>>
>>
>>51479336
Why the hell do you want to use cmd? Just use minTTY that comes with mingw.
>>
>>51478915
>THE books
They're are literally dozens of better software books out they're today than these old, outdated works. They're both memes.

K&R is a good meme because DMR, but memetheless, yea no.
>>
>>51477782
>OOP is cancer

Not really.
>>
>>51479276
fine

i actually had an international edition of K&R for a while, but it leaked this nasty smell whenever I opened it so I never read it
>>
>>51479474
So you're saying that SICP and K&R are just memes because they have old concepts?
>>
>>51478873
>implying 99% of all C ever written isn't 'my first fizzbuzz'
>>
>>51479522
Amend that to old, shitty concepts and yes.
>>
>>51479474
>old, outdated works
K&R teaches you more in 200 pages than those modern 1000+ page bloated textbooks with pack-in CD-ROMS.
>>
>>51479529
nice meming

wonder when you would show up after all the c# bashing itt
>>
>>51479542
>CD-ROMS
>modern book
>>
>>51479522
You can definitely learn from K&R so long as it's not your absolute first introduction to programming.

SICP is a meme.
>>
>>51479551
pack-in DVDs.
>>
>>51479548

I just got home, m8.

>nice meming

It's true. When we're talking about languages that get pushed as 'my first language', then there's no doubt that the lions share of code written is going to be newbie exercises.

The same goes for any popular language.
>>
>>51479581
>implying you're ever allowed to leave your Indian call center
>>
File: watamote; tired.jpg (39 KB, 998x720) Image search: [Google]
watamote; tired.jpg
39 KB, 998x720
Need some C++ help. I'm making a calculator that will take multiple numbers and operators.

I've been trying to figure out how to fix a bug where if I put the equal sign right after an operator, I get no answer.

Ex: 2 + 2 + 8 + =

int main()
{
double lnum = 0;
double rnum = 0;

cin >> lnum;
for(char oper; cin >> oper;)
{
if(oper == '+' || oper == '-' || oper == '*' || oper == '/')
{
cin >> rnum;
switch(oper)
{
case '+':
lnum += rnum;
break;
case '-':
lnum -= rnum;
break;
case '*':
lnum *= rnum;
break;
case '/':
lnum /= rnum;
break;
}
}
else if(oper == '=')
{
cout << "Answer: " << lnum;
return 0;
}
}
}
>>
>>51479598

I leave whenever I want.

t. Rama S. Radhakrishnan
>>
>>51479604
Well the way you are doing it right now won't work because it can't respect order of operation. If you re-implement and use a different algo you can cover that and will probably fix your issue.
>>
>>51479604
Delete the whole thing and rewrite using fgets() and strtok().
>>
Facts:
>K&R is outdated
>SICP is not a meme
>Java encourages bad code because it lacks free functions.
>c++ > c
>vim >= emacs > everything else
>Go is a meme
>Python and ruby are garbage
>webdev is for retards
>People who create getters/setters for every private variable dont understand OOP and are shit coders
>Indians need to get out of tech
>>
best C++ GUI library?
>>
>>51479644
Oh, alright. Thanks. Guess I'll be learning about tokens then.
>>
>>51479677
p. accurate except the zed shaw-tier k&r opinion
>>
>>51479677
please senpai, you're memeing too hard
>>
>>51479677
>vim >= emacs > everything else
Vim is better for entering and manipulating text
Emacs is better for a holistic programming experience
>>
>>51479694
qt probably
>>
>>51479677
>Java encourages bad code because it lacks free functions.

Truly irrelevant. For all the terrible things that Java does, this is low on the shitlist.
>>
>>51479677
>I'm le edgy elitist programmer
>>
>go to used book store
>find programming section
>all the books are for dummies-tier shit, or 1990s era references for things like java and perl

I can never find any of the meme books /g/ likes
>>
>>51479023
they're like $10,000 and only available at auctions
>>
>>51479786
>used book store

Of course not, what kind of monster would sell their SICP?
>>
>>51478942
>German keyboard
>Removed german characters
Why not just get a default US layout then?
>>
>>51479820
SICP 1st edition is pretty easy to find anywhere
they're like $5 at any online bookseller.
1st edition K&Rs are also equally worthless
>>
File: emag__eht.png (180 KB, 1366x768) Image search: [Google]
emag__eht.png
180 KB, 1366x768
I tried to separate my code but I'm retarded.
Is this even possible?
...
Also is there any better way to scrape info from websites like this?
>>
>>51479877
use strtok
>>
>>51479897
>use strtok
;_;
>>
>>51479897
>>51479947
You could implement your own strtok like what I did in >>51478103.

Just traverse an array and look for strings manually.
>>
>>51479110
Returns a float.
import math
code = 114688837778579513684337030346042655818
def is_prime(n):
# for i in range(2, n):
for i in range(2, math.ceil(math.sqrt(n))):
if n%i == 0:
return False
return True
#llimit = 1000000
llimit = 1722277
mlimit = 9999999
while llimit < mlimit:
for i in range(llimit, llimit+999, 2):
if is_prime(i) == True:
if i%code == 0:
print i
break
else:
continue
print 'incremented '+str(llimit)+' to '+str(llimit+999)
llimit = llimit + 999

>>
>>51478288
>nested loops are always O(n^2)

confirmed for not understanding Big O notation
>>
>>51479110
changed to range(2, int(math.ceil(math.sqrt(n))))
so much quicker
>>
>>51479992>>51479947>>51479897>>51479877
that is python, people
>>
>>51480035
Ai AI donkey faggot
>>
>>51480102
jjust use it through ctypes
>>
keks
>>
File: 1429250603669.png (84 KB, 1000x1000) Image search: [Google]
1429250603669.png
84 KB, 1000x1000
>>51479897
>people recommending strtok when ip_address isn't even in scope
>>
FAGGOTS
>>
File: IMG_20151122_185216_2.png (750 KB, 717x550) Image search: [Google]
IMG_20151122_185216_2.png
750 KB, 717x550
I'm not asking anyone to do my homework, just give me a hint or something. I'm stuck as fuck right now. Pic related is my assignment, on the left is what it should do, on the right is what I have written so far. Sorry for the quality, best I can do right now. Thanks
>>
>>51480243
Ask cortana
>>
>>51480243
rewrite it in C
>>
>>51480243
Ask a classmate to use his working code
>>
File: JUST FUCK.jpg (7 KB, 250x250) Image search: [Google]
JUST FUCK.jpg
7 KB, 250x250
>I left all my assignments until the day before they were due again
when will I fucking learn my lesson
>>
File: 14482121463530.jpg (1 MB, 2310x2306) Image search: [Google]
14482121463530.jpg
1 MB, 2310x2306
Does essential /g/'s programming book list img exists? Can't find it, found only sci's wiki guide.
>>
>>51480329
There's a lot of Russian ones on there, is /sci/ bilingual?
>>
>>51480329
what the fuck is with all the russian books

https://wiki.installgentoo.com/index.php/Programming_Books
http://g.sicp.me/books/
>>
>>51477701
What's a good gui builder for c++. Cross plat is a must
>>
File: Python-Icon.png (2 KB, 48x48) Image search: [Google]
Python-Icon.png
2 KB, 48x48
>>51480243
learn to take screenshots
also
>printing with list comprehension
>>
>>51478834
Didn't paperback SICP used to cost $10?

Just checked and MIT press is selling for $50, what the fuck?
>>
>>51480386

Qt
>>
>>51480383
Because it's from 2ch's /pr/, dummy.
>>
>>51480410
>what the fuck?

unabated Judaism.
>>
File: WP_20151122_20_12_10_Raw.jpg (1 MB, 2592x1936) Image search: [Google]
WP_20151122_20_12_10_Raw.jpg
1 MB, 2592x1936
Comfy Sunday night studying
>>
>>51480390
I'm at work and trying to do this in my truck, the service around here isn't good enough for my phone to provide internet so I can post with my laptop.
>>
>>51480454
>not a real gun

May as well not even post it.
>>
File: C.png (136 KB, 2000x2126) Image search: [Google]
C.png
136 KB, 2000x2126
>>
File: 1442106773709.jpg (95 KB, 1280x720) Image search: [Google]
1442106773709.jpg
95 KB, 1280x720
Just started learning webdev, am I doing a good job?

codepen.io/anon/pen/QjPopO
>>
Tell me about PHP.
Is it the true redpill non-meme webdev language?
>>
File: 1445732905653.jpg (418 KB, 768x768) Image search: [Google]
1445732905653.jpg
418 KB, 768x768
Couple questions:
struct history_st& history()
{
static struct history_st globalhistory;
return globalhistory;
}

int main(void)
{
struct history_st* history = history();
}
// Produces error: 'history' cannot be used as a function.


Ok maybe it's because I'm using a variable with the same name as the function? Can the compiler really not figure that out, if not why the hell not? I go with my intuition and change history to "history1". This seems to work but then I get:

error: cannot convert 'history_st' to 'history_st*' in initialization


Well why the hell wouldn't this work? A pointer to a reference is normally completely fine correct? Such as:

//This is perfectly legal!
int var = 5;
int *p_var = &var;


So finally I change the code to the below piece, and all is well. It compiles fine and I presume it works how I want. However doesn't history() return a reference to a history_st structure? I thought references were supposed to refer to actual objects, but I guess they work on other references too? Take for example this:
int my_reference = 5;
int &alias1 = my_reference; //this is ok and makes sense
int &alias2 = alias1; // does this also refer to my_reference?


// Final working code, compiles.
struct history_st& history()
{
static struct history_st globalhistory;
return globalhistory;
}

int main(void)
{
struct history_st& history1 = history();
}


Cheers and thanks for any clarifications.
>>
>>51480549
there is literally not a single worse language than PHP

it is literally preferable to web dev in assembly to writing PHP
>>
File: anon's homework.png (3 KB, 183x255) Image search: [Google]
anon's homework.png
3 KB, 183x255
>>51480243
def buildList(list):
list = []
i = 1
while True:
item = input("Enter item #%d" % i)
if item == "QUIT":
break
list.append(item)
i += 1
return list

def listPrint(list):
size = len(list)
print("Printing list of size %d" % size)
for i in range(0, size):
print("%d: %s" % (i, list[i]))

def listPut(list, n, item):
list[n] = item
>>
>>51480584
literally this
>>
>>51478023
Confirmed for never written anything past fizzbuzz.
>>
>>51480626
font in pic?
>>
>>51480549
PHP is not a programming language, please do not call it that
>>
>>51480626
Oh, and the image you posted doesn't specify what the behavior should be if
n >= len(list)
, so I just let it use the default behavior (throwing an error).

>>51480639
Terminus, 12px.
>>
>>51480576
References aren't like pointers. Taking the reference of a reference just gets you another reference to the object, since you can't reassign a reference.

Also, in C++ you don't need to use "struct history_st" except when declaring. Just "history_st".
>>
File: 1448146787938.jpg (69 KB, 640x400) Image search: [Google]
1448146787938.jpg
69 KB, 640x400
>>51480626
"Anon's homework.jpg" kek.

Thanks senpai, a little more help than I wanted but you're still the fucking best.
>>
>>51480576
>>51480670
Oh, and I can see you're getting confused about the dual use of the & operator. When applied to a type, it means "reference to type". When applied to a variable, it's the same as C and it gets the address of the variable.
>>
>>51480626
the 0 in in range is kinda superfluous don't you think?
>>
>>51479160
>because you need a shitty plugin
Well, i need a shitty VM to run C#.
>>
>>51480746
C# is shit so it checks out
>>
>>51480746
same for java

and actually, mono has AOT.
>>
>>51479558
Why SICP meme? Because of lisp?
>>
>>51480534
>>51480549
>>>/g/wdg
>>
>>51480689
I know, I shouldn't have just given you the code but I wasn't sure where to start (no offense)

Here's a few things to note:

* The conditions for while/for/etc statements don't need parentheses around them like in C
* The example output shows that you're supposed to prompt the user for each item, which you can do by passing a string into the input() function.
* Instead of repeating the input assignment to v twice (once at the beginning of the function and once per loop), it might be preferable assign v a default value (like ""), and then loop "forever" (while True), and break the loop when you encounter a "QUIT" message.
* The listPrint function is just supposed to print the list, not build one, so you shouldn't call buildList at the start. Also, "el" is only in scope for the definition of buildList, so that code wouldn't work in any case.
* Instead of writing x = x + 1, you can write x += 1. You can do this same sort of thing with other operators like - and *.
* I have no idea what you were attempting to do with while (x != buildList(el)). Again, el is not in scope, and you don't want to rebuild the list. At all.
* I don't know what you thought putting code inside brackets would do, but it doesn't make sense. Also, that's not the way for..in loops work. You'd have to write
for x in k:
print(x)

But the example output shows that you need to print the index you're at, so you need to get the length of the list, and then print and access each index.

If you haven't yet, take a look at Learn Python the Hard Way (an online Python book). It's a good tutorial that might help you.
>>
>>51480735
Ah, you're right, I don't use Python and was just looking up the syntax to help anon. Didn't realize you could use range on a single operand.
>>
File: NoFace.jpg (25 KB, 200x301) Image search: [Google]
NoFace.jpg
25 KB, 200x301
>>51478378
>yfw he is going to stop for 1 month and restart posting the same shit from Jan since he will retake that class
>>
>>51480830
* single numeric operand
>>
>>51480243
learn to type "how to take a screenshot" in google first
>>
File: image.png (368 KB, 1918x1038) Image search: [Google]
image.png
368 KB, 1918x1038
>>51480848
i made a 4chan thread saver.
pic is the result
>>
>>51480921
post her nudes already
>>
>>51479604
Since you're basically defining a syntax here, I think you need to add some kind of error checking. Otherwise it's going to be very fragile.

Using strtok, as anon suggested, might be a good idea. Another option might be to write a small parser for your syntax. The parser would be able to do the error checking.
>>
anyone else did this to a friend's code to watch him suffer?
#define > >=
#define < <=
#define == <=
#define true ((rand()&20)!=15)
#define false (!true)
#define float int
>>
>>51480815
Yea, those things you were saying you have no idea what they were for. I didn't either. I couldn't get anything I had tried in the beginning to work and eventually just started guessing and looking stuff we hadn't even learned yet online which was a mistake. But I'll definitely look that book up over this break that's about to begin. Thanks again bro.
>>
>>51480962
wat. thats not my thread
>>
>>51478378
please post links
>>
File: Anonymous.jpg (60 KB, 780x439) Image search: [Google]
Anonymous.jpg
60 KB, 780x439
>>51480991
I know, but did op deliver on that very thread? I assume not.
>>
Give me something to do
>>
>>51480983
can't do that.

but the best is replacing while with if
>>
>>51481010
>>>/b/653340116
>>
File: vim-editor.png (6 KB, 528x528) Image search: [Google]
vim-editor.png
6 KB, 528x528
I'm looking to get started with programming in C++.

I have a book I'm following and it gives recommendations on some compilers and other things needed for a C++ programming environment in Unix-Linux.

Just wanted to see if anyone here maybe had a graphic, or recommendations, for some essential programming environment software.
>>
Hey /g/ I'm a total noob to computers but very interested in programing and just on how to get really good at computer use. Where do i begging?
>>
>>51481047
>essential programming environment
Literally a Linux distro. Including Cygwin.
>>
>>51480983
That's pleb tier, in Forth you can redefine numbers if you want:
: 1 2 ; 
1 1 + cr .
4 ok
>>
>>51478378
please do the needful
>>
File: Borat.jpg (19 KB, 232x300) Image search: [Google]
Borat.jpg
19 KB, 232x300
>>51481041
>>
>>51480921
Why are you telling me?
>>
>>51481110
accident lol
>>
Working on a C project I have to do with 3 other classmates.
>probably gonna end up doing the whole thing alone cause they dgaf and cause I ccb to go and motivate them
>also it's easier to program alone cause noone is slowing you down
>>
>>51477723
It is dead for /G/
>>
>>51481064
based forth
the ultimate expressive language
Thread replies: 255
Thread images: 41

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.