[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: 90's kid with sunglasses
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: 36
File: big__Black-Lagoon-Review-04.jpg (56 KB, 800x450) Image search: [Google]
big__Black-Lagoon-Review-04.jpg
56 KB, 800x450
old SHITTY thread: >>54026777

let's stop posting traps for fuck sake

what are you working on /dpt/?
>>
i love programming but don't know what to write helpppppp

What looks good on resume? etc
>>
So why was swing replaced with javafx?
>>
>>54030414
https://github.com/avinassh/rockstar
problem solved
>>
>>54030414
a compiler or something
>>
File: bat.webm (2 MB, 640x360) Image search: [Google]
bat.webm
2 MB, 640x360
Ask your much beloved programming literate anything (IAMA)
>>
>>54030436
I opened that webm and I swear I could smell the bat for a second.
>>
>>54030434
>https://github.com/avinassh/rockstar
>indian
>>
>>54030414
>What looks good on resume?
Work on a product that sells. Or a popular FOSS project.
>>
>>54030436
least favorite*
>>
File: 1459561969325.jpg (124 KB, 625x690) Image search: [Google]
1459561969325.jpg
124 KB, 625x690
No one answered my question from the last thread :'(

Every time I see a list of project ideas it's something like TOP 9001 PROJECT IDEAS, etc. Or at the very least it's a list of 100+.

I'm looking for a small list of project ideas that don't have a lot of overlap in terms of the skills learned in each.

I.e., if you were trying to learn programming as fast as possible through doing projects, what are 10-20 or so projects you'd do?
>>
>>54030701
why not just do what you want to do?
>>
>>54030701
What's your skill level? (Don't just say 'novice'; what have you made so far? etc)
>>
Anyone using the AIDE app?

I might get it since my laptop fried and i m reverse engineering some apks to learn from. I would really like to start making beer money soon fro. Google play
>>
>>54030701
Well I'd take it easy. What you want to have is a goal or desired outcome that you work towards. Currently I'm writing a program to do parallelized matrix multiplication. That's my end step. After I do that I can start working to another goal, like maybe distributed computing, who knows.

Of course we all want to jump straight to creating a massive application but really you should reach for challenging but feasible problems to solve.
>>
>>54030762
I have the premium version. Used to code nonstop on my OG Droid and then Droid 4.
>>
>>54030775
OK fuck yeah I guess that's a go for me to start.
How much did the premium cost and does it let me publish apps with the free version?
What else is needed for the free version?
What does the premium version do?
How much space does the free version take up?
>>
>>54030725
I'll probably end up doing a mixture of that and the answer to my question, I'm just curious about this question theoretically.

If I could phrase it in another way I'm guessing I'm asking: if motivation/preference weren't a factor, what small list of projects would teach someone essential skills fastest?

>>54030746
I've taken a few basic uni courses in C and Java. Know some Python.

Made a basic Boggle game for my Java class and then ported it to be Android compatible. Did a simulator of MIPS archictecture in C for a class with some guidance. Made a simple CRC checker.

So, I can do the basics. I've just never done anything large or really utilized OOP in a serious way.
>>
File: Untitled.png (9 KB, 608x426) Image search: [Google]
Untitled.png
9 KB, 608x426
>>54030436
how2 get stuff compiled with MinGW to work on older versions of Windows? I read that you could make it use crtdll instead of msvcrt or something but I can't find any info on it or if that's even the issue.
>>
>>54030402
stop this stop this programming fag meme meme
>>
>>54030820
I don't remember
I don't remember, I think nothing
I don't remember, but it works
I don't remember

I think I got premium for dropbox integration, so I could work on projects on the go and at home.
>>
>>54030436
why does atof return in like half a dozen different registers?
>>
>>54030969
So you do recommend it as an equivalent to the Android studio ?
>>
>>54030969
So did you program on your smartphone using landscape or portrait orientation?

I like using landscape but half the screen is taken up from the layout design when I'm using just the note editor on Android
I'm afraid it will be the same when I'm programming software in the Android ide.
>>
File: poo in it.jpg (192 KB, 954x954) Image search: [Google]
poo in it.jpg
192 KB, 954x954
>>54030434
well memed pajeet
>>
>>54030971
are you talking about a custom atof implementation? System V abi uses at most 2 registers for returning shit (rax, rdx) and Windows uses just rax/xmm0 if I remember correctly.
>>
>>54031108
glibc
It seems to return in rdx, rdi, and xmm0
seriously wasn't expecting it to fuck with rdx, so when it did, it broke my program
>>
Give me reasons to use OCaml over D.
Because I kind of can't find any.
>>
is there a library out there that just lets me have a window, and then draw pixels on it?
I just don't want to have to learn some ridiculously complicated library to put a fucking triangle on a screen

SDL is close to this, but only after some hideous looking hacks, which I'm 90% sure would make anyone who uses it properly start projectile vomitting blood
Mind you, it is C, so it's hard to tell if those hideous looking hacks aren't perfectly standard or something
void set_pixel(SDL_Surface *surface, point p1, unsigned int colour)
{
unsigned int *pixels = (unsigned int *)surface->pixels;
pixels[(p1.y*surface->w)+p1.x] = colour;
}
>>
File: smug alexandrescu.jpg (94 KB, 960x540) Image search: [Google]
smug alexandrescu.jpg
94 KB, 960x540
>>54031191
there are no reasons
D is literally perfect
>>
>>54031272
I'm actually serious. The only *potential* drawback of D is that there are not that many native libraries floating around and you're stuck with using C libraries (which is pretty much every one) which that you have to (automatically) create headers for (which is still not a big deal because all C datatypes can be unambiguously mapped to D).
>>
>>54030960
how about you stop being a fag and the meme will end
>>
>>54031272
what about the gee cee? it's been how many years that they've worked on core.memory? and yet most of phobos still uses the GC
>>
>>54031312
I'm serious too anon
>>
>>54031363
So does OCaml. Additionally, OCaml's GC can't even into threading (which D's can).
>>
>>54031272
>D is literally perfect
No, IDEs can't deal with the powerful metaprogramming facilities and show you the stdlib source file in panic :^)
>>
>>54031389
but the claim was that D was literally perfect :)

