[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: 25
old thread >> 54253840

What are you working on /dpt/?
>>
>>54262333
bump
>>
bool isPrime(int num){

}


do et
>>
File: cibomatto.gif (200 KB, 80x160) Image search: [Google]
cibomatto.gif
200 KB, 80x160
>>54262176
>>54262219
>>54262333


AAAAAAAAAAAAAAAA
>>
>>54262333
Commit suicide.
>>54262435
>>
fuck. yeah. we won. thanks based mod
>>
BASED MODS
>>
>>54262695
>>54262736
by 'it' i mean OP's font rendering. i looked at yours and it genuinely looks shit, it's like bold, it's all intense and in your face. for fuck's sake get a grip delusional butthurt fag
>>
>>54262768
and it has fringing artifacts or something, there's something seriously wrong with it, it's not aesthetically pleasing at all, it hurts to look at
>>
>>54262768
It looks bold on your shit tier low dpi screen probably
>>
>>54262781
kill yourself

>>54262116 certainly looks better than >>54262065
>>
>>54262776
where.

This is scaled up btw and the screenshot has compression etc.
>>
dude weed.
>>
File: fringing.png (1 MB, 2048x540) Image search: [Google]
fringing.png
1 MB, 2048x540
>>54262802
look around the edges of the letters. there are clearly fringing artifacts. around the edges it's a lot brighter than either the text or the background.
>>
File: 1461477468308.jpg (95 KB, 757x878) Image search: [Google]
1461477468308.jpg
95 KB, 757x878
How do I get started of building actual programs?

I've only had experience in building programs that are much more suited to mathematical languages such as MATLAB and don't know where to start looking for where I can get information on getting a program to interact with a host machine more than parsing a file in and out of a .bat file.
>>
>>54262419
// TODO (Anonymous): Find out why this function does not work
bool isPrime(int num) {
return false;
}
>>
>>54262824
anime
sluts
>>
File: sensible font rendering.png (273 KB, 1740x436) Image search: [Google]
sensible font rendering.png
273 KB, 1740x436
>>54262821
>>
I reiterate, all forms of font smoothing are disgusting. We've already had the solution for many years -- bitmap fonts.
>>
>>54262824
learn about OOP (preferably on C++ first)

It's not shitty once you get past the object part
>>
File: 1452997698979.jpg (21 KB, 352x385) Image search: [Google]
1452997698979.jpg
21 KB, 352x385
how the fuck do I contact a user on bitbucket?
>>
>>54262895
OOP is a stupid way to structure programs. It just leads to all sorts of unnecessary complexity.
>>
>>54262900
send them a mail?
>>
>>54262895
>OOP
disgusting
>>
>>54262915
just found out you can only send internal messages
>>
>>54262419
#include <stdio.h>

main()
{
int i, p, j = 104729;
for(i = j; i > 0; --i) {
//printf("%d\n", i);
if(j % i == 0) p++;
}

if(p > 2) printf("not prime\n");
else printf("prime\n");
}
>>
>>54262900
go to their profile and click "Send Message"?
or >>54262915
>>
>>54262909
>>54262918
retards confirmed

>>54262895
learn it in java it's much easier
>>
>>54262872
I see what you're seeing, but realistically you can't see it on my screen even if I put my face on the fucking screen. I guess that would mean going back to original argument "buy a retina screen lol" but seriously it's font rendering who gives a flying fuck except for web devs.
>>
Inheritance style of program building leads to a lot of awkward hierarchies and the worst of all, "class relationships"
Compositional style tends to deliver programs that are easier to reason about
>>
answer this easy question stupid shitters

if a float type has a magnitude range of (2^-62, 2^62) and can accurately represent all integers between -2^16 and 2^16, then can it represent e.g. (14.125 + 1.0/(2^10)) with full accuracy? and a float type with a magnitude range of (2^-14,2^14) and an integer range of (-2^10,2^10) can not?
>>
>get a job offer for a small business I'm interning at right now
>it's decent, but I counter back with $15k more, expecting them to go down to $5k or $7.5k
>they accept without countering back
Wtf, I honestly didn't expect this. Is this normal?
What am I going to do with all this money?
>>
>>54262932
If you already know any decent programming language, I agree. If you don't stick to C++
>>
I'm interested in collision detection.

Let's say my player moves at 5px at a time in a 2d plane. there's a wall 3px away from him. I want him to be flush up against the wall, so could I get the distance between him and the nearest wall, and then have him move that distance (3px)? How would this work for a tile diagonally away from the player?

Also, how can I detect collision without checking every single tile in the entire map? I was thinking of having a few quadrants of maybe like 25 tiles at a time, or maybe I could have it check on the tiles visible on screen?

I'm new to this. Any direction would be appreciated
>>
>>54262957
they probably offered a low to begin with because they thought you'd want a higher salary so you did what they wanted you to do, implicitly meet them halfway
>>
>OOP is shit!

I don't think OOP is the greatest paradigm, but I especially despise people who think they're on some Xth plane of programming clairvoyance by saying it's shit.

I'm tired of the memes.
>>
>>54262943
it's fucking gay, it's all what """"looks good"""" in the same way that a gucci handbag """"looks good"""", it's not useful in the long run, the font rendering is heavier, more intense and puts more strain on the viewer's eyes
>>
>>54262970
quadtree space partitioning
>>
>>54262978
C doesn't have OOP, therefore it's shit senpai.
>>
>>54262824
>>54262895
>learn about OOP
Learn about it, but don't get stuck at it, unless you want to be mediocre. OOP really only addresses one side of the expression problem. Do FP, too.
>>
>>54262988

You can do object-oriented programming in C, though. I'm not saying the language is designed for it, but a lot of programs are structured that way.
>>
>>54262999
this, using some form of OOP is pretty much the only way to have a large-sized program
>>
>>54262895
>C++ OOP
calm down, Satan.
Common Lisp Object System is what this anon needs to be exposed to.
>>
>>54263008
For program development? lel
>>
>>54262983
>quadtree space partitioning
Can you explain a little mor?
>>
>>54262895

I've done a course in OOP in university, but it taught us more about the theory than the application of said theory
>>
Is it possible to declare a function pointer that takes a function of any kind, not just the type and number of arguments it was declared as?
something like
void (*genericfunc)(...)
or whatever?
>>
File: 1458712160766.png (206 KB, 748x639) Image search: [Google]
1458712160766.png
206 KB, 748x639
>>54262333
>Follow along with this https://www.baserails.com/questions/adding-a-friendship-request-action
>NameError in (literally every page of my site I visit)
>undefined local variable or method `active_friendships' (in user.rb, the very first line of code I added from that guide; it's safe to assume that if I remove it, the next error message will be "undefined local variable or method `passive_friendships'" and so on)
>Followed the guide to the letter
>Entire site breaks
>That's been happening again and again and again for about a week now after reading and following along with every guide I've found on the internet about adding a friends system to your site
>Never been able to find a single stackoverflow response to these problems that actually works

Is there anyone out there who knows of a real, working guide to making a friendship system in ruby, in the year 2016? I think one of the biggest problems is that the vast majority of these guides were either written in 2009 or 2010 and never updated. That guide I linked above is from 2014, and it's by far the most recent one I've been able to find. And I apologize for being so shit, I just started getting into programming a few months ago. No college education, no help from friends, nothing but google and very, VERY rarely asking /g/ for advice in cases like this where I can't figure it out for a week straight or longer.
>>
first for D
>>
>>54263028
For a proper introduction to a sane means of object-oriented programming.
If you want to send some poor anon off with shit advice for "just making programs" then fuck it, go learn JavaScript and Python and have a field day.
To be fair, Python isn't all that terrible.
>>
>>54262419
#include <stdbool.h>
#include <stdio.h>
#include <curl/curl.h>

bool isPrime(int num) {
CURL *curl;
long http_code;
char buffer[1024];
sprintf(buffer, "http://numbers.mezurashico.com/primes/%d", num);

curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, buffer);
curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
curl_easy_cleanup(curl);

return http_code == 200;
}
>>
>>54263127
that's going to return true unless your internet isn't working kekekekekek
>>
how do i get the textbox values from a parent window to a popup window in c#?
>>
>>54263007
Bullshit.
Just leave state-wrangling to the DB and enjoy easy coding.
>>
>>54263151
>http://numbers.mezurashico.com/primes
http code is 404 if it is not prime
>>
>>54263196
>http://mezurashi.co/products/prime-number-api

