[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
/dpt/ - 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: 49
Who fuckin' knows where the last thread was.

What are you working on?
>>
>>53960084
first for C#
>>
>>53960084
it got deleted by the janitor because he didn't delete the shitposts, so the entire thread was consumed by them. watch him not delete any shitposts in this thread either.

how do i into java references? i'm reading the website on it but i'm not very good at reading documentation. how do i make main create a queue, then pass that queue to a function foobar by reference? thanks for doing my homework for me dpt i know i can count on you
>>
>>53960115
bar the foo to the formainbar
>>
File: 1458269377205.png (99 KB, 260x244) Image search: [Google]
1458269377205.png
99 KB, 260x244
>tfw all the strings in your C program had their null terminators overwritten and we're sitting next to each other in memory and the program only worked through stupid dumb luck, but only on my machine
>>
>>53960064

Wow, thanks. This actually sped up the program by so many factors.

So the LinkedList is only great if you intend to do a ton of removing and adding?
>>
>>53960200
Meant for >>53960037
>>
>>53960200
>bone up on data structures

all Lists are slower than all Arrays, because a list is ultimately going to be one of two things:

1: based on an array (but with a shitload of surrounding code) - slower because duh
2: based on disparate objects with pointer or pointer-like links (single/double) - slower because iteration

generally ArrayLists are slower than bare arrays but still MUCH faster than linked lists
>>
I'm trying to write to a file in java but for everything is asking me to catch the exceptions so if i create a file writer my file writer will be unreachable for the rest of the code, what the fuck am i doing wrong?
>>
>>53960144
I'm learning strings in C and they scare me atm desu senpai

is there any way I can trim the fat from them? e.g., if I declare a char array of 256, and i only take a 30 character string, is there a way to trim the array or somesuch
>>
>>53960316
Kek, looks like I got it backwards. Time to go around and change old projects.
>>
>>53960331
If dynamic, just add a null terminators and realloc.
If they're on the stack, just null terminate and forget.
>>
>reminder to the /pol/ shit posters that both sides are dissatisfied with the current state of affairs in America, however both choose to spend their time in recursive debates and attending rallys.
Only you can make America great again by developing your skills, working hard and achieving glory for God.

Thats what this thread is here to help with boys, keep your toes out of the mud.
>>
>>53960400

2nd american revolution when?
>>
>>53960200
>>53960292
So you have the right idea. The issue is that `.get()` always starts at the first node. You may be calling .get() on perfectly sequential integers but it doesn't know that, it assume the next .get() could have any argument. If you were to use an iterator (which is stateful and maintains a reference into the list) then that would be true (although on modern architectures arraylist access is almost always at little faster because of caching).

>So the LinkedList is only great if you intend to do a ton of removing and adding?
To be honest if you're in javaland then linked lists are almost never going to be of much use. The cool thing about singly linked lists is they support multiple heads and you can do cool things with immutability.
>>
>>53960317
You need to read up on Exceptions for writing to a file
>>
first for C++
>>
File: 1439184297147.jpg (111 KB, 777x499) Image search: [Google]
1439184297147.jpg
111 KB, 777x499
>>53960400
There won't be an America worth achieving glory for once the Liberals destroy it.
>>
>>53960440
There is literally nothing wrong with being a Liberal. Debt is imaginary it doesn't exist
>>
>>53960331
>if I declare a char array of 256, and i only take a 30 character string
The difference between 30 bytes of memory and 256 is insignificant and not worth your time. Resizable arrays are a solved problem, exponential reallocation mean you don't need to worry about this outside of embedded settings anymore.
>>
Is there a way to remove trailing 0s on integers with printf, without modifying the integer?
e.g. 1234 prints as 1234, but 5000 prints as 5
>>
>>53960464
Human concepts are very real if there is a will and force to defend it anon.
>>
File: ree.png (631 KB, 681x681) Image search: [Google]
ree.png
631 KB, 681x681
>>53960400
>>53960421
>>53960440
>>53960464
>>53960494
STOP POSTING THIS OFF-TOPIC SHIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIT
>>
How to save and load a list of numpy arrays to and from a file?
>>
>>53960484
>5000 prints as 5
No, you'll have to modify the integer or something.
>>
>>53960484

int n = 5000;

while(n != 0)
{
if(n % 10 == 0)
{
n / 10;
}
else
{
break;
}

}

>>
>>53960317
try(Writer f = blahblahblah) {
f.whatever(butts)
} catch(LazyProgrammerException e) {
die();
}
>>
>>53960494
Life is an illusion this isn't real
>>
File: titanoboa.jpg (182 KB, 1186x673) Image search: [Google]
titanoboa.jpg
182 KB, 1186x673
back on topic: why should we not allow snek's into our secret little club?
>>
>>53960317
You really do need to catch those exceptions. Java made the questionable decision of making a certain class of exceptions a compile-time error not to catch or declare to throw if their callee declares them as a potential to be thrown. It's sometimes a good way to make sure your dumbshit coworker/caller thinks about all the possible outcomes of the call but it also leads to some really stupid shit like noop catch-all clauses.
>>
File: BJARNEY.jpg (41 KB, 432x324) Image search: [Google]
BJARNEY.jpg
41 KB, 432x324
>>53960561
and as a follow up: why haven't we made /dpt/ an all out C++ master race thread?

/pol/ pollution is obviously bad, but all this java/haskell/python pleb pollution is sometimes worse.
>>
>>53960572
I'm on intellij idea and it's throwing an error and saying there is no try catch i don't remember this happening before though
>>
>>53960528
rate my code /g/ shit all over my code please
>>
>>53960606
Can you post the code in question?

>>53960614
It's alright at doing an obvious thing? Allman style is ugly and it's not particularly clever but it's nuts and bolts middle american code.
>>
>>53960757
I am Canadian
>>
>>53960757
It's the GoogleScraperDemo
http://jaunt-api.com/
and i added a FileWriter
>>
File: punished stroustrup c++.jpg (107 KB, 768x1024) Image search: [Google]
punished stroustrup c++.jpg
107 KB, 768x1024
>>53960598
stroustrup: a hero denied by his homeland
>>
>>53960084
don't associate rukia or bleach at all with /g/ autism
>>
 
public class App
{
public static void main( String[] args )
{
Foo f1 = new Foo();
doSomethingToFoo(f1);
System.out.println(f1.bar); //f1.bar is still 0
}

static void doSomethingToFoo(Foo f) {
f = new Foo();
f.bar = 99;
}

static class Foo {
int bar = 0;
}
}

how do i make f1.bar end up as 99? i can't have it be initialized globally and i need to change it in another method. this is java
>>
Why do you guys hate Java so much? Here at Oracle we are here to help you
>>
>>53960850
because its mainstream, here in /g/ the neets only like obscure shit and "harder" stuff
>>
>>53960840
You need to return an int, not a void
>>
>>53960877
i don't think i'm supposed to do it like that though. http://pastebin.com/ACYSrEec here's the pseudocode i got from the chapter, it's supposed to simulate people arriving at a bank
>>
>>53960840
add public to your int bar declaration of 0 in Foo class declaration.
>>
File: votingrepublican.jpg (59 KB, 800x600) Image search: [Google]
votingrepublican.jpg
59 KB, 800x600
>>53960440
>>
>>53960930
stop.
>>
>>53960930

go back to S4P where you belong.
>>
>>53960782
Have you explicitly imported the exception you're trying to catch?
>>
>>53960840
>static void doSomethingToFoo(Foo f) {
> f = new Foo();
> f.bar = 99;
> }
Literally just remove
> f = new Foo();
and it should work. Why would you create a new object there?
>>
File: howbad.jpg (179 KB, 898x600) Image search: [Google]
howbad.jpg
179 KB, 898x600
>>53960987
What i did was just right click "Add try... catch block"

Anybody user Jaunt-API?
How do i know if i had a successful login?
>>
>>53961031
>What i did was just right click "Add try... catch block"
Right, that's probably the issue. When you write
try {} catch(TYPE e) {}

`TYPE` needs to have been imported. Your editor probably added the logic to catch whatever exceptions FileWriter throws but didn't import the exceptions it's expecting to catch.
>>
>>53961108
Ok so, i'll import everything needed so i avoid the forced try catch blocks
>>
 Queue<Customer> q = new LinkedList<Customer>(); 


is this right in java? I want to have a queue of customers. I can use Queue outright can't I? i don't have to implement it myself?
>>
>>53961132
LinkedList implements Queue, so yes

it's in the docs :^)
>>
>>53961169
i aint got time for that shyt nigga
>>
>>53961131
No, you have to have to catch checked exceptions no matter what. But whenever you catch an exception, that exception must be imported. So you have to do two things: import the exception, and catch it.
>>
in python you can add only unique items in constant time using a set.

Is there a data structure that you can do this with in haskell?
>>
>>53961132
>all that code and ugly syntax for a queue
i feel sorry for you pajeet
>>
>>53960978
Shut the fuck up trip faggot. I belong here a lot more than you do.
>>
>>53961132
>I can use Queue outright can't I?
You can use Queue as the type but you can't use it as a concrete type because it's an interface (you can't instantiate interfaces, only implementations (also know as non-abstract classes in java))
>>
>>53961132
Yes. Queue is an interface, which just tells the compiler which methods work on it. On the doc page, you can see the list of classes that implement the Queue interface, each with advantages and disadvantages. LinkedList is a good choice.
>All Known Implementing Classes:
>AbstractQueue, ArrayBlockingQueue, ArrayDeque, ConcurrentLinkedDeque, ConcurrentLinkedQueue, DelayQueue, LinkedBlockingDeque, LinkedBlockingQueue, LinkedList, LinkedTransferQueue, PriorityBlockingQueue, PriorityQueue, SynchronousQueue
https://docs.oracle.com/javase/7/docs/api/java/util/Queue.html
>>
Alrighto- Do you guys know if there is a way or plug in to run XCode, or any way to program in Swift on a Linux OS?
>>
>>53961215
>Is there a data structure that you can do this with in haskell?
Data.Set supports either log(n) time or amortized linear time depending on who you ask.
>>
>>53961235

I highly doubt that you Sanders-loving socialist faggot.
>>
>>53960500
Object serialization. (c)pickle is great in python.
>>
>>53961270
Considering you're abusing the trip function like a fresh arrival I don't, you short fingered Drumpf-loving fascist faggot. Make sure to tag your next post with your trip code so everyone knows it's you.
>>
>>53961291
>you short fingered Drumpf-loving fascist faggot.

You've got it all wrong, my child.
>>
>>53961291
>>53961270

>leans back and starts eating popcorn
>>
>>53961215
how do python do dat
>>
>>53961249
alright, i think i see. thanks
>>
>>53961284
Thanks, but too late; got it with numpy.savez
>>
>>53961393
https://en.wikipedia.org/wiki/Hash_table#Sets
>>
>>53960084
Thank you for using an anime image.

To answer your question, a file server that implements TCP reliability over UDP & sends the client a file packet-by-packet.
>>
>>53961291
>Drumpf
dropped
>>
>>53961269
okay so haskell has sets too, they're just not in the preloaded modules, neat.
No set comprehensions, though, which is kinda sad.

>>53961393
the constant time (on average)?

sets are implemented as a hash table.
>>
>>53961434
tru
>>
>>53961411
which uses pickle at some point. Good idea to go w/ what the library uses though.
>>
>>53961438
Yes, he was.
>>
I heard that if I start wearing girl clothes I will really get better at programming. Is that true? I mean, I'm asking for a friend.
>>
>>53961535
lol
cnn at its finest
>>
>>53961554
It helps a pretty good amount, yeah.
>>
File: gurlcoding.jpg (226 KB, 869x1776) Image search: [Google]
gurlcoding.jpg
226 KB, 869x1776
>>53961554
You will end up like this though
Post pics as well ;)
>>
Could someone help me?
So I'm doing a future value calculator in C++
Equation is: F=C*(1+r)^n

I have doubles assigned for each variable and the final value is "double value = initial * pow((1+rate), periods);"

And I get a fucking retarded number at anything I enter like: 6.085e-310. Every fucking time. Same thing for two other equations I use for compounding interest and loan balance. I have no clue at this point.
>>
File: test.png (147 KB, 1920x1080) Image search: [Google]
test.png
147 KB, 1920x1080
>>53961673
here's a screenshot
>>
>>53961554
Yes. I ordered mine yesterday. If you're not a cute trap you're not even allowed to be a part of this thread.
>>
>>53961696
Your equation is using a ton of uninitialized values. You need to do the calculation after all of those values have been input.
>>
>>53961696
indent
>>
>>53961554
Yes, the more broken you are as a human being the better you'll do as a programmer. Which is not to say all cross dressers are broken people, but you are and this will make you more broken. So do it, sell your soul to the LBGT devil, and you'll have programming prowess beyond your wildest imaginings.
>>
>>53961755
I think I get what you mean I'll try that

>>53961761
I will later :-)
>>
>>53961768
Does being any part of LGBT make you a better programmer?
>>
>>53961696
>>53961755
This, just move the "balance = ..." line to after you read in all those values from cin and it'll work.
>>
File: 1437639281365.png (547 KB, 635x640) Image search: [Google]
1437639281365.png
547 KB, 635x640
>>53960144
pls post more anime girls with Dorito hairs I need it for my collection
>>
>>53961755
>>53961811
Yeah that fixed it. Much appreciated guys.
>>
how to pass no arguments to a function with at least one parameter in C++?
>>
>>53961903
i'm asking for pajeet.
>>
>>53961903
function(void)
>>
>>53960598
>want to be a C/C++ developer
>Everything around me is webshit or java or 10++years of experience in C or C++
JUST
FUCK
MY
SHIT
UP
>>
>>53961932
sorry, while also having the option to accept arguments. should i just overload it?
>>
>>53961950
yes or have a default parameter

