[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: 317
Thread images: 30

File: XGH.jpg (36KB, 318x374px) Image search: [Google]
XGH.jpg
36KB, 318x374px
What are you working on, /g/?

Previous thread: >>61589577
>>
nice 3rd thread retard
>>
Updating god knows how many scattered utilities to pull customer email addresses from a different source because rather than fixing the clusterfuck Visual FoxPro data source that limited to 35 characters, they created a new database for them and started migrating one side of the company over to using it without bothering to tell anyone.
>>
I think of picking up Clojure again. It's more fun than Haskell because it just werks.
>>
File: miku poop.jpg (103KB, 500x500px) Image search: [Google]
miku poop.jpg
103KB, 500x500px
This miku walks up to you and splatters you with Principles of Object Oriented Programming! (POOP)

What do?
>>
>>61594204
Teach her the way of FP.
>>
>>61594262
>2017
>still using FrontPage
WTF?
>>
>>61594295
I used that shit for my Playstation Portable fan site hosted on FreeWebs. Good times...
>>
>>61594295
reddit is the front page of the internet
>>
>>61594295
LOL
got me good there fampai :D
>>
>>61594336
>wow, looks like you made a joke!
>don't worry, here i am to redirect you to reddit
>>
Dumbass question:
why is the below code giving me an "Expected expression" error?

#include <iostream>
#define TESTVALUE 100
int main(int argc, const char * argv[]) {

int var1, var2, var3; /* initialize three variables */
var1 = var2 = var3 = TESTVALUE;

return 0;
}

>>
>>61594501
>
var1 = var2 = var3 = TESTVALUE;

is that even legal in sepples
>>
>>61594520
It's legal in C, and the code compiles when I take out the comment, so yea
>>
>>61594501
It works on my compiler. What editor / syntax checker plugin?
>>
>>61594542
XCode. Just re-typed the comment and it works fine now.

I guess it was a weird bug.
>>
I I have C program that loads dynamic libraries.
And I load 2 modules compiled from same memory managed language like Go. There will be basically 2 go runtimes running at same time in one program. Is that possible? Even if it's possible wouldn't it be huge overhead?
Is there any point in programming shared libraries in any other language than?
>>
>>61594530
>It's legal in C
didnt know that, god what trash.
>>
>>61594560
Why are you surprised?
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
>>61594560
>trash
You mean yourself? I agree.
>>
>>61594042
>It's a good thing, but I feel like it's too late.
for what it's worth, it definitely seems like Microsoft hasn't given up on it yet. i don't know if this is a factor for you, but it's worth mentioning that C# is actually getting very popular in the industry lately in a way a lot of people don't realize. i know people at a number of large/well-known companies which use it for all their tools, testing, automation, asset pipelines, internal servers, etc. often even when their actual public-facing products/services use other languages/tech altogether, so often times you'd never know it from the outside. it can be about as easy to use as Java when you're not trying to do anything particularly fancy, but you can also just turn off the safety and get about as much control as C++ should you need it. Java is so baby-proof it can just get in the way if you know what you're doing and wanna break the rules, while C++ would be way overkill and a nightmare to maintain for things like internal tooling and such. that's why i really do see C# as something in between, as opposed to just Microsoft's Java knockoff. it has a very valid application space that it's extremely well-suited for
>>
File: dude really.png (83KB, 313x290px) Image search: [Google]
dude really.png
83KB, 313x290px
>>61594560
Genuinely curious, how is that trash?
It allows you to condense three lines into one line (that may be a bit difficult to understand at first), and can be used inside test conditions to condense otherwise longer code.
>>
>>61594560
You'd rather put it on 3 separate lines?

>>61594556
Unless go is retardedly programed it should work.
>There will be basically 2 go runtimes running
Go can't compile?
>Is there any point in programming shared libraries in any other language than?
Just compile your shit.
>>
>>61594589
Why isnt ALGOL there?
>>61594607
var,var2,var3 = TESTVALUE
assert(var,var2,var3 == TESTVALUE)
>>
>>61594607
It allows the ol' if(x = y) bug that trips up thousands of beginners every second. Languages where either x=y must be a statement, or its an expression that evaulates to something non-boolean (usually the unit type), then you won't have this issue.

C people like to abuse this, though, a do stuff like
while ((c = getchar()) != '\n')  ...

under the guise that "less characters = elegance" (which is simply not true)
>>
>>61594621
>he thinks that the garbage collector somehow dissapears after compiling
>>
encrypted network in erlang akin to HTML4. No JS/CSS poo, like the Internet back in the early 90's.
>>
>>61594560
xDDDD
>>
>>61594666
>muh garbage collectors
They're not so bad.
>>
>>61594653
This isn't C abuse, it's idiomatic and highly encouraged because of how the assignment operator works.
Look at the stdio functions, most of them return values conducive of inclusion in higher order conditional statements like this.
>>
>>61594653
>abuse
you're retarded
>>
>>61594691
damn boi
>>
>>61594695
No but there would likely be 2 different instances of go garbage collector running at the same time.
>>
>>61594696
>>61594709
I understand that it's idiomatic, but it really convolutions the control flow of the program by putting a slew of side affects in a short amount of space. And it doesn't really help that order of evaluation within function arguments is undefined, so if you try to do these kinds of shortcuts in arguments, you're asking for UB. Modern languages have better solutions to stuff like
if ((status = do_operation(...)) != 0)
goto cleanup;
>>
>>61594711
lol thanks, I'm planning it to be a mix of BBS and IRC
>>
>>61594691
>no CSS
Anon I wouldn't want to have to specify the laundry list of properties of a tag every time. There's nothing wrong with tag classes and ids.

Also what's the syntax of the markup?

You better be using an S-Expression based markup.
>>
>>61594745
Sorry I'm low on sleep so my grammar is pretty bad
>>
>>61594745
>order of evaluation is undefined
Are you retarded?
In the example you posted, do_operation() is called, it's return value is assigned to status, then the entire expression is reduced to the return value of the assignment operator and this is then compared to 0.
It's extremely concise and I wish more people would program this way.
>>
>>61594757
well it doesn't matter what you want, I'm doing this for people who want style-less HTML back. I'm aiming for a purely informational system. The syntax could be something like the github .md markup, or S-expression as you said.
>>
>>61594745
Out of all the problems with C you complain about that?

The biggest problem with C is the lack of sane operator preference. Ideally you should write if statements and not need so many damn ()'s
>>
File: smug_ran1.jpg (180KB, 1732x1593px) Image search: [Google]
smug_ran1.jpg
180KB, 1732x1593px
>>61594814
Go is perfect for you then.
>>
>>61594836
Go is not even a programming language.
>>
>>61594794
>style-less HTML
So no font choices, no font color, no bold, no italics?

Only tables? God why?
>>
>>61594776
Yes but if you have something like
do_operation(x, x++)

it's completely unspecified what values will be passed to the function. But I guess if you try to mix assignments inside expression ONLY in conditionals like above, then you'll be okay. This is why I strongly believe that C is only a decent language in the hands of a very careful and deliberate programmer.

>>61594814
It's not horrible but it's lackluster compared to variant types.
As for operator precedence, I'm of the opinion that unambiguous code is better code, this is why I'm a lisp weenie. The operator precedence rules for bitwise operations in C (and thus carried into many other languages) are so strange that GCC actually emits warning when you don't put enough parenthesis.
>>
>>61594875
I'll add sane defaults (aka good looking tables and whatnot), there will be bold, italic etc styles but no CSS as I mentioned.

The browser will be in ncurses so no styling will be required. As I said a combination of IRC and BBS's of that time.
>>
>>61594849
what do you mean by that?
>>
>>61594878
I don't see how this is any different from calling
do_operation(x, (x = x + 1));


It's equally as stupid and ambiguous as to which value X will have, compilers are free to interpret this any way they want.
>>
I need to a build a binary sequence out of 4 possible values. Right now I have the idea of just using a case/switch and a string-builder to just append 00/11/01/10 as appropriate and then converting the whole thing to a long or bigint from binary at the end.
Am I overthinking this? Is there a more efficient method that doesnt involve fucking around with strings?
>>
how do I get practice after I've actually learned the basics of C++ and Java. When I mean the basics I mean I can do shitty command line programs.
>>
>>61594921
My point was that assignment-as-expression only works if you constrain your expression to really simple cases, and it's easy to get carried away and violate that if you obsess too much over concise code
>>
>>61594745
>buzzword spew
>zero understanding of what he's talking about
>your brain on lisp
lmao
>>
>>61594892
>there will be bold, italic etc styles but no CSS as I mentioned.
I have no idea why you wouldn't let people specify bold, italics and other styles in a CSS type region other than out of sheer dogma. It originally was just a macro.

Yeah anon, writing
(center color: black bold: background-color: red "text ...")

Every time makes me feel sooo legit instead of doing
(center style: ugly-style "text ...")
>>
>>61594998
>expects different values from the same variable
How is the compiler supposed to guess what you want?

Are you retarded?
>>
>>61594653
>C people like to abuse this,
>While assignment result != condition
Are you retarded?
>>
>>61595025
>no arguments
>your brain on C
lol
>>
>>61594070
I want to learn how to make software. Where do I start?
>>
>>61595035
why go thru all that effort when you can just use things like b or i? think efficient anon
>>
Is there proper lisp without GC?
>>
>>61595045
The C standard could easily just say "evaluate the arguments from right to left", which would make it easy to guess what you want

>>61595045
>>61595053
>>61594776
http://www.r-word.org/
>>
>>61595092
That's naming and not concepts anon. My argument still applies.
>>
>>61595100
The OG lisp was originally collectorless. It was awful. The inventor of lisp invented the garbage collector because lisp sucks without a garbage collector.
>>
File: PSP.png (106KB, 242x320px) Image search: [Google]
PSP.png
106KB, 242x320px
>>61595065
Learn PSP.
>>
>>61595130
>m-my argument still stands i swear
lel

i am saying, why bother making another file and writing 12 letters to make something bold, when you can just use a tag like b? if the markup was json based:

{
"h1":"This is a heading",
ul: {
"li":"one",
"li":"two",
"li":"three"
}
}

efficiency anon, learn it
>>
Why didn't I learn to use emacs earlier, this shits amazing with evil mode.
>>
Best C++ book for someone who's already decent?
>>
>>61595193
You're a total brainlet anon. My point is not having a means of abstraction is retarded.

Stop getting in technical details like json vs s-expressions or the name of the bold tag.

My example was the desirability to replace many properties with one property. Not the name of the bold tag brainlet.
>>
>>61595193
h1 This is a header
ul one
| two
| three
>>
>>61595102
the standard specifying a strict parameter evaluation order could eliminate potential compiler optimizations, while the only benefit would be the ability to mutate and refer to the same variable in multiple parameter expressions, which presumably, at least at the time the standard was formalized, was not considered a significant use case
>>
>>61595276
>resorted to namecalling
that was easy, thanks for the ego boost anon

my argument was that it'll be unnecessary to have the feature you said if the short tags apply the styles anyway, removing the necessity for CSS, thanks for exposing who's the real brainlet here though ;)
>>
>>61595274
Bjarne, Meyers, Alexandrescu
read erryday
>>
>>61595317
thats another way to do it but JSON is more structured and newlines / tabs have cross platform issues so I'll stick to JSON for now.
>>
>>61595351
JSON is trash.
More things need to adopt SDL
>>
>>61595370
you are thinking beauty instead of efficiency, just like a woman, its kinda cute desu
>>
>>61595388
SDL is beauty and efficiency though.
>>
>>61595147
What's it about? ToC says nothing except it's something about planning and design of software which only partially answers my question.
>>
>>61595335
>i definitely most assuredly didn't mock first so I have the moral high ground
Sure.
>writing tags like b, c, etc every single time is super fun. I would never want to abstract out of this
Please lookup what a turing tarpit is. It's okay though keep being dogmatic.
>>
>>61595404
>What's it about?
It's about what the ToC says.