there is pretty much no reason to use ocaml over d, except for menhir and ometa -- both of which could be implemented in d
>>
File: linus-torvalds.jpg (16 KB, 221x336) Image search: [Google]
linus-torvalds.jpg
16 KB, 221x336
>>54031410
>IDEs
I don't have any more alexandrescu reactions so have a torvalds
>>
File: 6854.gif (1 MB, 628x500) Image search: [Google]
6854.gif
1 MB, 628x500
>>54030402
>>
File: 1459086350723.jpg (60 KB, 540x589) Image search: [Google]
1459086350723.jpg
60 KB, 540x589
>>54030850
No one gonna respond again? :'(

>>54030768
I'm definitely not looking to do huge projects. I'm just looking for projects within my skill level that will teach me the most
>>
>>54031423
Actually Visual-D and Mono-D are pretty good, they give a far better overview over existing classes and templates than what most text editors can provide for large projects.
>>
File: stroustrup sez.png (1 MB, 1010x764) Image search: [Google]
stroustrup sez.png
1 MB, 1010x764
>>54031389
stroustrop says: garbage collectors are NO GOOD
>>
>>54031484
how did you not see this https://better-dpt-roll.github.io/
>>
>>54031553
I've seen it, and it's a nice list but it's not what I'm looking for

>Every time I see a list of project ideas it's something like TOP 9001 PROJECT IDEAS, etc. Or at the very least it's a list of 100+.
>I'm looking for a small list of project ideas that don't have a lot of overlap in terms of the skills learned in each.
>>
>>54031579
you're venturing into the territory of "think of a project idea yourself"

They don't have a list for that unfortunately
>>
>>54031528
because if a GC was added to C++, it would collect the whole godforsaken language
>>
>>54031618
W.....
.E....
..W...
...L..
....A.
.....D
>>
File: ech.png (10 KB, 800x600) Image search: [Google]
ech.png
10 KB, 800x600
>>54030947
Welp, just realized it defaulted to 64-bit causing those errors. Still have yet to figure out how to make it use crtdll like the MinGW FAQ says it is possible of though.
>>
If I wanted to make a basic text based adventure. What parts of java should I learn? I'll need to calculate the players attack based on the level of the player times 3. Then when a player kills a monster he will gain a small amount of exp. For every 30 exp the player will level up.

obviously, I'll need loops and if statements, but what else
Any help is appreciated.
>>
>>54031671
what the fuck are you doing on win95 that isn't malware related
>>
>>54031618
kek
>>
>>54031693
how do you know it isn't malware related?
>>
Arithmetic expression evaluator. An warm-up to a s-expression evaluator I'm gonna write soon (although the order of magnitude of complexity is far less).
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

void process_operator(char *st_op, int *op_size, int *st_arg, int *arg_size) {
int arg1 = st_arg[(*arg_size)--];
int arg2 = st_arg[(*arg_size)--];
char op = st_op[(*op_size)--];
switch(op) {
case '+':
st_arg[++(*arg_size)] = arg1 + arg2;
break;
case '-':
st_arg[++(*arg_size)] = arg1 - arg2;
break;
case '*':
st_arg[++(*arg_size)] = arg1 * arg2;
break;
case '/':
st_arg[++(*arg_size)] = arg1 / arg2;
break;
case '%':
st_arg[++(*arg_size)] = fmod(arg1, arg2);
break;
case '^':
st_arg[++(*arg_size)] = pow(arg1, arg2);
break;
}
}

int main(int argc, char** argv) {
char* expr = strtok(argv[1], " ");
char* st_op = (char*)calloc(512, sizeof(char));
int op_size = -1;
int* st_arg = (int*)calloc(1024, sizeof(int));
int arg_size = -1;
do{
if(!(st_arg[++arg_size] = strtod(expr, NULL))) {
arg_size--;
}
if(expr[0] == '+' || expr[0] == '-') {
while(op_size > -1) {
process_operator(st_op, &op_size, st_arg, &arg_size);
}
st_op[++op_size] = expr[0];
} else if(expr[0] == '*' || expr[0] == '/' || expr[0] == '%') {
while(op_size > -1 && st_op[op_size] != '+' && st_op[op_size] != '-') {
process_operator(st_op, &op_size, st_arg, &arg_size);
}
st_op[++op_size] = expr[0];
} else if(expr[0] == '^' && st_op[op_size] != '+' && st_op[op_size] != '-' && st_op[op_size] != '*' && st_op[op_size] != '/') {
while(op_size > -1) {
process_operator(st_op, &op_size, st_arg, &arg_size);
}
st_op[++op_size] = expr[0];
}

} while(expr = strtok(NULL, " "));

//clear stack
while(op_size > -1) {
process_operator(st_op, &op_size, st_arg, &arg_size);
}

printf("Result: %d\n", st_arg[arg_size]);

free(st_op);
free(st_arg);
return 0;
}
>>
>>54031685
skip java, just use one of these things https://www.google.com/search?q=rpg%20studio

not text based, but close enough if you want to put a bit more effort into it.

If you're in it to solely learn the language, that's easy too. It's just text. You need to learn general programming principals.
>>
>>54031616
Yes, I could try to compile my own list satisfying my criteria but I'm not already an accomplished programmer so I'm less than qualified.