void foo(int param = hard_coded_value) { }


for example
>>
>>53961967
>default parameter
don't know if i would have ever thought to do that myself, though it seems obvious now. cheers
>>
>>53961939
learn webshit. If you can learn C++ you can master a scriptlel language in half the time.
>>
is dpt usually this dead or...
>>
>>53962161
It's night time in burger land so no one is around to trap post, As a result, no one is around to argue said trap posting. Makes /dpt/ so much nicer.
>>
Posted in /fglt/ can anyone help

kind of a programming question as well
>>53962237
>>
>>53962208
Looks like the /pol/ shitposters went to bed too. Peace and quiet.
>>
Auditing my code against this:

https://github.com/TrustInSoft/tis-interpreter

If you have any level of autism about perfect code, this shit's for you.
>>
>>53962262
>Looks like the /pol/ shitposters went to bed too.

It'll never be that easy.
>>
>>53962260

Any particular reason you are using Bash?
>>
>>53962318
Because I suck at everything else in life.
>>
>>53962318
*Powershell: Linux Edition

Bash shouldn't be doing anything except executing programs in a convenient manner. C++ is for anything else having to do with terminal programs.
>>
>>53962326

Mate, if you're finding yourself iterating over anything more than the files in a directory, it may be the case that a more proper scripting language would be a better choice than Bash. Surely, you could easily learn Python, Ruby, or Perl.
>>
>>53962354
At this point i'm almost 8 hours into this project and I'd like to at least finish it.

