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

>>67903736

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

>>67903754
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 DEFAULT_STACK_CAP 16
#define GROWTH_FACTOR 1.6

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

void resize_if_needed();
};

template<typename T>
a_stack<T>::a_stack()
{
a_stack((size_t)DEFAULT_STACK_CAP);
}

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>
a_stack<T>::~a_stack()
{
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;
resize_if_needed();
}

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

>>67903818

>> No.67903835

>>67903786

Are you retarded

>> No.67903842

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

>> No.67903850

>>67903736
Why did he get fired?

>> No.67903871

>>67903850
yeah i don't get it

>> No.67903874

>>67903842

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

>>67903736
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():
print(random.randint(1,6))
qs=input('want to throw again(s/n)?')
if qs == s:
funk()

>> No.67903898

>>67903889
its called a loop

>> No.67903904

>>67903850
3 variables is more readable probably

>> No.67903923

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

Main.init(args);
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");
++count;
});
window.add(button);
window.showAll();
Main.run();
}

>> No.67903934

>>67903850
that solution will cause errors due to overflow

>> No.67903958

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

>>67903754
On Lisp Paul Graham
http://www.paulgraham.com/onlisp.html

>> No.67903971

Why are Java's lambda expressions so uncomfy

>> No.67903977

>>67903971
Why is Java so uncomfy?

>> No.67903997

>>67903971
Use Java 8.

>> No.67904006

>>67903962

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

>> No.67904027

>>67903971
i like them

>> No.67904065

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

>>67904006
https://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros

http://blog.racket-lang.org/2007/05/macros-matter.html

https://en.wikibooks.org/wiki/Scheme_Programming/Macros

https://docs.racket-lang.org/guide/macros.html

>> No.67904087

>>67904075
the same way they did for triangles?

>> No.67904093

>>67903971
would you prefer c++ lambdas?

>> No.67904095

TL;DR
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

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

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

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

>> No.67904128

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

>> No.67904143

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

>>67904095
its a beginner book

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

>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

>>67903997
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);
strings.add("moot");
strings.add("hiro");

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

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

>>67904150
>2018
>not practicing cyber shamanism

>> No.67904220

>>67904128

fug

>> No.67904224

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

>> No.67904255

>>67904205
are u retart
List<String> strings = new ArrayList<>(2);
strings.add("moot");
strings.add("hiro");

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

>> No.67904258

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

>> No.67904273

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

>> No.67904301

>>67903736
>What am I working on
Coping with the idiosyncrasies of gtkd:
https://github.com/gtkd-developers/GtkD/issues/51

Looks like my tool came into a real use

>> No.67904309

>>67904095
>>67904150
>>67904119
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

>>67904309
SICP was meme book before 4chan exist.

>> No.67904337

>>67904309

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

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

>>67904392
Electron :^)

>> No.67904444

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

>> No.67904452

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

>> No.67904485

>>67904444
the quadquad has spoken!

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

>>67904497
Linked lists are trivial.

>> No.67904509

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

Main.init(args);
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;

writeln("Hello");
});
// 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);
window.add(box);
window.showAll();
Main.run();
}

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

>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

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

>> No.67904525

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

>> No.67904528

>>67904497
What do you find complicated about them?

>> No.67904543

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

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

>>67904512
that box size isnt 20x20

>> No.67904596

>>67904543
>overflow is undefined behavior
What?

>> No.67904625

>>67904596
Signed overflow is undefined behavior.

>> No.67904637

>>67904625
does it ever actually do anything unexpected though?

>> No.67904656

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

>> No.67904660

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

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

>> No.67904673

>>67904660
>t. Brainlet

>> No.67904679

>>67904660
>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]
67904683

>>67904590
This is the exact image I use

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

>> No.67904689

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

>> No.67904693

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

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

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

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

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

>> No.67904752

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

>> No.67904768

>>67904734
>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]
67904780

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

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

>> No.67904812

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

>> No.67904821

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

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

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

>>67905016

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

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

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

>> No.67905151

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

>> No.67905161

>>67903818
Why do people define still member functions outside of classes?

>> No.67905171

>>67905161
Why do people still use member functions?

>> No.67905174

>>67905132
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]
67905184

