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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 316
Thread images: 45

File: 1484955216750.gif (168KB, 640x400px) Image search: [Google]
1484955216750.gif
168KB, 640x400px
What are you working on, /g/?

Old thread: >>58582142
>>
File: 1467663665086.png (1MB, 1280x720px) Image search: [Google]
1467663665086.png
1MB, 1280x720px
thank you for using an anime image
>>
File: 14781814112210.jpg (23KB, 604x336px) Image search: [Google]
14781814112210.jpg
23KB, 604x336px
Thank you for using an anime image
java is trash btw
>>
Lisp > Haskell
>>
File: file.png (121KB, 1133x492px) Image search: [Google]
file.png
121KB, 1133x492px
Beginner here.

Is there a way i can make this shorter?
>>
File: 1462653123421.jpg (141KB, 1920x1080px) Image search: [Google]
1462653123421.jpg
141KB, 1920x1080px
>>58586162
>lispfag can't even use his own language correctly
kek
>>
>>58586177
Stop using such a shitty, verbose language, perhaps?
>>
>>58586177
see >>58586188
>>
>>58586177
>using stdin for human input

TRIGGERED
>>
>>58586184
(> lisp haskell)

better?
>>
File: 1462666496055.jpg (95KB, 724x720px) Image search: [Google]
1462666496055.jpg
95KB, 724x720px
>>58586196
>lisp
>haskell
>>
>>58586177
switch (guess.CompareTo(random))
>>
>>58586194
what else are you supposed to use? and why?
>>
>>58586194
>human
mate...
>>
>>58586246
>mate
anon...
>>
>>58586238
Command line arguments, but those don't really work for that example.
However, almost no "real" programs are interacted with in that way.
>>
>>58586258
Stop.
You're not funny.
>>
>>58586226

Thanks anon, gonna try it
>>
>>58586263
rude
>>
>>58586264
Bah, you tried.
>>
>>58586196
(define-monad <id>
(>>= (lambda (a f) (f a)))
(return (lambda (x) x)))


>>58586238
It's fine for now, can have a look at ncurses if you really want to dig a hole before you try to fly.

>>58586261
stdin works... just need to check if the input is sane
>>
>>58586140
Tried writing some GL graphics code in Rust to see if it could be practical and if I'd turn into an SJW land whale in the process. Results are inconclusive at this time, for both questions.