Maybe next project.
>>
>>53962161
Pretty much. It's slow at east coast midnight and absoutely dead by west coast midnight. It's 80% shitty NEETs anyway so I don't know why they're such pussies about their sleep schedules but such is life.
>>
>>53962362
>8 hours
>>
is there a general method to generating an arbitrary number of class instances?

It gets into like, having data in variable names and that seems super messy.
>>
>>53962388
Not on that part mind you.

Anyway, does anyone actually have any idea about the problem?>>53962237
>>
when you write the alphabet 20 times and then accidentally delete the file

fuck me
>>
>>53962405
The point is you shouldn't spend 8 hours on a bash script because it's an indicator that you should be using another language in the first place. You should've known that before starting, but... you live and you learn. Remember that next time.
>>
>>53962416
write it with a mouse, that is
>>
>>53962423
Yeah, next time, but I'd like to get this working.
>>
>>53962416
u wot
for(int i = 65; i <= 90; ++i) printf("%c", (char)i);
>>
>>53962437
see >>53962426

I'm manually writing out a training set for my letter recognition
>>
Hi /dpt/, is anyone here good at C? I've been using a function for testing and it works just fine, but now that I've moved it into my actual work it breaks.
I can't really show you since I'm doing it for a university assignment and they have a webcrawler which tries to match your code to code on the internet to see if you copied it, but I'll show you what I can.
void myfunc(mytype** foo){
mytype* temp = *foo; //Problem here
dostuff(temp);
return;
}

