/dpt/ - Daily Programming Thread

This is /dpt/, the best subreddit of Cred Forums

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

Read this before asking questions

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

What are you working on ?

Other urls found in this thread:

gist.github.com/YoEight/9710441
plnkr.co/edit/kwCPUGVjesAOL61moMH9?p=preview
docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html
github.com/liviu-/ding
en.wikipedia.org/wiki/Operators_in_C_and_C++#Bitwise_operators
gist.githubusercontent.com/alessonforposterity/832da4fab11e10609dad/raw/258df12378399919ae088ba8731a7571d9c2c947/drgn.txt
kernel.org/doc/Documentation/volatile-considered-harmful.txt
lkml.org/lkml/2007/5/8/372
twitter.com/SFWRedditVideos

kpop > anime

What datatype should I use to store an 8-digit numeric account number?

>tfw to intelligent from programming in functional languages

an int

...

Thank you

gist.github.com/YoEight/9710441

i thought dynamic programming would be some crazy technique but it's just caching previous computations
wtf

welcome to the world of _ Oriented Programming and _ Driven Design

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.

>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

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.

It's your lie, tell it how you want.

Old: What are you working on, Cred Forums?

Destroying the FSF once and for all

I agree, this is homosex.

#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: $0 "
exit 1
fi

wget $1 -qO - | egrep 'File:

It's a script/10.

>bash

might as well be using PHP

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

savage

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

Goal: Build form in Angular 2 w/ validation.

Are you productive during your day, user?
Or does Cred Forums occupy all of your time?

When I'm at school, I'm not shitposting, so there's that.

>tfw to intelligent for oop

>tfw to intelligent too learn python

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.

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

aren't we all

what has changed in python over the last ten years? is it any less shit?

>Stack Overflow
i see them there too

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

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

>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

keked too hard

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

plnkr.co/edit/kwCPUGVjesAOL61moMH9?p=preview

pronounced like c'thun

>Goal: Build form in Angular 2 w/ validation.
>30 minutes later, I have a working router base
Can't make this shit up.

so, how do we help Cred Forums?
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...

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.

>- 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 Cred Forums. I doubt Cred Forums 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

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.

Switch to C# and you won't have to deal with JNI.

>PHP is probably fine for Cred Forums
I have no love for Go but please don't meme dangerously, user.

What would the problem be?

I plan on learning C# soon, but I need java for Android development

>Yeah no. PHP is probably fine for Cred Forums. I doubt Cred Forums 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.

Storage is cheap as shit. And all the images and videos hosted on Cred Forums 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.

>I doubt Cred Forums is CPU constrained
the mere act of going from, say, 8 servers to 1 or 2 would help

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

probably not that much though I would guess. Maybe I'm wrong.

function lumberAI(xCord, yCord){
var hasTrees = false;
for(i=1;idimensions) ? dimensions:xCord+i;
var maxY = (yCord+i>dimensions) ? dimensions:yCord+i;
var minX = (xCord-i

Stupid frogposter

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

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.

is dimensions > 1?

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?

>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?

This is why checked exceptions are fundamentally wrong.

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.

>hardware programming
not real programming

Whoops, it was actually 'unobtrusive'. Sorry about that.

Yes, always!

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.

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

What are you using right now you stupid fuck?

I'm drinking from a water bott-
Holy shit, I had no idea that water was programming!

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.

As if you needed more proof this thread is tweens roleplaying.

A purely functional Cred Forums 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.

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.

Ah, so you're using software on a hardware product.

You should stop pretending lad, you're just looking sad at this point.

OK, no hard feelings.

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

>Ah, so you're using software on a hardware product.
No, it's pure energy.

Sounds familiar.

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.

What the fuck are you talking about?
Did you even read my post?
I am in fact using hardware

>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?

Also
>script kiddie doesn't understand an energy-based OS would, by definition, be hardware, if it facilitated running a kernel and running operations

Stop roleplaying.

>check /dpt/
>it's full of cancer

>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

docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html

lol that should be "s mh" instead of baka fuck u hiroshima

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

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

what's a a checked exception?

yeah sorry it wasn't baka lol

lua is best language

In that case no. Perhaps change [0-9] to \d.

sucks for me

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

>exceptions

That's what you get for not using conditions

gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html

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))]

but it can't do
[ [i for i in range(0,10)] for j in range(0,5) ]

exceptions you are forced to catch.

map (read @ Integer . pure) . show . abs