>>67905142
reference counting is slow as shit
https://flyingfrogblog.blogspot.com/2011/01/boosts-sharedptr-up-to-10-slower-than.html

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

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

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

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

>> No.67905209

>>67905174
>>67905142
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

>>67905184
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]
67905222

>>67905035
idk what this means someone pls help

>> No.67905225

>>67905213
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
https://github.com/sjl/cl-chip8

absolute madman

>> No.67905240

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

>>67905240
ahahahaha

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

>>67905240
manual memory management is also heuristic in your brain

>> No.67905270

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

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

>>67905270
yeah I figured as much

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

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

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

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

>>67905310
>I, the programmer, knows when this memory is no longer required so I decide when it is freed
vs
>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

>>67905222
Dumb frogposter

>> No.67905342

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

>> No.67905345

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

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

>> No.67905353

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

>>67905353
profiling isnt static analysis though

>> No.67905364

>>67905345
Yeah but the manual stuff is ALL pre-compile time

>> No.67905367

>>67905356
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]
67905369

Daily status on regex benchmarks

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

>>67905364
>>67905367
wut
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

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

>>67905394
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]
67905402

>>67905229
What the fuck happened to Python?

>> No.67905403

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

>> No.67905408

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

>>67905369
wtf is C# doing

>> No.67905427

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

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

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

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

>>67905441
And you think maintaining a free list coats nothing?

>> No.67905466

>>67905461
what?

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

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

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

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

>> No.67905519

>>67905498
Ironically this

>> No.67905520

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

>> No.67905524

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

>> No.67905528

>>67905415
Being itself

>> No.67905532

>>67905369
>>67905415
>>67905427
C# has a compiled regex that performs better

>> No.67905537

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

>> No.67905538

>>67905524
>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]
67905555

>>67905538
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
hmmmm
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

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

>> No.67905578

>>67905575
(lol he gave up)

>> No.67905583

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

>> No.67905597

>>67904693
but why is his job interview question used in production?

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

>>67905555
stop shitposting with Mayoi nigger

>> No.67905607

>>67904512
dude

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

>>67904780
>>67905607
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

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

>>67905657
try looking at the source code for any video game

>> No.67905679

>flyingfrogblog
>Ocaml fanboy post in /g/

>> No.67905687

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

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

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

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

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

>> No.67905710

>>67905182
pls respond

>> No.67905714

>>67905694
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]
67905719

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

>>67905662
Nice try

>> No.67905730

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

>>67905709
you can if you want to

>> No.67905735

>>67905229
too much imperative.

>> No.67905737

>>67905182
```
Select * from table where bit_col = 0
```

>> No.67905743

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

>> No.67905748

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

>> No.67905758

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

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

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

>> No.67905777

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

>>67903736
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]
67905816

>>67905807
>defend this
no

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

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

>> No.67905824

>>67905800
languagelets BTFO

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

LOAD UP MY BIG NINE NOW IM FINNA SHOOT TO KILL

>> No.67905841

>>67905816
This is unironically great

>> No.67905844

>>67905835
lol wrong thraed sorry

>> No.67905848

>>67905816
>rust
lmao end your life.

>> No.67905850

>>67904752
https://nullprogram.com/blog/2018/07/20/
https://nullprogram.com/blog/2016/07/25/
http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html

>>67904732
undefined behaviors exist to give freedom to the implementer.

>> No.67905859

>>67904392
Your own or you platform's native one.

>> No.67905870

>>67904512
Because the anchor point is in the middle

>> No.67905880

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

>>67904392
https://github.com/ocornut/imgui

>> No.67905901

>Statically typed languages
why do these dinosaurs still exist

>> No.67905911

>>67905901
A powerful static type system is a useful thing.

>> No.67905917

>>67905503
>>67905524
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

>>67905901
Because some of us prefer our code to break less

>> No.67905936

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

>> No.67905942

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

>> No.67905946

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

>> No.67905962

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

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

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

>> No.67905999

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

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

>> No.67906020

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

>> No.67906021

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

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

>> No.67906022

>>67906002
>[..] someone [..] OCaml [..]
No

>> No.67906028

>>67906002
>>67906017
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

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

>>67906021
This code isn't equivalent.

>> No.67906036

>>67906021
based and ironpilled

>> No.67906046

>>67906028
fugg
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

>>67906021
Word of wisdom right here

>> No.67906055

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