The problem is that doing the assignment on the marked line causes a segmentation fault. I'm not entirely sure why. Even checking if the pointer is null causes a seg fault. The function worked just fine on different datatypes before, and doesn't work now, and I'm not using it differently so I don't know why this is happening.
>>
>>53962455
Oh I see. Make sure it turns out better than applel newton, ok anon?
>>
What motivates you guys to program? I don't feel motivated to program anymore after seeing how much work and how difficult it is to make a hard application
>>
>>53962476
wut
>>
>>53962478
come up with a project idea that you can see yourself completing and have an idea of how you would do it
>>
File: Newton_eat_up_martha.jpg (11 KB, 180x135) Image search: [Google]
Newton_eat_up_martha.jpg
11 KB, 180x135
>>53962481
>>
>>53962510
i dont get it but ok
>>
>>53962478
It's called delayed gratification. Programming relies heavily on this concept.
>>
>>53962260
I got it my original source on bash loops told me I didn't actually have to use counter<="$pages"; and that <="$pages"; would be good enough.
>>
File: Untitled.png (782 KB, 840x930) Image search: [Google]
Untitled.png
782 KB, 840x930
>>53962478
the motivation comes and goes. thinking of ideas and making them work can be fun though. who doesn't like a challenge every now and then?
>>
File: AAAAAAAAAAA.jpg (9 KB, 342x342) Image search: [Google]
AAAAAAAAAAA.jpg
9 KB, 342x342
I wasted my whole saturday trying to get my program working on windows.
>you have to download all the libs manually
>you have to -I and -L include them manually
>tdm-gcc's implementation of openmp is fucked up, causing bizarre race conditions that shouldn't even be possible
i mean, how the fuck do several isolated threads with different stacks create the same output
>>
>>53962583
What are you doing that requires several isolated threads?
>>
>>53962583

