[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: 348
Thread images: 39

File: timetocode.webm (2MB, 1152x648px) Image search: [Google]
timetocode.webm
2MB, 1152x648px
This is /dpt/, the best subreddit of /g/

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

Read this before asking questions

http://mattgemmell.com/what-have-you-tried/
http://www.catb.org/~esr/faqs/smart-questions.html

What are you working on ?
>>
kpop > anime
>>
What datatype should I use to store an 8-digit numeric account number?
>>
File: 1475249241820.jpg (174KB, 1000x929px) Image search: [Google]
1475249241820.jpg
174KB, 1000x929px
>tfw to intelligent from programming in functional languages
>>
>>56885936
an int
>>
File: 1460203639407.jpg (45KB, 500x225px) Image search: [Google]
1460203639407.jpg
45KB, 500x225px
>>
>>56885950
Thank you
>>
>>56885961
https://gist.github.com/YoEight/9710441
>>
i thought dynamic programming would be some crazy technique but it's just caching previous computations
wtf
>>
>>56886026
welcome to the world of _ Oriented Programming and _ Driven Design
>>
>>56886026
Caching previous computations is not really what dynamic programming is about. Dynamic programming is the process to find a way to be able to cache those previous computations and use them efficiently. Dynamic programming is about smart recursion.
>>
old thread is kill so ill repost

Whats the easiest way to make android apps. I know c++ really well but have barely used java. So id like to use c++ since I dont have to think about the syntax of everything.
Not looking for a super complicated touch screen master piece game. A basic gui with buttons and a large box that displays dynamically is really all Im looking for right now.
>>
>>56885939
>to intelligent

You sure are.
>>
Why does every build tool suck?
>>
I`ve been working for a while now on a new chan engine, LynxChan.
It provides admins flexibility, performance and customization.
I am currently beta testing it`s 1.7 version and working on a new front-end for it.
The engine can be found over gitgud.io/LynxChan/LynxChan
Pic related, the new front-end, Penumbra Lynx
>>
>>56886177
Intelligence doesn't necessarily mean your brain connects to your fingers well.

Personally i find stupid typos in almost every post i write. Words my brain knows how to spell, but my fingers are GTOW.
>>
>>56886247

It's your lie, tell it how you want.
>>
File: RMS.jpg (1MB, 2272x1704px) Image search: [Google]
RMS.jpg
1MB, 2272x1704px
Old: >>56878511
What are you working on, /g/?
>>
>>56886286
Destroying the FSF once and for all
>>
>>56886004
I agree, this is homosex.
>>
>>56885896
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: $0 <link>"
exit 1
fi

wget $1 -qO - | egrep 'File: <a href="[^"]+' -o | cut -d'/' -f 3- | sed 's|^|https://|g' | xargs -i{} -P10 wget -q -nc --show-progress {}

rate my bash skills /g/
>>
>>56886630

It's a script/10.
>>
>>56886630
>bash

might as well be using PHP
>>
>>56886176
Android studio supports C++ via the NDK. I don't know if you can avoid Java if you want to use the built in UI elements. I've used this setup for an app that used OpenCV and it works fine, but it's not simple.

The EASIEST way to create an app is to learn Ionic 2. Seriously. It's not C++. It uses Typescript and HTML which is cancer, but it's so fucking easy. Download a starter and start modifying it
>>
>>56886266
savage
>>
File: 1338897829820.jpg (134KB, 959x621px) Image search: [Google]
1338897829820.jpg
134KB, 959x621px
>>56886286

I am going to post some corny motivational images and build forms, how fucking exciting.

Goal: Build form in Angular 2 w/ validation.
>>
>>56886738
Are you productive during your day, anon?
Or does 4chan occupy all of your time?
>>
>>56887002

When I'm at school, I'm not shitposting, so there's that.
>>
File: intelligent-rage-feels.jpg (110KB, 601x601px) Image search: [Google]
intelligent-rage-feels.jpg
110KB, 601x601px
>tfw to intelligent for oop
>>
>tfw to intelligent too learn python
>>
>>56887041
You messed your o's up.
It's pythoon
>>
>Changed my cursor colour to bright pink
Can't concentrate as it's such a beautiful improvement to my qol
>>
I really don't want to start a derail or anything, but why are so many Q&A sites filled with Pajeets?

The only major site where I don't get meme answers is Stack Overflow.
>>
>>56887080
probably because they're trying to promote their career somehow. how? idk, maybe they include a link to their profile on their resume or think people will click on their account and see links they have to their pajeet version of linkedin or something
>>
>>56887021
>>56887041

aren't we all
>>
what has changed in python over the last ten years? is it any less shit?

>>56887080
>Stack Overflow
i see them there too

>>56887105
>they're trying to promote their career
this is my assumption
>>
>>56887320

I remember when my dad got a toaster at work. We used to borrow bread from from friends and go in at night to toast copies
>>
>>56887320
>I remember when my dad got a cd burner at work. We used to borrow cds from from friends and go in at night to burn copies.

I remember when my dad got a dildo at work. We used to borrow lube from from friends and go in at night to fuck copies
>>
>>56887056
keked too hard
>>
File: Mirin_Dajo_promotional.jpg (37KB, 350x443px) Image search: [Google]
Mirin_Dajo_promotional.jpg
37KB, 350x443px
>>56886989

...30 minutes later, I have a working router base. Wow, fml:

http://plnkr.co/edit/kwCPUGVjesAOL61moMH9?p=preview
>>
>>56887056
pronounced like c'thun
>>
File: 1407528210175.webm (2MB, 640x360px) Image search: [Google]
1407528210175.webm
2MB, 640x360px
>>56886989
>Goal: Build form in Angular 2 w/ validation.
>>56887455
>30 minutes later, I have a working router base
Can't make this shit up.
>>
>>56885896
so, how do we help 4chan?
I say:
- move the backend to Go, since PHP is slow and uses too much CPU/memory
- create /consumer/ board, add referrals to all amazon/ebay URLs posted there
- have images/gifs converted/compressed client-side, somehow...
>>
File: amidoingit.png (102KB, 1008x678px) Image search: [Google]
amidoingit.png
102KB, 1008x678px
Did I write the jni methods correctly?

I hadn't even heard of jni until 10 minutes ago, I've guessed based upon how other methods are written inside this class.

Anything obviously incorrect?
>>
What's a good way to compress 3D arrangements of voxels? 1D or 2D compression algorithms would give suboptimal performance.
>>
>>56887620
>- move the backend to Go, since PHP is slow and uses too much CPU/memory
>Let's rewrite everything in latest meme langugaes
Yeah no. PHP is probably fine for 4chan. I doubt 4chan is CPU constrained. More so bandwidth constrained.

>- create /consumer/ board, add referrals to all amazon/ebay URLs posted there
helps nothing
>- have images/gifs converted/compressed client-side, somehow...
insecure
>>
File: 1473020099083.gif (2MB, 500x529px) Image search: [Google]
1473020099083.gif
2MB, 500x529px
>>56887546

I guarantee that you have no idea how Angular 1 or 2 works, and likely don't even know javascript. Ib4 "javascript" is a meme language.

That may be, but it's a meme you better learn on top of your serverside unless you are a data science / math / machine learning professional.

I can make a form and send it to the server in about 5 mins, but not with a new library I have never used.

Feel free to get it done before me. You have my base to use.

What I need is email input with regEx to check for validity and password with hidden/unhidden buttons. Submit gets toggled based on form validity. Go for it.
>>
>>56887622

Switch to C# and you won't have to deal with JNI.
>>
>>56887692
>PHP is probably fine for 4chan
I have no love for Go but please don't meme dangerously, anon.
>>
>>56887753
What would the problem be?
>>
>>56887736
I plan on learning C# soon, but I need java for Android development
>>
>>56887692
>Yeah no. PHP is probably fine for 4chan. I doubt 4chan is CPU constrained. More so bandwidth constrained.
No, it boils down to storage. Uploading images from 200,000 simultaneous users take bandwidth yes, but it also takes a lot of storage space, which needs to go fast.
>>
>>56887780
Storage is cheap as shit. And all the images and videos hosted on 4chan at any given time isn't going to be more than a few gigs. You could probably host it all in ram is you wanted.
>>
Who else struggles to write code unless they're constantly referencing previous code they've written?

If I want to do x, y or z, I have to google or find documents in which I have already done this as a reference, otherwise I get stuck.
>>
>>56887692
>I doubt 4chan is CPU constrained
the mere act of going from, say, 8 servers to 1 or 2 would help
>>
File: 58678.png (17KB, 418x359px) Image search: [Google]
58678.png
17KB, 418x359px
Writer w; // i'm sorry, I must be declared outside the try block
try {
...
} catch (IOException e) {
...
} finally {
if (w != null) {
try { // here comes another try/catch block!
w.close();
} catch (IOException e) { // i am so sorry
...
}
}
}
>>
>>56887856
probably not that much though I would guess. Maybe I'm wrong.
>>
File: console.png (54KB, 517x859px) Image search: [Google]
console.png
54KB, 517x859px
        function lumberAI(xCord, yCord){
var hasTrees = false;
for(i=1;i<dimensions;i++){
var maxX = (xCord+i>dimensions) ? dimensions:xCord+i;
var maxY = (yCord+i>dimensions) ? dimensions:yCord+i;
var minX = (xCord-i<0) ? 0:xCord-i;
var minY = (yCord-i<0) ? 0:yCord-i;
console.log("cycle:" + i);
console.log("max X: " + maxX + ", max Y: " + maxY);
console.log("-----------");
for(;minY<maxY;minY++){
for(;minX<maxX;minX++){
if(map[minY][minX].type=="T"){
hasTrees = true;
}
console.log("min X: " + minX + ", min Y: " + minY);
}
}
if(hasTrees){
break;
}
}
}

Why wont the outer loop increment? I just started messing with JS so sorry if it's obvious.
>>
>>56887876
Stupid frogposter
>>
>>56887881
Go has basically Java-level performance, with less memory usage and easy concurrency
according to some benchmarks (that I can't remember now), one the fastest webservers out there is made in Go
>>
>>56887716
You don't have to lecture me, kid. I remember the times when 'inobtrusive JavaScript' was a thing and 'responsive design' was just starting out.

I actually made a few AJAX-ridden websites that would take seconds to load, with all the flashy shit that's standard now. (I wish I could direct you to the exact library I used, but thankfully I've already forgot its name.)

It was around the time that Backbone, Ember, Angular and other shitstains that went completely against the solid paradigm were becoming mainstream that I decided to quit webdev. Quite frankly, I'm glad I did.
>>
>>56887893
is dimensions > 1?
>>
>>56887780
the current static thumbnail generation it has doesn't help at all with storage either, they should honestly switch to dynamic thumbnailing
>>
Do any of you faggots actually know anything about hardware programming or microcontrollers in general? Or is this thread just script kiddies?
>>
>>56887716
>I can make a form and send it to the server in about 5 mins, but not with a new library I have never used.
Also, what do you do if the client has disable JavaScript? Just serve a blank page? What if the user circumvents the JS validation, which is trivial in any case? You still do validate on the server anyway, right?
>>
>>56887876

This is why checked exceptions are fundamentally wrong.
>>
>>56887972
I used to know a little about it, but as a 16yo I could financially afford to experiment and play with microcontrollers that break just from static electricity.
>>
>>56887972
>hardware programming
not real programming
>>
>>56887959
Whoops, it was actually 'unobtrusive'. Sorry about that.
>>
>>56887963
Yes, always!
>>
File: 1473908653841.jpg (412KB, 1600x1066px) Image search: [Google]
1473908653841.jpg
412KB, 1600x1066px
>>56887959

If you are pulling in over $140,000 and doing "real-work", more power to you. There is a paradigm on here where people shit on full-stack like it's beneath them. The catch is that it's only beneath you if you can do the real jobs.

>>56887982

>Also, what do you do if the client has disable JavaScript? Just serve a blank page?

Sure, most real companies assume js is enabled and if it's not, you tell them to fucking enable it or fuck off. Same with outdated browsers.

>What if the user circumvents the JS validation, which is trivial in any case? You still do validate on the server anyway, right?

That's a pretty silly question. Every API call is checked on the backend. Logins go through an Authentication server to issue a token, which again, gets checked on every call.

P.S. I hate front-end too, but a lot of back-end work is also fucking with libraries / monotonous shit.
>>
>>56888012
What are you using right now you stupid fuck?
>>
>>56888084
I'm drinking from a water bott-
Holy shit, I had no idea that water was programming!
>>
>>56887972

I can build a combination lock out of basic logic-gates and have before. Completely useless "skill" irl. I am the "javascript script kiddie" above.

Someone recently asked me to do math in hex and binary at an interview. I lolled, but am glad I knew how.
>>
>>56888102
>>56888012
As if you needed more proof this thread is tweens roleplaying.
>>
>>56888084
A purely functional 4chan browser written and proved correct in Agda, exported to Haskell with clearly separated side effects using monads and algebraic effects with handlers running on pure energy generated from the interactions between prezygohistomorphic prepromorphisms in the ∞-category of co-presheaves on Grothendieck quasitoposes.
>>
>>56888116
It's sad that you think your job has to be programming or it must be worthless, and yet decide to go to a programming board and insult people for programming.

You are a glorified electrician.
>>
>>56888139
Ah, so you're using software on a hardware product.

>>56888157
You should stop pretending lad, you're just looking sad at this point.
>>
>>56888075
OK, no hard feelings.
>>
>>56888180
>ah so you're using software on a hardware product
Not him, but congratulations on not understanding my post.

You live in some weird world where merely USING something makes it programming related.
>>
>>56888180
>Ah, so you're using software on a hardware product.
No, it's pure energy.
>>
>>56887847
Sounds familiar.
>>
>>56888233
>>56888238
You're doing a good job convincing me that you're not using hardware in any way shape or form to use the software.

Stop roleplaying.
>>
>>56888264
What the fuck are you talking about?
Did you even read my post?
I am in fact using hardware
>>
>>56888264
>hurrr, I'm hardware programmer, pay heed to me, you lowly germs
>>
Need some help with c.

I have an int set to a random number.

How would i then set that number to an array?
ex:

random = 1234;
array_random={1,2,3,4};

Is there a simpler way then doing a for loop and dividing?
>>
>>56888238
Also
>script kiddie doesn't understand an energy-based OS would, by definition, be hardware, if it facilitated running a kernel and running operations

>>56888289
>>56888285

Stop roleplaying.
>>
>check /dpt/
>it's full of cancer
>>
>>56887893
>cycle:1
>cycle:2
>cycle:3
>Why wont the outer loop increment?
What are you talking about?
>>
Can I shorten this regex and capture the same things?

([0-9]+[baka])( [0-9]+[baka])*


It sho
>>
>>56887876
https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
>>
>>56888323
lol that should be "s mh" instead of baka fuck u hiroshima

([0-9]+[hms])( [0-9]+[hms])*
>>
>>56888323
([0-9]+[abk])( [0-9]+[abk])*
>>
>>56888000
what's a a checked exception?
>>
>>56888353
yeah sorry it wasn't baka lol
>>
lua is best language
>>
>>56888377
In that case no. Perhaps change [0-9] to \d.
>>
>>56888385
sucks for me
>>
>>56888359

Look it up first, and if you don't understand it, then maybe I'll explain further.
>>
>>56887876
>exceptions

That's what you get for not using conditions

http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html
>>
>>56888297
C being a programming language of the past, you will have to use the programming techniques of the said past.

# Submit to the power of Python
array_random = [int(x) for x in str(random.randint(0, MAX))]
>>
>>56888383
but it can't do
[ [i for i in range(0,10)] for j in range(0,5) ]
>>
>>56888359
exceptions you are forced to catch.
>>
>>56888419
map (read @ Integer . pure) . show . abs
>>
>>56888297
I could do this easily with log10 and bitwise fuckery, but you'd have to reverse it afterwards.
>>
>>56888426
for i = 0, 10 do
>>
File: usage.gif (6KB, 717x200px) Image search: [Google]
usage.gif
6KB, 717x200px
rate & review my tool guise https://github.com/liviu-/ding
>>
Which IDE do you guys use for C/C++?
>>
>>56888465
Is that @ type application? How does it work?
>>
>>56888504
Vim
>>
>>56888297
I dont'e think .so/
>>
>>56888465
@ isn't a function
>>
>>56888509
>>56888517

you need to enable the TypeApplications extension
>>
>>56888504
Vim+YouCompleteMe+tmux
>>
File: LANGUAGE TypeApplications.png (13KB, 597x294px) Image search: [Google]
LANGUAGE TypeApplications.png
13KB, 597x294px
>>56888509
it substitutes type variables
>>
>>56888413
Fine. If it's that complicated, i will.
>>
Programming in C is so tedious.
>>
>>56888479
>MIT
>Not GPLv3
Into the trash it goes.
>>
>>56888564
Nice. I remember it was discussed some time ago. The syntax sucks, but I guess it's useful enough to justify its use sometimes.
>>
Why does so much of /g/ go into IT or have these meme certs?
>>
>>56888504
CLion with vim plugin
>>
what should I do with my odroid-c2
>>
>>56888584
:((
>>
>>56888578
Please expand upon this thought. What are you working on right now that makes you think this, what language would you rather be using, how would that language makes things easier for you and why aren't us using that language?
>>
Hey /g/, I'm a complete newbie on C, and I've been studying some code and I was wondering what is the meaning of the & and ~ operator when doing assignments?
e.g
char character;
#define ASCII_Z = 0;
long digit;
digit = character & ~ASCII_Z;

what is happening with the digit variable?
>>
>>56888592
Haskell is actually running out of syntax imho

a @ t
and
a@t
are not the same
>>
>>56888504
MSVS
>>
>>56888297
malloc an array of size length of the string version of int
map over the string version of the int
for each, add the the int to the malloced array
profit
>>
File: sadfrog.jpg (150KB, 1010x810px) Image search: [Google]
sadfrog.jpg
150KB, 1010x810px
>>56888620
fugg, GHC was a mistake.
>>
>>56888633
My main issue is this
I would like there to be a bang pattern for compile time evaluation.

! and ~ are already taken
What short/concise thing could be used?
>>
>>56888584
>GPLv3
>not BSD 4 clause
It's like you're asking to be cucked by GNU/rms
>>
>>56888611
I thought I'd have a go at making a small game engine in C. Managing memory manually, that sort of stuff. I'd rather be using C++ or C#.
>>
>>56888649
Spice it up with ¡
>>
>>56888617
https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Bitwise_operators
>>
quick, give me an idea so I can do something in c!!!
>>
>>56888617
~ is a bitwise not
& is a bitwise and
Time for you to learn binary
>>
File: 1408751367381.jpg (2MB, 3504x2336px) Image search: [Google]
1408751367381.jpg
2MB, 3504x2336px
>>56888656
>cucked by GNU/rms
Explain. Richard M. Stallman (PhD) intentions are and have always been pure.
>>
>>56888702
VM
>>
>>56888682
>tfw no InterrobangPatterns
‽
>>
tell spencer i said hi
>>
>>56888726
>ywn use -XPilcrowPatterns
>>
>>56888712
>communism
>pure
>>
>>56888737
okay
>>
>>56888675
Just for the xp of having done something in C, or why?
>>
>>56888769
fuck off
>>
>>56888712
>Richard M. Stallman (PhD) intentions are and have always been pure
That pedophile birdfucker is known for coopting projects and either kicking out the original developers or making them answer to him just for using the GNU license and being pretty
>>
>>56888775
Just for the experience of doing it in C.
>>
>>56888426
>i for i
what were they thinking? Fuck me.
>>
>>56888712
>honorary doctorate
doesn't count
>>
>>56888820
Good. That'll give you a sense of what must actually be going on under the hood when you're using higher level libraries.
>>
File: carlos.png (272KB, 560x560px) Image search: [Google]
carlos.png
272KB, 560x560px
>>56888827
I guess you could say that code could make the whole world blind
>>
>>56888702
An OS
>>
>>56888856
Carlos!!
>>
>>56888845
So far, I get the feeling that higher level libs/langs do a hell of a lot of memory allocations.
>>
>>56888888
noice
>>
>>56888710
I know that but...
I've never seen it being used in assignment operators.

Mostly, just for checking if statements.
>>
>>56888906
that's the only time a scriptfag will ever get sexts
>>
>>56888904
Correct.
>>
>>56888797

``no``
>>
File: neko desu.gif (1MB, 487x456px) Image search: [Google]
neko desu.gif
1MB, 487x456px
How do I get valgrind to stop and take me to gdb when it finds an error?
>>
what is better for developing web applications java or c#?
>>
>>56889001
C#
>>
I never have the problem that i lack for something to do, programmingwise.
I always ha a project i should be working on, if i could just work up the drive to do it.
>>
>>56889014
care to explain?
>>
>>56889036
ASP.NET is popular and well supported.

C# is generally a much better language than Java.
>>
>>56889063

>tfw contracting for Java shop and they are convinced Java is actually good and try to push it for projects
>tfw got out of it...this time
>tfw realizing the place I got placed in uses straight SQL-commands instead of entity mapping

Shiggy diggy.
>>
>>56888910
Why wouldn't you be able to use bitwise operations in assign expressions?
After all, all assignment is, is storing a bit-pattern in a chunk of memory.
>>
>>56886630
I'll bite since most here won't say much.

If you are actually using bash use
!#/usr/bin/env bash


Also if you intend to use some bashism then use '[[' instead of '[' since '[[' is a bash builtin and '[' is going to make an external call to /bin/[

Fetch line is hard to read and tough to trace through, limiting your pipes makes for better shell code ( in my opinion ). While it isn't as hacky or as fun if its not a oneliner I try to avoid using more then 2 pipes per command.

Also, learn AWK, the grep,cut,sed could all we done in awk cutting out 2 pipes.

Further more there isn't much bash involved here, if you really want to write bash code see if you can eliminate the grep, cut, and sed by using just bash.

Last but not least, most autistic tip I'm going to give... egrep is not specified as part of POSIX, use grep -E which I know is contradictory to me pushing bashisms.
>>
>>56889036
you won't have to deal with java
>>
>>56889105
lel. Any company that uses Java is going to be shit tier. Java is only common because it's taught in every university, so if you can't be bothered to learn anything new, Java is probably all you know and you probbaly think it's the best.
>>
File: 911 was an inside job.webm (653KB, 598x598px) Image search: [Google]
911 was an inside job.webm
653KB, 598x598px
Playing with Processing. Something a bit easier after the L-systems this time.
>>
Hey anons, how can i do this:
Get data from one file1.txt and insert it into bottom of file2.txt with shell?
>>
>>56889236
cat file1.txt >> file2.txt
>>
>>56889236
git gud
more lurk
cat file1.txt >> file2.txt
>>
I'm trying to invert a matrix in C via Gauss-Jordan elimination but I am screwing up somewhere in my code.

    for(j = 0; j < n; j++)
{
int temp = j;

//Finding maximum jth column element in last (n - j) rows
for(i = j + 1; i < n; i++)
{
if(inverted[i][j] > inverted[temp][j])
{
temp = i;
}
}


//Swapping row which has maximum jth column element
if(temp != j)
{
for(k = 0; k < n * 2; k++)
{
double swap = inverted[j][k];
inverted[j][k] = inverted[temp][k];
inverted[temp][k] = swap;
}
}

//Performing row operations to form required identity matrix out of the input matrix
for(i = 0; i < n; i++)
{
if(i != j)
{
double row_op = inverted[i][j];

for(k = 0; k < n * 2; k++)
{
inverted[i][k] -= (inverted[j][k] / inverted[j][j]) * row_op;
}
}
else
{
double row_op = inverted[i][j];

for(k = 0; k < n * 2; k++)
{
inverted[i][k] /= row_op;
}
}
}
}


Thing is, inverted before and after shows the Identity matrix in the right places for the augmented matrix but the numbers are all wrong for some reason. Someone please help.
>>
>>56889157

Nice random walk, guy.
>>
>>56889333
nice blog
>>
>>56889333
break the code up a bit
>>
How do I access an element thats inside a struct and that struct is inside another struct in C?

im trying to do (*stk).head.data but its not working

"stk" is a pointer to the structure that has the element "head" which is a pointer to another struct which has an element "int data"
>>
>>56889405

Why even post if you are going to ironically suggest I was not on topic? Why are you even here if you aren't contributing anything programming related or asking for help?
>>
>>56889425
(*stk).head.data should work fine
stk->head.data too

assuming head is not a pointer

>>56889429
he's just a cunt, ignore him
>>
>>56889429
Nobody's going to read your shitty code.
>>
>>56889423

I doubt it would make much difference if I separated out the clearly documented 3 sections inside the loop into separated functions.
>>
>>56889440
>element "head" which is a pointer to another struct
>assuming head is not a pointer
>>
>>56889455
yes it would, because then if you trust that your functions work, then people reading can just see the top level logic
>>
>>56889440
head is a pointer. Im trying to learn stacks and head is the top of my stack which is a pointer to the other struct which has the data in it
>>
>>56889470
stk->head->data
or
(*((*stk).head)).data
you can't use . on pointers
you want ->, which is the same as (*p).x
>>
Anyone have a link to the 5th edition of C++ Primer PDF? One that is not like 100 MB please.
>>
>>56889483
thanks my dude it worked
>>
>>56889468

The top level logic is clear from the one line documentation and no one is going to reuse max-j element column, swap row with max jth column and Gauss-Jordan subtract/division functions.

It's not like the logic is using way too much nesting either.
>>
there should be a deftype in c
which is basically typdef but with arguments reversed

deftype month
struct { int number
, int days
, char name[10]
}
>>
>>56888297
so you're trying to take each digit of a random number (say, 1234 is the given random number as posted) and then put each individual digit into an array (giving [1, 2, 3, 4])?

>>56888626
said it best I believe. some itoa fuckery combined with malloc should do the trick.
>>
Why do you all hate Ruby (the tripfag)? He's helped me a number of times.
>>
>>56889632
t. Ruby the tripfag
>>
>>56889632
He's a nice guy and all, but unironically thinks ruby is a good language. Sadly this means he is clinically retarded.
>>
>>56889632
No one hates Ruby the tripfag.

OSGTP is a bit of dick, though.
>>
File: ruby browny.png (47KB, 955x497px) Image search: [Google]
ruby browny.png
47KB, 955x497px
>>
>>56889688
:( i like mommy AND daddy
>>
>>56889632
he's kinda autistic and he cares too much about "setting the record straight"
>>
>>56889696
oh God I'm dieing
>>
>>56889688
>OSGTP is a bit of dick, though.

What did I do?

>>56889600

But.. why?
>>
>>56889716
so pretty much like 90% of /dpt/ posters?
>>
>>56889731
for readability
>>
OSGTP is just mad that OOP is on its last indefensible legs
>>
>tfw not autistic enough to tripfag on this board
>>
>>56889708
Shut up doggo.
>>56889731
If you only like niggers, is Ruby a black person?
>>
>>56888323
((^¦ )[0-9]+[hms])+
>>
>>56889680

Ruby is a good language, but people do Javascript-esque stuff with it like the abomination of Ruby on Rails.

My opinion is that Ruby, and any dynamically typed language, really is not meant for very big applications (>100k LOC). Typing is very handy and prevent very horrible screwups in code that gets that large but people have used these languages for large codebases and I have no idea what kind of rationale they would have to do that.
>>
>>56889696
>if you act like it's normal people won't care
Hahaha, that's some complete lack of self-awareness right there.
>>
>>56889771
OSGTP actually convinced me on the whole negress thing. Niggers maybe stupid violent apes, but some of their women are pretty nice...
>>
File: 1472300988435.gif (2MB, 450x250px) Image search: [Google]
1472300988435.gif
2MB, 450x250px
>>56889774
> (^¦
>>
>>56889781
>any dynamically typed language, really is not meant for very big applications (>100 LOC).
ftfy
>>
>>56889800
Or anything business-critical really. If you wanna dick around and make a program to rename some files or whatever then sure feel free to use ruby or python or whatever.
>>
>>56889749

It doesn't really help readability when everybody's been subjected to standard typedefs for 40 odd years.

>>56889771
>If you only like niggers, is Ruby a black person?

Who said I only liked niggers? I just think black women are sexy.

>>56889790

Das it mane.
>>
>>56889774
genius

do you think
((| )\d+[baka])+
would work as well?
>>
>>56889696
how do i get those garish colours for myself?
>>
>>56889860
meant
((| )\d+[hms])+
>>
>>56889860
If your regex thing supports \d, sure. why wouldn't it?
>>
>>56889751
what is this meme?
are there sources for this oop hate?
>>
>>56889843
C++:
using type = othertype;

D:
alias type = othertype;

Haskell:
type type = othertype
>>
>>56889888
we've had this discussion again and again and again

go through the archives if you want to know why OOP is shit and why it's dying
>>
>>56889886
no sorry, i meant if i have nothing before | so instead of (^| ) to use (| )
>>
responding to the guy who mentioned memory mapped files in the context of a text editor,


I'll think about it but I want to limit the complexity of the editor to maybe 1000 lines at maximum. I'm not exactly sure how to use a gap buffer and mmap (osx here) at the same time either.

Can I modify a mmap'd file without it changing the contents on the hard disk? Or would I have to load the segment of the file into a cache and modify it there? I'm worried that could lead to some complexity that I'd like to avoid.
>>
>>56889860
( ?\d+[hms])+
>>
>>56889897

I get what you're driving at, but C doesn't change much. That's kind of its thing.
>>
>>56889918
>go through the archives
implying anyone would ever do this
>>
>>56889936
#define type othertype
>>
>>56889888
>are there sources for this oop hate?

Unbelievably contrived examples of user error.
>>
>>56889956
Justify the existence of the visitor pattern
>>
>>56889956
All programming errors are user errors. There would be no need for paradigms and type checking etc if everything everyone wrote was perfect everytime.
>>
>>56889926
omg too good thank u
>>
File: Jesus-facepalm.jpg (61KB, 900x599px) Image search: [Google]
Jesus-facepalm.jpg
61KB, 900x599px
#define newname oldname

typedef oldname newname;


Score one for consistency, C.
>>
>>56889977
Design patterns != OOP.
>>
>>56889977

Like I said before, if I gave examples they would be just as contrived.
>>
>>56890080
Justify its existence
do it now

>>56890078
Design patterns exist to "fix" problems inherent with OOP
>>
do you guys code at home

what are you programming
>>
>>56890103
>Design patterns exist to "fix" problems inherent with OOP
You're going to have to justify that claim. That's like me claiming some retarded shit like dinosaurs never existing and expecting people to believe me.
>>
I'm not going to speak for anyone else, but this picture quite accurately illustrates how i feel about oop.
>>
>there are plebs in this thread who unironically use arrays, loops and classes
This is how you do it right kiddos https://gist.githubusercontent.com/alessonforposterity/832da4fab11e10609dad/raw/258df12378399919ae088ba8731a7571d9c2c947/drgn.txt
>>
>>56885961
suck on this logarithmic fibonacci
fib n =
fib_iter 1 0 0 1 n
where

fib_iter _ b _ _ 0 = b

fib_iter a b p q cnt =
if even cnt
then (fib_iter a b (p*p + q*q) (2*p*q + q*q) (cnt `div` 2))
else (fib_iter
(b*q + a*q + a*p)
(b*p + a*q)
p q (cnt-1))
>>
>>56890120
I never leave my house so where else would I program?
>>
>>56890141
How can you seriously compare those two statements

"Design patterns" are almost entirely used in OOP or by former OOP programmers
90% are "how can we avoid doing it the proper way so that we can still call it OOP and use inheritance and stuff"
>>
Design patterns exist because people keep coming up with similar solution to similar problems.
>>
>>56890198
>to similar problems
To similar OOP problems
>>
File: chart.png (86KB, 1200x800px) Image search: [Google]
chart.png
86KB, 1200x800px
Idiomatic generic D code written by a ruskie with broken English is as fast C/C++/FORTRAN code plus hand-crafted assembly folded 10000 times by a team of crack jews for their processors only.
>>
>>56890280
rewrite it in haskell
>>
>>56890280
God bless that madman
>>
>>56890219
Actually, you are partly correct. The problem domain that (programming) design patterns deal with is how to structure your code. OOP is a design paradigm that deal with how to structure your code.
>>
File: chrome_2016-10-02_13-16-01.png (90KB, 1898x493px) Image search: [Google]
chrome_2016-10-02_13-16-01.png
90KB, 1898x493px
Why does clang not have any output?
>>
>>56890316
I don't get how you can continue to deny this
It's not "partly" correct it's entirely correct
Why the fuck do you think so many design patterns mention inheritance?
>>
>>56890316
One could even say that OOP is itself a design patter, because it's a (some would add the qualifier 'alleged') solution to the problem of structuring your code.
>>
>>56890332
I guess it's optimized away because you never actually use the struct.
>>
File: i wish a nigga didnt.png (283KB, 714x574px) Image search: [Google]
i wish a nigga didnt.png
283KB, 714x574px
Is it possible that gcc -O2 could be causing valgrind false positives?
Because valgrind tells me that there's errors on a certain line, I go to check it in vdb, and every single variable on that line has been optimized out so I can't know what's wrong.

Also, when i compile with -O0, the valgrind messages go away.
>>
File: chrome_2016-10-02_13-19-05.png (152KB, 1895x581px) Image search: [Google]
chrome_2016-10-02_13-19-05.png
152KB, 1895x581px
>>56890349
nada
>>
>>56890353
It's been a while, but shouldn't -g give you the correct line number?
>>
>>56890335
It's only partly correct because there are a lot of design patters that don't deal with oop at all.
>>
>>56890369
>>56890349
Only seems to work when i disable all optimization

clang is B R O K E N
>>
>>56890369
Looks like an optimization. Try -O0.
>>
>>56890383
No, there are very few "design patterns" that are actually not remotely like the others at all and are just very broad statements.

If you're gonna go down this "planning is a design pattern" "testing is a design pattern" bullshit road, at least think it through
>>
>>56890412
B R O K E N
R
O
K
E
N
>>
>>56890353
>Can these optimizations break things?
>When I turned them off, they stopped breaking things

i dunno anon what do you think
>>
>>56890382
Yes, it's giving me the "right" line number, but gdb gives me nothing to work with, everything is optimized out.
I could see the values of the optimized away variables under -O0, but then the valgrind errors go away.

This makes me think it's a false positive and can be safely ignored.
>>
>>56890405
>clang is B R O K E N
Other way around, the other compilers are broken because they emit a useless copying loop.
>>
>>56890461
i guess clang has never heard of memory mapped io
>>
Why are there no decent c compilers for windows?
>>
>>56890474
Then you should use volatile.
>>
>>56890474
volatile
>>
>>56890482
Cuz Windows sucks for programming
>>
>>56890332
Why would it?
>>
File: chrome_2016-10-02_13-27-58.png (90KB, 1882x452px) Image search: [Google]
chrome_2016-10-02_13-27-58.png
90KB, 1882x452px
which one is objectively better
>>
File: 1466451231438.jpg (152KB, 640x720px) Image search: [Google]
1466451231438.jpg
152KB, 640x720px
>>56890405
>look ma i made a c program!
>what's undefined behavior?
>>
File: senpai.webm (3MB, 600x338px) Image search: [Google]
senpai.webm
3MB, 600x338px
/dpt/-chan, daisuki~

>>56890506
Intel

>>56890485
https://www.kernel.org/doc/Documentation/volatile-considered-harmful.txt

>>56890332
That code has an undefined behavior: A variable is read while being uninitialized. Initialize OtherData then clang shall output some code.
>>
>>56890540
>The use of volatile in kernel code is almost never correct
>almost never
>>
>>56890540
>https://www.kernel.org/doc/Documentation/volatile-considered-harmful.txt
Are you fucking retarded?
>>
File: memio.jpg (28KB, 607x119px) Image search: [Google]
memio.jpg
28KB, 607x119px
>>56890540
>https://www.kernel.org/doc/Documentation/volatile-considered-harmful.txt
Did you even bother reading that?
>>
>>56890506
Depends on how memcpy is implemented and which cpu families you're targeting.
>>
>>56890600
not portable
>>
>>56886630
1. This is sh, not bash
2. Quote variables
3. Use xml tools instead of grep/sed to get info from html
>>
>>56890414
>If you're gonna go down this "planning is a design pattern" "testing is a design pattern" bullshit road, at least think it through
What? No, that sound like bullshit.

I have here here a book called Game Programming Patterns by Robert Nystrom. I was going to list all the patterns from this book that have nothing to do with oop, but flipping through the book there were fewer than i had thought. Some notable examples though, are
>observer
>double buffer
>game loop
>event queue
>dirty flag

Many other patters do deal with objects, so can be said to deal with solving the problems of oop, although i don't think any of the patterns deal with inheritance, which is often regarded as the central dogma of oop. And many of these patterns are actually nice ways of structuring your program even if you don't give a fuck about oop or inheritance.

I forget what my point was with this, but it's a pretty fun book. I recommend it.
>>
>>56890675
>I/O mapping
>not portable
Yeah, no shit.
Next you're gonna tell us assembly is not portable.
>>
>>56885936
Account numbers should most likely be stored as strings. Account IDs should be stored as integers.

The difference is meaningful leading zeroes and shit like that.
>>
>>56885936
byte[8]
>>
>>56890699
>double buffer
Not a "design pattern"
>game loop
Not a "design pattern"
>event queue
Not a "design pattern"
>dirty flag
Not a "design pattern"
>observer
Retarded OOP design pattern

You've literally paid money to a fucking guy telling you that a boolean is a design pattern or vector<someAction> is a design pattern or update render loop is a design pattern
>>
>>56890710
the logic behind a lock is portable. a lock is a lock, you use it the same way whatever architecture you are targeting. the behavior of volatile is not.
>>
Doing some work with computer vision, I need some help trying to make this algorithm. I'll probably post this in /sci/ as well, but you all might be able to help.

I'm making an autonomous 1/8th scale racecar. I need a way to get the angle and radius of a turn.
Here's what I know: I know the point which the turn starts and the point which it ends. So effectively, I just need to make an algorithm that can get the angle and radius of a spline.

I had though about trying to treat the spline between A and B as the arc length of an ellipse but that doesn't give me enough information to solve for the angle and radius. Furthermore, I also need to find the apex of the spline. That should be much easier once I have the angle and radius since at that point I can just treat it as a parabola..

Any thoughts?
>>
>>56890731
>Retarded OOP design pattern
Observers are great. What's the alternative to this pattern?
>>
I've edited a java library and added some new methods.

I try and call these methods from my program, but they're not recognised.

What am I doing wrong?

Java and Android studio
>inb4 java is the problem
>>
File: help.png (9KB, 811x379px) Image search: [Google]
help.png
9KB, 811x379px
What am I missing here? Why doesn't this print the 3?
>>
>>56890797
You made them public?
>>
>>56890770
[e -> f a]
>>
>>56890769
er...

Doesn't it completely depend on what kind of curve the real turn has? It could be a circle arc, or it could be a spline curve or whatever. Without knowing that how are you meant to estimate the curve?
>>
>>56890732
>the logic behind a lock is portable. a lock is a lock,
Who's talking about locks?
>the behavior of volatile is not.
It doesn't need to be.
>>
>>56890823
What's that mean?
>>
>>56890832
it means don't try to fucking wrap everything in your oop nonsense

>list of classes inheriting from some base class describing event reception
just use a container of functions you dumbass
like callbacks or shit
>>
File: img_53bd73c3d0544.png (48KB, 674x228px) Image search: [Google]
img_53bd73c3d0544.png
48KB, 674x228px
>>56890824
It does, I'm trying to find a general solution that works for all cases.

A spline curve can be a circle arc, but an arc is not always a spline.

All I know is the point A and B mentioned beforehand. Surely there's got to be a way.
>>
>>56890828
>Who's talking about locks?
https://www.kernel.org/doc/Documentation/volatile-considered-harmful.txt
https://lkml.org/lkml/2007/5/8/372
>>
>>56890863
but my question was what's the alternative to the observer pattern?

>just don't do it because it's nonsense
isn't much of an answer
>>
>>56890873
I butchered that.. let me try again...

All arcs are splines but not all splines are arcs.
>>
>>56890891
Use a container full of functions
>>
>>56890873
i would use a bezier curve, and adjust the length of the control point lines as needed.
>>
>>56890904
what do you mean by container? Like.. a collection of functions?
>>
>>56890885
No one in this thread was talking about locks.
We were talking about memory mapped I/O,,which if you actually read your links you'll see they agree that it is the one cases where volatile is appropriate.
>>
>>56890731
I suspected this post might appear.

These are all solutions to problems that appear, in this case specifically, making real time applications.

What you're doing going "i don't like design patterns, therefor anything i might like can impossibly be a design pattern, by definition". I which case further discussion i useless.

And observer pattern is a way to avoid having one part of the code constantly poking another part of the code and going "are we there yet? are we there yet?". It has nothing to do with oop.
>>
>>56890907
I would, but most turns are going to be a quadratic Bezier curve. I have the start point and end point.. I'll need to find the control point if I want to use it.
>>
>>56890914
anything really

>>56890927
You're retarded. ALL of those are not fucking patterns. Jesus Christ.
I guess I'm using the PostOn4chan Pattern right now and the FormBasicSentences Pattern.

The difference between observer and sense is that the sensible solution is just to store functions / callbacks and the stupid solution is to wrap functions inside OOP inheritance objects and then store objects just to stay on the bandwagon
>>
File: myerror.png (10KB, 762x84px) Image search: [Google]
myerror.png
10KB, 762x84px
>>56890817
It's all public.
I've been stuck for days /:
>>
>>56890815
Nevermind, figured it out
>>
>>56890977
Post more code than that senpai, otherwise we can't help. If it's too large, make a gist.
>>
>>56890968
>I'll need to find the control point if I want to use it.
yeah, so estimate where it goes. Not hard.
>>
when does the stack call overflow?
>>
>>56890975
>anything really
How is a collection of functions a replacement for the observer pattern?
>>
>>56890968
If all you have is two points, you might as well estimate the curve as the straight line between these points, for all anyone knows.
You also need the irrationality of your points, ie. the tangents, to be able to make a reasonable guess. If you have the tangents you can calculate a control point.
>>
>>56891023
How do you think the observer pattern works?
[object1, object2, object3]
object1/2/3 contain pointers to vtables (which contain pointers to functions)

the rest is just closure
>>
File: MVI_2032.webm (2MB, 1280x720px) Image search: [Google]
MVI_2032.webm
2MB, 1280x720px
>>
>>56890977
Have you imported that library?
>>
>>56888504
qt
>>
>>56891030
>irrationality
*directionality

wtf? i'm starting to suspect my fingers are developing estranged limb syndrome
>>
>>56890977
Are you sure you are building and linking to the updated library, the version that has your code in it?
>>
>>56891053
right, well that effectively is the observer pattern to me. Half of all OOP design patterns are just a weird ways of avoiding first class functions.
>>
>>56891130
Most of them are ways of avoiding the proper way of doing things. Because they're got to fit objects in there somewhere. Because it's all about OOP.
>>
>>56891053
you are confusing a concept with its implementation.
>>
Is it ok to have more then 1 index in table/mysql?
>>
>>56891150
>the proper way
In your opinion.
>>
>>56891158
The fucking premise of the "observer pattern" is OOP.
If it comes bottled with a UML diagram it's probably more OOP trash.

>>56891188
Are you seriously saying fucking avoiding the normal solution for NO REASON OTHER TO INSERT OBJECTS is fucking reasonable?
>>
>>56891203
you are talking about vtable which is an implementation technique among others.
>>
>>56891006
I'll make a gist account tonight if I'm still stuck, thank you anon

>>56891061
>>56891096
I've copied and pasted it into my /libs/ folder, replacing the original, rebuilt, cleaned, synced etc, and it still won't work

It's just not recognising what I've edited, despite my code being correct. Something is wrong in the setup, but I can't find any documentation
>>
>>56891150
I'm actually interested in seeing you write a book or an article or something on the PROPER way of doing things. Something concrete, with examples, that a newb could actually learn from and avoid getting stuck in the oop quagmire.

I suspect that a lot of what you write would map directly to what the rest of us think of as design patterns.
>>
>>56891238
The OOP way literally just fucking complicates things to add objects
How are you defending this
>>
>>56891203
>Are you seriously saying fucking avoiding the normal solution for NO REASON OTHER TO INSERT OBJECTS is fucking reasonable?
Of course it is.

When you design a fully OOP language, you set some constraints for that language. Sometimes you have to make adaptations to adhere to those constraints.

Just like many things in C are completely retarded, but they are that way for performance reasons.

I could come up with a million examples of things that are normal in OOP languages that you would have to do really dumb stuff to accomplish in functional languages.
>>
>>56891261
>>56891261
>>56891261
>>56891261
>>
>>56891246
You want to know the proper way of doing things?
I'll enlighten you

You see a problem
you find the solution

this is the difficult part
- YOU DON'T TRY TO FIT IT INTO OBJECTS -

you use the solution
>>
>>56891251
Yeah, well, that's just, like, your opinion, man.
>>
>>56891268
>constraints
That's bullshit.
The reason they do it is because they think it's better.
They think OOP is a good thing.

They definitely don't do it because of "constraints". A "constrained" language looks like C, not like Java or C#.
>>
>>56891282
What if your problem is to use objects.
>>
>>56891268
>I could come up with a million examples of things that are normal in OOP languages that you would have to do really dumb stuff to accomplish in functional languages.
Give one example.
>>
>>56891314
Using objects is normally the problem
>>
>>56891310
>C a constrained language
It's actually the opposite.
>>
>>56891282
But anon, this is how design patterns emerge.
>>
>>56891395
no, a design pattern is like this:

you see the obvious solution
you try to find a way to force fucking objects into it in the most awkward possible format
you brand it as the new Enterprise Observing Entity Component Pattern (TM) (C)
>>
>>56891449
We clearly have different concepts of what a design pattern is.
>>
a design pattern is an interface abstraction technique.
>>
>>56891481
Yes, you think everything under the sun is a design pattern, and I don't.
>>
>>56890073
#define
and
typedef
are two completely different things, low quality b8.
>>
>>56892479
What? They're not conceptually similar? Asking for a little consistency in notation is too much to ask?
>>
>>56886177
trolling is a art :^)
>>
>>56889600
If you can't understand why C type declarations are the way they are, you shouldn't try to suggest anything else.
>>
>>56890540
>what is RAII
dumb signaturefag
>>
so what is the most promising successor of C: D or (sjw)Rust?
Thread posts: 348
Thread images: 39


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