wrong url
>>
>>54263064
In C, it is well defined to cast a function pointer to any type. It's just undefined behaviour to call a the function pointer if the function signature doesn't match the pointed-to function.
Where is a somewhat contrived example:
#include <stdio.h>

typedef void (*genfn_t)(void);
typedef int (*printf_t)(const char *, ...);

int call(genfn_t arg)
{
printf_t fn = (printf_t)arg;
fn("Hello world!\n");
}

int main()
{
call((genfn_t)printf);
}
>>
>>54263250
>to any type
To any other function pointer, i mean. C doesn't guarantee that function pointers and object pointers are compatible (but POSIX does).
>>
>>54263186
>>>/g/wdg
>>
>>54263251
were they endangered/illegal tortoises?
>>
>>54263251
There's no correlation, they hijack random stuff with random sales (whatever people pay them for).
>>
>>54263295
I have no idea, I didn't know you could get illegal tortoises. I'll investigate this.
>>
>>54263400
apparently that kind of thing (maybe not specifically with hacking websites) has been going on for quite a while

http://www.tortoisetrust.org/articles/imports.html
>>
>>54262970
analytic geometry
>>
>>54262333
>Sears edition

Bueno
>>
File: sears.jpg (67 KB, 620x465) Image search: [Google]
sears.jpg
67 KB, 620x465
>>54263488
>>
>>54263282
>implying dbs are only for the web
>>
Heads up my dudes, Humble Bundle is running a bundle of 1337 hacking books