However, I'm now quite convinced the GL specs are absolutely retarded about data types. I know old school C doesn't give a shit but this is supposed to be a well-thought out standard of some sort and it keeps mixing unsigned, signed and even pointers(!) with each other as if they didn't matter; all of those require a cast in Rust, making the API look uglier than ever.
>>
>>58586194
It's the Unix way :^)
>>
>>58586277
>can have a look at ncurses
>C#
How?
>>
>>58586278
ha, at least it works... OepnGL in chicken scheme is a pain unless you use glls... oh and then there are no docs covering the "schemefied" functions apart from one saying "it's like the C binding" (which it's not).

>>58586289
https://github.com/sushihangover/CursesSharp
https://github.com/rnowley/csharp-ncurses
ect...
>>
>>58586177
you know you have to put braces around multiple statements after an if?

in your case you'd execute only the first statement after each if and execute the second intended one everytime. You'd print "you have... guesses left" every loop
>>
>>58586305
*execute the first statement after the "if" if it was true and the second one everytime
>>
>>58586305
if he switches to python he can save it
>>
File: full.jpg (26KB, 600x450px) Image search: [Google]
full.jpg
26KB, 600x450px
>>58586188
>>58586191
>>58586194
His code doesn't even work because he's missing curly braces. But that doesn't matter. What actually matters is the language amirite? This is proof that /g/ cannot program.
>>
>>58586305

Yeah, thanks.

I had it in braces before and it worked, then i removed them because it made the code shorter, the compiler didn't list any errors so i thought it was ok.

Have to remember to test it all the time
>>
>>58586325
You're the proof /g/ can't program, since your autism can't even comprehend that maybe the screenshot doesn't include irrelevant parts of the program, such as the using statements.

Kill yourself.
>>
>>58586325
(unless (any (lambda (lang) (eq? +anon-lang+)) (list lisp haskell c)) (post (gen-generic-/g/-post))
>>
>>58586330
never leave out braces

shorter doesn't mean better
>>
Has anybody tried Xamarin?
>>
File: 1482319077284.png (22KB, 300x188px) Image search: [Google]
1482319077284.png
22KB, 300x188px
>>58586332
>maybe the screenshot doesn't include irrelevant parts of the program, such as the using statements
So curly braces are using statements. hmm ok.
>>
File: 1484619194267.png (704KB, 2015x2204px) Image search: [Google]
1484619194267.png
704KB, 2015x2204px
I just finished working through K&R and I want to do some shit in C. What are some good little open-source programs to hack?

I'm currently using dwm as window manager and it looks like the perfect project to modify (completely written in C, very small and well documented), but I'm not that experienced yet and I don't think I can into X programming yet. If anyone knows any projects in a similar vein I'd love to know about them. I'm on Linux btw.
>>
>>58586332
what the hell are "using statements"?
like (using (glfw3) (with-window 620 480 "" (program)))?
>>
>>58586396
nice pic btw
>>
>>58586396
rewrite in order:
cat, wc, ls, hexdump, brainfuck, little man computer, match brackets, small scheme, something with sdl, something with opengl 2.0 (3.3 is a fucking pain)
>>
>>58586396
thanks for posting an anime image.
dwm seems okay, i haven't touched it myself but i have heard multiple people of about your level recommend it for the exact same purpose
>>58586407
this
>>
>>58586433
lsw, sselp, dmenu, dwm, st, surf
quite a nice intro to X11 and other libs
>>
>>58586420
>opengl 2.0 (3.3 is a fucking pain)
If you know exactly what you're doing, GL 3.3 (and maybe a 4.x extension or two) are basically GL: The Good Parts. Supported on just about any PC and some mobile hardware, and potentially very fast.

Figuring out how to use it, however, _is_ a fucking pain because of all the outdated tutorials and even old API specs still maintained on the web.
>>
>>58586401
c# equivalent of #include
>>
>>58586396
Xlib isn't hard at all actually, just skim through the docs a bit and see yourself. you could add notification functionality using glib / gtk+ or a clock, or implement the ability to make windows vertical, those are the things i'd like to see in dwm
you could also make a decent terminal emulator to replace st, its god awful
>>
>>58586396
Most of the suckless stuff is very simple and seems somewhat easy to fuck around with.
If you're seriously inexperienced with C though, it would probably be a better idea to write a few programs of your own first to get somewhat decent at it.
Trying to dive right into "real world" programs is probably just going to be overwhelming and confusing.
>>
>>58586462
even worse when using scheme as there's even less tutorials for that... and half of the things make it almost impossible to run 3.3 as only glls works properly if I don't implement half of it in C.
>>58586477
see >>58586447
it's the suckless beginner path with hello world (lsw) ect...
>>
learning some C++

say I want to write a generic binary tree. how do I ensure the type used in the template can be compared?

something like
class BinTree<T implements Comparable>
in Java
>>
>>58586464
still doesn't fix his code
>>
>>58586510
of course not
i just told that anon what a using statement is
>>
I'm stuck with a problem within MFC (which I have to use because reasons): I want to have a window that keeps its aspect ratio no matter what. Drag? Simple enough. Maximize? Yeah ok, capture the WM_ and do stuff. But tiling operations such as WINKEY + RIGHT? Get fucked. Anyone know of an implementation I could look at?
>>
>>58586509
don't bother, C++ is awful, just do a regular template and use <, it won't compile for types that can't be compared (the error message will still be garbage)
>>
>>58586509
>how do I ensure the type used in the template can be compared?
You can't. You just HOPE that the type overloads the comparison operators and actually returns at least a partial ordering from it.
You really shouldn't use C++. It's complete garbage.
>>
>>58586439
yes, Javascript is a shitty language
but so is, for example, C (if you're saying type soundness / coercion is the principle behind quality).
struct s { void * d; };
struct s o;
*((int*)&o) = 42;
>>
>>58586525
>>58586521
lmao is this real? rust doesn't have this problem
>>
>>58586552
>*((int*)&o)
That's undefined behaviour, you fucking idiot.
>>
>>58586553
that's because rust is new, C++ hasn't ripped off haskell's type classes yet, concepts were delayed
>>
>>58586568
guess it lags behind too much to be useful
>>58586552
does the adress in d cast to int point to 42? thats efficient as fuck
>>
>>58586521
>>58586525
well fuck

how do libraries solve this problem? are you supposed to get that from the error messages or is there some way of annotating this?
>>
>>58586585
there is no decent way of avoiding this, unless you want to fucking do a base class just for comparison
>>
btw i got it
thank you based opencv template matching
>>
>>58586497
>even worse when using scheme
Ah ok, I can understand that. At least from my brief experiment with Rust it's only casting, casting everywhere.

And no working offsetof --- better explain those magic numbers in comments or something.

>>58586509
There was a proposed C++ feature called Concepts that would have implemented this, but the language is already so fucking complicated they couldn't polish all the details in time for the last few editions of the standard. It almost got into C++17 but was rejected by the committee.

Right now if you pass an incompatible type as a template argument it'll just get going and generate invalid garbage, then shit out several screens of failed resolution attempts. It can get pretty unreadable, especially with the standard library.
>>
>>58586562
yep. my point. UB is still part of the language. (or the lack of.. just like implementation-defined, unspecified and well-defined behaviors are). the guy I'm replying to is saying javascript isn't a real language because it has some memetastic qualities. if thats true then a lot of languages aren't "real".
>>
>>58586603
Scheme is blessed with obscure examples (about 4 of them in total on 4 different gl eggs) and hardly any docs. I'm slowly translating a C++ tutorial to scheme
>>
File: benis.png (101KB, 442x510px) Image search: [Google]
benis.png
101KB, 442x510px
>>58586396
Wait, that's not C
>>
File: code.png (10KB, 286x477px) Image search: [Google]
code.png
10KB, 286x477px
newbie here

So I made this little program to find the fraction of whatever number you type in (num) within the range of 1-rng

so for example if i want to find the number 1.47 within the range of 25 it will return 22/15, actually a tuple of (22, 15) which is an approixmation for 1.47. The higher the rng the higher the accuracy.

How should i make it more effective and quick? When rng is high it takes the loop forever to get it done. i need a more effective algorithm guise
>>
>>58586813
R?
>>
is this good? first program ever.

#include<stdio.h>
#include<stdbool.h>

void print_plus_one(void) {

static int a = 0;
printf("%d\n", a);
static bool reachedTen = false;


if(a == 10){
reachedTen = true;

};

if (reachedTen == false){
a++;
};
if(reachedTen == true){
a--;
};

}

int main(void) {

for(int i=0; i<21; i++){
print_plus_one();
}

return 0;
}
>>
>>58586177
It doesn't seem like anyone answered your question, anon.
I just had a go at reducing the LoC by making it harder to read:
static void Main(string[] args) {
Console.WriteLine("I'm thinking of a number between 1 and 10, you have 4 changes to guess which one");
var output = new[] { "Higher", "Lower", "You won", };
var answer = new Random().Next(1, 10);
var rules = new List<Func<int, bool>> { a => answer > a, a => answer < a, a => a == answer};
for (var i = 3; i >= 0; i--) {
var guess = Convert.ToInt32(Console.ReadLine());
var attempt = rules.Select(rule => rule(guess)).Select((val, index) => new {val, index}).First(result => result.val).index;
Console.WriteLine(output[attempt]);
if (attempt == output.Length - 1) break;
if (i == 0) { Console.WriteLine("You lost"); break; }
Console.WriteLine("You have {0} {1} left", i, i > 1 ? "guesses" : "guess");
}
Console.WriteLine("Answer was: {0}", answer);
}
>>
>>58586910
>== true
>== false
it's terrible

but at least you got your braces mostly right
>>
>>58586917
why is it terrible?
>>
>>58586876
from fractions import Fraction

def fract(num, rng):
return Fraction.from_float(num).limit_denominator(rng)
>>
>>58586915
I'm dumb, reading thru the code I just realized that linq bullshit is too complex for what could happen:
// this is overly complex
var attempt = rules.Select(rule => rule(guess)).Select((val, index) => new {val, index}).First(result => result.val).index;
// shorter and faster, not that it matters on a 3 element list
var attempt = rules.Select(rule => rule(guess)).ToList().IndexOf(true);
>>
>>58586932
You can have
if (bla)

and
if (!bla)

to check whether is bla true or false.
>>
>>58586910
What kind of output do you expect from the program?
>>
>>58586345
How are you enjoying your job so far?

Oh wait.
>>
>>58586984
gotcha. is that a convention?

just to satisfy my curiosity, do these two implementations compile to the same machine code? the only difference is the C code, right?
>>
File: snek.jpg (31KB, 480x470px) Image search: [Google]
snek.jpg
31KB, 480x470px
>>58586177
from random import randint

rnd = randint(1, 10)
print("I'm thinking of a number between 1 and 10, you have 4 chances to guess which one")

for i in range(3, -1, -1):
guess = int(input("Your guess: "))
if guess == rnd:
print("You won!")
break
else:
print("Higher!") if guess < rnd else print("Lower!")
print("You have %d guesses left" % i)
if i == 0:
print ("You lost!")
>>
>>58586910
If this is your first time and got a program to compile, congratulations I guess.

    static int a = 0;

Don't use static unless you have a very good reason to. It can get confusing as hell if the function is called from multiple places; the different invocations of the function will refer to the same "a" variable and possibly affect each other in surprising ways. You can get the same output from a program that doesn't have this problem.

    if (reachedTen == false){
a++;
};

The semicolon after the closing brace does nothing (compiler probably parses it as an empty statement following the if's block, but does not necessarily emit any code).

If you're using gcc or something compatible, always compile your code with "-Wall" to get as much feedback about silly code as possible.
>>
File: 1484527508382.gif (1MB, 560x372px) Image search: [Google]
1484527508382.gif
1MB, 560x372px
>>58587013
>>
>>58587011

It will, given a decent enough compiler, generate the same instruction. A comparison to == true is more explicit and clear so may help you, as a novice, understand. However, it's a convention used by seasoned programmers.
>>
>>58586999
0
1
2
3
4
5
6
7
8
9
10
9
8
7
6
5
4
3
2
1
0

it works
>>
>>58587017
also why include stdbool.h if you don't have to?
remove it, and the true/falses and now its portable ANSI C and doesn't require a C99 compiler..
>>
>>58587035

** It's NOT a convention used by seasoned programmers.
>>
File: 1479327686989-0.jpg (65KB, 743x524px) Image search: [Google]
1479327686989-0.jpg
65KB, 743x524px
Reminder: you can solve many problems in your code by yourself if you won't just put your code into the compiler but thoroughly execute your code manually, writing down the state of the program with every line of code.
>>
>>58587038
i was using gcc, but my editor is using a linter which is compatible with c99. didn't realize i didn't need it
>>
what language will get me a job quickly
>>
>>58587047
or you can step through it with a debugger
>>
>>58587011
ANSI C didn't have explicit boolean type, so it performs comparison with 0.
!bla will convert bla into 0 if there was non-zero value, or into 1 if there was zero.
>>
>>58587060
spanish -- for when the wall gets built
>>
>>58587060
Probably Java, C#, PHP or JavaScript, but you're basically lower pajeet tier if you know 1 language and have no feel or theoretical knowledge for how/why it even works.
>>
>>58587078
well, i removed it, but i couldn't figure out how to use _Bool quickly, so I rolled my own. i mean, defining a boolean isn't hard. this language is serious podracing

#include<stdio.h>
typedef int bool;
#define true 1;
#define false 0;

void print_plus_one(void) {

static int a = 0;
printf("%d\n", a);
static bool reachedTen = false;


if(a == 10){
reachedTen = true;

};

if (!reachedTen){
a++;
};
if(reachedTen){
a--;
};

}

int main(void) {

for(int i=0; i<21; i++){
print_plus_one();
}

return 0;
}
>>
>>58587109
#define true 1;


    static bool reachedTen = false;


Careful with macros: #define is not a C statement and doesn't have to end with a semicolon. This preprocesses into
static bool reachedTen = false;;
.
>>
>>58587141
and
>>
>>58587109
That looks ugly.

#include <stdio.h>

void print_plus_one(void) {
static int a = 0;
printf("%d\n", a);
static int reachedTen = 0;

if (a == 10) {
reachedTen = 1;
}

if (!reachedTen) {
a++;
} else {
a--;
}
}


Keep it simple, stupid.
>>
>>58587141
Should probably have copypasted the line with #define false on it.

Also, you could just use 1/0 as true/false like real C programmers. Unreadable crap means you're either a super wizard or at least have breddy gud job security.
>>
>A language should ideally support many concepts in a well-factored way, so that the programmer can choose the right concepts whenever they are needed without being encumbered by the others.
>This style of programming is sometimes called multiparadigm programming, implying that it is something exotic and out of the ordinary.
>On the contrary, in our experience it is clear that it should be the normal way of programming. Mainstream languages are far from supporting this.
>Nevertheless, understanding the right concepts can help improve programming style even in languages that do not directly support them, just as object-oriented programming is possible in C with the right programmer attitude.

>this is an actual paper we have to read
>>
File: .png (566KB, 1000x352px) Image search: [Google]
.png
566KB, 1000x352px
>>58586156
>>
>>58587187
And? Grokking multiple paradigms is generally a good thing.

I took a course on Haskell at uni, never ended up using it for anything relevant but I think my C++ (and JS) improved slightly from focusing on functional programming for a while.
>>
>>58587212
Sure, but I thought that saying "object-oriented programming is possible in C with the right programmer attitude." is about as retarded as saying you could, in theory, build a functioning computer out of bottle caps and turds. You can, but why the fuck would you?
>>
Is Clojure any good?
>>
>mfw
>>
>>58587169
because of the (void) parameters. lets make it actually valid ansi c:

#include <stdio.h>

void print_plus_one(void) {
static int a = 0;
static int reachedTen = 0;
printf("%d\n", a);

if (a == 10) reachedTen = 1;
if (reachedTen) {
a--;
} else {
a++;
}
}

int main(void) {
int i;
for(i = 0; i < 21; i++) {
print_plus_one();
}

return 0;
}


otherwise
>warning: ISO C90 forbids mixed declarations and code [-Wpedantic]
>error: 'for' loop initial declarations are only allowed in C99 or C11 mode

and to be autistic - inverse the reachedTen conditional to make it read simpler.


(but I'm all for basic c99 'cause its not 1991)
>>
>>58587250
Plenty of C APIs basically do this already: You construct an object by calling CreateSomething, which returns an opaque typedef'd pointer, then invoke methods on said object by calling functions that accept the pointer and maybe some other parameters.

It's a pretty common pattern in Windows APIs since they can be called from C, C++, C# or even PowerShell.
>>
>>58587288
>but I'm all for basic c99 'cause its not 1991

I'm all for c11, because it's not 2001
>>
>>58587318
>I'm all for c11, because it's not 2001

I'm all for javascript, because it's not 2016
>>
>>58587338
ppffft, is that even webscale? Better use node
>>
>>58587304
I know that's how you do it. My question is, why?

I was under the impression that the main benefits of object-oriented programming, like information hiding, polymorphism and so on, weren't as much of a concern in C, if they were at all. Sure, I imagine there are ways of achieving these benefits somehow, but I still don't see a reason to do it when you could use something like C++ with far less hassle.
>>
>>58587250
Object oriented programming is about putting functions in the same namespace as the data type.

Most C programmers just define struct Foo and then define functions like foo_bar and foo_baz with the namespace prefix.
>>
>>58587318
c11 doesn't add that much useful stuff.

anonymous unions/struct are nice
static asserts can be useful
_generic is pretty ugly

and more than half the stuff is optional
>>
>>58587338
>>58587346
Just don't you dare write old and busted JS, use ES2017 instead. Who cares if it's standardized properly or not when you can just transpile it and confuse everyone with syntax from the future.
>>
>>58587359
They are a concern if you're trying to write a standard multiplatform API that may need drastically different things under the hood in different systems.

Also, clean and safe APIs are much easier to bind into other languages.
>>
vector<std::wstring> tokenvec = tokenize(wLine,L"\t\n");
if (tokenvec[0].at(0) == L"/") // ISO C++ forbids comparison between pointer and integer


How come I get a pointer when I read a single wchar?
>>
>looking over the source code for 'su'
>what the fuck does any of this do
I'll never make it ;_;
>>
>>58587404
>L"/"
L'/'
>>
>>58587359
>but I still don't see a reason to do it when you could use something like C++ with far less hassle.

One good reason is ABI compatibility. C has a stable ABI, C++ does not (unless you expose a C one)

>>58587375
It's nice to have memory alignment in a portable way, I guess.
>>
>>58587359
>Sure, I imagine there are ways of achieving these benefits somehow, but I still don't see a reason to do it when you could use something like C++ with far less hassle.

programming in C is like shooting a colt .45 after shooting a 9mm beretta your whole life.

once you do, you'll understand

>american calibre
>american made firearm
>>
>>58587411
ugh m8
https://android.googlesource.com/platform/system/extras/+/android-4.2.2_r1.2/su/su.c
>>
File: 1278210151791.png (3KB, 493x402px) Image search: [Google]
1278210151791.png
3KB, 493x402px
>>58587419
t-thanks
>>
>>58587404
how come?
// std::string::at
char& at (size_t pos);
const char& at (size_t pos) const;

but yeah
>>58587419
char to char, not char to string
>>
>>58587432
>https://android.googlesource.com/platform/system/extras/+/android-4.2.2_r1.2/su/su.c
Huh?

That's not this:
http://src.gnu-darwin.org/src/usr.bin/su/su.c.html
>>
File: screenshot_739.png (9KB, 654x71px) Image search: [Google]
screenshot_739.png
9KB, 654x71px
Anyone have a simple solution for swapping "," to "." for keypresses?

Using a german keyboard but my program uses US numerics, cuz it's easier to code with.

Most things i've found don't tell how to swap the keys only how to handle them. "SendKey" doesn't really work.

ALSO!
Why are images hosted by picture related now?
>>
>>58587448
GNU bloat

at least look at this

https://github.com/openbsd/src/blob/master/usr.bin/su/su.c
>>
>>58587393
>They are a concern if you're trying to write a standard multiplatform API that may need drastically different things under the hood in different systems.
I've never had to do that before. I suppose I'll just bow to your superior experience and accept that it's sometimes necessary.

>>58587421
ABI?

>>58587427
I'm not American, I don't get gun metaphors.
>>
>>58587453
http://www.oblita.com/interception.html
>>
>>58587448
gnu utils are notoriously ugly as fuck
check out openbsd's:
https://github.com/openbsd/src/blob/5271000b44abe23907b73bbb3aa38ddf4a0bce08/usr.bin/su/su.c
>>
>>58587493
I forgot to mention i'm using vb.net
>>
>>58587504
https://github.com/jasonpang/Interceptor
>>
>>58587486
>I don't get gun metaphors.
>current year
>has yet to interface first hand with another device that shaped human history
>>
>>58587494
>>58587471
Kek that is so much cleaner holy fuck.

>gnu utils are notoriously ugly as fuck
You're not kidding. What the fuck was stallman thinking?
>>
>>58587513
stfu its free you cant complain
>>
>>58587521
I wouldn't want to maintain it, but I guess it works so whatever.
>>
File: 1457024417693.jpg (35KB, 385x375px) Image search: [Google]
1457024417693.jpg
35KB, 385x375px
>>58587509
There's nothing simple about any of that.
>>
>>58587486
>ABI

https://en.wikipedia.org/wiki/Application_binary_interface

tl;dr it's the binary analog to an API. If the ABI is stable, it means I can compile my library on compiler A and 10 years later you can compile a program on compiler B that can still use library A without recompiling it. It's pretty important for FFI, and that's a main reason gtk does object-oriented programing in C rather than C++. So it's much easier to bind a new language to gtk than it is to qt.
>>
Many of those old Unix utilities are written in a pretty awful style desu. A very error prone style too; would not pass code review in a modern environment.

But they're known to work so who cares.

>>58587486
>ABI?
Application Binary Interface. Calling conventions, low-level handling of types, etc.

C is simple enough it's basically standard at least for a particular combination of architecture and OS, but C++ has many more things going on under the hood --- like how to implement virtual functions when they can't be statically analyzed --- and different compilers tend to do them in different ways, leading to binary compatibility issues.
>>
>>58587513
GNU likes to be extremely portable (just not consistent from version to version) and having a tons more feature creep and thus complexity breeds.

also, the bsd guys are known for their amazing C quality

let check out cat:
netbsd: http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/cat/cat.c?rev=1.54.4.1&content-type=text/x-cvsweb-markup
gnu: http://git.savannah.gnu.org/cgit/coreutils.git/plain/src/cat.c

a conspiracy theory is that stallman wants gnu coreutils to be so fucking complex that any infraction on the GPL will be noticable, and also hard to accomplish
>>
File: 1446491360141.png (98KB, 400x410px) Image search: [Google]
1446491360141.png
98KB, 400x410px
>>58587538
    Private Sub Txb_KeyDown(sender As Object, e As KeyEventArgs)
If (e.Key = Key.OemComma) Then
'e.Key = ChrW(Key.OemPeriod)
e.Handled = True
End If
End Sub


The problem is that "Sendkey" doesn't work and i'd rather not have to go through a ton of trouble to do this simple change.
As you can see it's a super generic sub that will affect all textboxes in the program.
>>
>>58587545
>>58587547
Thanks for the explanation, guys. Wish they'd put some sort of reasoning for that in the paper, but throwing meme arrows around was my bad.
>>
>>58587513
I like Linus' comment on the GNU style guide

>First off, I'd suggest printing out a copy of the GNU coding standards, and NOT read it. Burn them, it's a great symbolic gesture.
>>
File: 1323123516269.jpg (51KB, 600x600px) Image search: [Google]
1323123516269.jpg
51KB, 600x600px
>>58587560
>also, the bsd guys are known for their amazing C quality
>all those if-else pyramids
>>
You should use goto for error handling in C, prove me wrong.
>>
Trying to understand the theory behind approximation algorithms and more accurately one phrase in the book: This linear program is the dual linear program of the set cover linear programming relaxation.

So I have a NP-hard problem, for which I have a linear programming solution that works only in theory but runs in polynomial time (did not understand how) which is sort of neat. Then I use that Z*_LP to devise a dual solution which is supposed to effectively round the fractional x*_j items of Z*_LP and provide me with an alpha-approximation that's within a factor of alpha of the original problem's optimal integer programming solution.

I should probably try to find a good place to understand the concept of 'dual' better and how it's used to create primal linear programs.

tl;dr; what the hell is a dual and what's the intuition behind it
>>
>>58587560
>amazing C
for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
if (prev == '\n') {
if (sflag) {
if (ch == '\n') {
if (gobble)
continue;
gobble = 1;
} else
gobble = 0;
}
if (nflag) {
if (!bflag || ch != '\n') {
(void)fprintf(stdout,
"%6d\t", ++line);
if (ferror(stdout))
break;
} else if (eflag) {
(void)fprintf(stdout,
"%6s\t", "");
if (ferror(stdout))
break;
}
}
}
if (ch == '\n') {
if (eflag)
if (putchar('$') == EOF)
break;
} else if (ch == '\t') {
if (tflag) {
if (putchar('^') == EOF || putchar('I') == EOF)
break;
continue;
}
} else if (vflag) {
if (!isascii(ch)) {
if (putchar('M') == EOF || putchar('-') == EOF)
break;
ch = toascii(ch);
}
if (iscntrl(ch)) {
if (putchar('^') == EOF ||
putchar(ch == '\177' ? '?' :
ch | 0100) == EOF)
break;
continue;
}
}
if (putchar(ch) == EOF)
break;
}
if (ferror(fp)) {
warn("%s", filename);
rval = EXIT_FAILURE;
clearerr(fp);
}
if (ferror(stdout))
err(EXIT_FAILURE, "stdout");
>>
>>58587641
can you do better?
now can you make yours faster?
now can you make yours cached aligned?
>>
holy shit post some fucking programming music

https://www.youtube.com/watch?v=WRhRiIYxcqM
>>
What are the best technologies to use for a marketplace app for buying and selling shit?

Something that could handle 300k daily active users.
>>
>>58587676
A computer
>>
File: theo.jpg (421KB, 800x802px) Image search: [Google]
theo.jpg
421KB, 800x802px
>>58587641

I want to make love to that code
>>
>>58587021
>interlaced

plz kill yourself
>>
>>58587641
It's most likely optimized.
>>
File: 4d7.png (825KB, 700x700px) Image search: [Google]
4d7.png
825KB, 700x700px
>>58587671
That's not programming music; that's hacker music!

Reported to the authorities.
>>
>>58587671
>not posting comfy shit
pleb.
https://www.youtube.com/watch?v=wVePuBRmgms
>>
>>58587610
Don't bait people.
>>
>>58587432
>https://android.googlesource.com/platform/system/extras/+/android-4.2.2_r1.2/su/su.c
Why is this so short, neat and clean?
>>
>>58587671
https://www.youtube.com/watch?v=wfxDIyYU9nM
>>
>>58587739
https://www.youtube.com/watch?v=iohbzmcX6zg


HACK THE PLANET!
>>
>>58587671
https://www.youtube.com/watch?v=0r6C3z3TEKw

>dat mega driver
>>
Since we're on the GNU coreutils bashing. `yes` is my favorite

http://lingrok.org/xref/coreutils/src/yes.c
https://github.com/openbsd/src/blob/master/usr.bin/yes/yes.c
>>
>>58587671
https://www.youtube.com/watch?v=rDBbaGCCIhk

>tfw 80s miami
>>
>>58587790
I love going to applestores, run a console and have yes run, or say in a loop with random char arrays and leave.
>>
>>58587671
anything nine inch nails probably or ministry
>>
>>58587790
Jesus...
>>
Are my macros okay, /dpt/?

#define TRY(b, desc) \
if (b) {\
error_set("Couldn't " desc);\
goto cleanup;\
}

#define TRYA(b, format, ...) \
if (b) {\
error_set("Couldn't " format, ##__VA_ARGS__);\
goto cleanup;\
}
>>
>>58587806
https://www.youtube.com/watch?v=nLzjm9E1hwg

anime used to be good
>>
>>58587790
>http://lingrok.org/xref/coreutils/src/yes.c
What an abomination...
>>
>>58587864
>missing comma
>not do { } while(0)
You are shit and your macros suck.
>>
>>58587806
How to make badass videos like that? Better than programming
>>
>>58587813
I used to have a script to do that with ghast sounds from Minecraft. It would fork itself and sleep for a few minutes and then turn up the volume to maximum, so I'd start it, leave the store, and just sit outside and watch through the front window for all the employees to panic and run over to the haunted computer with its bloodcurdling screams.
>>
>>58587908
learn to program shaders?
>>
>>58587864
stellar
>>
>>58587671
https://www.youtube.com/watch?v=l3NoYyNKSXQ
>>
>>58587926
I doubt that's made with shaders alone
>>
File: rad.jpg (185KB, 1280x720px) Image search: [Google]
rad.jpg
185KB, 1280x720px
>>58587671
https://youtu.be/oKD-MVfC9Ag?t=10m10s
>>
>>58587671
https://www.youtube.com/watch?v=58QOBqAWNzE
>>
Lads is it okay to put banter in code comments? Things like

/* wtf was Mark high when he wrote this? */

/* who wrote this garbage?? */

/* Dave you fucking muppet, you forgot to check for NULL */
>>
File: fputs.png (54KB, 1920x1080px) Image search: [Google]
fputs.png
54KB, 1920x1080px
>>58587790
and to add in libc comparisons..
>>
>>58588034
hah, no.
>>
>>58588030
https://www.youtube.com/watch?v=gTeMdsKq0d0
>>
>>58588048
Why not?
>>
>>58588034
Depends on context. If you're writing for a big company you're playing with fire. If it's your own shit or things your writing with buddies, go nuts. Just be aware a lot of code hosting sites get their panties in a twist if you make non-pc comments.
>>
>>58588049
>>58588030

fuck programming, time to fire up Flaming Cliffs 3 and pilot some sweet fighter jets
>>
>>58588049
>empty energy drinks, ciggie on the mouth
>coding furiously
>lines of code appearing faster than shit
>zipping coffee
>old monitor
>camera circling
it's perfect
>>
>>58588034
No, that's unprofessional as fuck and otherwise distilled bloat.
>>
>>58588060
unprofessional
>>
>>58588086
countless switches blinking behind him
>>
File: 1339664207856.gif (306KB, 528x297px) Image search: [Google]
1339664207856.gif
306KB, 528x297px
>>58587941
>good taste
good taste
>>
>>58588102
an F-14 flying in front of his window
>>
>>58588099
If it's not public code, then does it really matter?
>>
>>58588034
/* removing this comment causes the program to crash for some weird reason */
>>
>>58588126
>what is information leak

I still remember when some idiot name his child process manager class Pedophile and it showed up to clients when an error occurred.
>>
>>58588085
>Flying non-clickable cockpits

pleb
>>
>>58588034
the best "banter" is one that documents you losing your sanity.
example: https://bitbucket.org/WAHa_06x36/old-xee/src/fe1cec107972603523e67e7be29a83e493f5cac2/XeePhotoshopLoader.m?at=default&fileviewer=file-view-default#XeePhotoshopLoader.m-102
>>
>>58588149
They still haven't released a professional F-15 simulator. F-18 soon tho
>>
>>58588143
kek
>>
>>58588156
he mad
>>
>>58588126
if you ever go public, you'd wish you had kept it professional instead of having to use time to clean your code, worst case is that you forget and get into trouble later on.

it's not worth it.
>>
>>58588143
>child process manager class Pedophile and it showed up to clients when an error occurred.
Oh man my sides
>>
>>58588156
>objective C
off_t nextchunk=[fh offsetInFile]+((chunklen+3)&~3);

That's not very eloquent , just like Steve would want.
>>
File: 1451045858949.jpg (584KB, 3840x2160px) Image search: [Google]
1451045858949.jpg
584KB, 3840x2160px
>>58588143
>child process manager class Pedophile

If I were his client I would have given him a bonus for that.
>>
>>58588143

There is tell around my company of a threadpool-ish class which, in that it monitored child threads, was named Pedophile. This is all good for a laugh, until your customers call in to complain that your program is crashing with only the message, "Error: Pedophile has no children to watch."
>>
>>58588156
Top fucking kek.

>sanity check
lost
>>
>>58588203
Okay, how about this instead?

/* crikey, was Mark feeling unwell when he wrote this? */

/* who wrote this interesting code? */

/* Dave you smegging gimboid, you forgot to check for NULL */
>>
>>58587453
on linux that's just:
xmodmap -e "keycode 62 = 44"
xmodmap -e "keycode 44 = 62"
>>
>>58587671
https://www.youtube.com/watch?v=JQQip0nBblk
>>
Why are there so many Indian programmers, if they're supposedly so terrible? They must not be, otherwise it wouldn't be a viable career for so many of them.
>>
>>58588333
They work for very cheap.
>>
>>58587671
https://www.youtube.com/watch?v=nJcFALXvLf0
>>
>>58588333
>India: Population, total
>Data as of Dec 31, 2014
>1.27 billion

I wonder why theres so many.
>>
>>58588309
I need it to be in a specific application, not system wide.
Otherwise i could just have gone with
,=.
>>
>>58588367
Not relevant. Bad code is worse than cheap, or even free.
>>
>>58588381
Tell that to clueless managers.
>>
>>58588378
create a copy of the german keyboard layout, swap the keys, add the layout to the list of available layouts and switch it for that one application then?
>>
>>58588333
>Why are there so many Indian programmers

Because there are a lot of indians.
>>
>>58588381
It's bad for the poor fuckers that have to clean up after the poojets.

It's not bad for he who is doing the hiring: more money stay on his pocket, and the program works. It may be buggy and unmaintainable, but he doesn't know from that, all he knows is that it works and he could have it working for half the price he would pay to a real programmer.
>>
File: so.png (739KB, 954x1400px) Image search: [Google]
so.png
739KB, 954x1400px
>>58587671
https://www.youtube.com/watch?v=c2orBsXp4HM

ITS THE
RIGHT TIME
To RISE UP to the TOP
PRIME TIME
Cuz we can't get ENOUGH
FIGHT FOR
The COMPUTERS that we MADE
TO TAKE BACK
The FREEDOMS that you CRAVE
>>
>>58588413
too complicated for something that such be so simple.
sigh, guess i'll use an autohotkey script until i find an easier way, have to continue with other parts this has already taken too much time.
>>
(define-generics monad
[>>= monad func]
#:fast-defaults
([false? (define (>>= x f) #f)]
[list? (define (>>= l f) (append* (map f l)))]
[empty? (define (>>= e f) '())]
[procedure?
(define (>>= g f)
(λ (x) (f (g x) x)))])

(struct just (x)
#:methods gen:monad
[(define (>>= j f)
(match j
[(just x) (f x)])])
(define nothing #f)
>>
File: 1YBlp4Y.png (27KB, 1000x1000px) Image search: [Google]
1YBlp4Y.png
27KB, 1000x1000px
Finished the object superclass, the scene composition and the environment for my UI lib also some cutesy logo in Ai

I wonder what's next for it though, like you legit could use it to make multi-platform applications and it wouldn't run like shit like Electron
>>
File: awww yea.jpg (40KB, 396x264px) Image search: [Google]
awww yea.jpg
40KB, 396x264px
>>58587671
https://www.youtube.com/watch?v=z4sEwYmsZf8
>>
>>58588625
https://www.youtube.com/watch?v=PDwuwf9EX5I
>>
>>58586140

a large computational linguistics / text mining project
i will most likely use python for this kind of stuff
>>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

unsigned int buffer[256] = {0};
char position = 0;
unsigned int t = 0;
unsigned int r = 0;
char numbers[] = "0123456789";
unsigned int push(unsigned int byte){
buffer[position] = byte;
position += 1;
return buffer[position-1];
}
unsigned int pop(){
position -= 1;
return buffer[position];
}
void play(char *string, int len){
unsigned int tmp = 0;
for (int i = 0; i!= len; i++){
switch(string[i]){
case 't': push(t); break;
case '+': push(pop() + pop()); break;
case '-': push(pop() - pop()); break;
case '*': push(pop() * pop()); break;
case '^': push(pop() ^ pop()); break;
case '&': push(pop() & pop()); break;
case '>': push(pop() >> pop()); break;
case '<': push(pop() << pop()); break;
case '|': push(pop() | pop()); break;
case 'd': push(buffer[position]);break;
case '~': push(~pop());break;
case '?': if (buffer[position]) pop();break;
case '!': push(!pop());break;
case '/': push(pop() / ((tmp=pop())?tmp:1));break;
default:
for (unsigned int j = 0; j != 11; j++){
if (numbers[j] == string[i]){
push(j);
break;
}
}
break;
}
}
}
int main(int argc, char **argv){
if (argc!=2) exit(1);
int len = strlen(argv[1]);
for (;;t++){
play(argv[1], len);
putchar(pop());
}
}


First program, how did I do?

try: "t8t>&"
>>
File: Filzhut1.gif (324KB, 401x353px) Image search: [Google]
Filzhut1.gif
324KB, 401x353px
>>58588673

use normal ints, its rarely required to use unsigned ones.

otherwise, its a normal beginner program
youre gonna far, kiddo
>>
>>58588673
what does it do?
>>
>>58588673
That's pretty fucking sophisticated for a first program.

I think you're ready to learn about buffer underflows. Try "+++++++++++++++++++++"
>>
File: 1465503238206.png (5KB, 376x214px) Image search: [Google]
1465503238206.png
5KB, 376x214px
>>58588729
>its rarely required to use unsigned ones.

Unsigned integers have well-defined overflow behavior. You faggot.
>>
>>58588761
It's Javafag. Because Java doesn't support unsigned integers he doesn't believe they're useful.
>>
File: see you around (faggot).gif (443KB, 400x296px) Image search: [Google]
see you around (faggot).gif
443KB, 400x296px
>>58588729
>uint
>not superior
>>
File: 1468270963923.png (266KB, 409x513px) Image search: [Google]
1468270963923.png
266KB, 409x513px
>>58588784
>Javafag

stay away
>>
haskell or lisp
>>
>>58588673
>for (int i = 0; i!= len; i++){

You really should get in the habit of writing i < len, it's more descriptive and otherwise you're flirting with bugs.
>>
File: Plebejer.png (85KB, 300x291px) Image search: [Google]
Plebejer.png
85KB, 300x291px
>>58588831

what about a relevant language
>>
>>58587671
https://youtu.be/_9a66JXmvYU?t=58s
>>
>>58588744
it's a fractal generator which also happens to produce a 8000kHz 8bit unsigned audio stream you can play with
aucat -r 8000 -i -
, aplay, ect...

>>58588729
I'm relying a lot on overflow and unsigned is easier to think in (plus t = 0).

>>58588756
all I hear is static and no segfault... I'm exploiting underflow/overflow to avoid checking if I need to wrap around as it's a ring buffer.

>>58588845
yeah, this was a quick program so didn't really pay attention. Will fix for next time though
>>
>>58588996

if thats truly your first program, you have talent
>>
File: skytorrents.png (59KB, 1081x576px) Image search: [Google]
skytorrents.png
59KB, 1081x576px
heard about skytorrents[.]in ?
>>
>>58589020
yes
>>
>>58589020
nope. tell me about it
>>
>>58589037
it's a nice torrent site with no ads & javascript
I just made a python fetcher
#!/usr/bin/python3.5
import os
from urllib.parse import quote
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re as regex
search_query = input("Search Query:").replace(" ","+")
url = "https://www.skytorrents.in/search/all/ed/1/?q="+quote(search_query)
response = urlopen(url).read().decode('utf8')
soup = BeautifulSoup(response, 'html.parser')
titles = []
magnets = []
info = []
files = []
seeds = []
leeches = []
i = 0
for td in soup.find_all('td', style = regex.compile('^text-align: right')):
if i == 0:
files.append(td.getText())
elif i == 1:
seeds.append(td.getText())
elif i == 2:
leeches.append(td.getText())
elif (i%3) == 0:
files.append(td.getText())
elif (i%2) == 0:
seeds.append(td.getText())
else:
leeches.append(td.getText())
i = i + 1

for a in soup.find_all('a', href = regex.compile('^/info')):
titles.append(a['title'])
for a in soup.find_all('a', href = regex.compile('^magnet')):
magnets.append(a['href'])
i=1
for item in titles:
print('{}){} [Files:{}][Seeds:{}][Leeches:{}]'.format(i,item,files[i-1],seeds[i-1],leeches[i-1]))
i = i + 1
choice = input("Choose torrent:")
os.system("nohup xdg-open \""+magnets[int(choice)-1]+"\" > /dev/null 2>&1 &")
>>
>>58589020
Not only have I heard of it, it's general lack of bloat gave me a solid erection. It's sites like that which remind me how much web "developers" are fucking hacks.
>>
>>58589067
>not the new what.cd

Worthless.
>>
File: Task_Manager_Processes.jpg (116KB, 865x726px) Image search: [Google]
Task_Manager_Processes.jpg
116KB, 865x726px
I've been learning Python for just over a month, I also want to start coding some neat project for Win10/7 to improve.

As in overview ( https://msdn.microsoft.com/en-us/library/d56de412(v=vs.110).aspx ) they suggest to code the following:
it should be a service deamon for system monitoring and performing certain actions when, for example, some system value threshold is met. I also want to implement network communication (i.e. wget analogue). They also note starting to write it in C#, since it is the default for Visual Studio.

Any good books and resources regarding all of these?
>>
>>58586608
>yep. my point is that I'm retarded
>>
>>58589156
yet they've still not proven what differentiates a "real" language from a "fake" language
>>
>>58587011
>gotcha. is that a convention?
would you write something like this?
if (((b == true) == true) == true) ...
>>
>>58587367
>Object oriented programming is about putting functions in the same namespace as the data type.
you heard it here first lads!
>>
I'm setting up a new SPARC64 system and need a hostname. Any suggestions? For reference, my main computer's hostname is serenity.
>>
File: anim.webm (664KB, 1060x729px) Image search: [Google]
anim.webm
664KB, 1060x729px
I added a popover menu for every song and an option to download the audio.

Any idea how to implement a clickable seekbar in react?
>>
>>58589260
cuckboi
>>
>>58588424
there are also a lot of chinese, yet there arent any chinese memes
>>
>>58589260
How did you got a SPARC64 system?
>>
>>58589374
From a surplus store.
>>
>>58589260
obviously
DefianceOfEllisonsEgo
>>
>>58586140
Hey guys I'm drawing a blank for some functionality in Java. I've got a set of three variables (string, int, double) for my project that need to be kept "together" and eventually I'm going to have a list of them.

My first thought was to make a class with three instance variables but I wouldn't need any methods. I remember from uni days that there is something you can do in java that lets you group multiple variables together like this without having to make an entire class. My brain is apparently still sleeping cause I can't remember it.
>>
>>58589448
Sounds like an anonymous type.
>>
File: 1474778268681.gif (18KB, 125x125px) Image search: [Google]
1474778268681.gif
18KB, 125x125px
Why is Haskell's package system unqiuely infuriating?
$ ghci
Prelude> import System.Random

<no location info>: error:
Could not find module ‘System.Random’

$ cabal install random
Resolving dependencies...
All the requested packages are already installed:
random-1.1
Use --reinstall if you want to reinstall anyway.

$ cabal install random --reinstall
Resolving dependencies...
In order, the following would be installed:
random-1.1 (reinstall)
cabal: The following packages are likely to be broken by the reinstalls:
...
<long list of packages>
...
Use --force-reinstalls if you want to install anyway.


What the fuck did I do to anger the Cabal gods?
>>
File: Screenshot_2017-01-21_12-21-02.png (22KB, 821x534px) Image search: [Google]
Screenshot_2017-01-21_12-21-02.png
22KB, 821x534px
>>58589428
pgud
>>
>>58589370
They all go into biology.
>>
>>58589497
This is entirely the reason I dump haskell. The tooling is shit.
>>
>>58589497
Haskell is a house of cards.
>>
>>58589448
you could have a List<Object> ...but thats a terrible idea. why not just make the POJO?
>>
>>58589486
No I don't think that was it. Maybe I've remembering something from another language.

Looks like the most lightweight approach is to create a custom class.

>>58589560
Yeah I'd rather avoid that, it doesn't seem like it will save me that much space.
>>
>>58589497
Use stack instead, or another thing you could do is if you have a cabal project, you can make sure the package is used by that project, and use
cabal repl


Also, I'd use something like MonadRandom (possibly even write your own) rather than System.Random, assuming you don't want to be threading the generator around everywhere
>>
Figuring out data types is the most crucial part of OOP, or any other programming for that matter.
If you have data that is grouped but can't obviously be made into its own data type then you likely have serious design problems
>>
>>58589601
There's no good reason that this particular error should come up in my repl unwarranted, or that I should have to sandbox my environment in a Slack project just to use a standard module
>>
>>58589618

https://wiki.haskell.org/Cabal-Install#I_just_installed_packages.2C_but_now_the_packages_are_not_found
>
This happens when you install a package globally, and the previous packages were installed locally. Note that cabal-install install locally by default and the "runhaskell Setup" commands install globally by default.

Does this help?
>>
>>58589618
>>58589631
I think you can do

cabal install random --global


Are you using haskell platform?
>>
File: Capture.png (3KB, 60x309px) Image search: [Google]
Capture.png
3KB, 60x309px
How do I select an entire column in Sublime Text 3? All the way to the bottom of the file.

I know about Shift + Right Click. It works, but I want it to go all the way to the bottom. Similar as to doing Ctrl + A, I guess.

The file is over 100,000+ lines. I'd rather not sit all day dragging the mouse down. Can't find it in their documentation.
>>
>>58589659
Ctrl-A, Ctrl-Shift-L, move cursor with left and right arrows, select with shift-left / right arrows. (Home and End also apply here)
>>
Trying to implement substrings for sauce in 4chanX
kinda redundant, but it's mostly for my own things
for key of parts
parts[key] = parts[key].replace /%(T?URL|IMG|[sh]?MD5|board|name|%|semi|sname\[\d*(\,\d*)?\])/g, (_, parameter) ->
type = Sauce.formatters[parameter] post, ext
if not type?
skip = true
return ''

is the current regex catch, seems to work fine
    sname[n1,n2]: (post) -> substr(post.file.name,0+n2,n1) 

is probably not gonna work tho. It is probably gonna get passed as a string while the variable is gonna be something like sname[4,2] and it's gonna just catch if it's exactly "sname[n1,n2]" as a string.
I haven't even tried building it yet, I can already see where the trainwreck is gonna happen
>>
File: 1476924920014.jpg (125KB, 540x720px) Image search: [Google]
1476924920014.jpg
125KB, 540x720px
Do you guys organize your program as get, get, get, get.... set, set, set, set... or get, set, get, set, etc.?

Apparently this is super important
>>
>>58589721
it depends, and there are some times when you need to order set and get in a particular way

otherwise, get get get set set set generally looks nicer
>>
I am interested in contributing to the AMD radeon HD foss drivers, as I have had a 7770 in my desktop for years and always tried to use the foss drivers. I have the standard AP comp sci java knowledge any student has, I know a bit of ruby and even less c, although I have the ansi c book and am reading it. This would be my first time contributing to an open source project, and I have no idea where to start and probably won't understand any of the code. Anyone have some tips on where to begin? Any tutorials on how beginners can contribute to big low-level projects like these? Or maybe about open source drivers in general? I want to be able to contribute as soon as possible, but I will be reading and learning more stuff on the side to supplement this. Pls help.
>>
>>58589721
I try to keep things that are related together. getter/setters

// Foo is something
int getFoo();
void setFoo();

// Bar is another thing
int getBar();
void setBar();

// this looks wrong
int getFoo();
int getBar();

void setBar();
void setFoo();
>>
>>58589778
i thought he meant calls
>>
>>58589721
Interleaving the reads and writes can mean improved cache utilization.
>>
>>58589770
check out the bug tracker for galluim/radeon

also, a preview of the code:
https://cgit.freedesktop.org/xorg/driver/xf86-video-ati/tree/src/evergreen_exa.c
>>
>>58589795
shouldn't the compiler handle this (assuming you didn't use atomics or something)
>>
>>58589850
Probably not in general.
>>
File: Screenshot_2017-01-21_18-54-05.png (290KB, 1150x853px) Image search: [Google]
Screenshot_2017-01-21_18-54-05.png
290KB, 1150x853px
I changed the background from a simple gradient to a nice image and turned blur on. Amazing how much better it looks after such a little change.
>>
>>58589876
simple gets and sets should be inlined and then the compiler will do obvious reordering. That is unless you know something I don't.
>>
>>58589888
How you managed to waste more space than Spotify and GPM on desktop is beyond me
>>
>>58589909
what's gpm and do you think normies care?
>>
>>58589894
Well, yeah, it all depends how simple the use case is. An algorithm could be designed in such a way that the getters or setters may have various things that prevent them from being reordered, and you have to redesign the algorithm to make it work some other way.
>>
>>58589770
Ask in IRC or the mailing list for beginner tasks.
>>
>>58589888
Is that a YouTube player?
>>
>>58589941
yeah, mainly, i'm also trying to add bandcamp, soundcloud, and in the future spotify, deezer and torrents
>>
File: Screenshot_2017-01-21_19-33-20.png (274KB, 1152x848px) Image search: [Google]
Screenshot_2017-01-21_19-33-20.png
274KB, 1152x848px
changed colours a bit and added a logo
>>
Should I learn C or java? Just have time to waste and want to pick up a programming language
>>
>>58590357
C
>>
If I want my program to load user libraries, should I spend time trying to sanitize everything and catch every possible error, or just hard crash?
>>
>>58590364
Okay, is the meme book a good place to start learning C?
>>
>>58590484
It's good for reference, more for people who have already programmed before though
Get either
C Programming: A Modern Approach
or
C Primer Plus
>>
>>58590484
It's decent, I learned C from it.
>>
>>58590509
Will check those out
>>58590525
Does it require any sort of prerequisite knawledge
>>
>>58589601
What is StateT?
>>
>>58590630
A monad transformer.
>>
>>58590641
Correct! now use it
>>
>>58590630
A monad transformer that adds state like behaviour, e.g.

do
put 3
x <- get
modify (*12)
modify (+x)
>>
>>58590667
see >>58590664
>>
>>58590630
>>58590667
>>58590689

as an example, RandT from MonadRandom is basically a wrapper on StateT, where the state is a random generator type (e.g. a seed)

rather than put (assignment) and get (reading), it gives you getRandom (reads the generator, calls a generator function, producing a new random generator and the result, and then sets the generator state)
>>
>>58590556
>Does it require any sort of prerequisite knawledge
Basic programming concepts like variables, loops and branching.
>>
>>58590689
And here's another use of stateT:

-- basically (++ i), where i is the internal state
counter :: (MonadState Int m) => m Int
counter = do
modify (+1)
get

-- tags the input value with the counter
count :: (MonadState Int m) => a -> m (a, Int)
count x = do
c <- counter
pure (x, c)

and
mapM count
-- labels a tree
>>
>>58590767
though you'd generally want

flip evalState 0 . mapM count
>>
>>58590664
No. I do OCaml only.
>>
>>58590767
unreadable edition

(`evalState` 0) . mapM (liftM2 (,) (modify (+1) *> get) . pure)
>>
>>58586151
>>58586156
for dpt in g:
n += 1
with open('/dpt/', 'w') as f:
for p in range(1, n)
post('thank you for using an anime image')
>>
>>58590882
>n += 1
>Python
>>
new thread when? :3
>>
>>58590882
>>58590898
No wait, it's the increment and decrement operators it doesn't have
Fuck
>>
>>58590914
Why is Python so shit?
How do you fuck up that badly?
>>
>>58590951
Why would you say it's "shit"? It's a wildly popular language that millions of people use every day and do amazing things with.
>>
new thread: >>58590966
>>
>>58590439
Sanitize. Even if you do it 100% right its still a security hole.
>>
I’m currently working on WAV files, and I generally get the idea of how the files are constructed and I’m having some fun creating and modifying sounds in C++, but I find literally nothing related to the regions and markers in these files, how they are encoded, no documentation whatsoever.
Anyone know anything about these?
>>
>>58586876
>Python
>How should i make it more effective and quick
import something, i'm sure
>>
>>58591022
I assume you read these:

https://en.wikipedia.org/wiki/Resource_Interchange_File_Format
https://en.wikipedia.org/wiki/WAV#RIFF_WAVE
Thread posts: 316
Thread images: 45


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.