Even with TDM-GCC, developing on Windows is hell. Many of the libraries one may want to use will need to be built from source, and half the time, that won't even work.
>>
>>53962643

that's why it's usually best to build things yourself whenever possible.
>>
>>53962583
lel, nub

https://chocolatey.org/
https://www.nuget.org/
>>
>>53962463
Nevermind, turns out I forgot to initialise foo even though I thought I did. I'm a retard.
>>
>>53960528
What's the point of this?
>>
I have a little neural network that takes in a 16x16 grid of booleans and outputs a number 0-25 for each letter.

Is having a training set of 20 per letter too much? How long is this going to take?

It's 256, 300, 150, 5
>>
testing for ugliness
g_oBoard.EnterThreadCriticalSection
threadIndex = g_oBoard.GetThreadIndexFromThreadNum( g_oGrid.activeTileThreadNum )
IF ISFALSE(g_oBoard.threadFollowed(threadIndex)) THEN 'thread isn't already followed?
g_oBoard.threadFollowed(threadIndex) = %TRUE
LOCAL redrawNow AS LONG
redrawNow = %TRUE
END IF
g_oBoard.LeaveThreadCriticalSection
IF ISTRUE(redrawNow) THEN SetEvent(g_hEvent_RedrawGridBuffer)
OpenUrlInWebBrowser( g_oBoard.ThreadURL( g_oGrid.activeTileThreadNum ) )
>>
>>53960115
because there are no pointers in java, everythign is pass by reference
>>
>>53961269
>>53961445
Data.Set is implemented as a tree, insertions/deletions are definitely not amortezed constant, it's O(log n). Hash tables are impossible to implement in a purely function manner, but if you really need hash tables, use hashtables package from hackage. It implements three different types of hash tables in IO or ST monad.
>>
query:

say i have some javascript built into a web page

that javascript produces a string ie "getlist townsinradius [townname]"

i need to pass that to a python server which passes it to a function which then does its shit and returns values to the js client

what do i need to learn to achieve this. i know basic python but never really fucked around with libraries. and what would help me achieve the result for the js part.
>>
File: kek.png (174 KB, 723x934) Image search: [Google]
kek.png
174 KB, 723x934
Why can't these companies be in Florida!!!
>>
>>53962911
What is so kek about this
>>
>>53962857
Django or flask?
>>
File: h1.png (131 KB, 278x362) Image search: [Google]
h1.png
131 KB, 278x362
>tfw your code compiles after relentlessly fixing shit for days
>>
>>53962960
It's a retarded question.

[spoiler]also I name screen grabs randomly[/spoiler]
>>
>>53962978
I'll be honest I read it 4 times before I understood what it was asking. What site is that?
>>
>>53962992

Pretty nifty, I saw some anon post it yesterday and it's got a nice look to it so I stuck around.

www.codeeval.com/
>>
File: 1451398111105.jpg (366 KB, 1100x1399) Image search: [Google]
1451398111105.jpg
366 KB, 1100x1399
>>53962977
>mfw
>>
>>53962977
its gonna crash bro
>>
>>53961939
>thousands of job postings
>90% are either Senior level java developer or webshit at a totally rad startup where they play ping-pong and call their employees rockstar programmers

Web 2.0 was a mistake
>>
>>53963008
>mfw this*
>>
File: untitled.png (87 KB, 1280x717) Image search: [Google]
untitled.png
87 KB, 1280x717
>>53962603
tripcode bruteforce search

>>53962643
should I just use MSVC or something?
surely, their openmp implementation can't be worse because right now only singlethreading works