https://www.humblebundle.com/books/no-starch-hacking-books
>>
>>54263036
google quadtree space partitioning
>>
>rendering font

not even once
>>
>>54263540
>the smart girl's guide to privacy
>>
>>54263526
they are, you're doing it wrong otherwise, you're doing some shitter app that doesn't require performance or sensible software engineering or anything
>>
>>54263452
>>54263452
I did a check on Wikipedia, they are all endangered species, some are illegal to take from the wild (and quite rightly so). Thanks
>>
>>54263540
>RE the Xbox

Wtf? I thought bunnie released that for free
>>
>>54263526
>>54263666
at the very least DBs aren't for managing the core business logic and state of your application for fuck's sake, they should be used for storing large amounts of data to persistent and widely accessible (over a network connection) storage
>>
>>54263079
your question is too specific to find a "tutorial" for. you need to think more abstract.
>>
>>54263540
I'm glad The Art of Exploitation is still relevant
>>
>>54263540
all gay/irrelevant as fuck
>>
>>54263666
>>54263711

Why would you not store your state in a DB? That's what they are for. (persistence as well, of course, be it local or remote)

I am working on something vaguely similar to adobe lightroom, and it performance is very much a concern, btw.
>>
>>54263782
kill yourself

i'm off to bed now i don't give a shit about arguing about this inane bullshit topic, it should be completely obvious why you wouldn't use a database as some sort of state machine, your program is the state machine and you write the "produce" to the database, not every single variable etc of the program, fuck you
>>
>>54263823
>variables
Why use those at all?

Anyways, good night.
>>
>tfw stray newlines in input stream fuck everything
Basically I have to read line by line. Line is either a character, number, or empty(newline).
If that character is x, then read that number, if that character is y, then print something, if it's a newline, then do other thing.
>>
>>54263939
and what's the problem?
>>
>To make a global variable in Javascript, you have to rely on the DOM element

I don't believe this shit.
window.VAR = "foo";  // we global variable now


Now I know why you neckbears hate Javashit.
>>
>>54263952
>>To make a global variable in Javascript, you have to rely on the DOM element

not really... plenty of reasons to hate js anyways
>>
>>54263952
No, you define the variable outside of the function's scope.

Also, surprise:
d = 'hello';
"hello"
console.log(window.d);
hello


It's attached to the window by default. But JavaScript is shit anyway.
>>
>>54263979
>plenty of reasons to hate js anyways

I dislike it because I heard rumors that Brendan Eich is a jew.
>>
>>54264048
But he was kicked from being Mozilla's CEO because he opposed gay marriage or something.
>>
>>54264098

Oh wow, that's pretty rad. Maybe it isn't so bad.
>>
Hey guys, writing some C++ here.

I have a class template, and I'm supposed to overload operators (- + * <<) for ease of use. How do I pass in the template object as an argument to the function (in order to print it)? This is what I have so far:

//header file
template <typename T> class matrix {
...
//this gives "matrix does not name a type" comp error
friend ostream& operator<<(ostream&, matrix&);
//same error here, with another syntax error
friend ostream& operator<<(ostream&, matrix<T>&);

...
}
>>
>>54264098
why cant he just have his opinion and not lose his job over it
>>
>>54264048
OTOH, Abelson & Sussman both sound pretty jewish and /g/ worships them.

