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

File: nene c++.jpg (155KB, 1440x810px) Image search: [Google]
nene c++.jpg
155KB, 1440x810px
old thread: >>61573303

What are you working on, /g/?
>>
File: asasd.png (378KB, 1113x619px) Image search: [Google]
asasd.png
378KB, 1113x619px
>>61579801
thoughts on game development?
>>
>>61579801
>This book is super easy
>I went through my Beginner C book even more!

Does learning C first actually make you a better C++ programmer?
>>
>>61579816
/dpt/ irrationally hate it or pretend, because video games are irrelevant on linux but its the most fun and interesting type of programming.
>>
Decompiler for native code.
>>
>>61579816
An industry waiting to go up in smoke. At least specialize in Graphics Programming so you can at least segway into animated movie studios.
>>
>>61579830
>C++ is basically C with OOP and a few other improvements
>"Does learning C first actually make you a better C++ programmer?"
I wonder.
>>
I tried watching new game but it's just so fucking dull. I don't usually have a problem with slow moving cute girl shows but I couldn't sit through this one without watching at 3.5x playback speed.

>>61579830
Yes, it really does.
Because then you'll learn to hate all the C++ features and how wasteful they are.
A lot of people like C++ just because it has a vector type in the standard library, but you can write your own in 2 minutes.
>>
>>61579844
>An industry waiting to go up in smoke
you dont really believe this do you?
>>
>>61579830
Not at all. C++17 and C are as similar as a whale and a turtle. They have totally different libraries, totally different styles of memory management, and totally different ways of organizing code.
>>
File: 1475385314834.png (876KB, 1354x1920px) Image search: [Google]
1475385314834.png
876KB, 1354x1920px
>>61579801
Good OP
>>
is anyone here an audio programmer

wanna work on a vst with me :3
>>
>>61579860
Atari's coming back to bring back the next gaming crash, mark my words, screencap this post, whatever.
>>
>>61579831
>CTRL+F "vgdg" in /v/, /vg/
>nothing
>Google "vgdg 4chan"
>no trace of an actual vgdg thread in archives
What's going on?
>>
>>61579816
I mean, a lot of people are doing very interesting things there. I'm not going to knock those guys.

On the other hand, there's something to be said for livable wages, good working conditions, job security, etc.

So I'd say that it's not for me, but I'm too smart to hate on people for wanting to make me video games.
>>
>>61579901
Try agdg.
>>
>>61579885
>Atari's coming back to bring back the next gaming crash
Atari have no relevance though, no one believes theyre going to succeed in the new console so how can they crash an industry theyre barely a part of.

The Chinks will do more damage slowly buying up big companies before a crash.
>>61579901
you want /agdg/
>>
>>61579884
Can you teach me audio programming maybe?
>>
File: 1479491492854.jpg (53KB, 420x236px) Image search: [Google]
1479491492854.jpg
53KB, 420x236px
>>61579920
Shhhh, don't say their name. They'll come shit up the thread
>>
File: 12w3e4rtyhj.png (610KB, 1354x1920px) Image search: [Google]
12w3e4rtyhj.png
610KB, 1354x1920px
>>61579865
optimized image
>>
>>61579927
theres a huge helpful audio programming pdf for C and C++ written by richard boulanger

its how a lot of musicians and audio programmers learnt their shit so just find a dl for it
>>
>>61579760

fixed it:

    void Engine::add(domain::Model& model)
{
moveables.emplace_back(Moveable(model));
auto* moveable = &moveables.back();
modelMoveables.emplace(&model, moveable);
}
>>
>>61579971
Could you upload a copy to mixtape.moe or something?
I can't find it.
>>
>>61579922
I don't know how they'll do it, but it'll happen.

The End is near, friend
>>
>>61579816
who the fuck wears a dog collar on their neck except sexual perverts
>>
>>61580019
#wokewomyn
>>
>>61579920
>>61579922
oh
thx
>>
>>61580019
Shes a jewess, so of course shes a deviant.
>>
File: emma.webm (3MB, 754x688px) Image search: [Google]
emma.webm
3MB, 754x688px
>>61580008
https://my.mixtape.moe/fimhjx.pdf
>>
>>61580049
thank you!
>>
>>61580008
Not the anon you're asking, but it looks like it's called The Audio Programming Book by MIT Press. Can't look now but it shouldn't be too difficult to find a torrent of it.
>>
>>61580008
Nvm, >>61580049 came through.
>>
File: 1410716416995.jpg (114KB, 429x631px) Image search: [Google]
1410716416995.jpg
114KB, 429x631px
>>61579801
Thank you for making a hijab/mudslime/nigger free /dpt/, OP
>>
File: Amazon.jpg (249KB, 908x446px) Image search: [Google]
Amazon.jpg
249KB, 908x446px
>>61579816
VR is the future, so it's gonna be even bigger than now.
>>
I've learned some C++ and took an Assembly course. What book on C would someone recommend?

Are the wiki's recommendations outdate?
>The C Programming Language (Keringhan and Ritchie)
>O'Reilly - Practical C Programming
>C Pogramming: A Modern Approach (K.N. KING)
>>
>>61580049
>thousand page C++ book I wish I had time to read No. 2761

A lifetime is not enough to master that fucking language that is alien to hardware anyway.
>>
>>61580362
It's an audio signal processing book written for C++.
It's explicitly a C++ book.
Audio signaling is a big field.
>>
>>61580397
>Audio signaling is a big field.
for you.
>>
File: amazon.png (66KB, 1848x871px) Image search: [Google]
amazon.png
66KB, 1848x871px
>>61580160
funny story

a couple days ago a wrote like 20 shitty one line reviews on amazon. exactly one of them was blocked for violating their "terms". All I did was mention walmart.

pic
>>
61580455
>explicitly say to keep outside brands out
>do it anyway
>lol i troll them XD
Kill yourself
>>
Trying to write my own SQL-like database in C using only the standard library
>>
>>61580455
w@lm@rt
>>
>>61580495
i don't read that shit you autist
>>
>>61580496
fyi, sqlite already exists
>>
>>61579801
If I'm creating a multithreaded application and I need to pass "commands" (each command is 48 bytes large) from one thread to another with minimal synchronization blocking, is my best choice a pipe?

How fast are pipes? Do I have to worry about the pipe overflowing? I might pass thousands of commands per second.
>>
>>61580545
It's an exercise
>>
>>61580557
Just use a (priority?) queue with a mutex slapped on it.
>>
>>61580397
>It's explicitly a C++ book.
That's why it's a thousand pages.
>>
>>61580397
>>61580676
did you losers even it up, its literally for C
>>
>>61580614
Ehh dynamic allocation ehh. Then again I bet pipes would have that problem too. Commands are equal priority so luckily nothing going on there.

Thinking about it I'm kind of leaning towards a 3 page circular buffer. If the program somehow fills up that circular buffer, I'd just the program synchronize stall because some things weren't meant to be and maybe the user should use the program less intensely.
>>
>>61580776
>>61580614
Now should I declare the circular buffer as a global array or is that a bad idea? Should I make a call to mmap or something?
>>
so I can't return a pointer to a member of a vector, because everytime the vector is resized it will become invalid right?

so what can I do instead?
>>
>>61580815
Either use an array and don't call realloc, or return an index.

OR use an array, but this time you're allowed to call realloc because you're returning a pointer to the pointer to the element, and when you realloc the array, update the pointer to the element.
>>
>>61580815
Return the actual member.

If you are planning on modifying the vector in-place then you'll need to do it before it gets otherwise updated anyway, so I don't see the problem.