I'm really not sure why I can't find an existing list of this kind already.

I think I'm just going to go through a few learn_x_language books and for each higher level concept look at the projects they suggest then look for overlap between the books
>>
>>54031693
Trying to make muh retro program run on retro operating systems like the original version of Win95. Might even try to make it run on 3 if I can just get it to compile.
>>54031704
kek
>>
>>54031704
If you were doing something malware related then that would make sense. Are you?
>>
File: TheProdigy.jpg (236 KB, 1737x662) Image search: [Google]
TheProdigy.jpg
236 KB, 1737x662
What's your opinion on the prodigy?
>>
>>54030434
WTF does this actually work?
>>
File: 1458642379416.png (1 MB, 1587x1600) Image search: [Google]
1458642379416.png
1 MB, 1587x1600
Am I a retard for not knowing how to call/run a class file from inside of another with Java?

In C++ it was so explicit, with the inclusion of header files. But I consistently see classes, from other class files, being instantiated outside of it with nothing expressing one's availability to the other, and I just don't understand what fucking magic is involved...is it because they are in the same project? Is it some kind of insane inheritance? WHAT IS IT.
>>
>>54031789
of course
>>
>>54031789
all it does is push commits tagged with previous dates
>>
>>54031794
It's because the JVM contains the entire java standard library and just drops in the code when you have an import statement.
the JVM autoloads the code for classes that exist in the same directory (without imports).
>>
Is there any reason these threads always got opener with Black Lagoon pics?
>>
>>54031816
because these faggots have some objection to trap pics being there instead
>>
How do I make this program generate a new random number every time I call it? Because the method generates the number before anything starts it doesn't create a new one
import java.util.Scanner;
import java.util.Random;
public class Helloworld1
{

public static int randInt(int min, int max) {
Random rand = new Random();
int randomNum = rand.nextInt((max - min) + 1) + min;
return randomNum;
}

public static void main(String[] args)
{
Scanner scan = new Scanner (System.in);
int randomNum;
randomNum = randInt(1, 10);
/*Declaring basic values for the players profile*/
int playerlevel = 1;
int playerexp = 0;
int playerattack = playerlevel * 3;


System.out.println("Enter users name: ");
String username = scan.nextLine();
System.out.println(username);
System.out.println(randomNum);
System.out.println(randomNum);
System.out.println(randomNum);
System.out.println(randomNum);



}
}
>>
>>54031905
I've decided doing
System.out.println(randInt(1, 10));