>only partially answers my question
In order to fully answer your question, I'd have to know what you don't know. I assumed you already knew programming.
>>
>>61594560
>trash
It's perfectly fine. Why would you repeat yourself?
You write normal expressions with multiple operations all the time why not do the same with assignment operator?
Don't tell me you're one of those pedants that do SSA form for everything. That's so fucking onerous.
>>
>>61595274
>>61595340
those guys. there's also a bunch of good shit online. check out:
Herb Sutter's GotW series
Jason Turner's C++ Weekly series
CppCon and BoostCon videos on YouTube
>>
>>61595415
its not about moral, but about controlling one's emotions. you lost your cool first which i take guilty pleasure in. you should work on your emotional reactions and self-control.

calling me "dogmatic" reminds me of when tumblrinas call people dogmatic, you should try to think more critically, friendly advice.

why abstract it out if its a performance hit? just to say it's more 2017? i want the users to have as much as control over the system as possible.

If I was you I'd start taking HRT since you got the brain to go with it, I'm not trying to insult you either
>>
File: ProgrammingChallenges, 4.0 (HD).png (2MB, 3840x2160px) Image search: [Google]
ProgrammingChallenges, 4.0 (HD).png
2MB, 3840x2160px
>>61594948
This should be a decent starting point.

Look at whatever project looks interesting and start working on it.
>>
>>61595474
forgot Sutter-sama
shame on me ;_;
>>