>>61580856
I think what he means by invalid is that the pointer (or an index) might not point to the same thing if something else gets inserted somewhere between [0] and [your_index].

Congratulations, you've just discovered the issue of cache invalidation. If you can solve it, you'll win 1 whole internet.
>>
Find the smallest x + y + z with integers x > y > z > 0 such that x + y, x – y, x + z, x – z, y + z, y – z are all perfect squares.
>>
>>61580951
This isn't a homework thread.
>>
>>61580887
That's why you don't do that or use extra levels of indirection.

I didn't consider inserting between elements because he specified resizing vectors, which does invalidate pointers because resizing vectors is handled by realloc.

The way to handle that what you have to do is change your vector from a vector<Obj> to a vector<Obj*>, or since that uses evil pointers, I guess vector<shared_ptr<Obj>>? Not big on smart pointers.
>>
>>61580951
>>>/sqt/
>>>/sci/
>>
>>61579884
There is nothing fancy to VST's, you get some idiot savant to create your algorithm like Fabrice Gabriel and an intern to make the UI. My friends dad has dabbled in it and has 2 masters and a PhD
>>
>>61580972
What thread is it?
>>
Rust. Yea or Nay?
>>
>>61581031
I've been reading Rust Essentials. Rust is okay. Bit more verbose but it's the closest to C++ performance you'll get
>>
>>61581031
The language isn't even stable.
They're STILL deleting keywords and forcing rewrites of existing code.
>>
>>61581077
>They're STILL deleting keywords and forcing rewrites of existing code.
So just like C++?
>>
File: brainlet_wojak.jpg (47KB, 645x968px) Image search: [Google]
brainlet_wojak.jpg
47KB, 645x968px
Who here a brainlet?
>only know how to program in C and Go because other languages have so many features I don't understand
>Try to learn C++, don't understand templates
>Try to learn Lisp, don't understand metaprogramming
>Try to learn Ruby, don't understand metaprogramming
>Try to learn Rust, don't understand borrow checker
>Try to learn Python, don't understand its iterators
>>
>>61581100
meta and templates are huge memes no one except stl/boost actually uses unironically
>>
>>61581100
Try out Nim or D.
Nim is pretty small, and it compiles to C but writing Nim is comfy
D is pretty big but it compiles to LLVM and writing D is comfy
>>
>>61580979
>he specified resizing vectors, which does invalidate pointers
He didn't say anything about reallocing. You "resize" a vector every time you add or remove something from it.
The amount of memory actually put aside isn't meant to matter, and more to the point you don't manually request a realloc so you won't know when anything will invalidate it.
The only thing you'll know is that addresses are still good so long as you don't insert anything else, and may all get shagged if you add just one thing.

So really the question is why do they want a reference to a member anyway, is it so it can be poked at later, or is it just a reference point for later use?
Either way, you probably don't want to maintain a reference to a specific part of a dynamic structure (exceptions being buffers/deques).
>>
>>61581100
>Try to learn C++, don't understand templates

templates are the easy part tho
>>
File: 24 caret gold.gif (546KB, 255x255px) Image search: [Google]
24 caret gold.gif
546KB, 255x255px
>>61581092
C++ is stable though, it's just that they renamed the stable branch to C#.
>>
How good is a life of a full time Java developer? Is it comfy and nice as I imagine or is it hard work actually? Any Java developer would like to share his job experiences?
>>
File: linq.png (299KB, 843x3218px) Image search: [Google]
linq.png
299KB, 843x3218px
>>61581142
>they renamed the stable branch to C#
>>
>>61581123
people use templates
>>
>>61581148
Where exactly did I suggest anyone with a functioning brain should use LINQ?

Did you confuse me for a tripfag or something?