works, is this correct or bad form?
>>
You're doing Random wrong. You create the Random object ONCE, then just keep pulling `nextInt`s out of it.
>>
How do I use math in java? It seems to return an error on plus and minus
>>
>>54032127
Works for me. You are probably just stupid.
>>
File: ctards will defend this.png (2 MB, 1920x1080) Image search: [Google]
ctards will defend this.png
2 MB, 1920x1080
C vs Haskell
>>
do any physical calculators these days support things like bitwise arithmetic or conversions between hex and dec?
>>
>>54032137
I'm aware im retarded. but help would be appreciated. it keeps returning errors
import java.util.Scanner;
import java.util.Random;
import java.math.*;
public class Helloworld1
{

public static int randInt(int min, int max) {
Random rand = new Random();
int randomNum = rand.nextInt((max - min) + 1) + min;
return randomNum;
}

public static void main(String[] args)
{
Scanner scan = new Scanner (System.in);
/*Declaring basic values for the players profile*/
int playerlevel = 1;
int playerexp = 0;
int playerattack = playerlevel * 3;
int playerhealth = 30;
int monster1 = 1;
int monster2 = 2;
int monster3 = 3;
int monsterincounter = 0;


System.out.println("Enter users name: ");
String username = scan.nextLine();
System.out.println(username);
if (playerhealth > 0){
monsterincounter + randInt(1, 3);
if (monsterincounter = monster1){
System.out.println("You have encountered a Rat!");
playerhealth - randInt(1,3);

}
}



}
}
>>
>>54032148
There are physical calculators that cost more than 10 bucks that CAN'T do that???
>>
>>54032153
>monsterincounter + randInt(1, 3);
The fuck is that supposed to do?
>playerhealth - randInt(1,3);
The fuck is that supposed to do?
>if (monsterincounter = monster1){
Why are you assigning a value to "monsterincounter" inside an if-statement?
>>
>>54032145
>autistic haskell zealot reads K&R
your shit code doesn't even compile
>>
>>54032145
Muh speed.
>>
>>54032145
MUH SPEED
MUH MEMORY
>>
File: Z-T.png (8 KB, 544x264) Image search: [Google]
Z-T.png
8 KB, 544x264
>>54032171
>>
>>54032156
I wouldn't know, that's why i'm asking.
my $10 calculator certainly doesn't have those features
>>
>>54032153
Java is your first programming language, isn't it?
>>
>>54032169
Randomly assigns monsterincounter a value, the value decides what monster you encounter.

its a precursor to the way monsters deal damage

this decides what monster you'll encounter. it's not all spaced out yet. I just started learning java this morning. I thought making a basic text adventure would help me learn some key points
>>
>>54032203
>cc

I feel like your personal motto is "I laugh at you because you are all the same."

Am I right?
>>
>>54031235
glew
>>
>>54032145
The funny thing is, C versions are easier to understand and to maintain.
>>
>>54032218
what's wrong with cc, it's what k & r used in the book
>>
>>54031235
you either do pure opengl API calls
or use a wrapper

if you consider a wrapper a complicated library, then tough luck

since opengl is itself complex
>>
>>54032220
if you've never studied fp, of course it's going to be alien to you
>>
>>54032236
your dumbass fp language is just converting your abstract equations to C anyway.
>>
>>54032215
>Randomly assigns monsterincounter a value, the value decides what monster you encounter.
No. It calculates the sum of "monsterincounter" and "randInt(1, 3)" and then throws away the result. Because you don't assign it to "monsterincounter".
>its a precursor to the way monsters deal damage
No. It calculates the difference of "playerhealth" and "randInt(1, 3)" and then throws away the result. Because you don't assign it to "playerhealth".
>this decides what monster you'll encounter.
No it doesn't. Regardless of how many if-then-else you put there, you will always encounter a rat. Because you're not comparing things, you're assigning a value.
>>
>>54032145
do one with IO
>>
>>54032247
the third one has io
itd look the same for the other two
e.g. ask a question, get input, do something with it
>>
>>54032145
>Looping getchar instead of gets
>Not doing reverse in-place
>Reimplementing strlen
>Reimplementing strcpy
>Haskell quicksort isn't even in-place
>Overall shitty code
>>
>>54032267
>Haskell quicksort isn't even in-place
That's because it's not possible to do it in-place in Haskell. And that's also why nobody uses it.
>>
>>54032267
>pure fp
>in place
listen to yourself
what are the advantages of it being in place anyways?
>>
>>54032283
Less unnecessary copying.
>>
>>54032283
Less memory consumption and faster execution speed. See >>54032176 >>54032179
>>
>>54032277
>60s programmer mad that nobody uses C anymore
FP is the future, cuck
>>
>>54032236
I actually used to know Haskell quite well, although I haven't used it for years, yet even I have to stop and think hard to understand what the Haskell code does. It's write-only language like Perl.
>>
>>54032296
I'm already using FP in superior languages.
>>
>>54032300
I wrote it that way because it was more efficient
it could of been
rev [] = []
rev (x:xs) = rev xs ++ [x]
>>
>>54032145
are you implying that C people have to make everything from scratch?
Someone has to define what these things do, it isn't magic.

Also how can your coding style vary so much across 3 simple projects
>>
>>54032307
>fp is map and filter
kys
>>
>>54032334
Stop projecting so hard.
>>
>>54032145
>programming baby
lmao tbqh
>>
>>54032323
I'm just saying C is outdated
nobody needs speed anymore
moore's law is still strong
and haskell is near c speed while being 10 times shorter than its respective c program
>>
>>54032347
what does your language use that is fp?
>inb4 python map and filter
>>
>>54032296
>FP is the future
a sloooooooooooow future
>>
>>54032350
>moore's law is still strong
you haven't been paying attention to the last ~7 years lmao
>>
>>54032350
You could make a program shorter by removing all whitespace too but that doesn't make it any more readable or maintainable either.
>>
>>54032365
First class functions, higher order functions and pure functions.
>>
>>54032350
>I'm just saying
you don't get to have an opinion if you don't know C, m8
>nobody needs speed anymore
>moore's law is still strong
child, please
>haskell is near c speed
you have to be 18+ to post on this subreddit
>>
>>54032371
did any of my haskell programs delete whitespace and used shitty structuring?

I'm just saying that what constitutes a C program can be, generally, done in Haskell with 5-10 times less lines of code
>>
>>54032387
but Haskell is near C speed
>>54032384
f# is basically fp anyways
>>
>>54032412
>but Haskell is near C speed
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=ghc&lang2=gcc
Sure, kiddo.
>>
>>54032412
>performance is an inherency of a language
When will this meme die

>yfw it's not the language itself that makes things faster but things the language allows you to do to increase performance
>yfw the same shitty algorithm will run at relatively the same speeds across languages because language overhead is fucking O(c)
>>
>>54032439
>ctard who never did fp writes inefficient Haskell code and compares it to C
kys
>>
File: mathsinjava.jpg (57 KB, 674x490) Image search: [Google]
mathsinjava.jpg
57 KB, 674x490
>>54032127
See if pic related helps.
>>
>>54032446
>python generally has the same speed as C
>>
>>54032399
> the less code the better
Why don't you code in J then? It's shorter than Haskell: http://rosettacode.org/wiki/Fibonacci_sequence#J .
>>
>>54032145
>what if my line is 1001 characters long
>>
File: 1437890407599.jpg (83 KB, 1280x720) Image search: [Google]
1437890407599.jpg
83 KB, 1280x720
>nobody in this thread has any idea what they're talking about
>>
>>54032471
APL is even better, nothing can beat good old ↑+.×/N/⊂2 2⍴1 1 1 0 .
>>
>>54032452
If it were so inefficient some versed Haskell users would have long since improved the solutions. But that didn't happen, I wonder why. Maybe the most popular programming language benchmark isn't popular enough for Haskell edgelords?

Kill yourself, faggot.
>>
>>54032446
>performance is an inherency of a language
It typically is though. Sure, you can write a shitty and slow algorithm in a fast language, but there are things which make languages inherently faster than others.
C has far less assumptions that it needs to check for, leading for the possibility of greater optimisations.
>>
>>54032471
>>54032489

because those langs are unreadable and even this fib versions aren't linear
>>
>>54032467
If you're implementing the same algorithms, yes.
Algorithms are in terms of O(n)
Language overhead becomes insignificant as n approaches infinity.
What, do you think Python is somehow sending different (business) instructions to your CPU than a C compiler would produce?
i=i+1 is the same as i=i+1 on the machine level.
>>
>>54032459
I've started using =+ and that seems to work for some reason. But I think I'll switch to yours. Seems more elegant and =+ just doesn't seem right. Sorry to be shit, I literally started learning this morning, been putting it off for a while aha
>>
>>54032467
Python is interpreted while C is compiled, so no.
>>
>>54032500
in algorithms, yes, in general code, no
>>
>>54032508
python is compiled, fucknugget
>>54032495
but that did happen in one case
I've read it before in here
>>
>>54032525
>but that did happen in one case
Oh really? Which of the cases that is still slower than C was that.
>>
>>54032480
how else are we gonna spend our worthless lives
>>54032538
I'm not arguing that Haskell is faster than C, I'm saying it's near C speed, and in certain cases, it supersedes C
>>
>>54032546
>I'm saying it's near C speed, and in certain cases, it supersedes C
None of the benchmarks on that site are near speed. Unless you are claiming that one second is "near" 0.5 seconds. That is still twice the time, and not even close to being "near".
>>
>>54032571
compared to other Lang's like python, java, etc , it is better
>>
>>54032581
That wasn't being argued.
>>
>>54032581
>Compiled-to-native language is faster than compiled-to-VM ones
No shit, Sherlock, but that's besides the point here.
>>
>>54032590
I'll take that 1 second gap and 20 times less loc over 300x loc
>>
>>54032618
>I have never heard of scaling
ok kid
>>
How would I make this statement work?

if(playeranswer.equals ("Yes" || "y" || "yes")){

}
>>
>>54032708
the stupid way is to have a bunch of !strcmp(playeranswer, "Yes") statements

the smart way is to put all your possible "yes" statements into an array and iterate over them, returning true if one of them finds a match.
char yes_answers[3] = { "Yes", "y", "yes" };
unsigned i = 0;
while(yes_answers[i++])
{
if (!strcmp(playeranswer, yes_answer[i])
return true;
}
>>
Quick question. Is atomicity like you have a database and you have an id field and you want to make sure no two records get given the same id so you make sure they never get created at the same time?
>>
File: 213.jpg (337 KB, 1279x623) Image search: [Google]
213.jpg
337 KB, 1279x623
>tfw haven't written code in years
>tfw forgotten fucking everything
>spend 5 minutes trying to figure out why my fucking int declaration wasn't working
>realize I'm a retard for making it static inside main

kill me
>>
>>54032749
> put all your possible "yes" statements into an array and iterate over them
> the smart way
The smart way would be to use PCRE and to match with "(Y|y)(es)?".
>>
>>54032782
>anon, i dont want to think or write code, i just want to import everything!

regex is really fucking slow btw
>>
>>54032500
>i=i+1 is the same as i=i+1 on the machine level
it isn't, your an idiot
>>
>>54032618
>backpedaling
color me surprised
>>
>>54032782
>>54032806
doesn't match yEs or whatever

just convert to lower and check against yes or y, that's pretty much how it has been done since middle ages
>>
>>54032806
It's way faster than iterating over an array strcmping things.
>>54032819
(i?)y(es)?
>>
>>54032847
you really don't need to compile a regex to compare against two strings
>>
>>54032749
>enter "no"
>segmentation fault
Typical C programming.
>>
>>54032863
ideally, any answer other than yes should return false

also
>>
>>54032708
put it to lower first
then just match against "y" or "yes"
>>
>>54032868
actually if you care about efficiency
just put "yes" first then the rest, since OR won't bother with the rest if the first one matches
>>
>>54032708
regex_t reg;
regcomp(&reg, "^[Yy](es)?$", REG_EXTENDED);

if (regexec(&reg, argv[1], 0, NULL, 0) == 0) {
...
}

regfree(&reg);
>>
If I have 3 threads running and am just using sleeps for their timings, not using any locks, they will fall out of synchronization, right?
>>
Hello, IT college student here.

In a couple of hours I'll be going to this company's HQ for a 'technical test', basically I'm trying to find a place for my summer internship and this is one of the requirments.

The test should contain logical questions, the language isn't too important.

I'm guessing some of the questions will be, for example, list all possible permutations of a couple of words, or reverse a string. I solved those easily.

Does /g/ know of any other I could practice in those couple of hours?
>>
>>54032936
Whoops, REG_NOSUB should have been one of the flags for regcomp. It doesn't make the code invalid though.
>>
>>54032950
yes

you answered your own question pretty much
>>
>>54032960
I guess my question is why

different speeds of whatever CPU core is handling the thread? But then I wonder why THAT happens...
>>
>>54032991
thread scheduling and sleep(x) not actually meaning that you get control back after x

CPU speeds can vary of course too, power saving and heat control stepping the CPU are very common
>>
>>54032991
Because you're running multitasking OS and other processes use the same CPU cores in non-deterministic fashion, because IO syscalls block your threads for some random time depending on a hardware, because sleeps are never perceive unless you're running RTOS. So stop asking stupid questions and make proper synchronization.
>>
>>54033023
>>54033029
So this would not occur if nothing else were using those CPU cores?
>>
>>54033052
Thread scheduler uses the CPU too so it's not possible unless you have a special purpose one.

Either way you're asking pretty stupid questions by this point.
>>
>>54033052
No, it would still occur since instruction execution time on CPU isn't fixed and can vary depending on memory latency and caches.
>>
>>54033079
Sorry ;_;

but thank you for the answers, they helped me better understand stuff
>>
>>54031718
>not using monadic parser combinators
>year of our Lord and Saviour (TM)
>>
>>54032350
u a cuck anon?
>>
>>54033193
MEMORY
O
D
E
L
>>
Any Java libs that let you convert ePUB to a Kindle compatible format (MS Word, HTML, PDF, .rtf, .mobi, .azw)?
>>
>>54032215
>>54032153
monsterincounter + randInt(1, 3);


should be

monsterincounter += randInt(1, 3);


+= will add the second value into the first. It's the equivalent of:
monsterincounter = monsterincounter + randInt(1, 3);


or if it's not supposed to keep growing, just assign the random value:
monsterincounter = randInt(1, 3);
>>
>>54033261

look at epublib you dirty devil
>>
>>54032215

> monsterincounter instead of monsterEncounter

why do people do things like this
>>
>>54031794

this is actually a smart and reasonable question to ask
>>
>>54031685

java is kinda overbuilt for this, python is faster or even javascript (with node)

but this is pretty basic, you just need loops, conditionals, and objects
>>
>>54032525

> python is compiled

misleading at best
>>
>>54033290
i don't see nothing about no conversion from .epub to X, only .chm to .epub
>>
File: indians2.png (7 KB, 530x130) Image search: [Google]
indians2.png
7 KB, 530x130
>>54031794
Read up about public vs private, static vs non-static.

Long story short:
The method/variable must be public.

If the method/variable is public, and static, you can just call it. Public static things are available everywhere. It's easy to just make everything public and static, but this is generally considered poor design.

If the variable/method is public, but not static, you must instantiate the class locally in the class you are working with.

MyClass dildos = new MyClass();
dildos.MyPublicString = "ayylmao";



This is one of the first things that trip people up about C# and Java.

The purpose is to ensure compartmentalization in massive enterprise applications. You wouldn't want Pajeet accessing and modifying the class handling financial calculations, would you?
>>
>>54031191
The type system and the module system. The speed and the high-level ML constructs. Really, is there even a reason to use D, let alone to use it over ocaml? D isn't as fast as ocaml yet.
>>
>>54032412
>basically
F# is as FP as it gets without going full retard meme like haskell.
>>
>>54031794
You have a list of all included packages at the start of file. When you include a packages, all classes from it become accessible to your current .java file. You can choose to not include the package, and instead write out full class name, including its package name when you use the new operator.

Java virtual machine searches for the package and class name combination when you ask it to create a class, and if it finds it in its currently defined codepath (you can extend it also - add places to look for classes - both in command line when starting your java frogram, and from java code), creates it for you. If it doesn't find it, throws class not found exception.
>>
Any android developer?

i want to login to a webpage and get data off it, however i need javascript to load the data while logged in what should i use? I read about retrofit but i don't think it is what i want
>>
>>54032497
It's actually the opposite: C only offers low-level operations, which makes it much harder to optimize high-level constructs (the likes of which are typically used at the actual programming level instead of the boilerplate level). The thing is, every professional genius has brought their wisdom to the compilation of faster C, so it's faster than a lot of languages eitherway. But compare instead the same constructs in naive C v.s. in higher level languages and you'll see that the C code is a lot slower (you need manual optimization to actually perform well at this point). Conversely, look at languages like ATS, which can beat C consistently, or the likes of rust and clean, which can beat it often and stay very close to it otherwise, despite very little resources being expanded in developing their compilers by comparison.
>>
>>54034040
>The type system and the module system.
D does it better.
>The speed and the high-level ML constructs.
D is faster and supports the same high-level constructs.
>D isn't as fast as ocaml yet.
https://github.com/logicchains/LPATHBench/blob/master/writeup.md
Okay.
>>
>>54034092
Embed a web view?
>>
>>54034248
Couldn't laugh any more so I was finally able to respond. They do say laugh is the best medicine, so thanks for that.
>>
>>54034455
You don't happen to know how floats work, do you?
>>
>>54034455
>-0.000001907
It's not that far off.
>>
>>54034455
what language is this
>>
>>54034455
>= -3.69999909 + 3.70000100

Sorry the first value is a negative
>>
>>54034455
Floating point arithmetic is never precise, you should never expect it to get some exact value, always check for value in a range.
>>
>>54034491
>>54034477
>>54034478

Right, it's just me being a retard.

Thanks/
>>
>>54034455
it ran out of space so it used scientific notation
>>
>>54034406
great arguments, senpai
>>
>>54034248
The D module system is as basic as possible. It doesn't even begin to reach above ocaml's module sytsem's big toe. At this point it's pretty certain you're just trolling.
D is slower and your own link shows this. Nevermind the fact that the ocaml code isn't even compiled but rather interpreted, it still beats D by about 50% in the last x86 benchmark. Not only that, but the figures reported couldn't even be reproduced by the author because the compiler stopped working with the next version and the gcc D compiler was significantly slower than the reported figures. In fact, the author notes that D was so shit that he had to use the C printf instead of D's writeln.
>>
>>54034513
> the ocaml code isn't even compiled but rather interpreted
[citation needed], I'm pretty sure ocaml is able to compile into native code.
>>
>>54030850
I'd strongly recommend making a web application with JSP or Spring (Java framework). Something like a to do list app, contact organizer, is a good start, or if you want more complex build something like a CRM.
>>
File: 48761653_p13_master1200.jpg (1 MB, 850x1200) Image search: [Google]
48761653_p13_master1200.jpg
1 MB, 850x1200
>tfw you finally figure something out after agonizing over it for hours

death comes easily now
>>
>>54034588
It's a good feeling.
>>
>>54034513
>The D module system is as basic as possible. It doesn't even begin to reach above ocaml's module sytsem's big toe.
I can read the OCaml docs as well. You're wrong.

>D is slower and your own link shows this.
If you weren't trolling and had actually read the page then you would have notice that there are multiple benchmarks. And they show that they're about equally fast.

>Nevermind the fact that the ocaml code isn't even compiled but rather interpreted
The OCaml for this benchmark was compiled, fagtron.

>Not only that, but the figures reported couldn't even be reproduced by the author because the compiler stopped working with the next version and the gcc D compiler was significantly slower than the reported figures. In fact, the author notes that D was so shit that he had to use the C printf instead of D's writeln.
And if you had paid ANY attention then you'd have realized that he made the first benchmark on an unsupported platform. And said benchmark doesn't even list D.

You are a fucking moron.
>>
>the year is (sum [2000, 10, 6])
>unironically shill for D
Why would anyone do it? D is stuck somewhere in between "practical but not hip" like C++ and Java and "not so practical but hip" like Haskell, OCaml and Go, being unpractical and not hip itself. It brings nothing new and offers no obvious advantages over established languages.
>>
How do I contribute to FOSS projects?
I mean like literally where to look for them and how to send them my contributions.

Are there any Java FOSS projects I could contribute to?
>>
>All these programming language wars
>Literally all of them are garbage collected
>inb4 muh optional in D

C, C++ and Rust are you only options.

I'm hoping for something like rust but with less restrictions as well.
>>
>>54034770
https://github.com/explore
https://github.com/trending/java
>>
File: maki.jpg (590 KB, 1240x1550) Image search: [Google]
maki.jpg
590 KB, 1240x1550
hello where is discussions about best girl?
i program hello world in C btw
>>
>>54034685
https://dlang.org/overview.html
>>54034770
Either look at the specific project you're interesting in and find the page where they tell you how to. Or find them on github and make pull requests.
>>
>>54034685
D has no niche. That's why nobody uses it.
>>
Is there a way to combine two csvs with different columns, sometimes sharing some? I just spent awhile making a python script to combine multiple csvs with different columns. Did I waste my time? I couldn't find anything with my google-fu.

Something like:
csv1.csv:
a b
1 2
2 3
csv2.csv:
a c
4 5

csvcombined.csv:
a b c
1 2
2 3
4 5

The closest thing I could find was something called pandas?
>>
ugh. spacing is wrong.
csvcombined.csv: should be like
a b c
1 2 null
2 3 null
4 null 5
>>
File: amelia_parliament_0.png (924 KB, 1280x720) Image search: [Google]
amelia_parliament_0.png
924 KB, 1280x720
>>54034804
>best girl
Amelia Andersdotter.
>PirateParty
>Runs Arch Linux
>Fights for freedom so you don't have to
>Agrees with me on pretty much everything except concessions made to stay politically relevant.
Bestest girl
>>
>>54034878
>3D
>>
>>54034822
Write it yourself?
You're a programmer right?
>>
>>54034805
> https://dlang.org/overview.html
I read it already, the problem is, there is "better C++ than C++", it's called C++14, it's fully backward compatible with C++03, supported by all compilers and it has no fucking GC. And if you're Ok with GC, then Java/C# are better languages with huge infrastructure and major corporations behind them. If you want to write something fast, then Python is a better choice, and if you want to learn something new, then Haskell, OCaml or Lisp is your choice.
>>
File: Capture.png (11 KB, 654x84) Image search: [Google]
Capture.png
11 KB, 654x84
>>54034797
Jesus.
>>
>>54034833
use comma, semicolon delimiter
>>
>>54034822
Pandas is your best bet if you don't want to write everything yourself, yes.
>>
>>54034363
But i want to get the html contents to make a list and show some data
>>
File: made_in_africa.png (7 KB, 313x194) Image search: [Google]
made_in_africa.png
7 KB, 313x194
>>54034909
>African tech is booming
>16 repositories
>>
>>54034611
I r8 it b8/8, you got me!
>>
If i may humbly ask, if i put a pointer (which is the root for a binary tree) as a function parameter which adjusts itself to either the right or left node for every recursion, for each time it recurses the pointer that has been adjusted is a copy right?

here is the function:

node *addleafprivate(int key, node*ptr){
if (ptr == NULL){
node *nt = new node;
nt->left = NULL;
nt->right = NULL;
nt->val = key;
return nt;
}
if (key < ptr->val){
cout << "before value is: " << ptr->val << endl;
ptr->left = addleafprivate(key, ptr->left);
cout << "current value is: "<< ptr->val << endl;
}
else if (key > ptr->val){
cout << "before value is: " << ptr->val << endl;
ptr->right = addleafprivate(key, ptr->right);
cout << "current value is: " << ptr->val << endl;
}
else{
cout << "m8 number added bub" << endl;
}

return ptr;

}
>>
>>54034796
ATS and clean aren't GC'd.
>>
>>54034899
>And if you're Ok with GC
Not entirely sure what's so bad about having the option. If you're working with people who consider it tell them no and tell them to stfu.
>if you want to write something fast write python

>better c++
Anon. There's degrees of better. The C++ committee has no hope of ever producing something good enough. C++ 14 has hardly any major improvements upon the old standard. Oh and also. This is C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf
This is D
https://dlang.org/dlangspec.pdf
There's a difference in page count. And the additional features D has are far bigger than C++.

But I'm not all that interested in D. It's what I replace C++ with because it's better in every aspect pretty much but it's not like its the ideal programming language.
There's no language I know of that I'd consider good/great.
>>
>>54034976
depends on how the struct is defined, because
ptr->left
dereferences the value at that pointer, so if it's defined as a pointer than it will be fine. if it's a value then you're passing a copy.

the problem with your code is that when you pass it a null pointer you're not updating the parent node to point at the new child. for all intents and purposes the parent still points to a null pointer.

also use code tags next time.
>>
>>54034976
better format:
node *addleafprivate(int key, node*ptr){
if (ptr == NULL){
node *nt = new node;
nt->left = NULL;
nt->right = NULL;
nt->val = key;
return nt;
}
if (key < ptr->val){
cout << "before value is: " << ptr->val << endl;
ptr->left = addleafprivate(key, ptr->left);
cout << "current value is: "<< ptr->val << endl;
}
else if (key > ptr->val){
cout << "before value is: " << ptr->val << endl;
ptr->right = addleafprivate(key, ptr->right);
cout << "current value is: " << ptr->val << endl;
}
else{
cout << "m8 number added bub" << endl;
}

return ptr;

}
>>
>>54035023
>>54034976

wait shit, i didn't read that properly cause of the bad formatting. ignore the second part.
>>
>>54035034
its ok, im grateful for the help im getting
(no sarcasm intended)
>>
>>54035047
no problem, is something about it not working?
>>
>>54034920
Thus why I suggested a webview so you can let it render the page w/ all JavaScript bullshit then grab the content off it.
>>
>>54034987
Clean is functional and not suited for most general purposes.
I'll have a look at ATS though.
>>
>>54035062
im just curious how it works, because it seems that im passing in a copy.

here is the result i get after compiling it:
>>
>>54035071
I was reading about it how do i save the login credentials? Or post the form i was thinking of textviews with the credentials and then attempt to login but with web view how would i do it? with cookies from httpUrlConnection? I don't know shit about this honestly
>>
>>54030402
kukri is best knife
>>
>>54035008
>Not entirely sure what's so bad about having the option
And what option should the Standard Library and third-party libs support? How do you integrate code written for GC with manual memory management? Three is no reason to be schizophrenic about GC, you either build your entire ecosystem around it or not.
>C++ 14 has hardly any major improvements upon the old standard
Yes, because it was a minor release after major C++11.
>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf
>https://dlang.org/dlangspec.pdf
First of all, standard is obviously more verbose than informal specification. Second, the actual language is described in the first 400 pages, the rest is description of the standard library. There is no mention of a standard library (which one?) in D specification. So C++ is actually smaller language.
>And the additional features D has are far bigger than C++
Yet at the same time it lacks other major features, like move semantics and generic lambdas.
>replace C++
If you want to replace C++, you should really try Rust, at least it brings something actually new.
>>
>>54035137
I dunno how to do that w/ Android, using Qt I could just use evaluateJavaScript() method on the view, so I could simply fill the data and submit the form using some injected JS. Look for equalivent function perhaps.
>>
>>54030701
write 10 - 20 compilers
>>
>>54035100
it may be hard to tell because your print statements aren't really telling you much.

how are you traversing the tree when you print it?

you can try an inorder traversal like
void print_tree(node *root) {
if (root == NULL) {
return;
}
print_tree(root->left);
cout << root->val << endl;
print_tree(root->right);
}
>>
>>54035062
Oh yes btw, my struct for the nodes is:

 struct node{
int val;
node *left;
node *right;
}
>>
>>54031946
For one off programs that is okay but generally you should only create a few instances of Random and reuse them because initially the seed is set to the current time in milliseconds which will give you less evenly distributed numbers.
>>
>>54031671
maybe try and install an old version of Visual studio (Visual C++ 4.0 maybe)
>>
>>54035277
or Visual C++ .NET 2003
>>
>>54035208
>>54035208
for print funct this is mine

void privateprint( node *ptr){
if (ptr != NULL){
if (ptr->left != NULL){
privateprint(ptr->left);
}
cout << ptr->val << endl;
if (ptr->right != NULL){
privateprint(ptr->right);
}
}
else{

cout << "teh list is empty bub" << endl;
}
}
>>
File: o3fkz[1].jpg (274 KB, 1920x1200) Image search: [Google]
o3fkz[1].jpg
274 KB, 1920x1200
>>54032350
>>
>>54031946
Solution to your original problem is to pass the time in milliseconds as a seed in the random constructor. That works too though.
>>
File: 1441875046526.jpg (34 KB, 498x482) Image search: [Google]
1441875046526.jpg
34 KB, 498x482
>>54032806
>O(n) where n is the length of the string to match
>regex is fucking slow
kill you're self
>>
File: 1431288185682.gif (496 KB, 500x455) Image search: [Google]
1431288185682.gif
496 KB, 500x455
>ITT indians struggling to code
>>
>>54035382
>making fun of people honestly trying to learn
Reddit is that way, friend.
>>
ITT: people that actually watch anime

how embarrassing.
>>
I love dictionaries
>>
 (Python2)
>>> C
['x', 'xII']
>>> D
['x', 'xII']
>>> C.remove('xII')
>>> C
['x']
>>> D
['x']


What the fuck. Why? You guys were right dynamic langauges are fucking retarded.
>>
>>54035448
Most likely because you did D = C and keep a reference but you clearly didn't show us that step because you wanted to be clever and have a reason to bitch about?

This is the same as if you were bitching about that in C:
int *a = malloc(sizeof(int));
int *b = a;

*b = 5
Oh my god, why is a 5 now?!
>>
File: 161017757_44042348.jpg (67 KB, 590x632) Image search: [Google]
161017757_44042348.jpg
67 KB, 590x632
>>54035448
that has nothing to do with the language being dynamic or not, fucktard. do you even know what's a reference type ?
>>
>>54035477
wtf isn't it = &a
>>
>>54035511
That would be the address to the pointer containing the address to the value.
>>
>>54035477
No I'm not trying to hide the fact that I put D = C that's obviously what I did, it's counter intuitive because D should be a new object, what's the point of defining a new object if any manipulation of the old object has the exact same effect of the new one, so you have a new retarded variable that doesn't do anything other than be a name for another thing. I don't see the point at all.
>>
File: Untitled.png (9 KB, 769x293) Image search: [Google]
Untitled.png
9 KB, 769x293
>>54035448
>what are references
>>
>>54035511
lel, just.. stop.. posting
Thread replies: 255
Thread images: 36

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.