>>53962911
codeeval literally taught me to program through doing those mundane challenges
though, i stopped going there after the devs broke compatibility with C.
my submissions would randomly hang and segfault despite running perfectly on my machine.
and then they made their runtime environments read-only, which broke all my old solutions.
none of my solutions would receive a score today because I was overwriting the test input file during runtime
also...
unsigned size = 0;
unsigned m = 0;
char *arr = (char *) calloc(MAX_BUF, sizeof(char));
char *tok = strtok(buf, " ");
while (tok != NULL)
{
if (tok[0] >= '0' && tok[0] <= '9')
{
m = atoi(tok);
break;
}
else
{
arr[size++] = tok[0];
tok = strtok(NULL, " ");
}
}
arr = realloc(arr, sizeof(char) * size);
if (m > size)
goto abort;
else
printf("%c\n", arr[size - m]);
>>
File: Fuck_Yea__in_HD_by_CrusierPL.png (76 KB, 900x773) Image search: [Google]
Fuck_Yea__in_HD_by_CrusierPL.png
76 KB, 900x773
>>53962977
>tfw you insert many new lines of code and hooks all over the place and it compiles the very first time
>>
File: 1459171932064.jpg (28 KB, 480x484) Image search: [Google]
1459171932064.jpg
28 KB, 480x484
>>53962977
>tfw you rewrite a 5 day C project in 4 hours in an OOP language
>>
File: maxresdefault.jpg (74 KB, 1280x720) Image search: [Google]
maxresdefault.jpg
74 KB, 1280x720
>when coding is like playing pinball
>the compiler throws an error you hit a bumper
>hit bumpers all night until the ball finally goes where you want it to
>>
>>53962850
what?

I don't code in java but.

what?
>>
>>53963190
This. I end up doing way to much trial and error
>>
When do you guys feel it's justifiable to comment?
In the sense that "this code needs comments"

I'm on a tiny hobby project, currently with less than 2000lines of code, very simple and just updating it with new features but noticed i didn't comment anywhere.
It's not a problem for me, because i think everything is named super obvious but what if i decided to open source it, should i add comments?
>>
>>53963190
That pic is giving me a huge hit of nostalgia.
>>
>>53963147
>C
why?
>>
>>53960084

Whenever I write code, I just end up testing it after only a few lines. It might be slower, but I usually never run into bugs. It really pays to have a fast computer for compiling.
>>
File: mathsinjava.jpg (57 KB, 674x490) Image search: [Google]
mathsinjava.jpg
57 KB, 674x490
>>53963201
>>
>>53963218
i have an i7-4790k, overkill for this?(i am using it for video processing though)
>>
>>53963206
Show your code to someone unfamiliar with it with a skill set similar to those you expect to see it. That's the best way to find out what information you need to add via commenting or otherwise.
>>
>>53963206
add comments in places where it's not obvious what the code does. on my 20k project I only use comments to describe complicated algorithms or to catagorize things inside namespaces, never more than a short sentance
>>
>>53963218
I recompile so much, I even do it by reflex after editing a comment. it only take like 2 or 3 secs, even on my old comp, so no big deal.
>>
>thread in Java which basically just starts 2 different threads in its run()
>want to kill this thread
Could someone explain how to do this? I keep seeing some interrupt() used with an if clause if there is a while in the run() method but I don't have that, I just start two threads once in the run() and then it sits there
>>
>>53963206
I usually use comments to explain questionable design decisions, but never what the code is doing.
>>
>>53963238
>>53963249
i'll keep that in mind, t. hanks!
>>
I wanna learn about machine learning buy Pattern Recognition and Machine Learning by Bishop is too mathy for me.
>>
>>53963273
isn't the point of comments to tell however is looking at it what the code does?
why are you writing a blog inside your code?
>>
>>53963217
Because he actually wants to be good at programming.
>>
do you guys ever release anything under licenses(open or not)? i released a project once under creative commons, share alike, because it was pretty understandable for a pleb like myself
>>
>>53962911
oh so just read up til newline, parse last char, do babby-tier logical operations and print until EOF?

is this really the sort of shit you can get hired for?
>>
>>53963296
but then why is this easier?
>4 hours in an OOP language
>>
write a function that functions that censors certain words from a string. you need to use a nested loop
>>
>>53963304
>I have never met anyone who can do Scheme, Haskell, and C pointers who can't pick up Java in two days, and create better Java code than people with five years of experience in Java, but try explaining that to the average HR drone.
That's why.
>>
>>53963286
>why are you writing a blog inside your code?
so I can remember what I was thinking when I wrote it
there's no need to tell what the code is actually doing unless it's cryptic-looking, even to you
>>
>>53963320
so you're saying i should also learn scheme and haskell so i can be not-hired by an HR drone, right?
>>
File: flat,800x800,075,f.jpg (99 KB, 600x800) Image search: [Google]
flat,800x800,075,f.jpg
99 KB, 600x800
>shares the source
>but removes all comments first
>>
>>53963356
I do this
>>
>>53963147
>>not doing object oriented C
>>
>>53963356
>>53963387
why?
>>
>>53963404
let the code speak for itself, amirite?