I could do this easily with log10 and bitwise fuckery, but you'd have to reverse it afterwards.

for i = 0, 10 do

rate & review my tool guise github.com/liviu-/ding

Which IDE do you guys use for C/C++?

Is that @ type application? How does it work?

Vim

I dont'e think .so/

@ isn't a function

you need to enable the TypeApplications extension

Vim+YouCompleteMe+tmux

it substitutes type variables

Fine. If it's that complicated, i will.

Programming in C is so tedious.

>MIT
>Not GPLv3
Into the trash it goes.

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 Cred Forums go into IT or have these meme certs?

CLion with vim plugin

what should I do with my odroid-c2

:((

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 Cred Forums, 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?

Haskell is actually running out of syntax imho

a @ t
and
a@t
are not the same

MSVS

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

fugg, GHC was a mistake.

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?

>GPLv3
>not BSD 4 clause
It's like you're asking to be cucked by GNU/rms

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

Spice it up with ¡

en.wikipedia.org/wiki/Operators_in_C_and_C++#Bitwise_operators

quick, give me an idea so I can do something in c!!!

~ is a bitwise not
& is a bitwise and
Time for you to learn binary

>cucked by GNU/rms
Explain. Richard M. Stallman (PhD) intentions are and have always been pure.

VM

>tfw no InterrobangPatterns
‽

tell spencer i said hi

>ywn use -XPilcrowPatterns

>communism
>pure

okay

Just for the xp of having done something in C, or why?

fuck off

>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

Just for the experience of doing it in C.

>i for i
what were they thinking? Fuck me.

>honorary doctorate
doesn't count

Good. That'll give you a sense of what must actually be going on under the hood when you're using higher level libraries.

I guess you could say that code could make the whole world blind

An OS

Carlos!!

So far, I get the feeling that higher level libs/langs do a hell of a lot of memory allocations.

noice

I know that but...
I've never seen it being used in assignment operators.

Mostly, just for checking if statements.

that's the only time a scriptfag will ever get sexts

Correct.

``no``

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#?

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.

care to explain?

ASP.NET is popular and well supported.

C# is generally a much better language than Java.

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

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.

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.

you won't have to deal with java

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.

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?

cat file1.txt >> file2.txt

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.

Nice random walk, guy.

nice blog

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"

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?

(*stk).head.data should work fine
stk->head.data too

assuming head is not a pointer

he's just a cunt, ignore him

Nobody's going to read your shitty code.

I doubt it would make much difference if I separated out the clearly documented 3 sections inside the loop into separated functions.

>element "head" which is a pointer to another struct
>assuming head is not a pointer

yes it would, because then if you trust that your functions work, then people reading can just see the top level logic

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

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.

thanks my dude it worked

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]
}

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])?

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.

t. Ruby the tripfag

He's a nice guy and all, but unironically thinks ruby is a good language. Sadly this means he is clinically retarded.

No one hates Ruby the tripfag.

OSGTP is a bit of dick, though.

...

:( i like mommy AND daddy

he's kinda autistic and he cares too much about "setting the record straight"

oh God I'm dieing

>OSGTP is a bit of dick, though.

What did I do?

But.. why?

so pretty much like 90% of /dpt/ posters?

for readability

OSGTP is just mad that OOP is on its last indefensible legs

>tfw not autistic enough to tripfag on this board

Shut up doggo.
If you only like niggers, is Ruby a black person?

((^¦ )[0-9]+[hms])+

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.

>if you act like it's normal people won't care
Hahaha, that's some complete lack of self-awareness right there.

OSGTP actually convinced me on the whole negress thing. Niggers maybe stupid violent apes, but some of their women are pretty nice...

> (^¦

>any dynamically typed language, really is not meant for very big applications (>100 LOC).
ftfy

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.

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

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

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

Das it mane.

genius

do you think ((| )\d+[baka])+ would work as well?

how do i get those garish colours for myself?

meant
((| )\d+[hms])+

If your regex thing supports \d, sure. why wouldn't it?

what is this meme?
are there sources for this oop hate?

C++:
using type = othertype;

D:
alias type = othertype;

Haskell:
type type = othertype

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

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.

( ?\d+[hms])+

I get what you're driving at, but C doesn't change much. That's kind of its thing.

>go through the archives
implying anyone would ever do this

#define type othertype

>are there sources for this oop hate?

Unbelievably contrived examples of user error.

Justify the existence of the visitor pattern

All programming errors are user errors. There would be no need for paradigms and type checking etc if everything everyone wrote was perfect everytime.

omg too good thank u

#define newname oldname

typedef oldname newname;


Score one for consistency, C.

Design patterns != OOP.

Like I said before, if I gave examples they would be just as contrived.

Justify its existence
do it now

Design patterns exist to "fix" problems inherent with OOP

do you guys code at home

what are you programming

>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 gist.githubusercontent.com/alessonforposterity/832da4fab11e10609dad/raw/258df12378399919ae088ba8731a7571d9c2c947/drgn.txt

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))

