[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

If you can see this message, the SSL certificate expiration has been fixed.
Become a Patron!

/g/ - Technology

View post   

[ Toggle deleted replies ]
File: 229 KB, 960x935, 42538000.png [View same] [iqdb] [saucenao] [google] [report]
67903736 No.67903736 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/?

Previous thread: >>67898036

>> No.67903754


There's no good material on learning hygenic macros. SICP doesn't even mention it.

>> No.67903773

trying to make a botnet with erlang

>> No.67903783

Why is libm separate from libc for GCC?
The lack of consistency between compilers in C is annoying me.

>> No.67903786

there's no such thing as a hygenic macro

>> No.67903805

Way too early.

>> No.67903818

nth for elegant C++
#include <stddef.h> //size_t
#include <cstring> //memcpy()

#define GROWTH_FACTOR 1.6

template<typename T>
class a_stack
T pop(void);
T peek(void);
void push(T);
size_t size();
bool empty();
size_t a_cap;
size_t a_size;
T* a_ar;

void resize_if_needed();

template<typename T>

template<typename T>
a_stack<T>::a_stack(size_t start_cap)
a_size = 0;
a_cap = start_cap;
a_ar = new T[a_cap];

template<typename T>
delete[] a_ar;

template<typename T>
T a_stack<T>::pop(void)
return a_ar[--a_size];

template<typename T>
T a_stack<T>::peek(void)
return a_ar[a_size-1];

template<typename T>
void a_stack<T>::push(T item)
a_ar[a_size++] = item;

template<typename T>
size_t a_stack<T>::size()
return a_size;

template<typename T>
bool a_stack<T>::empty()
return a_size == 0;

template<typename T>
void a_stack<T>::resize_if_needed()
if(a_size != a_cap) return;

T* a_old = a_ar;
a_ar = new T[(size_t)(a_cap * GROWTH_FACTOR)];
memcpy( a_ar, a_old, a_cap * sizeof(T) );
a_cap = (size_t)(a_cap * GROWTH_FACTOR);
delete[] a_old;

>> No.67903826
File: 82 KB, 680x680, madoka.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.67903835


Are you retarded

>> No.67903842

all macros are dirty. you might aswell be infecting your codebase with HIV

>> No.67903850

Why did he get fired?

>> No.67903871

yeah i don't get it

>> No.67903874


>he LITERALLY thinks I'm working on something important and not dicking around in my freetime

You can't see it but I'm laughing at your life

>> No.67903889

python is driving me to instanity i just wanted something like a goto function, i've tried continue and it all resolves into an empty screen, why is python such a semen slurping language?, please tell me they are not all like this

import random
def funk():
qs=input('want to throw again(s/n)?')
if qs == s:

>> No.67903898

its called a loop

>> No.67903904

3 variables is more readable probably

>> No.67903923

void main(string[] args) {
import gtk.Main : Main;

import gtk.MainWindow : MainWindow;

auto window = new MainWindow("Title");
window.setDefaultSize(200, 200);
import gtk.Button : Button;

auto button = new Button("Click here");
button.addOnClicked(delegate void(Button _) {
import std.stdio : writefln;

static ulong count = 1;
writefln("Button was clicked %s time%s.", count, count == 1 ? "" : "s");

>> No.67903934

that solution will cause errors due to overflow

>> No.67903958

If a overflow occur in the sum, two underflows will occur in the subtraction and the values will be correct at the end.

>> No.67903962

On Lisp Paul Graham

>> No.67903971

Why are Java's lambda expressions so uncomfy

>> No.67903977

Why is Java so uncomfy?

>> No.67903997

Use Java 8.

>> No.67904006


I only know scheme. Is this a problem or are they similar enough

>> No.67904027

i like them

>> No.67904065

Sir, plaese do the needful and removing this post. Java is very elegant and powerful langage.

>> No.67904075

I've heard of some old graphics systems rendering with quads instead of tris, having tris be quads with two vertices in the same place.
How did they figure out which pixels the quads covered, without using tris?

>> No.67904078





>> No.67904087

the same way they did for triangles?

>> No.67904093

would you prefer c++ lambdas?

>> No.67904095

Do I need to be an expert in scheme to read SICP?

This may seem like a dumb question, but do I need a solid grasp of scheme to read SICP? I have only programmed basic stuff in it but I understand the syntax (who can't) and why it was chosen for the book. I'd rather read the book properly and focus on the theory rather than try and digest the theory as well as a brand new language as well.

>> No.67904110

The way it's done for triangles is to divide the triangles into right angled tirangles.
So, doing the same for quads would mean dividing them into right angled triangles, and the rendering technique I'm talking about definitely didn't do that.

>> No.67904118

>The way it's done for triangles is to divide the triangles into right angled tirangles.
huh? you dont divide triangles into anything, you just take the triangle and run it through a rasterization function, I imagine that function would look quite similiar for a quad

>> No.67904119

SICP introduce scheme lang in firsts chapter since basic aritmetic,functions,recursion as iteration.

>> No.67904128

Common Lisp and scheme are quite different, and only have a superficial similarity in syntax.

>> No.67904143

>he doesn't like

>> No.67904150

I just tried to read SICP and chapter 1 it's talking about sourcerers and computer spirits
no wonder you retards love this book

>> No.67904152

its a beginner book

>> No.67904169
File: 37 KB, 586x578, 1527686937245.png [View same] [iqdb] [saucenao] [google] [report]

>gnu m68k assembly syntax mostly copies the MIT syntax used by Sun
>uses | for inline comments
>no way to bitwise or operands because gas only recognizes | for that operation which is always parsed as a comment under m68k rules
>can use an assembler option to disable bitwise or comments, but then it breaks all source files that use that syntax and forces you to use c-style comments /* */ for everything which is a lot more keystrokes and wasted space

>> No.67904205

spoiled by better languages
import java.util.List;
import java.util.ArrayList;
import java.util.function.Consumer;
void hello() {
List<String> strings = new ArrayList<String>(2);

Consumer<Object> greeter = s -> {
if(s.toString().equals("moot")) {
s = "fag";
System.out.println("Hello " + s + "!");

There's really nothing wrong with it, but I want to puke

>not practicing cyber shamanism

>> No.67904220



>> No.67904224

Good to know. As you can tell I haven't even opened it up yet.

>> No.67904255

are u retart
List<String> strings = new ArrayList<>(2);

.map(str -> str.equals("moot") ? "fag" : str)
.forEach(str -> System.out.println("Hello " + str + "!"));

>> No.67904258

> List<String> strings = new ArrayList<String>(2);

>> No.67904273

>are u retart
Yes. My professor is a graybeard and all my books are Java 6.

>> No.67904301

>What am I working on
Coping with the idiosyncrasies of gtkd:

Looks like my tool came into a real use

>> No.67904309

SICP is a meme that gained a cult following on 4chan's dead prog board. It was never good as an introduction course book.

>> No.67904315

SICP was meme book before 4chan exist.

>> No.67904337


I liked SICP even if I couldn't really get some of the more mathematical parts.

>> No.67904352

Every single thread there's an agrument about java. Pls just let java die.

>> No.67904381

worthless class

>> No.67904387

>no anime picture
kuso tsureddo desu

>> No.67904392

Is there any tools for developing GUI apps that aren't either slow as fuck, Qt, or JavaFX?

>> No.67904422

Electron :^)

>> No.67904444

If you use auto type inference in group projects you deserve to suffer the most horrible fate possible.

>> No.67904452

I only do group projects in dynamic languages and give every variable a one letter name

>> No.67904485

the quadquad has spoken!

In ruby this is just
["moot","hiro"].map { |s| s == "moot" ? "fag" : s }.each { |s| puts "herro #{s}~" }

>> No.67904497

Am I a massive brainlet or are linked links really complicated? I'm suppose to head in an assignment tomorrow and while there's an example in my book that does exactly what I need to do, it's still fucking my brain. I don't understand how the fuck they work

>> No.67904508

Linked lists are trivial.

>> No.67904509

Still learning gtk
void main(string[] args) {
import gtk.Main : Main;

import gtk.MainWindow : MainWindow;

auto window = new MainWindow("Hello world");
import gtk.Box : Box;
import gtkc.gtktypes : GtkOrientation;

auto box = new Box(GtkOrientation.HORIZONTAL, /*spacing:*/ 10);

import gtk.Button : Button;

auto sayhelloButton = new Button("Say Hello");
sayhelloButton.addOnClicked(delegate void(Button _) {
import std.stdio : writeln;

// packStart method positons widgets (like buttons) from left to right
// packEnd does the opposite
// void packStart (Widget child, bool expand, bool fill, uint padding);
box.packStart(sayhelloButton, true, true, 3);
auto goodbyeButton = new Button("Goodbye");
goodbyeButton.addOnClicked(delegate void(Button _) { Main.quit(); });
box.packStart(goodbyeButton, true, true, 3);

>> No.67904512
File: 27 KB, 1080x2220, Screenshot_20181003-191433_simplegame.jpg [View same] [iqdb] [saucenao] [google] [report]

>Making shitty game to learn android development
>Create a 20x20 bitmap in gimp
>Draw one at (0,0) and another at (20,20)
>They overlap like fuck

Can anyone explain why this is happening?

>> No.67904515

setting the pointers is complicated but it should be easy to understand how they work

>> No.67904525

>Use of define
>Class keyword instead of struct
>Implementing member functions outside the class with stupid repeated template header

>> No.67904528

What do you find complicated about them?

>> No.67904543

in C only unsigned variables have consistent overflow behavior
if they're signed, overflow is undefined behavior and will almost certainly cause bugs or compiler-specific fuckery

>> No.67904571

I'm not expert but I would say it may be because you can't draw stuff outside of the "window." try putting on at 20, 20 and another at 40, 40.

>> No.67904590

that box size isnt 20x20

>> No.67904596

>overflow is undefined behavior

>> No.67904625

Signed overflow is undefined behavior.

>> No.67904637

does it ever actually do anything unexpected though?

>> No.67904656

No but your compiler may optimize code paths based on this premise leading to possible unexplicable crashs.

>> No.67904660

Nah. Everything that requires pointers or manual memory operations is very complicated.

Why do you think most C and C++ programs have memory leaks? If you go too much into functionality you miss out on the low level stuff and if you go too much into the low level stuff then you don't produce anything of any value.

That's why languages beyond the 90s gave memory control to a compiler.

>> No.67904661

not defending the use of undefined behaviour but I cannot possibly imagine a circumstance where the compiler could do something like that

>> No.67904673

>t. Brainlet

>> No.67904679

>Why do you think most C and C++ programs have memory leaks
They don't though. Besides you don't need to use standard pointers in the case of C++.

>> No.67904683
File: 163 B, 20x20, plains.png [View same] [iqdb] [saucenao] [google] [report]

This is the exact image I use

Worth a shot, but just shifted the overlapping images a bit, thanks though

>> No.67904689

yes and you'll notice the image in your program is much bigger
it's being scaled up

>> No.67904693

Swapping via xor or twos complement arithmetic is a piece of trivia, not something you nearly ever actually use when programming. First of all, in many cases where you want to "swap" things, a compiler can just change out references later in your code, so there's no runtime "swap" that occurs at all.

In cases that require a real swap, like sorting or other algorithms, you should ideally use the idiomatic swap in your language, which is a swap-with-temp-variable if nothing better exists. The best way to swap two values in memory, or two registers on the CPU, depends on the specific ISA, so you should swap in whatever way will make it clear to your optimizing compiler that a swap is intended.

>> No.67904732

UBs exist to leave room for compilers to optimize, in exchange for being less correct.

Try to write a function that returns 1 is the sum of two integers is positive or negative.

>> No.67904734

>i only write <1000 sloc C code for my raspberry pi and i think i am a leet coder
Go back to your gook cartoon posting safe space you hobbyist koder.

>they don't
They do. All it takes is a google search to see it's pretty much lore in C/C++.

The entire selling point of C/C++ is the manual memory operations which gives it its speed. C++ with smart pointers is a worse version of Java.

>> No.67904745

>returns 1 is the sum of two integers is positive or negative.
I meant only if it's positive. I should sleep.

>> No.67904752

yes and I'm wondering what exactly those optimizations are because I cant think of any

>> No.67904768

>C++ with smart pointers is a worse version of Java.
[citation needed]

>> No.67904780
File: 29 KB, 400x465, 1530339624569.jpg [View same] [iqdb] [saucenao] [google] [report]

>it's being scaled up

Holy fuck that's annoying, so I have to scale my image down AFTER android decided to scale it up? No wonder there's so many lagdroid memes

>> No.67904790

>no portability
>slower than regular C++
>C++ syntax
>still leaks memory
>on and on

>> No.67904812

Can't you use things like px or dx, to specify the size using pixels or density? That should leave everything consistent.

>> No.67904821

how about you draw a more helpful image than a green square so you can tell if it's being scaled up or not?

>> No.67904844

>implying lines of has anything to do with code quality or time spent.
I think i know exactly who i'm dealing with here

>> No.67904885

You're in every thread shilling java and you get btfo'd everytime. Just give up already

>> No.67905016

Quick question from a brainlet

Is the write() syscall blocking?

>> No.67905035


>> No.67905132
File: 177 KB, 1920x1080, .jpg [View same] [iqdb] [saucenao] [google] [report]

shared_ptr is litteraly 10x slower than decade old GC's though

unique_ptr spams allocations and free's everywhere and just pretends they dont exist
>inb4 write your own allocator

>> No.67905142

>shared_ptr is litteraly 10x slower than decade old GC's though

>> No.67905151

What CHIP-8 game have you made /g/?

>> No.67905161

Why do people define still member functions outside of classes?

>> No.67905171

Why do people still use member functions?

>> No.67905174

Hi sir, where are the proofs?

>> No.67905182

I guys, shameless request for some assistance because I suck at SQL
Suppose I had a table, two columns.
Column 1 is a non-unique integer and Column 2 is a bit value.
There can be multiple instances of a row with the same integer value but they can differ in the bit value.
What script can I write that would allow to select the integer values that are only paired with one bit value. I.E all integer values that only have bit value 0 and no value 1

>> No.67905184
File: 170 KB, 750x1334, Illya 990 (TD).png.jpg [View same] [iqdb] [saucenao] [google] [report]

reference counting is slow as shit

niave 1985 raii is just as slow as it was in 1985, maybe it even made sense compared to GC's of the era idk
garbage collection gets faster every year, with some absurdly speedy ones, and a large variety that you can plug and play like determanistic, async, whatever

gc will get closer to perfect every year
c++ btfoed

>> No.67905190
File: 713 KB, 1067x600, sad.png [View same] [iqdb] [saucenao] [google] [report]

I'm writing a Chip-8 emulator in Metal so I maybe I could show it to Apple and then get hired as a graphics programmer. I just want a job.

>> No.67905204

Well sounds unique so it should definitely attract some attention from them. Never even heard anyone here use Metal before. It's definitely a fun thing to go through though. Good luck anon

>> No.67905205

Not just that but shared_ptr also puts your content an extra level of indirection away

>> No.67905209

ZGC is sub 10ms pause on multi terabyte heaps lol
please tell me you're using c++ std:: that spams tiny allocations on malloc everywhere in your realtime system and that 10ms is unnacepptable

std::set calls malloc everytime you insert lol

>> No.67905213

reference counting isn't slow, comparing it to mark and sweep depends on the use case and how you define performance
and there is no "perfect" gc because it's heuristic
I think I saw you make a retarded post on garbage collection before

>> No.67905222
File: 126 KB, 411x508, 34881937_1816032852039849_3570395373883097088_n.png [View same] [iqdb] [saucenao] [google] [report]

idk what this means someone pls help

>> No.67905225

GC's can profile and be tuned; and do get faster every year
obviously some day you will be able to tune it to the point where its the same as writing whatever autistic allocator you're going to pretend to write after you get btfoed in this very same conversation

c++ shouldn't have std::shared_ptr; until it deletes it from the standard its mogged by java and go

next up: you larp as a real time dev probably

>> No.67905229

>tfw you see a chip 8 emulator in common lisp

absolute madman

>> No.67905240

I'm not "larping" as a real-time dev, I am a real time dev, I don't use C++ though so it makes me wonder if their implementation of reference counting is bad because it's not an internal part of the language
GC will never be not be slower than manual memory management by definition, any tunings and optimizations will only be heuristics

>> No.67905245


>> No.67905260
File: 455 KB, 1592x1080, .jpg [View same] [iqdb] [saucenao] [google] [report]

manual memory management is also heuristic in your brain

>> No.67905270

>it makes me wonder if their implementation of reference counting is bad because it's not an internal part of the language
Its true. shared_ptr's semantics are fucked. Because you can make a shared_ptr out of a preexisting raw pointer, the implementation requires that the reference count and the data be in distinct heap chunks - meaning a completely extraneous malloc and free on every make/delete.

>> No.67905284

I like reading these coding threads because every once in a while you guys drop your e-bully (wannabe standup comedian) act and link to something educational. I'm sick of seeing C and C++ though. Those were my first two languages and I used them for over a decade, yet I never mastered them. The world has moved beyond them. Why do you guys keep talking as if those languages are relevant. It's hard enough to get anything done with high level languages. The overhead of C/C++ is so much you'll never get anything done with those languages.

>> No.67905285

true, but given the same circumstances it's always going to be faster to do it manually than have the computer detect it and do it for you

yeah I figured as much

>> No.67905300
File: 328 KB, 424x422, .png [View same] [iqdb] [saucenao] [google] [report]

anyway the fact is that the entire std:: namespace would be more performant in a modern GC than with the current implementation with the default malloc allocator

you can't really get more btfoed than that
when your OWN library written by your own standards comitee would be faster and better designed if you just copied it line for line into go / java haha

seriously sad
someone in 1980: 'wow i keep forgetting to call free, so ill just write a macro that calls malloc and free every single time i scope enter or do pretty much anything ever with my entire tstandard lib so progressive!!

turns out there's better way to prevent memory leaks than just using a macro to call malloc and free all over the place in tiny wasteful and slow allocations

>> No.67905310

>it's always going to be faster to do it manually than have the computer detect it and do it for you

prove it

>> No.67905314

Good enough for CHIP-8 emulators

But I agree. I use python at work, and I get a ton of projects done. It's a bit messier to work with, but use of type annotations and mypy make it very close to bug free, so I'm able to ship things very quickly.

While I love C, I can't imagine using that or C++ to make all the tools and projects I could at home and work, though I'll probably be using C or C++ to make a GB emulator at home, maybe a simple game or 2 and just that really, it does take a long time to dev in

>> No.67905325

>I, the programmer, knows when this memory is no longer required so I decide when it is freed
>The computer tracks every piece of memory, when it's no longer referenced it gets freed
Computer tracking the memory isn't free, so garbage collection is slower than manual memory management

>> No.67905326

Dumb frogposter

>> No.67905342

The programmer decides *before compilation*. This is a huge difference. Plus they have more qualitative knowledge of the system.

>> No.67905345

profiled GC knows when the memory is no longer required and humans are dumb and lazy

profiled GC decided *before compilation* and has total knowledge of the system

>> No.67905353

>profiled GC decided *before compilation* and has total knowledge of the system
it can't. there's limits on what you can discern with static analysis

>> No.67905356

profiling isnt static analysis though

>> No.67905364

Yeah but the manual stuff is ALL pre-compile time

>> No.67905367

same shit, you analyize the program on compliation to find out when memory should be freed, that doesn't work for complex systems

>> No.67905369
File: 80 KB, 504x688, regexbenchmark.png [View same] [iqdb] [saucenao] [google] [report]

Daily status on regex benchmarks

>> No.67905384
File: 56 KB, 305x454, .jpg [View same] [iqdb] [saucenao] [google] [report]

you profile while its running
objectievly better than the programming litteraly guessing what the behavior will be while she's writing it
or i guess you've solved the halting progblem in your head because you're so especial and better than any GC ever!!!
lol didnt think so

>> No.67905394

>while its running
you just said before compilation. which is it? Having a GC that could figure everything out at compile time would be solving the halting problem, yes

>> No.67905398

you can compile in previously generated profile data lol
or do dynamic profiling optimization

>> No.67905402
File: 80 KB, 1982x1133, Snek.png [View same] [iqdb] [saucenao] [google] [report]

What the fuck happened to Python?

>> No.67905403

GC isn't free and in the (relatively) low level code of very high performance applications it is unacceptable

>> No.67905408

that's ridiculous. I could never imagine a game working under circumstances like that, performance would be unpredictable as hell. And it would still have work to do at runtime while using the previously generated profile data, so it would again still be slower than managing memory yourself

>> No.67905415

wtf is C# doing

>> No.67905427

being a joke as usual

>> No.67905430

Is it possible to use GDB for logging?
I've got a program running in a microcontroller and just about the only thing I can do to inspect its state is to connect to it using GDB.
So is it possible that I can make it send debug messages over that connection?

>> No.67905433

we're talking about c++ dumbo
go read the standard lib
std::set calls malloc every single time you call an element lol

stop larping as real time dev
go read the rest of the conversation pls

what's ridiculous is that you think you know how to manage memory better than even a hypothetical static + runtime profiling GC
simply because you're a big brained primate

>> No.67905441

>what's ridiculous is that you think you know how to manage memory better than even a hypothetical static + runtime profiling GC
a GC would manage memory better than I do, but it would be slower at doing so because GC computation isn't free

>> No.67905461

And you think maintaining a free list coats nothing?

>> No.67905466


>> No.67905498
File: 41 KB, 816x960, 37830878.jpg [View same] [iqdb] [saucenao] [google] [report]

I don't wanna live forever, 'cause I know I'll be living in vain
And I don't wanna fit (fit, babe) wherever (wherever)
I just wanna keep calling your name until you come back home
I just wanna keep calling your name until you come back home
I just wanna keep calling your name until you come back home

>> No.67905503

Jesus Christ you're retarded

Do you honestly think malloc/free do zero bookkeeping? malloc and free are nontrivial operations. Given enough free memory a GC can easily consume fewer resources.

>> No.67905512

freshman python programming class because some of my credits wouldnt transfer :'(

>> No.67905519

Ironically this

>> No.67905520

you can write your own allocators dumbass
GC doesn't have magical control over memory that you don't

>> No.67905524

>>inb4 write your own allocator
>>inb4 larping as a real time dev
how did i know

>> No.67905528

Being itself

>> No.67905532

C# has a compiled regex that performs better

>> No.67905537

C++, D, Rust, Nim has comile time evaluated functions that performs better. What's your point?

>> No.67905538

>GC is better because it doesn't have to use the default allocators
>but you can write your own allocator
>y-you're not allowed to do that!
I'm not following your train of thought here

>> No.67905555
File: 2.40 MB, 400x360, .gif [View same] [iqdb] [saucenao] [google] [report]

why didn''t they write an allocator that isn't 10x slower than decade old GC's for the standard c++ library
were they just virtue signalling when they gave the options for custom allocators lol
why didn't they make one themselves to deal with the shitty behavior of their own standard lib
btw you can write your own JVM GC too if you want so its pretty much an irrelevent point
except proving that im right once more

>> No.67905557

dpt/ makes more sense than /dpt/
dpt/ is not in the root.

>> No.67905575

I don't know mate I don't use C++, its a garbage language

>> No.67905578

(lol he gave up)

>> No.67905583

how do you expect me to answer questions about a language I don't use?

>> No.67905597

but why is his job interview question used in production?

>> No.67905598
File: 173 KB, 550x765, Mayoi.jpg [View same] [iqdb] [saucenao] [google] [report]

stop shitposting with Mayoi nigger

>> No.67905607


public int convertToDp(int input) { // Get the screen's density scale
final float scale = getResources().getDisplayMetrics().density; // Convert the dps to pixels, based on density scale
return (int) (input * scale + 0.5f);

Run your image sizes through this to get them to be the correct size on the screen.

>> No.67905633

Basically every screen is a different size so they use some shit like virtual pixels (or density dependent pixels) to try to match the sizes between phones. Are you using android studio?

>> No.67905657

>I, the programmer, knows when this memory is no longer required so I decide when it is freed
I have yet to see an example in real life of that.
>inb4 fizzbuzz project

>> No.67905662

FACT: I am a huge fucking retard, so shit in my mouth and call me your sister!

>> No.67905668

try looking at the source code for any video game

>> No.67905679

>Ocaml fanboy post in /g/

>> No.67905687

nono, that code was written by a programmer who finally figured it out after numerous hours of debugging and fine tuning and with 5 holes in his foot.
He didn't "know", he randomly stumbled on it after trial and error.

>> No.67905693

high performance video games are a ridiculous edge case and are practically real time systems (xms per frame in prod OR ELSE!)
data oriented design is just a heuristic just like a GC uses so whatever

>> No.67905694

>nono, that code was written by a programmer who finally figured it out after numerous hours of debugging and fine tuning and with 5 holes in his foot.
what the fuck are you talking about?
usually you have entities or resources in games that are explicitly freed from memory when they're destroyed or you hit a loading screen

>> No.67905708

>high performance video games are a ridiculous edge case
lol, that's a pretty big fucking edge then isn't it given how much code and technology goes into running them. of course they're real time systems, what else would they be

>> No.67905709

any modern gc (or competent programmer) would reuse that memory

>> No.67905710

pls respond

>> No.67905714

yes and that's the fizzbuzz-tier part of the project.

>> No.67905719
File: 347 KB, 800x600, 16z5dyv58nf01.png [View same] [iqdb] [saucenao] [google] [report]

I heard booyer-moore string search algorithm doesn't work with UTF-8 encoded strings. Is it true?

Nice try

>> No.67905730

video games are some of the most complicated applications written, not sure what you're getting at

you can if you want to

>> No.67905735

too much imperative.

>> No.67905737

Select * from table where bit_col = 0

>> No.67905743

You're one braindead autist, aren't ya ?

>> No.67905748

I'd say you are seeing how much difficulty you appear to have forming a coherent point

>> No.67905758

>if they're signed, overflow is undefined behavior and will almost certainly cause bugs or compiler-specific fuckery

>UBs exist to leave room for compilers to optimize, in exchange for being less correct.
This is false. That is the rationale behind SOME UB, but not this one. The reason this is UB is because it literally cannot be defined in the C standard while remaining portable and efficient (that is, not have the compiler insert conditionals every single time you want to use signed integer arithmetic to make the behaviour "defined").

Different processors do different things for signed integer overflow. Processors like x86 simply wrap around including the sign bit. Other processors preserve the sign bit while the rest of the bits wrap around and other processors refuse to do it at all and throw an exception.

>> No.67905759

Since >>67905709 clearly got my point, I would question you're reading comprehension instead.

>> No.67905777

manual memory managment for video games usually is not very complicated despite the ramblings of a few autistic programmers, they have mallocs all over the place

>> No.67905800

a , b = b , a

Have I understood the question correctly?

>> No.67905807

>int main ()
defend this

>> No.67905816
File: 176 KB, 821x1011, 1526672653247.png [View same] [iqdb] [saucenao] [google] [report]

>defend this

>> No.67905821
File: 5 KB, 819x56, f34f47658b30574b33b1e121a78bb908.png [View same] [iqdb] [saucenao] [google] [report]

anyone know where i can find the localhost link in mysql, i need it for netbeans

>> No.67905824

languagelets BTFO

>> No.67905835 [DELETED] 
File: 3.00 MB, 1920x1080, screencast.webm [View same] [iqdb] [saucenao] [google] [report]


>> No.67905841

This is unironically great

>> No.67905844

lol wrong thraed sorry

>> No.67905848

lmao end your life.

>> No.67905850


undefined behaviors exist to give freedom to the implementer.

>> No.67905859

Your own or you platform's native one.

>> No.67905870

Because the anchor point is in the middle

>> No.67905880

That'd still give me integer column values that may be paired with bit column values of 1 though because it is possible to have for example:
42, 0
42, 1

>> No.67905887


>> No.67905901

>Statically typed languages
why do these dinosaurs still exist

>> No.67905911

A powerful static type system is a useful thing.

>> No.67905917

But writing your own allocator is something every fucking high-performance project does, even video games. What the fuck is wrong with that?

GC has unpredictable performance impact and costs more than manually managing memory. It's just a fact.

>> No.67905934

Because some of us prefer our code to break less

>> No.67905936

almost all aaa games are mostly made of script code that is garbage collected.

>> No.67905942

Select * from table where int_col not in (select int_col from table where bit_col = 1)

>> No.67905946

Lisp is not the "One ring to rule them all" type of language. C/C++/Rust are.

>> No.67905962

>almost all aaa games are mostly made of script code that is garbage collected.
The actual important part of the game that are timing sensitive are not. The rendering engine is not GC'd, nor is the physics engine, because it'd be slow as shit and have an unpredictable performance profile.

I am 90% certain that most octotrees are also not garbage collected.

>> No.67905986

Tris are by always convex, quads may not be. I.e. scanning tris vertically will produce always one segment per scanline, for quads either one or two segments.

>> No.67905994

i dont think any quad renderer would handle concave quads, it would just draw them as a triangle

>> No.67905999

Ah okay, thanks. Was hoping not to use another nested select (this is a small part of a bigger query) but if that is the only way then so be it.
Thanks for your help.

>> No.67906002

Can someone help me through this OCaml exercise? It's about the option type.

Write a function default_int : int option -> int such that: default_int None = 0 and default_int (Some x) = x

My idea is
let default_int x =
match x with
| None -> Some 0
| _ -> Some (x : int);;

but I get a syntax error and I don't understand.

>> No.67906017

And did it occur to you to actually paste the error message?

>> No.67906020

>this expression has type option but an expression was expected of type int

>> No.67906021

Don't waste your time in functional masturbation and grow the fuck up.

int fn(int* x) {
return x ? *x : 0;

>> No.67906022

>[..] someone [..] OCaml [..]

>> No.67906028

Also, for the record, the reason you get an error is because you wrap your result in option.
let default_int x =
match x with
| None -> 0
| Some(x: Int) -> x ;;

>> No.67906031

B-but I want to impress the ladies by telling them I'm learning functional programming on my free time when they ask me what are my hobbies :(

>> No.67906033

This code isn't equivalent.

>> No.67906036

based and ironpilled

>> No.67906046

let default_int x =
match x with
| None -> 0
| Some(x: Int) -> x ;;

I don't write ocaml, but you attempt to return options. You also need to destructure the option in your match to actually extract the value, does the wildcard match is wrong

>> No.67906049

Word of wisdom right here

>> No.67906055

>"C is the most efficient programming language!"
>Emulates optional values by returning malloc'd values

>> No.67906057

No woman would let you into her pants if you can't implement default for option anon. Maybe you can pay some of the php devs at the truck stop to let you suck their dicks, but that's about it.

>> No.67906069

>what is a tagged union

>> No.67906071

Any perl monks ITT? How to do this without the sed part?:

$ echo foo | sed 's/foo/bar/g' | perl -ne 'print($_)'

>> No.67906073

Something a lot of C programmer don't use because they're clunky and annoying.

>> No.67906078

This also gives an error : "Syntax error: type was expected".

That's probably true. So I want to learn so I get to hand out with the cool kids and get to interact with the upper ladies

>> No.67906080

That's not only C.
You don't need a sumtype abstraction for a simple nullable type. If it's null return a fucking null. Grow up.

>> No.67906086

Then the renderer needs extra step to determine whether quad is concave or not. In any case, the rasterizer gets more complex compared to tri-only.

>> No.67906087

you just proved his point idiot

>> No.67906094

>If it's null return a fucking null
How do I return a null integer in C?
Yeah that's right, you can't, because there is no null integer.

>> No.67906097

Mega brainlet

>> No.67906099


>> No.67906102

>How do I return a null <T> in C?
null pointer

>> No.67906109

At least have some respect and use a std::optional.

>> No.67906116

You don't need to use malloc to be using a pointer to an int.

>> No.67906121

Not null

int *foo() {
int x = maybe_compute_x();
if (error)
return NULL;
return &x;

Is UB, and
int *foo() {
int x = maybe_compute_x();
if (error)
return NULL;
int *p = malloc(sizeof(x));
*p = x;
return p;

Is inefficient shit.

Try again.

>> No.67906122

I just proved my point

Looks like >>67906094 already got his answer >>67906102

>> No.67906123
File: 180 KB, 392x309, 1511393956944.png [View same] [iqdb] [saucenao] [google] [report]

Guys, I can't use magit or other tools to tools for git.
I go too used to absolutely shit commands, and I can't free myself from them.
Send help.

>> No.67906127

On which line? I can't magically fix your code for you, I dont even write ocaml so I dont know about its syntax quirks, but it probably just wants a type annotation somewhere

>> No.67906128

>int *foo() {
> int x = maybe_compute_x();
> if (error)
> return NULL;
> int *p = malloc(sizeof(x));
> *p = x;
> return p;
No use >>67906021

>> No.67906129

See >>67906121
Man, the C programmers here are retarded.

>> No.67906134

the people who invented C consider nullable pointers a mistake though and have discussed this at length

>> No.67906135

Different problem.
If pointers are a suitable optional type then they should be able to handle >>67906121 correctly and efficiently. And they can't.

>> No.67906139


>> No.67906143

See >>67906135

>> No.67906144

Where my OCaml niggas at?
>inb4 stuck behind GIL

>> No.67906155


>Different problem.
That's exactly the problem your fellow function monkey described in >>67906002

Now let's look at your conveniently moved goalpost
Should return an int*. Which is again, effectively the same. You don't need a sumtype abstraction for a nullable type.

>> No.67906164

Don't waste your time in functional masturbation and grow the fuck up.

int fn(std::optional<int> x) {
return x.value_or(0);

>> No.67906169

i guess someone disagrees with you seeing as union exists

>> No.67906170

Enjoy your std::visit

>> No.67906177

On the last one.
Removing the ": Int" "fixed it, but I have no idea what I'm doing.
let default_int x =
match x with
| None -> 0
| Some x -> x ;;

I'm trying earn my creds to hangout with the OCaml bois, but damn am I struggling with the syntax.
I chose OCaml because I wanted an easy ride (Haskell scared me at first and Scheme is nice for SICP but I felt like looking around).

>> No.67906180

>Should return an int*
All you're doing is moving the problem. Now the problem is in maybe_compute_x.

int *maybe_compute_x() {
int x;
// Some logic and maybe error
if (error)
return NULL;
int *p = malloc(sizeof(x));
*p = x;
return p;


>> No.67906182

std::optional has a pretty nice API, unlike std::variant.

>> No.67906186


>> No.67906189

Do you see an std::visit in there?

>> No.67906193

what if you pass it a pointer to a stack int to put the answer in though

>> No.67906198

That'd work fine and is probably what I'd do in C.
But it's ugly.

>> No.67906204

echo foo | perl -pne 's/foo/bar/g'

>> No.67906205

It's OK, I started with ocaml and gave up myself, then a year later I taught myself scala. Just stick with it.

Basically what happens in the match statement is that you destructure your input, essentially like a reverse constructor. When you say | Some x -> x you're specifying what should happen if the input argument was constructed with the Some constructor. Additionally you specify the argument x (which is named poorly since it shadows the original x) so I would write this as | Some number -> number

>> No.67906209

yes i wish c++ had sum types and pattern matching

>> No.67906213

Implement it yourself.

>> No.67906218

Rust doesn't have this problem.

>t. D fag, who has both sum types and null pointers

>> No.67906219

C++ does have sum types but they're shit because no pattern matching.

Pattern matching is something that really needs language support to be good.

>> No.67906230

True, but you can do it well enough to be usable.

>> No.67906239
File: 486 KB, 750x1198, 4C247A69-7BD3-4C9B-9077-2EEC8786253C.jpg [View same] [iqdb] [saucenao] [google] [report]

How do software developers choose which class a function operates within when there could be several fits?

My understanding of classes is that they should group tightly linked concepts together. Originally, player commands existed within the player class. I then realized several were only used in combat, and therefore better put into that class.

What about, say, text boxes? They fit into every area, but will have different needs depending on the use case. Should it be a global function? A class?

>> No.67906241

I'm not interested in usable, I'm interested in good.

>> No.67906252

Comfy! Thank you. I should learn the option switches.

>> No.67906260

Thanks. I thought pattern matching was just syntactic sugar for "if ... else if ... else if ... else ...", is it OK to think that way?
As for the Some constructor, I just discovered it with this exercise, so I'm still quite confused. I'm reading though https://v1.realworldocaml.org/v1/en/html/a-guided-tour.html to see if it can clear my mind.

>> No.67906285
File: 76 KB, 428x380, 1459093450548.png [View same] [iqdb] [saucenao] [google] [report]

time to drop awk, grep, sed and just use perl

>> No.67906309

Sorry I'm more of a lua guy

>> No.67906319

Sorry I'm more of a performance guy

>> No.67906342

pattern matching also unpack the data structure

for example,
Integer i -> return i+1;
Float f -> return f+1.0;

instead of
If Type(x) is Integer
return (X as Integer) + 1;
ELSE IF Type(x) is Float
return (X as Float) + 1.0;

>> No.67906378

Pattern maching is much more powerful than just if...else
For example in Haskell if a list has exactly two elements you can do this
let [a, b] = [1,2]
print a

>> No.67906387

c++17 has structured bindings

>> No.67906398

Pattern matching goes beyond structured bindings though

>> No.67906402

You can't do if-let with structured bindings though.
I really wish C++ had it.

>> No.67906406

It's two-fold. You can see it as nested if/else using typeOf to find out which code should be run, but it also destructures the input, allowing you to access its internals.

If I do x match {
case Dog(name, age) => ???
case Person(name, age, ssn) => ???

I get access to constructor arguments as well as type
The Some constructor lets you wrap a type. The resulting type is the Option[Int] (using scala syntax because that's what I write).

>> No.67906415

What are you referring to here?

>> No.67906435

not him, but I guess the following.

>> No.67906437

Can C++ also do this?
mySum (a:b:xs) = mySum $ a + b : xs
mySum [a] = a
mySum [] = 0

>> No.67906446

In Rust you can do this:
if let Some(x) = foo() {
// Do something with x

The branch is taken only if the destructuring is possible.

In C++ you have to do this shit:
if (Optional ox = foo()) { // Disgusting prefix
auto x = *ox; // Another disgusting variable
// Do something with x, while projectile vomiting

>> No.67906452
File: 134 KB, 570x259, 1516021435654.png [View same] [iqdb] [saucenao] [google] [report]

can haskell do this?

>> No.67906458


>> No.67906466
File: 28 KB, 253x180, 1538001931819.jpg [View same] [iqdb] [saucenao] [google] [report]

this was proposed btw
no, types prevent this

>> No.67906481


>> No.67906489

how do you implement memoization in haskell?

>> No.67906510

yes, C++ is useless, unlike Haskell
state monad or an unfolding in(?)finite data structure

>> No.67906511

This is already in C++17 and is not adequate.
Optional ox = foo();
if (auto x = *ox; ox) {}

Not only is this even worse in readability and scope but it's also undefined behavior because of doing *ox before checking if it's present.

>> No.67906512
File: 145 KB, 392x470, 1522979497453.png [View same] [iqdb] [saucenao] [google] [report]

Sir, do you have a PhD?

>> No.67906515

I guess you could implement a function like fmap but that only works for std::optional.

>> No.67906529

It's really cute Akari-chan you're just too fucking cute. Please marry me and become my daughter.

>> No.67906530

It's illegal to post akaris without a corresponding Rust code snippet.

>> No.67906532
File: 2 KB, 85x125, 1538101282165s.jpg [View same] [iqdb] [saucenao] [google] [report]

in Haskell you would use mapM_ or for_

foo `for_` \ox -> ... do something ...
do some other stuff

essentially it's a for each

>> No.67906546

I get it, because she's gay.

>> No.67906549
File: 83 KB, 750x750, 39157103.jpg [View same] [iqdb] [saucenao] [google] [report]

>Please marry me and become my daughter.
That's not how it works. You either marry Akaris mom and Akari becomes your daughter or you marry Akari in which case she becomes your wife.

>> No.67906558
File: 980 KB, 500x281, 1510784658524.gif [View same] [iqdb] [saucenao] [google] [report]

fuck the police

>> No.67906560

Now I've never done Python and I'm too lazy to look up the syntax, but your error is more of a logic error
qs=input('want to throw again(s/n)?')
while qs == s

do-while loop will always run it 1 time and after the first run will only repeat if the condition is met

>> No.67906567

What I don't understand is why they didn't make std::optional an iterable type. That would make it easy to express as
for (auto &x : optional_x)
/* ... */

>> No.67906569
File: 94 KB, 500x701, download.jpg [View same] [iqdb] [saucenao] [google] [report]

asking in StackOverflow be like

>> No.67906572
File: 616 KB, 680x218, 1537729858494.png [View same] [iqdb] [saucenao] [google] [report]

>mapM_ or for_

>> No.67906579
File: 934 KB, 320x240, pingu.gif [View same] [iqdb] [saucenao] [google] [report]

>Strongly dislike coding in Mathematica
>Afraid of criticizing it because I'm worried it might just be me being a brainlet too stupid to understand it

>> No.67906585
File: 124 KB, 1280x720, attackari.jpg [View same] [iqdb] [saucenao] [google] [report]

>>67906558 pic
the _ is used to indicate it doesn't return a result
if you don't like it, you can rename it this easily:
iDon'tLikeWord = mapM_

>> No.67906589

go back

Could be both

>> No.67906605
File: 131 KB, 978x680, 1536061426575.png [View same] [iqdb] [saucenao] [google] [report]


>> No.67906623
File: 3.09 MB, 1920x1080, 1528407511429.png [View same] [iqdb] [saucenao] [google] [report]


>> No.67906630

for (int i = 1; i > 0; i++)
This will optimise into an infinite loop.
The excuse of "I can't think of a way that could break" is the kind of stupid reasoning behind mos exploits in C programs. C will treat you well if you respect it.

>> No.67906634
File: 19 KB, 326x273, 1467996343753.jpg [View same] [iqdb] [saucenao] [google] [report]

rewrite in Haskell nobody will understand not even you, just say some stuff about monads and categories and say it's operationally impossible or some other big word nonsense
they'll believe it

>> No.67906641

I'll do both so she becomes my daughter AND my wife.

>> No.67906648

I've thought of this and the for instead of if really bugs my autism.

>> No.67906671

Also, you can't use else with this.

>> No.67906674

>infinite loop
for (;;)

>> No.67906686


>> No.67906687

Do you understand what a response is?
Do you understand the code?
Do you even know what you're talking about?
Are you retarded?
The idea was not to have an infinite loop, the idea was to have a finite loop.

>> No.67906693
File: 41 KB, 960x540, 1532493233567.jpg [View same] [iqdb] [saucenao] [google] [report]

i will revert back to zero when it reach integer max value. then i > 0 == false. loop stops. no infinite loop.

>> No.67906711

Yes, you're confirmed retarded.
Please go back to India, your English comprehension does not meet the minimum requirement of this board.

>> No.67906769
File: 168 KB, 671x603, 1521414097503.png [View same] [iqdb] [saucenao] [google] [report]

At the very least you didn't fucked up the subject...

>> No.67906803

jfc >>67906693 is right ya know.

for a 64 bit machine it will loop 2^64 - 1 then stop, assuming 2's complement

>> No.67906829

Just fuck my stack up, senpai

>> No.67906833

How are you all so retarded?
This has to be a joke.
We're talking about C undefined behaviour. Signed integer overflow is undefined behaviour in C. Someone was asking where this could lead to an optimisation which would introduce a bug, this is one of those situations. This loop would get optimised into an infinite loop, the number would be incremented (if it was actually accessed) but the check would be omitted, why? Because the compiler is allowed to assume that signed integer overflow will never happen during the execution of a program.
But if you read the fucking chain of responses which lead to what I wrote then you would have known most of this already.
People on this board shit on C for being a bad language, it's clear now that these people are just too fucking stupid for C.

>> No.67906846

where is (m)awk?

>> No.67906884
File: 56 KB, 802x525, 2018-10-04-072739_802x525_scrot.png [View same] [iqdb] [saucenao] [google] [report]


and you're an academic that doesn't actually program and has never held a job. See pic.

>> No.67906924
File: 68 KB, 702x672, 2018-10-04-073157_702x672_scrot.png [View same] [iqdb] [saucenao] [google] [report]

Actually this time.

>> No.67906934

shit u right tho.

Maybe if you weren't an autistic sperg and posted an -O3 output, like i did, people would beleive you.

>> No.67907023

Use godbolt

>> No.67907051

Thank you.
The second part was uncalled for though. In C you don't need to prove that undefined behaviour will cause you issues, you just need to prove that the behaviour will be undefined. You just experienced the reason above. What happens when you encounter undefined behaviour can range from "nothing interesting" to "something really weird locally" to "something really weird in an unrelated part of the program". It's undefined for a reason. You can't rely on undefined behaviour even based on prior experience of a compiler's specific optimisation level, compilers are free to change the behaviour for any reason. I've experienced errors which were caused by undefined behaviour but only in specific arrangements of code and not others. Compilers are really complicated and C's undefined behaviour really exposes this complexity if you try to "make use" of undefined behaviour.

>> No.67907278

What speed reading tool is that?
I've been looking for a good one

>> No.67907302

>Those todo list items

>> No.67907931

Can we please not be retarded and just wait til the goddamn bump limit

Name (leave empty)
Comment (leave empty)
Password [?]Password used for file deletion.