internal void AkarinResizeDibSection(
int width,
int height
) {

if (bitMapMemory) {
VirtualFree(bitMapMemory, 0, MEM_RELEASE);
}

bitMapWidth = width;
bitMapHeight = height;

bitMapInfo.bmiHeader.biSize = sizeof(bitMapInfo.bmiHeader);
bitMapInfo.bmiHeader.biWidth = bitMapWidth;
bitMapInfo.bmiHeader.biHeight = -bitMapHeight;
bitMapInfo.bmiHeader.biPlanes = 1;
bitMapInfo.bmiHeader.biBitCount = 32;
bitMapInfo.bmiHeader.biCompression = BI_RGB;

int bitMapMemorySize = (bitMapWidth*bitMapHeight)*bytesPerPixel;
bitMapMemory = VirtualAlloc(0, bitMapMemorySize, MEM_COMMIT, PAGE_READWRITE);

int pitch = width*bytesPerPixel;
uint8 *row = (uint8 *)bitMapMemory;
for (int y = 0; y < bitMapHeight; ++y)
{
uint8 *pixel = (uint8 *)row;
for (int x = 0; x < bitMapWidth; ++x)
{

//Blue
*pixel = 0;
++pixel;


//Green
*pixel = 0;
++pixel;

//Red
*pixel = 255;
++pixel;

*pixel = 0;
++pixel;

++pixel;
}

row += pitch;
}
}



what is wrong with this? it gave me access violation error for *pixel but i already supplied that i want to read and write the memory?
>>
>>61595434
because while a bit more verbose:
int x = 10, y = 10, z = 10
is more concise and doesnt leave room for confusion.
>>
>>61595482
>he's concerned about macro expansion being a performance hit
wew
>>
>>61595518
not allowed in C89

int x, y, z;
x = y = z = 10;
>>
>>61595482
>calling me "dogmatic"
Unless you're some sort of Markov Chain bot trained on /pol/, you're irrelephant and off-topic here.
>>
>>61595544
I know, just saying.
>>
>>61594204
I don't agree with oop and I don't agree with protected memory.
>>
>>61595518
Except that declares 3 variables. And has the same amount of 'confusion' probably since they both amount to zero.
x=y=z;

is super obvious. They're all the same value now. Z was never assigned to since it was the rightmost.
x=y=z*2;

Would also be fine. Is there any confusion?
x=y*2=z;

This is where there could be confusion but this is illegal because you can't assign to y*2.

Explain why you're confused beyond just being bad?
>>
>>61595567
>I don't agree with protected memory.
why
>>
>>61595584
Because he's a C programmerlet.
>>
>>61595511

nvm im just retarded, need to omit one
++pixel
>>
File: 1500721655553.jpg (39KB, 374x347px) Image search: [Google]
1500721655553.jpg
39KB, 374x347px
>writing a microkernel in Crystal
>unintentionally using a shit ton of C-bind calls
>don't know if it will compile
>terminal is just frozen

Wish me luck
>>
>>61595582
>probably since they both amount to zero.
what?
And im not confused by anything, just pure subjective way of doing things. And setting variables works the same. Although that amount of mutation is a little much, id probably just make new immutables.
>>
>>61595628
>he
>>
>>61595548
thats not what I called you though, read slowly and absorb bit by bit, I think you're hellbent on losing this argument.
>>61595525
im concerned about useless features being implemented because they are "pretty"
>>
>>61595663
>means of abstractions are useless
>I can't think of a way to implement macros without it being a performance hit to the user
I don't think you're cut out for software development anon. I'm sorry. I'd advise you switch to database entry.
>>
>>61595429
>It's about what the ToC says.
So analysis and design?

>I assumed you already knew programming.
Only imperative programming but it's something I guess. And I haven't even gone very deep with OOP, just the basics. At this point my primary language is C.