>> No.67906057

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

>>67906055
>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($_)'
bar

>> No.67906073

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

>> No.67906078

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

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

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

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

>>67906080
you just proved his point idiot

>> No.67906094

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

>>67906021
Mega brainlet

>> No.67906099

>>67906094
0

>> No.67906102

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

>> No.67906109

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

>> No.67906116

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

>> No.67906121

>>67906099
Not null

>>67906102
>>67906116
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

>>67906087
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]
67906123

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

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

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

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

>> No.67906134

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

>> No.67906135

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

>>67906129
>>67906128

>> No.67906143

>>67906139
See >>67906135

>> No.67906144

Where my OCaml niggas at?
>inb4 stuck behind GIL

>> No.67906155

>>67906135
>>67906143

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

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

>> No.67906164

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

>>67906155
i guess someone disagrees with you seeing as union exists

>> No.67906170

>>67906164
Enjoy your std::visit

>> No.67906177

>>67906127
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 ;;


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

>>67906155
>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;
// WARNING: INEFFICIENT SHIT
int *p = malloc(sizeof(x));
*p = x;
return p;
}

Lmao.

>> No.67906182

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

>> No.67906186

std::aids

>> No.67906189

>>67906170
Do you see an std::visit in there?

>> No.67906193

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

>> No.67906198

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

>> No.67906204

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

>> No.67906205

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

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

>> No.67906213

>>67906209
Implement it yourself.

>> No.67906218

Rust doesn't have this problem.


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

>> No.67906219

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

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

>> No.67906230

>>67906219
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]
67906239

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

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

>> No.67906252

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

>> No.67906260

>>67906205
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]
67906285

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

>> No.67906309

>perl
Sorry I'm more of a lua guy

>> No.67906319

>C
Sorry I'm more of a performance guy

>> No.67906342

>>67906260
pattern matching also unpack the data structure

for example,
match(x)
{
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

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

>>67906378
c++17 has structured bindings

>> No.67906398

>>67906387
Pattern matching goes beyond structured bindings though

>> No.67906402

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

>> No.67906406

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

>>67906402
What are you referring to here?

>> No.67906435

>>67906415
not him, but I guess the following.
https://doc.rust-lang.org/book/if-let.html

>> No.67906437

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

>> No.67906446

>>67906415
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]
67906452

>>67906437
can haskell do this?

>> No.67906458

>>67906452
Haskell
B T F O
T
F
O

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

>>67906446
this was proposed btw
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0305r0.html
>>67906452
no, types prevent this

>> No.67906481

>>67906466
>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0305r0.html
useless.

>> No.67906489

how do you implement memoization in haskell?

>> No.67906510

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

>> No.67906511

>>67906466
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]
67906512

>>67906489
Sir, do you have a PhD?

>> No.67906515

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

>> No.67906529

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

>> No.67906530

>>67906512
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]
67906532

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

>>67906530
I get it, because she's gay.

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

>>67906529
>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]
67906558

>>67906530
fuck the police

>> No.67906560

>>67903889
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
do
print(random.randint(1,6))
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

>>67906446
>>67906511
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]
67906569

asking in StackOverflow be like

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

>>67906532
>mapM_ or for_
>M_
>_

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

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

>>67906558 pic
>>67906572
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

>>67906569
go back

>>67906579
Could be both

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

>>67906585
HINATA BEAM

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

>>67906605

>> No.67906630

>>67904661
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]
67906634

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

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

>> No.67906648

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

>> No.67906671

>>67906567
Also, you can't use else with this.

>> No.67906674

>>67906630
>infinite loop
for (;;)

>> No.67906686

>>67906681
>>67906681
>>67906681

>> No.67906687

>>67906674
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]
67906693

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

>> No.67906711

>>67906693
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]
67906769

>>67906686
IT HASN'T FUCKING REACHED BUMP LIMIT YET
At the very least you didn't fucked up the subject...

>> No.67906803

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

>>67903889
Just fuck my stack up, senpai

>> No.67906833

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

>>67905369
where is (m)awk?

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

>>67906833

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

>>67906884
Actually this time.

>> No.67906934

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

>>67906884
>>67906924
Use godbolt

>> No.67907051

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

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

>> No.67907302

>>67905835
>Those todo list items

>> No.67907931

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

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action