don't let potentially outdated comments get in the way.
>>
>>53963435
where is the 'kill yourself' option?
>>
>>53963316
have fun debugging

char *hurt_feelings_mitigator(char *str, dict_t *bad_words)
{
size_t len = strlen(str);
char *censored = (char *) malloc(sizeof(char) * len + 1);
strcpy(censored, str);
size_t i, j;
for (i = 0; i < bad_words->count; i++)
{
for (j = 0; j < len; j++)
{
char pos = strstr(str, bad_words->arr[i])
unsigned carriage = 0;
if (pos)
{
while (str[carriage + 1] != ' ')
censored[i + carriage++] = '*';
}
j += carriage + 1;
}
}
return censored;
}
>>
>>53963435
>strawpoll
fuck off retard
>>
>>53963423
you don't update your comments as you're done updating parts of your code?
>>
>>53963471
sure, I try to. but I've also seen lots of cobwebs during comment reviews. enough to know that outdated comments sometimes linger.
>>
How come when I boot my MBR image in qemu using either -hda or -fda it works but when I try to boot it in https://copy.sh/v86/ using either cdrom, floppy, or hdd it doesn't boot?
>>
Is make still viable for new projects or did everyone decide on something better?
>>
>>53963201
don't listen to the retarded memeing shitkids. java is pass by value.

>>53960115
new Foo() gives you a reference to an object instance of the Foo class
>>
Hey guys, noobie to C and programming in general here, having troubles with scanning a value from the user in. When I run the program, it works until that point, but after that it appears to stop. I ran it through GDB and it works fine. I'll post the code if necessary.
>>
>>53963553
Decided to use an IDE like someone who isn't fucking retarded.
>>
do you guys put easter eggs in your projects?
>>
>>53963218
yeah don't run a fucking toaster like some of these linux neckbeards and test your code frequently. i hate the TDD and unit test cancer for most things but you can still test your code.

>>53963233
no the bigger the better. i should probably upgrade my computer this year, i'm still using a core 2 duo like a cheapskate, but a faster computer would definitely help
>>
>>53963564
Yes, post the code.
>>
>>53963567
no pajeet codemonkey answers pls
>>
Working on an open source ticket system for small computer repair shops. Once I'm finished all the way I plan on generalizing it for use in other areas like auto repair and other stuff (like geetars and shit)
>>
>>53963573
i've been thinking of putting in a flappy bird clone easter egg in my game but i probably won't end up doing it. it would probably only take a few days to do though so idk, maybe i will, but maybe it would add too much clutter to the actual game.
>>
int getInput()
{
int input=0;
printf("Enter starting value: ");
scanf("\n%d",&input);
printf("what the actual fguck is going on");
return input;
}

And then this is called in the main function. It gets to the point of asking the user for the starting value, but it never gets to the point of asking the user what the fuck is going on.
>>
>>53963553
have makefiles that your IDE runs through a script
>>
>>53960084
A C Reference Counting library
>>
>>53963623
>asking the user what the fuck is going on.
best quote of the day
>>
>>53963620
Do it anyway anon, easter eggs are awesome
>>
Not using a makfile at the moment, and honestly, don't know what that actually means
>>
>>53963623
>\n
Yeah, you probably don't want that.
>>
>>53963682
Got rid of it, still has the same problem.
>>
>>53963623
>scanf("\n%d",&input);
scanf("%d\n",&input);
>>
>>53963623
>printf("what the actual fguck is going on");
printf("what the actual fuck is going on");
>>
>>53963623
scanf("%d", input);
>>
>>53963343
Just saying someone good at C will generally write better code.
>>
>>53963724
what if you're just a hobbyist that program to solve daily problems?
>>
printf(" user >>53963714 is a fgucking fag");
>>
>>53963674
i think i will. your question inspired me to think more about how to integrate it nicely. thanks anon
>>
>>53963718
That causes me errors when I compile that it is expecting type int * but is receiving an int
>>
File: 1449756574386.jpg (3 MB, 3264x2448) Image search: [Google]
1449756574386.jpg
3 MB, 3264x2448
>>53963724
>
>>
>>53963455
>size_t len = strlen(str);
> char *censored = (char *) malloc(sizeof(char) * len + 1);
> strcpy(censored, str);
Please kill yourself.
>>
>>53963065
isn't meriken's one the best? Have a look at how he did it
https://github.com/meriken/merikens-tripcode-engine
>>
>} expected
>tried putting curly brackets every fucking where only spawns like 30 errors wherever i put one
>>
File: 1443572962894.jpg (17 KB, 429x399) Image search: [Google]
1443572962894.jpg
17 KB, 429x399
>>53963740
i thought it was funny
>>
>>53963455
You must drown in SJW pussy.