Anyway, C# is trash, but at least it's stable, predictable trash. Unlike C++.
>>
>>61581176
If I'm using vendor lock-in garbo, I'd rather use Swift than Micros**t's Java ripoff
>>
>>61581171
Only because macros are ``````````evil''''''''''.

Hilarious considering that C++ std libs are glued together with endless macros.
>>
>>61581185
C hash is comfy and not hat vendorlocked compared to swift
>>
>>61581197
>not hat vendorlocked compared to swift
I see Micros**t has brainwashed another brainlet
>>
>>61581185
I'd rather not use a runtime-dependant language at all, but if I had to I'd take C# if it works on the systems I need it to, otherwise Java.
JNI is an absolute pain in the fucking ass, but it does work... eventually.

I don't touch applel shite so Swift is about as useful a language to me as brainfuck.
>>
File: 1492127342874.png (28KB, 470x241px) Image search: [Google]
1492127342874.png
28KB, 470x241px
>>61581226
>but if I had to I'd take C#
if I had to I'd take Swift for a vendor lock in language
>>
>>61580316
No
>>
hiring programmer to develop some desktop apps
c #
simple work good pay
drop me an email or add me on skype
[email protected]
or skype me at selfie4cam
>>
>>61581256
>Starting internet arguments about what type of diarrhoea is the least intolerable
>"Your shit isn't the best shit, mine is" on a loop

You need a better hobby.
>>
C being dead is the biggest meme in the world. thankfully i never bought into it and devoted and am devoting time to learning it thoroughly, since every major position i look at requires extensive C knowledge
>>
File: bait-but-nevertheless-correct.png (17KB, 522x384px) Image search: [Google]
bait-but-nevertheless-correct.png
17KB, 522x384px
reminder
>>
>>61581362
>language is old and busted
>make a new language
>no one wants to switch
>instead the new language just allows a bridge
>Man how is old language still around

I fucking hate the software industry and C
>>
>>61580951
:^)
(define (square? x)
(define (square-iter candidate acc)
(if (= x (* candidate candidate))
#t
(if (memq candidate acc)
#f
(square-iter (quotient (+ candidate (quotient x candidate)) 2) (cons candidate acc)))))
(square-iter (quotient x 2) '()))

(define sumjmp '())
(define xjmp '())
(define x+yjmp '())

(let ((sum (call/cc (lambda (cont) (set! sumjmp cont) (cont 3)))))
(let ((x+y (call/cc (lambda (cont) (set! x+yjmp cont) (cont 2))))
(x (call/cc (lambda (cont) (set! xjmp cont) (cont 1)))))
(define (increment)
(cond ((and (= x+y (- sum 1)) (= x (- x+y 1))) (sumjmp (+ sum 1)))
((= x (- x+y 1)) (x+yjmp (+ x+y 1)))
(else (xjmp (+ x 1)))))
(if (not (square? x+y)) (increment)) ;x + y
(if (not (square? (- sum x))) (increment)) ;y + z
(if (not (square? (+ sum x (- x+y)))) (increment)) ;x + z
;in his problem z is the smallest and x the largest
;in this one x is the smallest and z the largest

(if (not (square? (- sum x+y x+y (- x)))) (increment)) ;z - y
(if (not (square? (- sum x+y x))) (increment)) ;z - x
(if (not (square? (- x+y x x))) (increment)) ;y - x
(printf "~A ~A ~A works~N" x (- x+y x) (- sum x+y))
))
>>
>>61581423

>old and busted
C is old, but not busted. It has all of the abstractions you could ever REALLY need. It's just that it doesn't hold your hand about anything. It expects that you know what you are doing.
>>
Fuck ring three man, I want ring zero. Ever since I was a system programmer at TicketMaster, fuck yeah man, i'm a king man, I fucking programmed in ring zero. Ring three is ghetto, f-fuck ring zero, that's for ghetto peasants. Peasants program in ring-fucking-three man. I fucking (short pause) Ring three is for peasants.
>>
>>61581457
Your opinion on languages is trash Ruby.
C requires twice the work and typing of a modern language together with the sheer volatility of C.
>>
The JVM is almost impossible to get good performance out of, your only option is primitive arrays. WHY
>>
File: book.gif (173KB, 400x486px) Image search: [Google]
book.gif
173KB, 400x486px
The only real way C might be considered "busted" is in how the pointer system didn't really grow well with future advances in CPU register widths.
Spending 8 bytes to store a pointer that might potentially point to a type smaller than 8 bytes (like a char) is incredibly wasteful.

Also NULL terminated char arrays, but C didn't invent those.
>>
New developers are not interested in C/C++ as much as they used to.
>>
>>61581414
python is both
>>
>>61581457
The problem is that any sufficiently complex C program will basically be reimplementing higher level language features in a shitty ad hoc manner. Every modern language will be BadLisp in a few decades, and no one wants to cut the middleman and actually use Lisp because it's the opposite of C: it has everything BUT simplicity and clarity.
>>
>>61581524
>Spending 8 bytes to store a pointer that might potentially point to a type smaller than 8 bytes (like a char) is incredibly wasteful.
dude what
>>
>>61581547
It has crap performance and crap development speed.
>>
>>61581549
>Every modern language will be BadLisp
Lisplets out
>>
>>61581524
lmao this feels like bait
>>
>>61581576
scheme > lisp
>>
>>61581586
PLEASE TELL ME WHY SCHEME ISNT LISP
No really whats the difference?
>>
>>61581423
C isn't old and busted, cuck
>>
>>61581557
>>61581577
In a 64-bit C implementation, all pointer types are 64 bits.
Even if your pointer points to a single character, the pointer itself takes up 8 bytes to hold the address value of the pointer.
>>
>>61581601
http://community.schemewiki.org/?scheme-vs-common-lisp
>>
>>61581576
Lisp is shit too, but it's shit for different reasons.

>>61581601
It is Lisp. It's weirdly common to imply "Lisp" means "Common Lisp".
>>
>>61581613
"rectangles > squares"

this is how retarded you are. delete your posts
>>
how can you just trust cmake to do the right thing?
>>
>>61581608
>house no. 4 is after house no. 23425226
>because it's smaller
>>
>>61581608
It doesn't matter what size type the pointer is pointing to. A pointer is an address. On a 64-bit architecture, addresses are 64 bits. You need the same number of bits to point at 0x0123456789ABCDEF whether the thing at that address is a char, a short, an int, a double, a struct, whatever.
>>
>>61581524
TempleOS uses 32-bit pointers in 64-bit code for all static data and code
>>
>>61580815
i tried using a std::vector<>::iterator and didnt work either
gooing to kill myself
>>
>>61581613
So Scheme is basically the Arch of Lisps?
>>
>>61581660
Does arch have call/cc?
>>
>>61581660
In a community sense, not really. Arch is supposed to be a quick-and-hacky approach to bottom up distros, Scheme became quick-and-hacky by incident because it's an academic tool, not a productivity tool. Common Lisp is the dialect that is meant to be used to make real world software.
>>
>>61581627
it just werksâ„¢
>>
>>61581650
Well if C somehow had support for relative addresses that would be nice.

I guess if you put a hard limit on the size of the stack you could make a distinct stack pointer data type, or if you put a hard limit on the total size of globals you could have a global pointer data type.
>>
>>61581658
Oh that's because iterators are secretly pointers. Welcome to C++! Where everything in C is evil, but everything in C++ is based on C things, but all the C++ things have most of the weaknesses of the C things, plus extra complicated weaknesses!
>>
>>61580887
>>61580979
>>61580815
to clarify I have a vector of structs, and I have a function that initializes these structs and adds them to the vector

currently it returns a pointer to vector.back();
which works until vector breaks the pointers by changing sizes ect

returning an iterator also doesn't really work

we have lots of memory to work with and aren't going to be creating more than a few dozens of these structs anyway; so I guess ill just use a predefined array and forget about using vectors

I've never done a project in cpp before
>>
>>61581650
that's literally just a few bytes of memory, though. you can't possibly be serious taking that as a critique of C. if you care about A FEW BYTES of memory that much you can use a 32 bit compiler
>>
made a thread
>>>/sci/9065965
>>
>>61581812
I'm not criticizing C, I'm just correcting misconceptions.
>>
Working on a text based protocol, sort of a revival of HTML4. purely informative websites with no style information and no client side scripting.

I am also thinking of adding live chat support maybe, think of a mix of IRSSI and lynx. I'll also add strong encryption.

This will be kind of like a mix of IRC and old BBS
>>
File: muh gaymen.png (256KB, 640x1136px) Image search: [Google]
muh gaymen.png
256KB, 640x1136px
Working on the GUI
>>
>>61581852
you may want to consider a different font
>>
>>61581414
lisp
>>
>>61581919
true,
some CL implementations meet C levels of speed, don't they?
>>
File: 1500351660853.jpg (48KB, 469x505px) Image search: [Google]
1500351660853.jpg
48KB, 469x505px
>they don't program using elixir
>>
>>61581801
Easiest way to do what you want to do is return a struct containing a pointer to the entire vector and the index of vector.back()
>>
>>61581941
>he thinks elixir is a good lang, not merely a not-bad lang
>>
>>61581941
>erlangs retarded son
>>
>>61581877
But that's the game's theme (shitty drawings)
>>
>>61581942
how about using lists
a pointer to a std::list wont be ruined by adding and removing elements right
>>
>>61582048
Yeah a list should work. I had my mind on vectors.
>>
>>61581764

>Well if C somehow had support for relative addresses that would be nice.
We have an operator for relative addresses: [ ]

>I guess if you put a hard limit on the size of the stack you could make a distinct stack pointer data type, or if you put a hard limit on the total size of globals you could have a global pointer data type.
Bad idea. Just... don't make any assumptions about the stack at all.
>>
>>61580557
that sounds like a job for channels. they're fast and you can set a buffer capacity after which they start to block on message insertions.

https://gobyexample.com/worker-pools
>>
>>61582155
>go
Stop.
>>
Bajrne Stroustroup is only 66 years old, he invented C++ in his 20's.

I googled him hoping that he'll die soon because he looks like shit but nooooooo.
>>
>>61582229
you're an asshole
he just got lucky with his university research project, he never thought C++ would be so accepted and he certainly didn't expect it to become the bloated mess it turned out to be.
>>
>>61582255
Wasn't C++ just experimenting with Simula classes on top of C for improving software development practices? It was originally called C with Classes.
>>
>>61582101
>We have an operator for relative addresses: [ ]
That's only for things of the same datatype.
>Bad idea. Just... don't make any assumptions about the stack at all.
The stack is already finite, you just don't know what it is. Maybe it's finite enough that stack pointers would be 32 bit? Can the stack be larger than 4 gigabytes?

>>61582155
I'm not porting my code to go.
>>
>>61582229
C++ was designed in 1985, so it would be more like 35yo.
>>
>>61582294
> Stroustrup began developing C++ in 1979 (then called "C with Classes")
>>
>>61582343
>not reading the whole thing
https://en.wikipedia.org/wiki/C%2B%2B#History
>In 1979, Bjarne Stroustrup, a Danish computer scientist, began work on "C with Classes", the predecessor to C++.
>In 1983, "C with Classes" was renamed to "C++"
>>
>>61579801
Are signed chars or bools atomic in C?
>>
>>61582229
and he's a managing director at morgan stanley and hence rich as fuck
>>
I wish I could do something useful. The code I write at my job is almost always completely useless. It's not even that I write bad code, it's just that the stuff I get assigned is basically just busy work because my team lead doesn't actually have enough real work to give out. It's incredibly frustrating to spend a few weeks on a giant change that is just an overengineered refactor that no one will ever care about and will probably just introduce more bugs.

I enjoy programming, but I really want to write code that someone will actually find useful too. What the hell should I do, /dpt/?
>>
>>61582494
Quit your job and become a neet.
>>
>>61582494
quit your job
>>
>>61582048
>>61582073
lists worked and fixed this freaking problem ive been working on all week
>>
>>61582289
find channel implementations for your language. Channels (buffered or unbuffered) are extremely useful for concurrency in any language, but theyre just the primitive-of-choice in Go
>>
>>61582494
>but I really want to write code that someone will actually find useful too
Contribute to FOSS projects.
>>
>>61582494
Do you work for a big company?
>>
>>61582503
>>61582536
That wouldn't solve my problems, I'd just also be broke too.

>>61582763
I think I like this idea. I wish there was something I could do about my day job too, but maybe working on open source projects will make it more bearable.

>>61582818
~300 total employees with a decent amount of devs.
>>
>>61582901
>That wouldn't solve my problems, I'd just also be broke too.
That's not true. Get on disability or become a single mother so the government can be your husband and provide for you.

Don't you want the government to be your loving husband?
>>
Doing K&R exercises
Got kind of demotivated when I got to these bit shifting exercises. It took me hours to do them but now I'm really glad I made the effort, it is a great feeling to be comfortable around a programming concept I used to find spooky magic shit
>>
>>61583091
You forgot braces on your second if. The last too statements are always running.
>>
https://arxiv.org/pdf/1607.03597.pdf
Could someone more used to reading papers correct me on this?
As I read this their small model only operates on 3x3x3 grid size but they've decided to compare it to much higher grid resolution.
But this doesn't make much sense because all because they've adapted the jacobi to "this work" at what's already a rather favorable situation given the other metrics they ignore in this performance test.
I don't see why they'd include the "small model" at all.

I'm just worried that this is NN propaganda. It's so common now.
>>
>>61583091
I'm surprised you don't get infinite recursion warnings here.
What compiler?
>>
>>61583109
wasn't that exactly but it helped me see a problem with it

>>61583202
g++
>>
>>61582494
>It's incredibly frustrating to spend a few weeks on a giant change that is just an overengineered refactor that no one will ever care about and will probably just introduce more bugs.
Sounds like you're expected to do more than you're capable of?
I wish I was in charge of rewriting large parts of our crappy code base.
>>
I was studying how different language implement OOP, and man, OOPs are just a huge clusterfuck. Why do we need OOP again? C and Go are the only two languages I have come across that are sane.
>>
>>61583245
>Why do we need OOP again?
We don't in the current way they're used.
I keep asking people what they need OOP for and you either get no real reason other than that that's how they learned to write things or they point to GUI. When you probe more into why they'd choose OOP for GUI they don't actually know/can't respond to basic critiques of OOP in GUI.

I'm not sure anyone actually knows. I don't know of any trustworthy programmers who do OOP.
>>
>>61583224
I guess I didn't word that quite right. The preexisting code was perfectly fine, so I wasn't really refactoring anything. Instead, I got to rip out a portion of our code and make it its own service.

If you didn't know, splitting out monoliths into microservices is super important for internal-only tools that get 10s of requests a day.
>>
I did it.
Had to change several things from what I posted last time.

int doCalc(long long b, int pos) {

current = numbs[pos];
for (int c = pos + 1; c <= pos + 12; c++){
current *= numbs[c];
}
if (current > 0)
std::cout << current << std::endl;
if (current > highest)
highest = current;
if (arrPos <= ((sizeof(numbs)/sizeof(numbs[0])) - 13))
arrPos++;
if (arrPos < ((sizeof(numbs)/sizeof(numbs[0])) - 12))
doCalc(highest, arrPos);
}
>>
>>61583425
a quick control f shows your previous program in neither this thread or the previous thread.
>>
>>61583452

Its this I deleted it a few seconds after posting it
>>61583091
>>
can someone explain call/cc for a brainlet?
>>
>>61579857
It's a lot harder and a lot uglier to implement a generic vector in C.
And the lack of type traits makes it not possible to make specialized optimizations as you can in C++.

Sorry, C++ is just superior.
>>
>>61579816
>that choker

I bet she'd be a good sex slave
>>
I thought I was good at Python though I've never written anything that large. So I started doing K&R and I fucking suck.
>>
>>61581100
> Not understanding borrow checker.
As much as hard the borrowk is, it usually starts nagging only once you start writing non-trivial shit.
>>
>>61583479
it's easy to simulate templates with #define macros
don't be dumb
>>
File: homer relaxing.png (338KB, 497x377px) Image search: [Google]
homer relaxing.png
338KB, 497x377px
Just finished fixing all bugs and quirks of a web application and just waiting for the client to respond to start production. Meanwhile the desktop application guys are freaking out because they still have bugs and they're close to deadline.
Life is good in javascript land
>>
>>61583504
Sure, the simplest templates yes.
It's a lot harder to simulate a template class/struct and all it's methods with macros.
You are being dumb.

And you simply can't do as much with them, without type traits.
>>
>>61583471
Yeah.

call/cc in it's most basic use is block of code you can return from
(call/cc (lambda (cont) (+ 2 (cont 3))))

Returns 3, not 5 because doing (cont 3) causes the process to abandon what it's doing, jump backwards to right before call/cc was called, and replace the call/cc with 3.

Now if you do something like
(define jmp '())
(begin (print (call/cc (cont) (set! jmp cont) (cont 'benis)))
(jmp 'ebin)
(print 'no))

The code will print benis of course. But what what happens after that is it gets suck in a loop of printing 'ebin over and over again, because we've set jmp to jump inside of the first print statement.

If you get really tricky with call/cc you can do some really strange things. Coroutines. Something called "amb" (look it up; pretty awesome though. My code >>61581440 here.
>>
>>61580496
>database
>using only the standard library

It already sucks. Good luck reliably writing data through the standard library's crap ass buffering.
>>
>>61579857
>C++ features are wasteful
you're an idiot
>>
>>61583545
If you actually need features like this, you need to rethink your solution on a fundamental level.
Nobody actually needs templates to accomplish type genericity in programming.
>>
>>61583546
Fuck in the second code example it should be
[code
(call/cc (lambda (cont) (set! jmp cont) (cont 'benis)))
[/code]
Basically call/cc is goto for brainchads. You can make code really complicated in a heartbeat.
>>
>>61583546
>>61583564
thanks, I think I understood what was going on until
(set! jmp cont)

and
(jmp 'ebin) 
>>
>>61581176
>>61581148
>>61581185

C# is one of the better languages out there. Of course a Haskell autist would bitch about it's imperfections, but to actually complain about lock-in is just... I have no words.
>>
>>61583589
(set! jmp cont) is storing the "continuation" away for later so we can jump to where it points to outside of the call/cc.

The technical way call/cc works is that call/cc stores a copy of the program's state in a continuation, and if you tuck that continuation in your pocket, with say (set! jmp cont), then you can halt the program and restart it at that continuation.
>>
>>61581764
>I guess if you put a hard limit on the size of the stack you could make a distinct stack pointer data type

That's how automatic variables work dumbass. They simply offset from the current stack frame.
>>
How hard is C#?
>>
>>61583559
Of course you don't.
I can play the same game as you. If you actually need the features of C, or even assembly, you need to rethink your solution on a fundamental level.
Nobody actually needs C or assembly to write programs, you should be able to do it using only a hex editor.

You are being fucking retarded.
Templates combined with C++'s other features are simply better than macros for accomplishing type genericity.
C++ allows you to be a lot more productive and do a lot more things with ease, with zero overhead.

I could do everything in C instead using inferior C only features and hacks, and I did used to because I was a C programmer and was good at it. But I realized that C++ simply allows me to be way more productive while going just as fast. And learning C++ has also made me an even better C programmer.

You enjoy making everything unnecessarily harder for yourself than they should be, or you're just too narrow minded to understand what better designed languages than C have to offer.
Get fucked, blub.
>>
>>61581495
the reason C is so widely required is partly because you need understanding to use it effectively. you don't need any significant understanding of the machine to program in python or ruby
>>
>>61583479
>It's a lot harder and a lot uglier to implement a generic vector in C.
That shit isn't even hard. I literally threw this together just now.
#include <stdalign.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct vec {
size_t cap;
size_t len;
size_t memb_size;
alignas(max_align_t) unsigned char data[];
};

struct vec *vec_new(size_t memb_size, size_t initial_cap)
{
struct vec *v = malloc(sizeof *v + memb_size * initial_cap);
if (!v)
return NULL;

v->cap = initial_cap;
v->len = 0;
v->memb_size = memb_size;

return v;
}

void *vec_alloc(struct vec **vec)
{
struct vec *v = *vec;

if (v->len == v->cap) {
size_t new_cap = v->cap * 2;

v = realloc(v, sizeof *v + v->memb_size * new_cap);
if (!v)
return NULL;

v->cap = new_cap;
*vec = v;
}

return &v->data[v->memb_size * v->len++];
}

bool vec_add(struct vec **vec, const void *elem)
{
void *ptr = vec_alloc(vec);
if (!ptr)
return false;

memcpy(ptr, elem, (*vec)->memb_size);
return true;
}

#define vec_for_each(vec, iter) \
for (iter = (void *)vec->data; \
(void *)iter < (void *)(vec->data + sizeof(*iter) * vec->len); \
++iter)

int main()
{
struct vec *v = vec_new(sizeof(int), 10);
if (!v)
return 1;

vec_add(&v, &(int){0});
vec_add(&v, &(int){4});
vec_add(&v, &(int){6});
vec_add(&v, &(int){2});
vec_add(&v, &(int){7});

int *ptr;
vec_for_each(v, ptr) {
printf("%d\n", *ptr);
}

free(v);
}

There are extra functions/macros you can add to make it nicer to use, but you get the point.
>>
>>61583669
>Nobody actually needs C or assembly to write programs

Call me back when C++ has a sane binary interface that doesn't exclude every other programming language in existence.
>>
>>61583669
>Muh zero overhead fairies
Stopped reading right there.
>>
>>61583673
>void*
This isn't even comparable. It's not even generic at all, and it's unsafe as fuck. You specify the size separately.

Sorry mate, this is fucking trash, 0/10. Garbage code.
You failed.

C can do almost type safe and generic vector with enough dirty and ugly hacks, but you've done it completely wrong.
>>
>>61583664
It's Java but less shit.
>>
>>61583744
>This isn't even comparable. It's not even generic at all, and it's unsafe as fuck. You specify the size separately.
You're a fuckin' baby if you can't handle sizeof(type)
>>
>>61583611
C# is slower than Java
>>
>>61583744
>It's not even generic at all
Sure it is. It is capable of holding any type without modifications.
>and it's unsafe as fuck
Don't use it incorrectly then. It's UB to add any type that is of a different type to the sizeof in vec_new.
>You specify the size separately
So? Are you so retarded that you can't even handle that?
>C can do almost type safe and generic vector with enough dirty and ugly hacks, but you've done it completely wrong.
My goal was not type safety, it was efficiency. I'm was trying to do this in as few allocations as possible.
None of of that "one allocation per element" shit.
>>
>>61583673
Not to mention that it's inefficient as fuck.
Why isn't memb_size known at compile time? Why is memb_size taking up space in the struct? You have to actually fetch it from memory every time, I thought Cfags where all about efficiency!

Why are you aligning by max_align_t? Can't you align by the actual type of object your holding? C++ templates has no problem doing this.
Why do you even _need_ to specify the size separately?
Why do you need a macro to iterate through it?

It's shit. This is no where near the level of std::vector.
>>
>>61583784
C# and Java are languages. They don't have speed. The .NET CLR and the JVM have speed. They're both state-of-the-art virtual machines.

Stop talking about things you know nothing about.
>>
>>61583803
>My goal was not type safety, it was efficiency
Yet std::vector manages to be both type safe and more efficient. All with ease, too.
How can C even compete?
>>
>>61583842
Show me an implementation of C# that's faster than that of Java
>>
>>61583813
>Why isn't memb_size known at compile time?
That would require macro shenanigans and passing the type around everywhere, which I couldn't be bothered doing.
>Why is memb_size taking up space in the struct?
Because I need to know it. I could use bitfields of some shit it "compress" the 3 'size_t's into 2, but it's not really worth the effort.
>You have to actually fetch it from memory every time
I would expect it to already be in the cache. The locality of my struct is actually very good, but I waste 8 bytes on this.
>I thought Cfags where all about efficiency
This code is actually pretty efficient. It requires fewer allocations than std::vector actually.
>Why are you aligning by max_align_t?
This is required for correctness.
>Can't you align by the actual type of object your holding?
No.
>Why do you need a macro to iterate through it?
Convenience.
>>
>>61583866
Show me one (1) post you made that wasn't shitposting.
>>
>>61583912
Is that supposed to be a deflection?
>>
>>61583887
>requires fewer allocations than std::vector
you don't actually know how to use std::vector, or how it's implemented, do you?
look, it's okay for you to admit you're wrong here. each programming language has its strengths, and this is one of the strengths c++ has over c.

and for all of you "hurr just use macros" idiots:
the preprocessor is a hack and terrible when it comes to debugging. you can make your life better (and no slower) with templates, consts, and automatically-inlined functions.
>>
>>61583858
>how can C compete?
It doesn't in this aspect but you're comparing it to something awful.
>>
>>61583887
>which I couldn't be bothered doing.
Why? I thought you said you could do it just as easily in C as in C++. I guess not.

>Because I need to know it
Only at compile time.

>I would expect it to already be in the cache
Shouldn't be anywhere at runtime at all. Should be just a compile time constant.

>The locality of my struct is actually very good
Not as good as std::vector, though.

>It requires fewer allocations than std::vector actually.
It doesn't, it does about the same amount of allocations. Unless you're referring to the resize factor you're using.

>This is required for correctness.
No it isn't. You only need to align by the type of the object you're storing.

>No.
Why? It's trivial to do in C++.

>>61583957
t. blub
>>
>>61583803
>None of of that "one allocation per element" shit.
C++ doesn't do this. C++ uses a resize factor like you're using, except it's better chosen. Most implementations use some floating point constant between 1 and 2, I think.
>>
File: 1480078544559.png (59KB, 658x662px) Image search: [Google]
1480078544559.png
59KB, 658x662px
>trying to do an exercise by turning unix time into H:M:S
>keep wondering why hour always said 4 instead of 12
>realized that I am in EST
>>
>>61584011
dumb frogposter
never post again
>>
>all this arguing about C++
Christ. "who's shit smells the worst?"

Meanwhile I made tiny progress (card rotation)
>>
>>61584002
It does for linked lists. A c style linked list blows c++ linked lists the fuck out.
>>
>>61584034
arbitrary or just 90 degree?
>>
>>61584035
No it doesn't. They both suck equally.
How is a C style linked list more efficient than a C++ style linked list? You can't even inline the element in the node struct with ease, and most C programmers don't do it.
>>
>>61584035
i don't think you understand what c++ is. it's literally built on top of c. if there really was a better linked list implementation (by the way, the fact you're even bringing up such a trash data structure is telling) then of course c++ would leverage whatever c tools it has to do the same job.
you are a fucking idiot in c++ AND c.
>>
>>61584034
>(card rotation)

What's this? You're just rotating squares?
>>
>>61584052
>You can't even inline the element in the node struct with ease, and most C programmers don't do it.
GCC comes with a macro system for doing this. It's not a big deal.

And yes that's the speedup. It's sad when fucking lisp can do linked lists better than "as fast as c but better" c++ due to dumb oop reasons.

If C++ had a less retarded oop design it could inline no problem.
>>
>>61584074
it's gonna be a scriptable card game sim eventually
>>
>>61583974
>I thought you said you could do it just as easily in C as in C++.
I never said that. I just said that implementing this type of thing isn't hard.
>Only at compile time.
>Shouldn't be anywhere at runtime at all. Should be just a compile time constant.
Meh.
>Not as good as std::vector, though.
>It doesn't, it does about the same amount of allocations. Unless you're referring to the resize factor you're using.
I'm pretty sure std::vector does not store its data with the "struct" itself. Mine does, so when you access the pointer, you're pulling in the first few elements into the cache as well.
1 allocation vs 2. Also, looking that the libstdc++ implementation of std::vector (as disgusting it is to read), it has more member in its struct than I do.
>No it isn't. You only need to align by the type of the object you're storing.
Yes, and I could potentially be storing an object with the same alignment as max_align_t.
>Why? It's trivial to do in C++.
You clearly don't understand the code. I'm not shitting out a declaration of the struct and all of its functions. There is no type information (aside from the size) associated with the struct. I am dealing with raw memory.
>>
>>61584040
Drawn arbitrary for dem smooth animations, but you can only externally set them in 90 degree increments.

>>61584058
LOL C and C++ have different semantics and most people despise the STL implementations.

>>61584074
It's gonna be a scriptable arbitrary-TCG-game framework but I'm pretty busy so I've only implemented rotating rectangles in the last few days
>>
>>61584058
>by the way, the fact you're even bringing up such a trash data structure is telling
Start crying because new (and new[]; why does this exist except to cause bugs? there is no such thing as a malloc[]) uses malloc, and fast malloc implementations use linked lists for keeping track of free regions.
>>
>>61584083
C++ inlines it no problem, though. I have no idea what you're going on about.
The C++ list implementation is part of the STL, and the STL is not object oriented. It can all be completely inlined. I can tell you've never used or learnt C++.
>>
>>61584106
new[] is a consquence of using array syntax for allocation, not some alien syntax decided at random
if anything complain about delete[]
>>
>>61584102
>arbitrary-TCG-game framework

pls keep posting so I'll know when it's time to d-d-d-duel
>>
>>61584106
>new uses malloc
It actually doesn't. It uses std::allocator which contains it's own implementation.
C++ does not use malloc, at all.
>>
>>61584106
>arguing with someone who thinks linked lists are bad

You should know better than this
>>
>>61584123
you've activated my trap card
>>
>>61584102
again, you have literally no idea what you're talking about and i'm beginning to think you're trolling. most people love the standard library (it isn't "the STL" anymore) and the semantic difference is so small it may as well not be there (excluding things c++ has in addition to c). how do you post while being such an idiot?

>>61584106
others have already addressed this retardation
>>
>>61584143
>he hasn't run a benchmark in his life and doesn't understand modern hardware
for starters: https://people.freebsd.org/~lstewart/articles/cpumemory.pdf
>>
File: 1500644974896.jpg (311KB, 864x1377px) Image search: [Google]
1500644974896.jpg
311KB, 864x1377px
>>61581568

performance isn't great, but.

great dev speed,
beautiful codebase,
code is easy to understand,
good support
pip life
easy to write in functional style
list comprehensions
lambdas
classes if your are faggot
a fine collections module
beautiful
>>
>>61584157
show us that code you're hiding so we can critique it :^) if that's c++: are you using fold expressions yet?
>>
>>61584176
Okay hotshot, how do YOU keep track of memory segments returned by the kernel?
>>
>>61584197
https://gitla.in/iitalics/opentcg/tree/model
Good luck, my code is literally perfect
>>
can I create games while learning C++ or do I have to wait until a certain point where a "game essential" instruction is presented?
>>
>>61584228
If you know other languages, then you can probably go straight to SFML and make simple games easily. If you have zero experience, I would recommend an easier language like Lua that allows you to immediately make games (Love2D)
>>
>>61584209
trick question: i don't
i allocate from pools
>>
>>61584095
>it has more member in its struct than I do.
You sure you're not being confused by static const members?
$ cat main.cxx 
#include <iostream>
#include <vector>

int main() {
std::cout << sizeof(std::vector<int>) << '\n';
}
$ g++ main.cxx && ./a.out
24

24 bytes is enough to store a 3 8 byte fields: len, cap, and a pointer to the data.
So no, it's not bigger.

>Yes, and I could potentially be storing an object with the same alignment as max_align_t.
Which most of the time you aren't, so you're actually wasting a lot of memory by doing that.
You should be able to trivially align by the type of the object, like alignas(T) where T is the template parameter.

>You clearly don't understand the code. I'm not shitting out a declaration of the struct and all of its functions. There is no type information (aside from the size) associated with the struct. I am dealing with raw memory.
And this is why it's not anywhere near comparable to std::vector and C++ templates.
>>
>>61584246
thank you, anon.Sadly, I'm part of the second group so I guess I will go along with the lessons and pick a good lua book
>>
>>61584130
https://stackoverflow.com/questions/34813448/does-operator-newsize-t-use-malloc#34813830
:^)

>>61584109
>the STL is not object oriented
Just lie to us anon! Lie to us more! Please tell me how string isn't an object oriented version of char*. And how all that template shit isn't OOP in the slightest. Or how there aren't member functions in the stl. Please tell me how iterators aren't a retarded abstraction over pointers. How smart pointers aren't objects.

>>61584176
Please amaze the world with your implementation of malloc that runs faster and doesn't use linked lists. You could make your own proprietary version and sell it even.

>>61584209
He appends each new fragment to the end and uses qsort. Bubblesort would be better due to its superior best case (even though that plan is retarded nonetheless), but he uses qsort out of dogma.
>>
>>61584264
>i allocate from pools

So you essentially keep a linked list of huge non-contiguous memory blocks?
>>
Just opened up K&R and I must admit that C is a very interesting language. I've been studying C++ and python as a hobby but C just has a way about itself. I can't explain it.

Just did exercise 1.2-1.3 and just got my brainlet blown, I think I love C now. I thought you guys were just memeing C, now I rethinking that assumption.

I like how the book makes it seem like the authors are right there next to you explaining everything to you. Anyone who says learning C is hard needs to an hero, immediately.

Those are my 0.02 cents. Learn C and read K&R, seriously!
>>
Y'all need to quit dealing in absolutes.

>>61584284
No problem. Love2d will let you learn the gist of making games (rendering, update loops, stuff like that), without having to trudge through the unholy mess that is C++. So you'll be able to reapply a lot of this stuff later on
>>
>>61584222
took a peek at your main, let's start there :^)
1. control the framerate of your UI
2. create an engine/application object which manages the UI and other such application things
3. create the application in main (and not in its own scoped block) and return engine.run();
>>
>>61584307
>using reddit spaces
>baiting this badly
Honestly, if you like C you should look at Go, it is basically a more modern C which is garbage collected, better concurrency support, package management etc.
>>
>>61584344
>which is garbage collected
And that makes it utterly inappropriate to even be compared to C.
>>
>>61584344
>reddit spacing
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALf'dskdkfdsfdsfdsjg'lkgdf'lkgdfgk'fdkg'kfd'gk'fdkg


[[[[[[[[[
>>
>>61584284
Lua is a neat language, but be warned: Lua is a very unconventional language. As a result, some of the things you learn in Lua will not translate well to other languages.
>>
>>61584307
>0.02 cents
>>
>>61584302
did you even read the article? if malloc implements linked lists, that's fine, perhaps it's the best data structure for the job. doesn't change the fact that linked lists are trash data structures for 90% of the things they're used for you foaming moron.

>>61584306
if i have a large block of contiguous memory, that's contiguous memory. that's what a pool generally is.
>>
>>61584344
GO, really? You are offering literally a language from a botnet company. And you are complaining about spacing???? Please abort yourself now.
>>
>>61584316
Thanks anon but right now my philosophy is do something that will get it working quickly yet modular enough so that I can throw stuff out when it needs to expand.
I've been thinking about my views and controllers and I think I'm managing stuff wrong in them, but not sure when I'll get around to refactoring them esp. considering they just werk atm
>>
>>61581622
>Lisp is shit too, but it's shit for different reasons.
Quote needed.
>>
>>61584390
if you are just playing around, that's fine, have fun!
>>
>>61584222
I like your iter code. I can tell you've used Rust.
>>
>>61584387
Go wasn't made by Google. It was made by Rob Pike, Ken Thompson and Robert Greisemer.
>>
>>61584368
it seems pretty well documented, at least
>>
>>61584377
>that's what a pool generally is.

You said "pools", plural.

So, what do you do when you need memory but the "pool" (it's just one big array really) is already at full capacity?
>>
>>61584451
i'm not sure what you're getting at.
the pool should be big enough for my use from the start of the program. if i am dynamically allocating memory, i can always allocate bigger and bigger contiguous blocks on the heap as i need them (so long as hardware permits). memory allocation is slow though, so it's probably better if i use a pool(s) for certain situations involving lots of allocation and freeing.
>>
File: Come_on_Now.jpg (28KB, 1096x53px) Image search: [Google]
Come_on_Now.jpg
28KB, 1096x53px
>>61584445
You can't be that stupid...
>>
File: lying little shit.jpg (58KB, 500x502px) Image search: [Google]
lying little shit.jpg
58KB, 500x502px
>>61584488
>i can always allocate bigger and bigger contiguous blocks on the heap as i need them

>guys I keep a list of pointers to a bunch of arrays
>its totally not a linked list I swear

Do you believe your own bullshit

>so it's probably better if i use a pool(s) for certain situations involving lots of allocation and freeing.

That's exactly what malloc does
>>
>>61584519
wait, you've never heard of software that manages its own pools of memory before? and is your reading comprehension really so poor? how long have you been programming? a week? you are the biggest fucking idiot i've ever seen on /g/ and there are people here who think Rust is the second coming of Jesus Christ
>>
>>61584503
Okay, compare these languages websites.
https://www.oracle.com/java/index.html
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/
https://golang.org/
Go's website does not say anything about Google at all. Lastly, just because they worked on it while they were working at Google, doesn't mean Google developed it. Even though Google has developers who work on Go, the Go community exists outside of Google. That's like saying Linux is from Microsoft because they contributed a bit.
>>
>>61584552
>you've never heard of software that manages its own pools of memory before?

Oh, those who keep a list of pointers to arrays? The ones who grab chunks of memory from the arrays until they're fully used? And then allocate new arrays to append to the LINKED LIST?
>>
>>61584222
>static std::unique_ptr...
that almost certainly is incorrect
>that iter header
why are you creating an iterator struct when c++ already has an iterator object? and i'm pretty sure the standard library has methods you can use instead of fully implementing your own for zip and enumerate
>forward declaring sf classes
maybe this ties into the next thing but
>using #pragma
may as well label everything NONPORTABLE
>>
>>61584640
>may as well label everything NONPORTABLE
It works on GCC and Clang which makes it practically 100% portable.
Other compilers do not matter, and they probably support pragma anyway.
>>
>>61584618
reading comprehension you mouth-breathing acne-ridden bottom-feeder:
>if malloc implements linked lists, that's fine, perhaps it's the best data structure for the job
also, guess what: malloc is implementation defined - it might not necessarily be using linked lists
also, i don't use linked lists for managing allocated memory in my pools.
you clearly have no idea what you're talking about. i have nothing to gain from talking to you, and you're to ignorant to gain anything from talking to me. maybe another anon will entertain you and pick this up, but i'm dropping it
>>
>>61584583
Yep, you're fucking retarded
>>
>>61584583
>>>61584503
>Okay, compare these languages websites.
>https://www.oracle.com/java/index.html
>https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/
>https://golang.org/
>Go's website does not say anything about Google at all. Lastly, just because they worked on it while they were working at Google, doesn't mean Google developed it. Even though Google has developers who work on Go, the Go community exists outside of Google. That's like saying Linux is from Microsoft because they contributed a bit.
>Contributed to it

So that's where systemd came from
>>
>>61581077
That's literally wrong since 2 years
>>
>>61584764
Systemd is from red hat.
>>
>>61584782
And just who is on the board at red hat?

> Spotted the CIA nigger
>>
https://aturon.github.io/blog/2017/07/26/revisiting-rusts-modules/
Thoughts?
>>
>>61579857
C is excellent for embedded but in a world where you are trying to build a piece of software with multiple people, things like naked pointers are just all around bad.
>>
>>61584818
>naked pointers

Anon, we call those pointers.
Are you a numale?
>>
So I'm looking to avoid semaphores and mutexes and shit due to speed reasons. Online reading suggests that bools are atomic which means that I should be able to do:
void give(int i, foo * indata) {
while(arr[i]);
arr[i].flag = (memcpy(arr[i],indata,sizeof(foo)), true);
}

And
void recieve(int i, foo * outdata) {
while(!arr[i]);
arr[i].flag = (memcpy(outdata, arr[i],sizeof(struct foo)), false);
}

My readings suggest that the , operator is a sequence point so the ordering is not compiler dependent, bools are atomic, and marking that bool as volatile will prevent gcc from optimizing the busyloop.

Will this plan work? Or do I need to go to assembly?
>>
I have 3 tests waiting for me and I want to code.
I am going for a run, come back and work 2hours on each subject and then spend 2 hours on coding.
The breaks in-between should be devoted to something like relaxation, going to the toilet, kill time with my phone and 4chins.
25minutes work/5 minute break per set and after reaching the 4th set(2hours) I take a 15 minute break.
Any other tips to get myself back on track?
Any hacks for productivity I should know about?
Assume that I know just that and nothing more.
Maybe I can learn another thing or two here.
>>
>>61584850
Oops. The busyloops should be
while(arr[i].flag);
while(!arr[i].flag);
>>
>>61584824
Are you senile?
>>
>>61581362
>>61581423

C is the systems language for Unix. The canonical interface for all Unix system calls is C. Ergo, you have to understand C if you want to develop on Unix.

C can only be replaced when Unix is replaced.
>>
>>61584855
schedules are gay and being productive is for losers
>>
>>61584867
>like, oh my GOD did you see that guy???
>he just dereferenced a RAW memory address!!
>that's so unsafe!!
>what if he doesn't zero it out it could point ANYWHERE??! :OOOO

ohhhh you poor poor baby
>>
>>61584881
Are you literally being proud of dereferencing a pointer?
>>
>>61584892
You're the one making a big deal about it.
>>
>>61584899
You are the one who posted this >>61584824
>>
>>61584902
you reply awfully fast
are you angry?

you posted this btw >>61584818
>>
>>61584909
>you reply awfully fast
Come on, grandpa. Keep up --you are too slow
>>
Grandpa? Did you fall asleep again?
God damn it!
>>
>>61584909
Guy who actually posted that here. The point was that if we never use naked pointers we run into much fewer issues with who owns what object and we won't have memory leaks because we never have to manually destruct things.
>>
>>61585025
>i don't want to clean up my own mess
are you a child?
>>
>>61585025
>never have to manually destruct things
Instead you get to decide whether a shared_ptr will cause a circular dependency and thus a memory leak or if you need a weak_ptr, but maybe weak_ptrs could cause segfaults. Exciting!
>>
File: Desktop.png (82KB, 1920x1080px) Image search: [Google]
Desktop.png
82KB, 1920x1080px
>>61579801
How do I get vim/syntastic to see macros defined by CMake?
Getting real damn annoying trying to integrate my syntax checkers with CMake magic. Autoconf could at least output a config.h containing the macro defs.
Pic related pls respond.
>>
File: wow cool.png (2KB, 98x576px) Image search: [Google]
wow cool.png
2KB, 98x576px
It's 2:20 am, I have to be up in a few hours for work. I wanted to see if I could figure out how pathfinding works, seems a bit finicky and I'll need to do some tests tomorrow whenever I get back home. If you guys saw my code you'd probably kick me out forever or laugh at me or tell me to kill myself. it's really bad, but i'm happy that I took an idea I had and made it a reality, I didn't google or read anything at all, just did it.

My approach was at each turn/tick/movement, to calculate the distance between every adjacent square and the destination/goal, then move the '@' there, repeating until the destination is reached. I'm not sure if this is the right way to go about pathfinding or not, but it was the best I could come up with at the moment. I plan to try and add walls tomorrow to make things more interesting. Maybe later I can make mazes and a maze solving program. Thanks for reading my blog post and gnight.
>>
>>61583180

I don't either. This paper is pretty shit, since they used like three metrics of measurements overall to say their model is better. In what world are tests with the same plume with and without geometry and the time taken enough to qualify that?

Also, I'm very skeptical about using machine learning for making simulations Why aren't fast approximations good enough?
>>
idea guy here

crypto coin that takes advantage of hardware quirks such that it can only be efficiently mined on authentic nintendo game boys
>>
>>61585069
Use A* algorithm.
>>
>>61585128
Even better, use somebody else's free and highly optimized and implementation of A* instead of poorly implementing it on your own
>>
>>61585153
But where's the fun in that?
>>
>>61585153
>>61584818
Do you have an original thought in your head?
Or do you only regurgitate things other people have told you?
>>
File: nani.gif (438KB, 300x300px) Image search: [Google]
nani.gif
438KB, 300x300px
>>61585123
>>61585123
not possible?
gameboys use processor architectures which you can still buy today/can be very easily and cheaply emulated at many times the speed

inb4
>falling for this b8
>>
>>61585128
Sounds cool, anon.
>>61585153
What would that accomplish? That's like buying a puzzle but then just having someone else put all the pieces together for you. Why even bother? I didn't want to accomplish anything with this little exercise, it was just something fun to try to figure out, I like seeing how far I can get using just my brain, and then afterwards I read the proper way to do it. Is very enjoyable
>>
>>61585205
Don't try to reason with him.
He believes that mantra about never rolling your own libraries for any reason.
He's basically a codemonkey.
>>
>>61585205
Use Djikstra's Algorithm.
>>
>>61585168
Mathematicians write algorithms. Programmers stitch code from a thousand different repositories together into some kind of Frankenstein abomination. Good programmers are like normal programmers except their abominations actually run.

>>61585180
Go ahead, ignore libraries and frameworks representing thousands of manhours of existing work so you can start from scratch to create probably the worst implementation imaginable.
>>
>>61585225
Let me ask you again

Do you have an original thought in that head of yours or do you exclusively regurgitate cargo cult garbage you read in programmer blogs because you're too stupid to form your own opinions on programming methodology?

I bet you think gotos are literally the devil too right?
>>
>>61585205
You need to get your priorities straight. Are you writing a pathfinding algorithm, or are you writing a program that happens to require pathfinding?

Those are two very different things that very quickly tell you where you should be investing your time.

>>61585220
>codemonkey

I don't think that word means what you think it means.
>>
>>61585237
Jesus christ, you're either a 1st year undergrad or a "self-taught programmer" still in the middle of reading his first programming book.
>>
>>61585253
>he went to school to learn programming
>literally the one white collar career you can realistically learn yourself

lmao
>>
>>61584850
Nobody? Wasn't this thread having a C/C++ shitflinging contest earlier?

Where did all those C/C++ experts go to? The more I read the manual the more I think this code well defined and thread safe. Please tell me how I'm wrong.
>>
>>61584850
>>61585282
Don't rely on that shit. Use atomic_bool.
>>
>>61585282
>>61585303
this
Where did you get the idea that bool's are atomic from?
How are they special in any way? iirc it's just typedef int
>>
>>61585322
>>61585303
I got the idea from misunderstandings. Switched my bool volatile to bool _Atomic volatile. And now I know about c11 _Atomic.

Part of the problems are every time I try to search for C shit in google I get C++ shit.

Also on my system bool has a sizeof 1.
>>
>>61585068
pls respond.
>>
How are atomic types enforced by the CPU?
>>
>>61579816
gay, except for the graphics stuff, but that's not even game programming. that's graphics programming
>>
NEW THREAD!!

>>61585395
>>61585395
>>
>>61585394
literally through hardware instructions
https://en.wikipedia.org/wiki/Compare-and-swap#Implementations
>>
>>61585394
It's all handled by special CPU instructions that won't get interrupted.
>>
>>61581440
>Lisp
But why?
>>
>>61579816
pay is shit for all the stuff you must do, you have to be a jack of all trades and everyone expects you to do everything in little time
fuck that shit
fuck bioware
>>
>>61584678
>>61584640
even the intel compiler supports pragma
>>
>>61584880
Fuck you. It works.
>>
How do you start reading the source code of a big project?
Where do you start and where you go next?
I feel fucking retarded not being able to understand a big project.
>>
>>61585689
go into the docs if they have them
if they don't, plop a breakpoint on main and step through the program and follow it as it runs
>>
>>61585689
I try to find the main() function and follow the call chain from there.
It's certainly not easy to try and understand a large pre-existing project though.
>>
File: 1499205812770.png (114KB, 500x700px) Image search: [Google]
1499205812770.png
114KB, 500x700px
>>61581414
>fast development
>literally any functional language other than maybe scala

lmao no sunshine
Thread posts: 322
Thread images: 30


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

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


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