I don't know how to analyse the problem, design a system that solves it, think out all the use cases, model software and implement it based on all the previous steps, though I've been learning all these in uni (some of the courses related were complete shit, others though good, didn't force you to learn and I was lazy). I only know few basic design patterns provided I haven't forgotten them.
I know how to write clean, well defined code that I and others can easily maintain and extend (that's pretty much the only thing I learned at the courses I mentioned + I read Clean Code) but I don't feel like my knowledge is enough / I tend to not pay enough attention when in hurry and I tend to put off the work until very close to the deadline.
I don't know how to write defensively, optimize things, write portable code, I don't know TDD, how to design algorithms and data structures to solve my problem and prove their correctness, complexity, stability.
>>
File: gVNokdG.png (667KB, 835x917px) Image search: [Google]
gVNokdG.png
667KB, 835x917px
>>61594070
please /dpt/ I am losing my sanity, why does a while loop that fgets the stdout (proc_open) of a "docker run -t --rm -v ..." never finish? the code has no problem with normal shell commands.
>>
>>61595699
Optional end tags are awful. Who thought this syntax was a good idea.
>>61595642
>>code is more concise and doesnt leave room for confusion.
As opposed to?
Clearly you were implying there's confusion in doing multiple assignments per line.
Why mention that there's no "room for confusion" if it's just a general truth. I don't produce a complete list of attributes for any type of syntactic style. It seems very odd to make that statement if you didn't contrast it to something.
Imagine if I were saying "x=y=z; is great, and it doesn't summon nasal demons" in response to something. Normal people don't bring up completely irrelevant shit.
>>
>>61595706
>resorting to name calling and ad hominems again
i love this anon, you're like my squeak to or something, so reactive
>>
I come from /sci/, I want to learn python.
What is the best no autistic book to start learning ? I don't want a book for brainlet please.
Thank you.
>>
>>61595584
protected memory is jew memory.

and fuck calling conventions
>>
>>61595728
confusion != literal incomprehension
In extensive code id just rather see individual setting, especially when bug-testing.
If x and y and z are WRONG_VALUE, itd be much harder to debug and refactor vs x = wrong, y = wrong, z = wrong
>>
>>61595729
Both of us are using ad hominems but only one of us is getting triggered anon :).
>>
>>61595632
it didn't, back to the drawing board :^(
>>
>>61595717
>Only imperative programming
It's enough.

>And I haven't even gone very deep with OOP
If you'd like to learn more about OOP, read the GOF and Fowler's Pattern Oriented Software Architecture. If you wanna learn FP, read the SICP.

>I don't know how to analyse the problem, design a system that solves it, think out all the use cases, model software and implement it based on all the previous steps
PSP will help then.

>but I don't feel like my knowledge is enough
It doesn't have to be, once your project gets large enough, other people with supplementary knowledge will help.

>I don't know how to write defensively, optimize things, write portable code, I don't know TDD, how to design algorithms and data structures to solve my problem and prove their correctness, complexity, stability.
All of that is great, but not mandatory.

Just take it easy and go one step at a time, man. Never stop learning, but don't wait until you have more knowledge to start things.
>>
>>61595745
what's your programming experience
>>
>>61594691
so gopher?
>>
>>61595877
mainly systems and embedded programming. wrote a PCI subsystem for arm64 in a mix of C and ASM.

next time when you want to argue try to do it against someone you have equal or better experience than and maybe you'll do better next time.
>>
So I finally finished my first ever program in C++, converting a tgf graph file into a gv file of its strongly connected components.

That was certainly a journey.
>>
>>61595906
jesus fuck how autistic are you?
you asked for a suggestion
he asked you for experience to have some context
and you sperg out like that
L M A O
>>
>>61595906
>next time when you want to argue try to do it against someone you have equal or better experience than and maybe you'll do better next time.
what are you talking about
>>
>>61595906
kill yourself
>>
File: 1474325315193.jpg (44KB, 636x616px) Image search: [Google]
1474325315193.jpg
44KB, 636x616px
Employed Haskell programmer reporting in
>>
>>61595906
Yeah, you're from /sci/ alright
>>
>>61595906
jesus christ..
>>
>>61595976
next time when you want to argue try to do it against someone you have equal or better experience than and maybe you'll do better next time.
>>
>>61595976
next time when you want to argue try to do it against someone you have equal or better experience than and maybe you'll do better next time.
>>
>>61596002
>>61596020
Never fucking reply to me again unless you are contributing to the thread.
>>
>>61595906
Well, then you have no problem finding learning resources on your own aren't you my man

Experienced C programmers like yourself pick up python in a week just by using docs.python.org
>>
>>61595789
what does this even mean?
>>
>>61596043
next time when you want to argue try to do it against someone you have equal or better experience than and maybe you'll do better next time.
>>
writing a functoinal kernel sans i/o
>>
>>61595939
Used anything 3rd party or from scratch? Try rewriting it using boost for shits and giggles, compare two version
>>
>>61595874
>other people with supplementary knowledge will help.
I assume other people will only screw up my work more. I need to get good enough to minimize this effect as much as possible and not screw up myself. Also, what I forgot to mention is that I need to learn to read and maintain other people's code. After 200 lines of code I fall asleep on the keyboard or forget important details.
>All of that is great, but not mandatory.
It is mandatory if I don't want to make garbage.
>>
>>61595976
next time when you want to argue try to do it against someone you have equal or better experience than and maybe you'll do better next time.
>>
>>61596120
From scratch. Read the file, load it into a bunch of objects of my Node class, run my implementation of Tarjan's algorithm (which took two days to debug because I forgot to pass the stack by reference down the recursive call, resulting in every SCC consisting of only one node), then write out the gv file.
Nothing complicated but I think it was a great learning project.

>boost
I keep hearing about this but I'm too lazy to google. Tl;dr me please.
>>
>>61596160
>>boost
>I keep hearing about this but I'm too lazy to google. Tl;dr me please.
http://lmgtfy.com/?q=libboost
>>
>>61594554

You might be doing Option-Space. It inserts a different kind of space character. Caused me a lot of issues back then.
>>
>>61596156
>I assume other people will only screw up my work more.
Possibly, but you can't make anything big by yourself. Read TSP too on top of PSP btw.

>Also, what I forgot to mention is that I need to learn to read and maintain other people's code.
That's a skill that requires practice, I'm afraid.

>After 200 lines of code I fall asleep on the keyboard or forget important details.
Well, the whole point of architecture and writing modular code is so that you won't have to maintain anything over 200 lines of code at any given time.

>It is mandatory if I don't want to make garbage.
You'd be surprised how many of those things are overrated...
>>
>>61596160
>tl;dr me
The current memetic idiom is "give me a quick rundown", anon.
>>
>>61596209
Option-Space is a non-breaking space, which is used to avoid undesired line breaks.

A<NBSP>B means that A B will never be separated by line wrapping.

On Linux it can be written with Compose+Space+Space
>>
File: 2017-07-27_21-38-23.png (22KB, 749x571px) Image search: [Google]
2017-07-27_21-38-23.png
22KB, 749x571px
>>61596191
Kek, umatrix killed lmgtfy
>>
>>61596160
Nice work anon. I think graph algorithms are neat learning projects for sure.
>adult male
>never wrote Tarjan's algorithm from scratch

Boost is a uuge and heavy C++ library with all kinds of things (cli parsing, threads, meta, etc.), some graph algos being the part of it. iirc there is a scc function so it shouldn't be time consuming at all for you. Could be fun to compare performances and all, and write your first boost program
>>
>>61596276
F
>>
>>61596276
whats the difference between ublock and umatrix?

i only use ublock
>>
File: rape.jpg (22KB, 441x272px) Image search: [Google]
rape.jpg
22KB, 441x272px
>>61594070
Easiest way to learn programming everyone?
>>
>>61596064
Nothing. He's just barfing his brain out.
I suppose if we're favorable we could assume he means the style doesn't let you step through each of the assignments individually.
But implicit in this structure is that you'd want to assign them sequentially so what's the point if you can just inspect before the expression?

There's no argument here. Also he flip flops on if he's actually confused VS not confused.
>>61595518
Confused.
>>61595642
Not confused.
>>61595789
Confused.

It's just shitposting. Hopefully this post will help you understand it and ignore it as I did.
>>
>>61596288
boost isn't a library, it's a collection of libraries, huge distinction, they also vary in quality
but generally you don't need boost.thread and the family anymore, the only useful things in boost right now are boost.asio and boost.filesystem, the latter is going to be useless once c++17 is out (std.fs will be modeled after boost.fs though)
>>
>>61595717
Most of that comes from experience. There are rules of thumb like "design against an interface", "make interfaces easy to use correctly, and hard to break" which only make sense after having seen larger code bases.
If you design against an interface, for example, TDD and mocking your dependencies/outputs becomes easier. If your libraries' API is robust, you'll have less issues from stupid users, etc.
>>
File: disappointed.gif (2MB, 320x240px) Image search: [Google]
disappointed.gif
2MB, 320x240px
>>61594336
>>
>>61596339
>easiest way to learn craft
It's a craft. You don't learn programming and be done with it like that.
Realistically if you wanted the best help in someone guiding you on how to learn whatever you want to learn you present your goals, current knowledge and amount of time you can spend on it.

I hear coursera is something people really like. Maybe try that if you're too lazy to ask for help proper.
>>
>>61596264

Yes. My keyboard layout required me to press Option a lot of times to type curved brackets and such. Usually a non-breaking space snuck in, which resulted in strange compilation errors, until I got fed up and disabled it. Not sure if that is the case with C/C++, but might be worth watching out for.
>>
>>61594336
>reddit is to the internet as frontpage is to webpage development
FP was pretty good actually. Wasn't a lot of tools for that back then.
>>
>>61596400
Ideally it should be treated as whitespace by any compiler
>>
What would be the easiest way of doing the following in Python:

open an image
when you mouse over the image, have a way to see which pixel the mouse is pointing at
>>
>>61595804
im happy you reached self awareness :p
>>
>>61596300
ublock blocks ads based on lists.

umatrix can also do that to a lesser extent (it's still recommended to use both), but it basically lets you filter every single cookie/request/XHR/script/file. So for instance if 4chan randomly decides to connect to ekansovki or whatever botnet site of the day gookmoot sold out to, by default umatrix will block connection to that site. Same goes for google analytics, facebook tracking scripts, and other random stuff.
The flip side of this is that many websites use a different domain for various stuff (e.g. a cdn). Then you have to manually enable that domain as a rule for that site. It has a nice UI that makes it really easy though - and you can filter individual components as well, so you can accept a third-party script but still block their cookies.
It also has a few other neat features, like auto-flushing your cache and changing (or even cycling) your useragent.

>>61596288
Thanks man!
That sounds interesting, I'll check it out.
>>
>>61596424
Maybe use Tkinter to access the mouse
>>
>>61596424
p=Tkinter.Tk()
coords = p.winfo_pointerxy()
functionToGetPixel(coords)
>>
>>61595877
I don't have programming experience.
The other guy who reply is not the guy who posted the question...
>>
File: 1497393716929.png (9KB, 420x420px) Image search: [Google]
1497393716929.png
9KB, 420x420px
how the FUCK do you learn WIN API anon (without sacrificing your life and suicide)

????
>>
>>61596550
By living a life of sin and dying in an ironic way.
>>
File: 2684727372.png (162KB, 297x314px) Image search: [Google]
2684727372.png
162KB, 297x314px
>>61596550
It's impossible.
>>
>>61596602
>>61596614

how the fuck are you supposed to use it then

or learn, theres barely any tutorial
>>
>>61596550
>>61596602
>>61596614
>>61596633
What? WinAPI is incredibly simple and MSDN has some of the best documentation for anything on the internet. If you want to do something just google "winapi [short description of what you're trying to do]" and the first result will be either a stackoverflow page detailing the function you should use, or the MSDN page itself which could teach a 5 year old how to use the function properly.
>>
>>61596633
https://msdn.microsoft.com/en-us/library/windows/desktop/ff818516(v=vs.85).aspx
>>
File: 1501030543703.jpg (86KB, 799x536px) Image search: [Google]
1501030543703.jpg
86KB, 799x536px
>>61594204
>>
>>61594070
someone has to do the front end for an open source community multiplayer client for a game.
It's going to be browser based. I've done some UI stuff and it was quite fun but now I looked at the Java dev-client that actually has all the communication with the backend and I am just too fucking bad to understand that.
I just want to place some neat boxes with JS and send a message when you press a button.
Looked like FizzBuzz Enterprise Edition to me.
>>
>>61596663
>>61596663

okay what do you query to look up StretchDIBits or how to paint a window with BeginPaint and EndPaint
>>
>>61596226
>you can't make anything big by yourself
That's why I need to learn how to deal with others and how not to be too much of a pain to them.

>TSP
The Traveling Salesman Problem? That's what Google says.

>That's a skill that requires practice, I'm afraid.
Yep.

>Well, the whole point of architecture and writing modular code is so that you won't have to maintain anything over 200 lines of code at any given time.
Some people don't know that. I don't want to be one of these and I also want to learn to deal with them. I guess the latter is also one of the things that require practice.

>You'd be surprised how many of those things are overrated...
I only see them underrated everywhere.
1,5 year of development in hardware gives 2x more performance while just using an O(nlogn) algorithm instead of an O(n2) can make shit tens and hundreds times faster. Yet people don't give a flying fuck. This goes even to the point when a desktop text editor is written with technologies normally used in web apps and it loads like a browser or even an operating system.
A portable application means available to more consumers. Testing helps eliminate errors as well as better design the system. You might not have to struggle with some harder algorithmic problems every day but once you do it's essential to find an effective and stable solution because a change in an algorithm complexity affects performance more than a change in a technology (both the language used and the hardware).
>>
>>61596747
>That's why I need to learn how to deal with others and how not to be too much of a pain to them.
Learn TSP (Team Software Process) then.
>>
>>61596276
F
>>
>>61596747
>The Traveling Salesman Problem? That's what Google says.
>>
>>61596764
>>61596782
Thanks.
>>
>>61594070
I'm adding parallelism to a program.

Do I have to worry about load balancing the threads on different cores myself, or does the kernel do a decent job of that?

I know how to fix a thread to a core with PTHREAD_SETAFFINITY_NP, but manually specifying threads hurts performance because sometimes I'm fixing the process on a busy thread.

Also unportable to specify different numbers due to Intel's fucking hyperthreading meaning that I can fix thread1 to core 1 and thread2 to core 2 and end up fixing both threads to the same core.
>>
>>61596803
Just use OpenMP, anon.
>>
Doing work in an Xcode project.
Need to copy a folder to the Package Contents of the output file with the Copy Bundle Resources section in the Build Phases of the project settings.
This folder has 2 sub folders that I want left out of this copy, but I don't want to mess with the hierarchy of the folder when it's put into the bundle.

How do?
>>
>>61596717
https://msdn.microsoft.com/en-us/library/windows/desktop/dd162487(v=vs.85).aspx
literally just googled "BeginPaint", opened the MSDN link and scrolled down to the example section
>>
>>61596829
Maybe wrong word choice. The threads do very different things. My program's being split into a client thread and a server thread. Isn't OpenMP more for spawning a bunch of processes that do the same thing?
>>
C++ doesn't leak memory after the program ends right?

Say I allocate space for an object using new, but never ever call delete (and don't use smart pointers or whatever). Assuming I need to use this object all the way until the end of my program, I'm fine, right?
>>
>>61597008
Yes, the kernel frees all memory at process termination
>>
>>61597008
On a modern protected mode operating system, yes. You should still free everything before exiting because tools like valgrind will still report it as a memory leak and it can make it harder to find real leaks in the noise.
>>
>>61597047
Thought so

>>61597071
Good to know, thanks
>>
Hey lads, I'm trying to write a TCP server for a game I'm making.

Right when I receive and decode the connection data, the server freezes and the client ends up hanging.

What can I do to fix that?
>>
>>61597008
>>61597071
Just do:
int
main(int k)
{
shmget(&k, 1, 512);
}
>>
>>61597150
You can start by not using the memest of languages
>>
>>61597281
What do you suggest I use then?
>>
The last man on Earth sat alone in a room. There was a knock on the door.
>>
Okay in Java let's say you have a file with a bunch of integers and you want to read each line into it's own array, with the elements of the array being the integers on its corresponding line.


How do you do this?
>>
>>61597327
Any functional programming language would set you off to a memetic start!
>>
>>61597402
just read the file iteratively in a loop with BufferedReader.

arr[i] = Integer.parseInt(that line);

I don't remember the methods involved but there are ways to read a file line by line via this way
>>
>>61597008
Think about what would happen if your browser crashed while streaming a large HD video. If memory could only be freed at runtime, you could lose whole gigs of ram, as good as dead until you rebooted. Killing a process is essentially reclaiming its memory.
>>
>>61597402
Scanner.nextint() IIRC
>>
>>61597445
But golang is procedural (or am i being memed here)
>>
>>61597472
Not all meme languages are functional, my man.
>>
>>61597342
Get on the floor.
>>
>>61597472
You're getting memed. Mentioning Go here is a surefire way to get memed on.
>>
>>61597472
Procedural != functional.
Anon is talking about Haskell, Lisp, etc.
>>
>>61597402
read to a ArrayList of int[]s like so
import java.util.*;

class A {
public static void main(String[] args) {
ArrayList<int[]> a = new ArrayList<int[]>();

int b[] = new int[] {1,2,3,4,5};
int c[] = new int[] {5,6};
int d[] = new int[] {9,9,9};
int e[] = new int[] {1,2,3,4};

a.add(b);
a.add(c);
a.add(d);
a.add(e);

System.out.println(a.get(2)[2]); // prints 9
}
}
>>
>>61597493
>>61597464
Pretty sure his question involves file parsing.
>>
>>61597510
nice try trying to get the homework done fgt
>>
>>61597510
Can't java open a file as a stream and pass the stream to scanner?
>>
>>61597510
Basically I want to make each line of a file it's own separate array.
>>
somebody PLEASE help me out, should have posted on this thread: >>61597594
>>
>>61597150
>TCP server
https://gafferongames.com/post/udp_vs_tcp/
he changed his website layout to be retarded nu-web2.0 horseshit but this guy is an expert multiplayer game programmer. I think he's writing a book too. He has a bunch of articles written about how to do game multiplayer programming. I'd recommend reading all of them.

No idea what's causing your bug. I'm not even sure what language that code is written in.
>>
>>61597626
Thanks anon, I figured out the reason and its a sad problem

My client end was left waiting for the server response, and I never gave back a response
>>
>>61597619
>interested in compilers and operating systems

you can become a professor
>>
>>61597619
You're getting fucked by h1b desu. Those job listings that have ridiculous requirements are deliberately done to justify hiring pajeets. Sorry.
>>
>>61597674
I considered doing this, but getting a PhD is 6+ years of work for just a little over minimum wage. I can't afford that right now.
Is there any way to get an interesting job in low-level programming with a bachelor's degree?

>>61597683
praying that trump will axe the h1b program soon
>>
>>61597674
lol, this is true

or one day aspire to be one of the wizards who contributes to the kernel
>>
>>61597706
>lol
>reddit spacing
>>
>>61597703
Yeah.
https://en.wikipedia.org/wiki/List_of_United_States_defense_contractors
Can't hire a pajeet if it requires a security clearance.
>>
>>61597703
>I considered doing this,
i don't know how it works in America (assuming you're American), but isn't there some position in universities where the professors have a student to help them giving lectures or something?
>>
>>61597730
Yeah but that's basically slavery desu. Getting a PHD is awful. Part of the reason why some phd types are so smug is because they think they have conviction for putting up with being a phd candidate.
>>
>>61597708
fucking gate keeping weeb

how does this trigger you?
>>
Is there a how-to-get-an-IT-job guide for 20-somethings without an education? Learn Java and contribute to stuff?
>>
>>61595494
yo
>>
>>61597721
Never thought of this, I'll look up some of those places. Thanks for the tip

>>61597730
Yeah, graduate teaching assistants. Many universities give free housing and the pay is extremely minimal. I need to help out my family with finances in the coming years, I can't afford to disappear to some university and make pennies for 6 years
>>
>>61597755
get certifications and shit

Also, what's IT exactly? help desk job or programmer jobs?

t. yuropoor guy here
>>
>>61597801
Realized I was being unclear. Preferrably software development.
>>
>>61597755
The place I'm at offers apprenticeships. They'll take people with no background who can demonstrate aptitude, train them, and place them at legit jobs.

You're not going to contribute to anything in a meaningful way without much more experience.
>>
>>61594070
Anyone know of a /g/ /prog/ like community with chat?

It's either all normie shit or all anime shit.
>>
>>61596391
I want to learn C++ and Java, just want a good book to get started as I know jack shit, but it interests me.
>>
>>61597813
there was some irc /g/ rooms or rizon, don't know if it still up tho
>>
>>61596663
Indeed. Winapi is easy to learn it's just largely stupid garbage. But the docs are good.
>>
>>61597808
then you'll need a good portfolio.

make some apps and publish them, go on git hub and contribute to some open-source project

the usual. do you know how to program?
>>
>>61597831
Yeah, there's stuff like #/g/punk and #8/agdg/ but they're about as slow as expected.
>>
>>61597813
Mostly they're like any other 4chan IRC chat. People who wish to establish identity go there. It tends to be shitty.
Go to other places like language or field specific chats.
>>
>>61597854
Gotcha. I don't know any programming right now, I'm clueless. I just began reading that Java introduction book by Liang and I'm using Netbeans.
>>
>>61597906
yup, if you're really good at android and iOS and make apps for it (publish app store + fill apps with ads + paid apps), you don't even need a job and you can make a living off it.

but you must be really good
>>
>read up on data oriented programming
>OOP seems like more and more of a mistake
But I don't wanna write a million loose functions named after the struct they operate on
>>
>>61597905
>language or field specific chats.

I'll check them out.
>>
>>61597905
/prog/ was the worst.

it's usually way too academic and focused on functional shit that people rarely use daily
>>
>>61597993
>nobody uses it because i dont
>>
>>61597934
You can still use member functions and implicit *this pointers.
But you're clearly not deep enough to understand that you shouldn't write a million functions at all.

Namespacing is also a good way to organize loose functions.
>>
>>61597993
>too academic
Imo it was just a bunch of wank. I didn't consider it very academic outside the language they used.
>>
>>61598055
things have changed, but in the /prog/ days, no one was using lisp or haskell outside of a grad lab.

what do you use? and what do you do with it? genuinely curious. functional programming jobs are usually for really cool shit or super heavy lifting.
>>
>>61598116
Nothing professional so youre going to discount me, but Idris. More and more places seem to be switching though due to FPL's benefit of run-time safety.
>>
>>61598141
I get it. I tried to make myself learn haskell, but without a professional application for it, I just felt like I was wasting my time. Sitting around dreaming up little exercises. I'd love to do some bad ass bayesian shit, but it's hard to devote enough to without being paid for it.
>>
>>61598186
>>61598141
author of the Haskell Book is streaming some Haskell rn on Twitch bois. name "bitemyapp"
>>
>>61598215
Learn You A Haskell for Great Good? fuck, I'll check it out
>>
>>61598186
The easiest thing is to just re-write a small application/module you currently have and see what you think.
>>
>>61598247
nah this one "Haskell Programming: From First Principles"

he's paid to code Haskell so he's doing something right
>>
CL or Scheme?
>>
File: Screenshot_20170727_211522.png (50KB, 939x765px) Image search: [Google]
Screenshot_20170727_211522.png
50KB, 939x765px
>>61598055
No, nobody uses it because nobody uses it. It's an objective fact.
>>
>>61598358
>Delphi is making a comeback
Why.jpg
>>
>>61598372
I think it's the first language they teach at russian universities.
>>
>>61598372
Because it supports Linux, Mac and Android now.
>>
>>61598358
>2% scratch
Doubt.jpg
>>
>>61598394
scratch to javascript transpiler when
>>
>>61598337
Landoflisp.com
Read the comic at the bottom
(CL imo)
>>
File: pls.png (202KB, 863x431px) Image search: [Google]
pls.png
202KB, 863x431px
>>61598409
>yfw javascript is the new bytecode
>>
>>61598427
webassembly is almost here friendo
>>
>>61594070
writing a script that groups the results of some sql query. You can only go so many levels of tuple keyed dictionaries of lists of lists before you start losing your mind.
>>
File: fuse_on_my_grave.png (2MB, 1920x1080px) Image search: [Google]
fuse_on_my_grave.png
2MB, 1920x1080px
>>61598438
Is that supposed to cheer me up?
>>
>>61598462
Yeah. If you find yourself trying to sneak too much logic into SQL, just fucking script it. You'd have to be dealing with massive data for it to make enough of a difference.
>>
File: 1427286647587.jpg (25KB, 396x385px) Image search: [Google]
1427286647587.jpg
25KB, 396x385px
>>61598468
If one has to do webdev for a living, wouldn't they prefer writing client-side code in any language they choose and compiling to webassembly and do specific compiler-level optimizations for that particular website?

>companies start obfuscating their websites
>adblock/anti-adblock arms race goes even further
>vulnerabilities go through the roof
>like flash all over again but this time you can't just block a plugin

I'm cheerful as FUCK, retarded normies brought this fate upon themselves. Grab a huge barrel of popcorn, the next few years will be absolutely hilarious
>>
>>61596944

problem is knowing what to look anon if i have a map on my brain for all the keywords in msdn i wouldnt have asked
>>
Why do webdevs prefer to jump through hoops with backend js when c#/java/go exist?
>>
>>61598599
The hoops keep getting easier to jump through. I never liked tomcat. I don't like microsoft libraries or docs, and I don't like that IIS is the best option for serving.
>>
>>61598599
So they don't have to learn c#/java/go.

They're not the ones writing the backends, they just jump on it and make the backend developers feel important.
>>
File: his optimism: gone.png (922KB, 1000x700px) Image search: [Google]
his optimism: gone.png
922KB, 1000x700px
What's the proper way to write a backend for your website?
Does it act like a daemon and handle all HTTP requests, or do you hand it off to something like ngnix?
>>
>>61594070
Still working on my job seeker program. Just need it to submit my cv and I can productively shitpost while looking for a job at the same time.
>>
>>61598522
Yeah, I had to really push it with the queries for this project. the db designed poorly and 20 fucking GB of mostly text. On top of that I'm stuck with a postgres copy of the clients Sql server db so everything has to be sql standard.
Had to write a pivot function from scratch and now all this fucking grouping. Wew
>>
Trying to save an array of values as an excel file through Python/openpyxl.

Does anyone know why the code below isn't working? When I run it, I create several excel files, but all of them are empty. Am I not saving things correctly?


def convert_array_to_excel_file(data_arr, file_array):
folder_str = file_array[0]
files = file_array[1:] #resize array to make it easier to work with

for ind in xrange(len(files)):
files[ind] = files[ind][:len(files[ind])- 4] #remove '.txt'
print "FILENAME: ", files[ind]

print "TYPE = ", type(data_arr)

num_rows = data_arr.shape[1]
num_cols = data_arr.shape[2]

for arr_ind in xrange(data_arr.shape[0]): #Once per each file processed
arr = data_arr[arr_ind]
wb = Workbook()

ws = wb.create_sheet()
#iterate through all values in each text file and place them in
# a worksheet
for curr_row in xrange(num_rows):
for curr_col in xrange(num_cols):
ws.cell(row=curr_row+1, column = curr_col+1).value = arr[curr_row][curr_col]

wb.save(files[arr_ind] + ".xlsx")
>>
>>61598791
Did you do close() on the file at the end of your program?
>>
File: 1463285950309.jpg (36KB, 600x564px) Image search: [Google]
1463285950309.jpg
36KB, 600x564px
>>61598522
>legions of nameless researchers devote their entire lives to make more efficient RDBMS systems
>companies invest billions of dollars in making more robust database systems
>database software released to the world is the product of decades of blood, sweat, and tears by incredibly intelligent people from all over the world
>"haha just script it bro"

FUCK you, and FUCK your kind. If you aren't getting the absolute maximum amount of data out of every single SQL statement you write, you are spitting on the legacy of our forebearers. Turn in your /dpt/ badge, right the FUCK NOW
>>
>>61598806
I just added
wb.close()


at the end of the code block I uploaded, but nothing changed, unfortunately
>>
>>61598818
make some prints to the console to assure you're attempting to write something to the file.

Also, are you writing in binary or something?
>>
>>61598818
help(wb)
>>
>>61598843
it appears I'm not actually changing the value of the cell (what the fuck?)

>Also, are you writing in binary or something?
Nah, just need to get some temperatures in a .txt file to excel, and want to automate it (I'm going to be doing it a lot more, so might as well)
>>
>>61598813
SQL logic is ugly as fuck and tedious to write. Why bother writing an ugly mess of SQL that's hard to read/maintain vs a few lines of clean code. Especially when it's a one-off request for data.

Like I said, if you're dealing with massive data or speed is life and death, SQL is worth it.
>>
>>61598883
Forgot to add pic
>>
>>61598883
Excel can open comma seperated values documents no problem.

I'd recommend just formatting the temperatures to a comma seperated values format.
>>
File: timesareachanging.jpg (59KB, 640x337px) Image search: [Google]
timesareachanging.jpg
59KB, 640x337px
Java or C#? What will give me more mileage/practicality?

>Pic obviously unrelated
>>
>>61598903
D
>>
>>61598889
declarative data languages are a blessing from above, it is our duty to understand them properly
>>
>>61598813
>merit is determined by how much money is poured in

Do you hate people who develop web applications without PHP too?
>>
>>61598903
java
>>
File: 1497894855298.jpg (130KB, 811x577px) Image search: [Google]
1497894855298.jpg
130KB, 811x577px
How would you test this code?

#include <argp.h>
#include <config.h>
#include "args.h"

error_t parse_opt(int key, char *arg, struct argp_state *state)
{
struct args *args = state->input;

if (args->count > 128)
argp_usage(state);

switch (key)
{
case 'q': case 's':
args->silent = 1;
break;

case 'v':
args->verbose = 1;
break;

case 'o':
args->output_file = arg;
break;

case ARGP_KEY_ARG:
if (args->count-- < 0)
break;
break;

case ARGP_KEY_END:
if (state->arg_num < 1)
argp_usage(state);
break;

default:
return ARGP_ERR_UNKNOWN;
break;
}
return 0;
}

void parse_args(int argc, char **argv)
{
const char *argp_program_version = PACKAGE_VERSION;
const char *argp_program_bug_address = PACKAGE_BUGREPORT;
const char* doc = "Eternity";
char args_doc[] = "file1.jpg file2.png file3.bmp ...";

struct argp_option options[] = {
{"verbose",'v', 0, 0, "Produce verbose output", 0},
{"quiet", 'q', 0, 0, "Don't produce any output", 0},
{"silent", 's', 0, OPTION_ALIAS, NULL, 0},
{"output", 'o', "FILE", 0, "Output to FILE instead of std output", 0},
{0}
};

struct argp argp = {options, parse_opt, args_doc, doc, NULL, 0, NULL};
struct args args;
args.count = argc;
args.silent = args.verbose = 0;
args.output_file = "-";

argp_parse(&argp, argc, argv, 0, 0, &args);
}
>>
>>61598931
do i look like some kind of QA clown to you?
>>
>>61598896
Yeah anon all you need to do is parse that to:
temperature
0.0
0.0
0.0

And save that as a .csv file. Then excel can open it.
>>
>>61598931
write test cases for it?
>>
>>61598896
You need to create a row and add it to the workbook. Then you need to add cells to the row.

Your cell method might work, but I'm pretty sure you still need to explicitly add it to the workbook.
>>
What are your thoughts on Qt? Any good alternative for multiplatform desktop development? Excluding electron (fucking piece of shit)
>>
>>61599002
>Any good alternative for multiplatform desktop development?
JavaFX
>>
>>61598931

does the program match the expected output given this specific input?

yes:
pass

no:
fail


I know it's a difficult concept to grasp but keep trying and you'll get it some day :)
>>
>>61599015
How is the performance? I worked with WPF on .NET (windows only, I know) and the tech looks pretty similar, and WPF is a fucking cancer
>>
File: dennis.jpg (24KB, 418x556px) Image search: [Google]
dennis.jpg
24KB, 418x556px
When interacting with the Sysfs in Linux using C/C++, why do I need to open and close the file each time I write to the file?

I thought I would be able to do something like:

FILE *sysFile = fopen(""/sys/class/gpio/export", "w")

for (gpios in range){
fwrite(gpio)
fflush()
}

fclose()

but it's only working when I do:


for (gpios in range){
FILE *sysFile = fopen(""/sys/class/gpio/export", "w")
fwrite(gpio)
fclose()
}


really makes me think
>>
>>61598813
this discussion reminds me of
https://aadrake.com/command-line-tools-can-be-235x-faster-than-your-hadoop-cluster.html

sometimes if a bash script works, its the best tool for the job, sometimes its even more effective than professional tools with industry sweat and blood in them
>>
>>61599054
Acceptable but it requires hardware accelerated desktops
Qt is definitely much faster
>>
>>61594070
I want to fuck Kylie Kujo in the discord chat
>>
I'm making a 3D engine using js and webgl. It's my first real project and the only thing I find EXTREMELY difficult is the code design aspect of it. Can't really understand how to properly organize code in classes etc. But my progress is slow and steady , I guess that's good despite the occasional feeling of "I'm not being cut for this thing".
>>
>>61599002
dear imgui ^_^

or something weird like wxwidgets

Qt and electron are da best though tbqh
>>
>>61599063
Add a rewind(sysFile) at the start of each loop iteration and see if that fixes it.
/sys is special, and you can't really think of them as normal files.
Maybe everything needs to be written at the start of the file?
>>
>>61598896
>>61598981
Just to be clear, look at your cell instantiation.

There's no reference to your sheet. That cell could be meant for any sheet, on any workbook. Without telling the sheet to add the cell, of course you get nothing.
>>
>>61598901
Fair enough. Thanks, y'all!
>>
>>61599119

I was really surprised when flushing the buffer didn't work as that's usually the standard procedure.

I'll try this tomorrow though. If that fails, at least I have my less-elegant solution. It's an improvement from writing a bash command to a buffer and calling system() on it at least.
>>
>>61599103
figuring out the architecture is always the hardest part, don't feel bad if that's what you're having difficulty with, but why the fuck are you making a 3d engine in javascript
>>
>>61599220
Architecture is tough, but the two hardest things in computer science are cache invalidation, naming things, and off by one errors.
>>
>>61599268
>but the two hardest things in computer science are cache invalidation, naming things, and off by one errors.
well said
>>
>>61599103
So, what are you making then?
>3D engine
Doesn't say much.

Alter your program structure iteratively. Implement a feature, pay technical debt. Implement a feature, pay technical debt. If you implement a feature a day, paying technical debt as it comes up then you're doing better than 99% of software projects.
>js and webgl
Yuck!
>>
>>61599268
naming things is basically architecture
>>
I'm stuck on Lua 5.1, but want to use a library that requires Lua 5.3's bitwise operators. Decided to go with the bitlib library that ships bundled with 5.2+ for this.
Found this backport of it that should work on 5.1:
https://raw.githubusercontent.com/ezdiy/lua-bit32/master/bit32.c

Forgive the retardo question, but how do I compile this C file into a .so or whatever I can require() in my Lua files?
>>
>>61599370
>>61599354
Fuck forgot the source file
gcc -o bit32.so bit32.c -shared {rest of your flags that you need}
>>
>>61599350
Naming things isn't exactly the same as structuring things, but you're not exactly wrong.
>>
What tools should I learn if I want to be a 1337 programmer?
>>
>>61599390
prolly perl
>>
>>61599382
Sweet, thanks. Looks like the bit32.c doesn't compile though, it falls over on that first typedef.
>>
>>61599390
Learn a scripting language like Python or Ruby; one which has enough users that there are libraries for most tools (I prefer Ruby).

Then I dunno, because I'm not a 1337 programmer. Maybe learn C and some assembly? Eventually leading to C++, C#, Java, Go? To Lisp, Haskell, Rust, etc.? Just do anything, and keep learning I guess.
>>
>>61599422
holy shit do people still use perl?

perl is like the opposite of riding a bike. every perl script I've ever written and tried to edit, it's alien.

it's an esolang that's cool for doing trivial shit.
>>
>>61599456
>Eventually leading to C++, C#, Java, Go?
Those are literally all dumb code monkey languages. No leet programmer needs to learn those garbage languages.

>>61599475
>holy shit do people still use perl?
Not really.
>>
>>61599451
That's probably because you're not linking it with the libraries it needs. I don't know what libraries it needs.

Try -llua. But it could be anything. Been years since I touched lua, and looking at that source code, glad it's stayed that way desu.
>>
>>61599482
>C++ and C# are dumb monkey languages
Oh, shut the fuck up. Let me guess, you hate C as well? Your OS was probably written in C, did you know that? C is what the smartest programmers use, heard of K&R? It's basically the most respected programming book.
>>
What's a good way to keep track of pointers and indirection? Any tools, preferably simple ones?

I like C so far but the syntax gives me a headache.
>>
>>61599524
What do you mean by keep track of?

Keeping track of pointers isn't much different from keeping track of other variables, the main difference is the value of the pointer is a variable.

If you're debugging, gdb and printf are you friends.

I wish gdb worked with my project....
>>
>>61599517
>Let me guess, you hate C as well?
No. What the hell did I say that implied that?

>>61599524
You just need to learn it. Indirection is a fundamental thing in programming. C just makes it explicit and is more powerful than most languages in that regard.
>>
>>61599475
>>61599482
Perl is still a good language if you use it as bash on steroids. It's almost kind of stupid how much faster it is these days when dealing with shit it was made for, i.e. text processing.
>>
NEW THREAD!

>>61599590
>>61599590
>>
>>61599584
>if you use it as bash on steroids
agreed on that point
>>
>>61599483
The docs aren't me helping any further here either, and all examples I can find are bunk.
>>
>>61599659
I looked online and saw that the flag you want is -llualib

I really don't know a systematic way of finding out what the names of the libraries you need are.
>>
>>61599020
ok but what if there's no output?
How do I test functions with side effects?
>>
>>61600369
what's the function do?
Thread posts: 317
Thread images: 30


[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.