I never leave my house so where else would I program?

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.

>to similar problems
To similar OOP problems

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.

rewrite it in haskell

God bless that madman

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.

Why does clang not have any output?

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?

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.

I guess it's optimized away because you never actually use the struct.

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.

nada

It's been a while, but shouldn't -g give you the correct line number?

It's only partly correct because there are a lot of design patters that don't deal with oop at all.

Only seems to work when i disable all optimization

clang is B R O K E N

Looks like an optimization. Try -O0.

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

B R O K E N
R
O
K
E
N

>Can these optimizations break things?
>When I turned them off, they stopped breaking things

i dunno user what do you think

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.

>clang is B R O K E N
Other way around, the other compilers are broken because they emit a useless copying loop.

i guess clang has never heard of memory mapped io

Why are there no decent c compilers for windows?

Then you should use volatile.

volatile

Cuz Windows sucks for programming

Why would it?

which one is objectively better

>look ma i made a c program!
>what's undefined behavior?

/dpt/-chan, daisuki~

Intel

kernel.org/doc/Documentation/volatile-considered-harmful.txt

That code has an undefined behavior: A variable is read while being uninitialized. Initialize OtherData then clang shall output some code.

>The use of volatile in kernel code is almost never correct
>almost never

>kernel.org/doc/Documentation/volatile-considered-harmful.txt
Are you fucking retarded?

>kernel.org/doc/Documentation/volatile-considered-harmful.txt
Did you even bother reading that?

Depends on how memcpy is implemented and which cpu families you're targeting.

not portable

1. This is sh, not bash
2. Quote variables
3. Use xml tools instead of grep/sed to get info from html

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

>I/O mapping
>not portable
Yeah, no shit.
Next you're gonna tell us assembly is not portable.

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.

byte[8]

>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 is a design pattern or update render loop is a design pattern

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?

>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

What am I missing here? Why doesn't this print the 3?

You made them public?

[e -> f a]

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?

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

What's that mean?

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

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.

>Who's talking about locks?
kernel.org/doc/Documentation/volatile-considered-harmful.txt
lkml.org/lkml/2007/5/8/372

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

I butchered that.. let me try again...

All arcs are splines but not all splines are arcs.

Use a container full of functions

i would use a bezier curve, and adjust the length of the control point lines as needed.

what do you mean by container? Like.. a collection of functions?

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.

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.

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.

anything really

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

It's all public.
I've been stuck for days /:

Nevermind, figured it out

Post more code than that senpai, otherwise we can't help. If it's too large, make a gist.

>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?

>anything really
How is a collection of functions a replacement for the observer pattern?

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.

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

...

Have you imported that library?

qt

>irrationality
*directionality

wtf? i'm starting to suspect my fingers are developing estranged limb syndrome

Are you sure you are building and linking to the updated library, the version that has your code in it?

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.

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.

you are confusing a concept with its implementation.

Is it ok to have more then 1 index in table/mysql?

>the proper way
In your opinion.

The fucking premise of the "observer pattern" is OOP.
If it comes bottled with a UML diagram it's probably more OOP trash.

Are you seriously saying fucking avoiding the normal solution for NO REASON OTHER TO INSERT OBJECTS is fucking reasonable?

you are talking about vtable which is an implementation technique among others.

I'll make a gist account tonight if I'm still stuck, thank you user

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

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.

The OOP way literally just fucking complicates things to add objects
How are you defending this

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

...

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

Yeah, well, that's just, like, your opinion, man.

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

What if your problem is to use objects.

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

Using objects is normally the problem

>C a constrained language
It's actually the opposite.

But user, this is how design patterns emerge.

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)

We clearly have different concepts of what a design pattern is.

a design pattern is an interface abstraction technique.

Yes, you think everything under the sun is a design pattern, and I don't.

#define and typedef are two completely different things, low quality b8.

What? They're not conceptually similar? Asking for a little consistency in notation is too much to ask?