Thanks for using my favorite standard IO function, strrrr strrrr. <3
>>
>>53963791
Yah fucked up somewhere. It doesn't just do that for shits and giggles.
>>
>>53960877
>>53960926
/g/ is literally retarded
>>
>>53963803
i found it turns out it was a debug line i added that was out of place
>>
File: LOLZ.jpg (6 KB, 306x165) Image search: [Google]
LOLZ.jpg
6 KB, 306x165
just finished codecademy Java course with no errors or anything. Swept right through it.

c-can i get a java job yet?
>>
>>53963734
Then don't use C.
>>
>>53963885
>codecademy
LOLZ
>>
>>53963909

b-but i can create

>muh arrays
>muh hashtables
>>
File: 1402088914853.jpg (157 KB, 1300x892) Image search: [Google]
1402088914853.jpg
157 KB, 1300x892
>>53963885
>>53963909
>>53963932
>>
>>53963932
now do object polymorphism and concurrency
>>
>>53963765
There's nothing wrong with this.
>>
>>53963969
>this is what C programmers actually believe
it would be more elegantly solved using OOP. you're literally dealing with objects/items anyway.
>>
>>53963981
>dealing with objects/items
when are you not dealing with objects/items?
>>
>>53964015
i mean, in this example you're literally using "Items", not some AbstractFactoryBeanTreeObserverMeme
>>
>>53964038
i'm not samefag, i was asking a question
>>
>>53960084
I have programmed a deep learning algorithm to analyze threads and it's posts: When it discovers a thread that is likely one it already saw once it will repost the original answers with the most replies to.
It's working great
Some high quality bait has a 100% response guarantee.
>>
>>53964042
you can model all software using OOP, just that some critics think it's not suitable for everything because software can be more abstract than real-life objects. but in the example i think it'd be very appropriate to use OOP instead of long implementation-specific switch statements scattered across your code base.
>>
File: robot.png (5 KB, 353x91) Image search: [Google]
robot.png
5 KB, 353x91
>>53964055
>
>>
File: 20160410_104201.png (72 KB, 233x289) Image search: [Google]
20160410_104201.png
72 KB, 233x289
Daily reminder that traps aren't programming literates or anything: they are just degenerates. So stop with that Hime meme

>All it takes to avoid the trap is to recognize it. (https://www.gnu.org/philosophy/when-free-depends-on-nonfree)
The GNU/dictator has spoken. How do you recognise traps you may ask? It's easy: ask all women to show you their source code. If they refuse, then they are necessarily traps.
>>
>>53963724
lel, no.
>>
>>53964074
i see
>>
>>53963885
Alright senpai give me your greatest fizzbuzz
>>
File: 1458196346157.jpg (101 KB, 1280x720) Image search: [Google]
1458196346157.jpg
101 KB, 1280x720
How do I prove that there are no consecutive whole numbers that are both prime except 2 and 3 before trying to write a potentially futile program to find them?
>>
>>53964201
>consecutive numbers
>(2n-1, 2n)
>(2n, 2n+1)
>n > 1
>>
>>53964201
Because every second number is divisible by 2?
>>
File: i know all the memes.jpg (97 KB, 245x337) Image search: [Google]
i know all the memes.jpg
97 KB, 245x337
>>53963765
i'd implement the bag as a linked list of item enums and have UseItemFromBag delete the node passed to it after changing the pokemon stats according to the item enum's corresponding struct entry in a global item_effects array;
like, if APPLE is equal to 298, it's ITEM_EFFECTS[298] would state that it's affects enum PP_STAT by +30
>>
File: tfw.png (189 KB, 2560x2489) Image search: [Google]
tfw.png
189 KB, 2560x2489
>>53964201
See you in infinity's time faggot
>>
>>53960528
I'm pretty sure you meant n /=10; instead of n / 10;
>>
any great ways to make gui with mono? everything i've seen has been lackluster.
>>
>>53964201
Find the opposite hypothesis and reject it.
>>
File: primes.jpg (63 KB, 994x578) Image search: [Google]
primes.jpg
63 KB, 994x578
>>53964201
>>53964496

This is the sort of problem Z3 is built to solve. Everyone knows that

>>53964240

But how to prove it? Pic related.
Thread replies: 255
Thread images: 49

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.