So do Liskov & jerusalemschy (or hower the lua guy's name is written)

And McCarthy was definitely Jewish.
>>
>>54264155
Because SJWs
>>
>>54264155

SJW won't let you do that.
>>
>>54263948
minor errors, finally got it to work
>>
>>54264155
because having certain opinions affects a company's prospects for revenue.
>>
>>54264162
>jerusalemschy

I actually chuckled, good work.
>>
>>54263711
>DBs aren't for managing the core business logic and state of your application for fuck's sake,
of course, but that doesnt't mean that your program should have any sort of core state
>>
>>54264144
http://stackoverflow.com/a/4661372
>>
I'm also the author of ied, a package manager for Node. I mostly code in JavaScript and Go nowadays, but tend to make fun of Haskell on Twitter. Some of my code is on GitHub.
>>
>>54264398
how does it feel knowing that you put your users on government watchlists every time they use your software?
>>
>>54262419
boolean isprime(int num){
int i = num -1;
while(i>1){
if(num % i == 0){
return false;
}
i--;
}
return true;
}
>>
>>54264225
I don't get the argument that dbs are not for managing state. While it is not your only option, I think it's a perfectly ok use for them.
>>
>>54264444
depends on the kind of state you're storing. if you're keeping track of where in the program you are that would be slow as fuck to fetch from a DB (but also probably bad program design).
also check'd
>>
>>54264438
stupidly inefficient.
>>
>>54264463
I mean, your DB could be in memory, making it less than as fuck slow, but I guess I understand what your saying. For really transient state (is this button being pressed?) it would be overkill.
>>
>>54264248
Thanks man.

This has to be the most convoluted shit I've ever seen.
>>
>>54264426

If you aren't already on gov't watch lists, then you aren't living.
>>
I tried java ages ago and I never really got the hang of it, what are good programming languages to learn that aren't c or any varient of this or python.
>>
>>54264552
SQL
Some lisp (I recommend clojure or racket)
JS (not good, but it's everywhere, so doesn't hurt to know a little)
Maybe C# (like Java but a bit saner)
>>
>>54264552
C#, C++.

Apart from those it really depends what you are trying to do. Those the best general purpose ones I can think of.
>>
>>54264466
boolean isprime2(int num){
int i = 2;
while(i*2 < num){
if(num % i == 0){
System.out.println(System.currentTimeMillis() - tStart);
return false;
}
i++;
}
return true;
}

twice as fast, so half as stupid i guess?
>>
i'm going to make a computer algebra system.
How the fuck am i going to represent the data, and work on it internally.

So far i have these two representations, i came up with both but i have no idea of the advantages and disadvantages of each

Type A:
 class Node {
int type, id;
vector<Node*> children;
}
class Leaf
{}
class Tree{
Node* main;
vector<Leaf*> Constants;
}

No inheritance for Node, if its a connection Node, it will hold a type and ID that both show what kind of node it is.
i.e. a + could be a Type 1 ID 1
a * Type 1 ID 2
a cos Type 2 ID 1
a sin Type 2 ID 2
and so on based on what i tell each type is.
as for leaf nodes, they have 0 children and they have a type that tells what kind of leaf node it is. The ID is used as an index to where the data it holds in the Leaf vector.
Leaf class is basically a father class that is used as a base
ie. class Variable : public Leaf
or class Number : public Leaf
or class Franction : public Leaf

Type B:
class Node{
}
class Connection:public Node;
class Leaf: public Node;

Where everything inherits from Node.
and i'd use virtual functions to represent how each should react to a certain thing that happens.
feels like the least memory hungry implementation but the most headache inducing with having to try and handle covering the tree and stuff.

It kinda annoys me that i can't find a decent thing that shows how each and every implementation is good and bad out there.

and i saw yacas, but for some reason, i can barely understand anything in the code.
>>
>>54262419

Use Fermat's primarity test Luke
>>
>>54264744
For starters, why aren't you using a for loop? There is absolutely no reason for that to be a while loop.
There is absolutely no reason to check any even numbers (besides 2) because they are all guaranteed to not be prime.
You only need to check up to the square root of num, as no factors of it are going to be larger than that.
>>
>>54264830
>For starters, why aren't you using a for loop? There is absolutely no reason for that to be a while loop.
There is no reason for it to be a for, either. Both work the same.

>There is absolutely no reason to check any even numbers (besides 2) because they are all guaranteed to not be prime.
Even numbers will break the loop inmediately, duh.

>You only need to check up to the square root of num, as no factors of it are going to be larger than that.
That's exactly what he's doing.
>>
>>54264876
>That's exactly what he's doing.
Oh, nvm. You were right there. Should be i*i.
>>
>>54264876
>There is no reason for it to be a for, either. Both work the same.
for is more concise.
>>
>>54264904
True that.
>>
>>54264830
boolean isprime3(int num){
for(int i = 2; i*i<num; i++){
if(num % i == 0){
return false;
}
}
return true;
}

>Version 3 - what should have been
>>
>>54264979
fails for 2 and 3.
>>
>>54264979
>i++
i += 2
>>
>>54265027
I mean, for 1.
>>
>>54264798
Why not just do a regular AST (abstract syntax tree):
enum ExprKind {
Variable,
Constant,
Sum,
Product,
};

struct Expr {
ExprKind kind;
std::vector<Expr*> children;

float constant;
std::string variable;

explicit Expr (ExprKind k) {
kind = k;
}
};

int main () {
// a * x + 1
Expr* sum = new Expr(Sum);
Expr* prod = new Expr(Product);
Expr* a = new Expr(Variable);
a->variable = "a";
Expr* x = new Expr(Variable);
x->variable = "x";
prod->children.push_back(a);
prod->children.push_back(x);
// prod = a * x

sum->children.push_back(prod);
Expr* c1 = new Expr(Constant);
c1->constant = 1;
sum->children.push_back(c1);
// sum = <prod> + 1
// = a * x + 1
}
>>
when working with overloaded operators, how do you properly resolve the scope (namespace? what's the term?) of the operators?
eg:
 cout << a == b << endl; 

where the bitshift operator is the standard overloaded output operator and the equality operator is overloaded to compare objects 'a' and 'b' and return a bool. compiler spits an endless amount of warnings out at me, so i'm pretty sure i'm missing a step.
>>
>>54264144
>>54264248
ok i got the extrovert option and how its different from what anon has done.
but why did the introvert approach not work for this anon. isn't it basically the same thing?
only different i see is that matrix& was const in the answer.
>>
>>54265048
Do you know how primes work?
>>
>>54265055
ignore me, i'm retarded. parens are king.
>>
>>54265073
1 is not prime.
>>
>>54265055
The precedence? It stays the same.
>>54265039
no, that would skip testing division by e.g. 3
>>
>>54265073
>>54265082
But that code returns true.
>>
How to get a random word from a file that has one word per line?

My first idea was to get the file size with fseek + ftell, then when I want to get a random word, fseek to a position less than the file size, then read chars until a newline, then fgets. However, I read that the method of getting file size with fseek, ftell isn't portable with Windows, which is what my professor uses

Should I unironically call fgets a random number of times less than the number of lines in the file?
>>
>>54265085
i think the compiler was trying to assign the value of object a to stdout via the bitshift operator which was overloaded to perform additive operations to members of a's class. parens solved it nicely
>>
>>54265085
>no, that would skip testing division by e.g. 3
I forgot that i should be initialised to 3. Also, 1, 2 and even numbers should be a special case at the start.
>>
>>54262419
int isPrime(int n) 
{
int a;
int ceiling = sqrt(n);
if (n > 0)
goto end;
if (n == 2)
goto ok;
else
{
for (a = 0; a < ceiling; a++)
{
if (((a % n) == 0) && a != n)
ok: return 1;
}
}
end: return 0;
}
>>
>>54265062
because he's only had a declaration within the class, not the definition
>>
File: rust.jpg (93 KB, 450x450) Image search: [Google]
rust.jpg
93 KB, 450x450
I'm trying to be an adult and program outside of linux for once but I have no idea what I'm doing
Should I install Visual Studio or Visual Studio Code?
>>
>>54265049
so basically fuse all of them into 1?
but i'm planning to have a variable hold a name and a vector of results.
while a fraction holding 2 integers...
oh i see, the max number of things i'd need is
a vector of children, 2 identifiers, and a string and 2 integers.
but won't this implementation be memory costly? i did consider this to an extent, but it seemed more costly than my Type A
>>
>>54265108
But if you initialize i to 3, num = 8 would return true.
>>
>>54265122
>be an adult
>Sacrificing your freedom is "being an adult"
>Sucking microshaft's cock is "being an adult"
>>
>>54265122
VS community
>>
>>54265104
nevermind, it was the endl. i'm still not really sure why, but it was trying to add endl as an int (the function of the overloaded bitshift operator) to b's data structure. fucking c++
>>
>>54265100

That's literally the 'shuf' util. Look at the source code perhaps.
>>
>>54265150
which options do I enable? I just want to make stuff in C++
>>
>>54265027
 boolean isprime4(int num){
if (num == 1 || num == 3 || num <= 0) {
return false;
}
if (num > 2) {
for(int i = 2; i*i<num; i++){
if(num % i == 0){
return false;
}
}
}
return true;
}

> Chapter 4. The Return of the Prime
>>
>>54265140
>even numbers should be a special case at the start
I'll just post what I'm talking about:
bool is_prime(unsigned n)
{
if (n <= 1)
return false;
if (n % 2 == 0)
return n == 2;

for (unsigned i = 3; i <= sqrt(n); i += 2)
if (n % i == 0)
return false;
return true;
}
>>
>>54265156
fstat() is POSIX.
>>
>>54265179
>>54265184
both return false for 3 (which is prime)
>>
>>54265178
The visual c++ option
>>
>>54265213
No it doesn't. 3 > sqrt(3), so the loop never executes, and immediately returns true.
>>
>>54265131
Technically you have a few extra bytes in there that aren't always used. But vtables in OOP are costly too. I'm just not a big fan of OOP, I'm currently writing an entire language parser and evaluator with type inference and I'm not using inheritance once, just not a big fan.
The pro to doing it this way is that it's really easy to obtain the children expressions of any node, for if you want to apply an operation to all sub expression (e.g., search for a variable by name). But it is a matter of style. The OOP way would be
struct Expr {
virtual ~Expr () = 0;

virtual std::vector<Expr*> get_children () {
return std::vector<Expr*>();
}
};
Expr::~Expr () {}

struct ExprVariable : public Expr {
std::string name;
// ...
};
struct ExprConstant : public Expr {
float constant;
// ...
};


It's more boilerplate than I'd be happy writing but if you want to OOP, then OOP away
>>
>>54265250
You are right.

i*i <= n would probably be slighly faster, no?
>>
>>54265284
sqrt is only executed once (any compiler would perform an operation this simple), while yours has a multiplication every loop. If you were super paranoid about that optimisation not happening, you could pull the sqrt out of the loop.
Yours MIGHT be slightly faster for small numbers, but would definitely be slower for big numbers.
>>
>>54265326
>while yours has a multiplication every loop.
its optimized u dip

isprime4(int):
cmp edi, 3
sete sil
cmp edi, 1
setle al
or sil, al
jne .L6
cmp edi, 4
jle .L7
test dil, 1
je .L2
mov ecx, 2
jmp .L4
.L5:
mov eax, edi
cdq
idiv ecx
test edx, edx
je .L2
.L4:
add ecx, 1
mov eax, ecx
imul eax, ecx
cmp edi, eax
jg .L5
.L7:
mov esi, 1
.L2:
mov eax, esi
ret
.L6:
xor esi, esi
mov eax, esi
ret
>>
>>54265326
Oh, yeah, of course.
>>
>>54265274
i'm still learning, why would i say no to OOP alternatives
also didn;t know vtables were performance costly.
styles wont matter if i end up with a better result, plus learning more style might ease me up into reading code done by other people.
Would love to read anything you can add up on what you already taught me with that reply.
>>
>>54265370
>imul eax, ecx
>>
File: me.jpg (75 KB, 720x960) Image search: [Google]
me.jpg
75 KB, 720x960
>>54262333
What do you guys wear when you program? Pic related is what I wear. A nice little dress.
>>
here's a real fucking challenge m8s

template<typename T>
double nroot(T num, int root){

}


Get the degree of root based on the input
>>
>>54265511
Do your own Meme++ homework
>>
>>54265497
>What do you guys wear when you program?

Khakis.
>>
>>54265511
return pow(num,1.0/root);
>>
>>54265537
lol what shitty class would have homework like that. Besides, school is over with.
>>
>>54265497
boxers and a t shirt

im in bed any time im programming
>>
>>54265497
Did your mum take that photo?
>>
File: GithubFaggotCat.png (35 KB, 1200x630) Image search: [Google]
GithubFaggotCat.png
35 KB, 1200x630
I'm a bored developer, anyone want to make a project together? It can be any number of n anons.
>>
>>54265561
yes
>>
>>54265579
Yeah sure, but it has to be in C89.
>>
>>54265579
throw up a repo on github and let all of /dpt/ contribute.
>>
>>54265588
I'm in.
>>
>>54265579
Like what?
>>
>>54265579
I'm in yo

I call C++
>>
>>54265614
>>54265590
>>54265588
What are we developing?
>>
no one told me ddd existed... ive been using command line gdb and list all this time...
>>
>>54265588
>C89
Use C11, you stupid fuck. There is no valid reason to start a new project in C89.
>>
https://github.com/GOPLamda/TheGNULinuxFreedomGame


Pick Language.
http://www.strawpoll.me/10069824
>>
>>54265641
There isn't much of a difference desu.
You can use whatever C version you want, i'm still gonna be writing standards compliant ANSI C.
>>
>>54265641
>Not using C99
kek
>>
>>54265649
>There isn't much of a difference desu.
int main()
{
printf("Hello world\n");
int a;
}

>This is invalid C89

>>54265651
I was advocating for the use of a later C standard though. C11 is preferred, but C99 is acceptable.
>>
>>54265651
>>54265641
>not using Rust
get on with the times, grandpas
>>
>>54265621
Don't know, but I'll make the logo!
>>
I'm closing the poll at 11pm CST. Get your voice represented by picking the best language.
>>
>>54265645
>C/C++
Are you fucking serious? Those are two completely different languages.
>>
>>54262333
I am trying to work out how to make a name proper case and pAtErN case with C++. This is what I have so far. I have already figured out upper case and lower case.

void toProper(char *p)
{
// write code to convert to proper case i.e. firts capital and rest small

if (*p == 0)
{
while (*p)
{

*p = (*p>='a' && *p<='z') ? *p=*p-32 : *p;
p++;

}
}
else
{

while (*p)
{

*p = (*p>='A' && *p<='Z') ? *p=*p+32 : *p;
p++;

}

}


}

void toPattern(char *p)
{
// write code to convert to the pattern ... aBcDeFgHiJ...one capital and one small
}


How do I do this? I thought I could just use an if statement for proper case, and then modular arithmetic for the pattern (even odd), but it doesn't work.
>>
>>54265756
Oh my fucking god you autist. C++ has all the same features as C + OOP.
>>
>>54265786
You clearly know nothing about either language.
>>
>>54265786
>C++ is just C with OOP

wow

If we decided to write the project in one language, it would be completely different than if it were written in the other
>>
>>54265810
>>54265796
trolled you :^)
>>
>>54265786
idiomatic C++ looks absolutely nothing like C
standards compliant C doesn't even compile in a C++ compiler
>>
>>54265775
God damn, that is some shit code.
Also, I don't know enough about the input the function expects to be able to help.
Is it supposed to be only a single word or a sentence?
If it's a sentence, is it supposed to output "hElLo WoRlD" or "hElLo wOrLd"?
>>
File: wow.jpg (75 KB, 1042x619) Image search: [Google]
wow.jpg
75 KB, 1042x619
You guys sure do like Java huh?
>>
>>54265859
I said name you fucktard.

pAtErN case is the second one.
>>
>>54265890
Why don't you go eat some black monkey ass hole you fucking dip
>>
>>54265863
I'm sure less people would vote for java if c and c++ were separate. Many faggots here hate one or the other so wouldn't vote for both together, not to mention that grouping them like that is pants-on-head retarded.

and the guy voting for python is obviously trolling
>>
>>54265775
pid_t dfork(int infd, int outfd, int errfd, const char *dir, mode_t mask)
{
int rw[2];

if (pipe(rw) == -1)
return -1;

pid_t pid = fork();

if (pid == -1)
{
close(rw[0]);
close(rw[1]);
return -1;
}

if (pid)
{
close(rw[1]);
if (read(rw[0], &pid, sizeof(pid)) != sizeof(pid))
pid = -1;
close(rw[0]);
return pid;
}

if (close(rw[0]) == -1 || setsid() == -1 || (pid = fork()) == -1)
{
close(rw[1]);
exit(1);
}

if (pid)
exit(0);

pid = getpid();

if ((dir != NULL && chdir(dir) == -1) ||
dup2(infd, STDIN_FILENO) == -1 ||
dup2(outfd, STDOUT_FILENO) == -1 ||
dup2(errfd, STDERR_FILENO) == -1 ||
write(rw[1], &pid, sizeof(pid)) != sizeof(pid))
{
close(rw[1]);
exit(1);
}

close(rw[1]);
umask(mask);

return 0;
}
>>
>>54265910
>Implying I don't have a VPN with which I can vote Java multiple times
>>
>>54265890
>you fucktard
Feeling insulted, are we? Just so you have something to compare it to, here is some code for Propercase that doesn't suck.
void proper_case(char *str)
{
*str = toupper(*str);
while (*++str)
*str = tolower(*str);
}
>>
>>54265823
>I_was_only_acting_retarded.jpg
>>
>>54265929
k Pajeet
>>
>>54265931
>I_was_only_pretending_to_be_a_programmer.jpg
>>
Ok /dpt/ I wan't to learn a new language but I can't think of one because I have a few constraints on what I can learn. The langauge can't be Functional, Object oriented, interpreted or web based. Please help
>>
>>54265978
Assembly is the only one that isn't one of those
>>
>>54265978
C
>>
>>54265978
Rust
>>
>>54265978
rust
c
assembly
>>
>>54265997
>>54265999
>>54266001
>>54266007
man i sure am slow to type, but that ended up being a good summary of the answers
>>
>>54265939
You know that you're only supposed to call someone pajeet when they say anything positive about anything related to Java or Microsoft, right?
Get your memes right.
void pattern_case(char *str)
{
for (bool l = true; *str; ++str, l = !l)
*str = (l ? tolower : toupper)(*str);
}
>>
>>54265978
Python
>>
For those of you who use Visual Studio with Python, how the fuck do I import a built-in module, so that Intellisense can detect it?
>>
>>54266022
Pajeet shut the hell up. Go shit in the street or something geez oh man
>>
>>54266007
Im coming from C++ so will that make it easier to learn C?
>>
>>54265931
That wasn't me.

http://c-faq.com/misc/cplusplus.html

What I meant was a C styled language and based on the framework we chose we'd go straight C or C++. I figured most people know those languages and would feel comfortable working in either one. So I grouped them together because of the library space and similarities.
>>
>>54266027
import *your module here*
>>
>>54265978
SQL
Prolog
Logo
>>
>>54266039
Having the ++ so that you can increment values.
>>
>>54265978
>web based
What does that even mean in the context of languages? HTML?
>>
>>54266024
>object oriented
>interpreted
>>
>>54266066
>>web based
having a website
>>
File: screen.1461814414.png (6 KB, 620x161) Image search: [Google]
screen.1461814414.png
6 KB, 620x161
>>54266043
nope
>>
>>54266039
Not any much as knowing Java already will help you learn C. Although you already know what pointers are so that's good.
>>
>>54266066
PHP, javascript,CSS. Shit like that
>>
This question is for all the people that hate OOP. What language do you use?
>>
>>54266086
Your not doing it right.
>>
>>54266117
c89. c99 is bloat
>>
So I'm starting with C# and for my first little application I'm gonna build a time clock application. I want to be able to add employees, allow employees to clock in and out and record their times to a text file. What I'm curious about is how to structure it in an OO way. I've read you should typically convert nouns into objects so I imagine I should have an employee class and a time clock class.

I'm not sure how to split up the methods though. Should the employee class have a clock in method or should the time clock have it? Or should I only have a time clock or employee class that has all the functionality?

I guess my basic point is, how do I figure out how to structure my applications (simple as they may be)?
>>
>>54266156
Go home, granddad.
>>
>>54266135
No shit that's why I asked the question.
You're useless, stop replying to me.
>>
>>54266180
No
>>
File: not.jpg (58 KB, 600x600) Image search: [Google]
not.jpg
58 KB, 600x600
>>54265671
>>54266001
>>54266007
>drinking the SJW kool-aid
>>
>>54266162
You'll have multiple employees. They should each contain their in/out times
>>
>>54266162
>how do I figure out how to structure my applications
trial and error. Or read up on shit like domain-driven design and CQRS, and then still figure it out by trial and error but possibly with fewer errors now.
>>
C is eternal. Everything else is dust in the wind.
>>
>>54266232

That is my intention, I currently have all the functionality set up in the time clock class and each employee has a folder with their employee ID and a text file for each date inside.
>>
>>54266231
it's a language. It can't have an ideology. More than that - it's open source and free. If sjw maintainers bother you so much you could, for example: fork it, name it nigger-rust and still keep fetching from upstream and using the results of sjws' work without having being able to do anything about it short of changing the license.
>>
>>54265579
name a decent idea and im probably in
i always fall for these dumb /g/ projects
>>
>>54266256

I was afraid that would be the answer. Thanks for the info though. I'll just go ahead and write it and see what I can learn from the post mortem.
>>
Whiny wanker with the retarded CS professor here

(She told us 5 games, 3 of which we will have to make in C on the final exam)

I thought I'd be able to do all 5 today but I wasted a lot of time mucking around, spent the last two hours making hangman because I am apparently pants on head retarded. It's only 250 lines too. There's a 3/5 chance that I didn't waste that time though, so it's worth it.
It's actually pretty fun, too.

/blog
>>
>>54266358
It's going to be a Java game about GNU / LINUX / FREEDOM.

What Java frameworks do you all know for developing games? Can someone make a strawpoll? I'm outside rn.
>>
>>54266353
I don't want to use a language created by illogical people
>>
>>54266394
>What Java frameworks do you all know for developing games
PooInTheGpu
>>
>>54266394
LibGDX is pretty good
>>
>>54266383
>yfw that it's gonna be you who actually slows down their team of three

>>54266401
there is nothing illogical about them - they are using all means to transfer all the power they can from one group to some other
>>
>>54266394
The project is already doomed to fail. Don't waste your time.
>>
>>54266423
We're probably just going to each do our own game, so if hangman is one of them, it'll be done :)
We have 3 hours anyway
>>
>>54266401
thats illogical
>>
Let's see if you guys actually know how to program
https://www.codingame.com/clashofcode/clash/146927d7beb36b09a4d5227198e0e7f68e8d5a
>>
>>54266117
C++11 without inheritance or encapsulation

>>54266462
He's probably just flustered that he can't write Rust without the compiler bitching at him.
>>
>>54266462
Rust is deprecated by C++ anyways and it doesn't have any SJW devs
>>
>>54266525
(You)
>>
>>54266533
(You)
>>
>>54266401
>>54266423
not that anon, but the illogical part is that they appear to be doing it instinctively, like animals

I don't think they are even aware of their own actions
>>
>>54265978
D
>>
File: NewThreadForm.png (9 KB, 527x213) Image search: [Google]
NewThreadForm.png
9 KB, 527x213
>>54262333
Doing a final project for my Web Development class.

Haven't even begun fucking with the CSS, but I came up with a really original idea. I bet none of you guys have seen this before!

Speaking of which, do you think an expanded version could become popular? I think it'd be fun for people, you know?
>>
>>54266597
You mean the exact system as Yotsuba?
>>
>>54266612
It... was a joke...
You got the autisms, m8?

I'm saying I'm replicating a chan-style board for my Web Dev class....
(clearly, with this chan as inspiration, although I will actually changing the CSS if I have time. It's due Friday)
>>
>>54266117
Clojure
Thread replies: 255
Thread images: 25

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.