[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 44
File: 1458970213219.png (2 MB, 1598x1585) Image search: [Google]
1458970213219.png
2 MB, 1598x1585
Previous thread: >>53697617

What are you working on, /g/?
>>
File: lambert_vs_orennayar_g22.jpg (32 KB, 782x782) Image search: [Google]
lambert_vs_orennayar_g22.jpg
32 KB, 782x782
should i bother with implementing an oren-nayar diffuse shader? what if i just use a really washed out (high ambient term) lambert?
>>
>>53705124
I am working on trolling a conspiracy board on another conspiracy board that the members also visit and the owners allowed.

Good times lads
>>
>>53705124
building sportstore in asp.net mvc

this is fun
>>
File: Untitled.png (105 KB, 1212x1444) Image search: [Google]
Untitled.png
105 KB, 1212x1444
Am I retarded? I mean, I know I'm retarded, but is this getting too long? I have no point of reference. It's a WIP shunting yard algorithm btw.

opPrecedance determines the priority of the operator. numOrOp determines if it is a number or an operator and StF is just a string to float converter I cobbled so I wouldn't have to use sstream or stof.

No I'm not a CS Major. This is a hobby.
>>
>>53705359
nigga are you coding in notepad?
>>
>>53705377
Yes. Fuck you.
>>
Thank you for not using an anime image.`
>>
>>53705388
>88
>hail hilter
Relevant dubs for a notepad user. At the very least you could install notepad++ for syntax highlighting.
>>
File: summerbait.jpg (1 MB, 1920x1411) Image search: [Google]
summerbait.jpg
1 MB, 1920x1411
>>53705440
no problem
>>
File: 1455349399420.jpg (58 KB, 499x496) Image search: [Google]
1455349399420.jpg
58 KB, 499x496
>>53705359
>notepad
>>
>>53705359
       There is a famously bad comment style:

i=i+1; /* Add one to i */

and there are worse ways to do it:

/**********************************
* *
* Add one to i *
* *
**********************************/

i=i+1;

Don't laugh now, wait until you see it in real life.

-- pikestyle
>>
>>53705472
Why would I? I have no problems using Notepad. I like that it is barebones.
>>
>>53705359
>is this getting too long?
too long for notepad, seriously

but otherwise, it's mostly just comments, and code can't really get too long as long as it's well-written enough
>>
File: Oren-nayar-vase2.jpg (82 KB, 749x278) Image search: [Google]
Oren-nayar-vase2.jpg
82 KB, 749x278
>>53705154
https://www.shadertoy.com/view/ldBGz3
>>
>>53705522
I basically just added the comments before I posted it. The only comments that are actually in the code are the ones in omission blocks.
>>
>>53705510
there are atleast two additional features that are absolutely necessary for an editor used to write software
the ability to revert more than once and the ability to indent blocks
>>
>>53705359

Roughly half of this is comments, hence why it appears to be too long.

Also, your indentation style is horrendous, which would make it appear wider than it should.
>>
>>53705562
>Necessary
That's not what necessary means. Necessary would mean I literally couldn't make functioning programs without them. What you mean by necessary is "useful to have".
>>
>>53705583
So what you're saying is don't use tab?
>>
>>53705604
Or use a real editor that doesn't have a tab width of 8.
>>
File: 1450527443379.jpg (66 KB, 528x792) Image search: [Google]
1450527443379.jpg
66 KB, 528x792
>>53705626
>Use another editor because the tab width is slightly too long
>>
>>53705590
"computability" is also often used in place of "effectively computable", so get your semantical bullshit out of here
it's effectively impossible to write large, functioning programs without those features, as it takes forever to rewrite code when refactoring and it's pretty much impossible to properly indent your code to keep it readable for longer than a few hours (which you can't even seem to achieve with your small bit of code)
>>
File: 1456014633597.png (60 KB, 799x586) Image search: [Google]
1456014633597.png
60 KB, 799x586
>>53705543
>raytrace
>>
File: 1444805576558.jpg (44 KB, 544x509) Image search: [Google]
1444805576558.jpg
44 KB, 544x509
>>53705687
>Get out of here with your semantical bullshit
>Effectively impossible
Stop.
>>
>>53705650
>coding in notepad
>purposely writing unreadable code
ok senpai
>>
>>53705604
use 4-width tabs
>>
>>53705562
I don't know how to indent blocks in my editor. I'm not even sure what a block would look like for what I normally write desu. I just use macros for indenting. So I guess I fail the test.
>>
>>53705723
I can read it.
>>
>>53705124
i made that meme
>>
File: proprietary garbage.png (82 KB, 1915x1045) Image search: [Google]
proprietary garbage.png
82 KB, 1915x1045
>can't even use the free version without running into some bullshit

REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
>>
>>53705772
>Using an IDE that takes 20 full minutes to open
>>
>>53705124

>issue on my github
>guy logs this autism-level standards compliance complaint
>Google for facts around the matter
>Whole first page is him logging the same exact issue on hundreds of projects going back to 2011
>Most humorous discussion:

https://bugs.freedesktop.org/show_bug.cgi?id=70686
>>
>>53705742
Good for you.
Doesn't change that it's still harder to read than it should be.
>>
>>53705810
>First it was unreadable
>Now it's "harder to read than it should be"
Get your frivolous standards out of here.
>>
>>53705786
because you actually get work done in it, unlike vim and e-macs (fucking apple cucks)
>>
>>53705742

You can read it because your code is one page long. Look at the comments - the way they are a whole indent behind the code. Why is that? That just messes with readability.
>>
>>53705604

No, let me explain a little more clearly:
// This is fine
void foo(int arg)
{
// one level of indentation
}

// This is also fine
void foo(int arg) {
// one level of indentation
}

// This is not fine
void foo(int arg)
{
// Two levels of indentation
}
>>
>>53705838
I pray for your coworkers' sanity that you never pursue a career in programming.
>>
>>53705886
Well that's just a horse shit arbitrary standard. The third is clearly the most readable and the second is the least readable.
>>
>>53705886
And because I have to work with this horrible codebase, this is not fucking fine:

    echo "<HTML>";
echo "<HEAD>";
echo "<TITLE>";
echo "Title goeshere"
echo "</TITLE>"
....
>>
>>53705918
If you had ever actually worked in development you would know that 90% of the people in it are full retard.
>>
File: 14133589028810.jpg (232 KB, 2000x1339) Image search: [Google]
14133589028810.jpg
232 KB, 2000x1339
Is /dpt/ smart enough to solve a task from olympiad?

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
>>
>>53705809
I've reduced the amount of possible github accounts that could be you to about 3.
>>
>>53705863
>unlike vim and e-macs
>(fucking apple cucks)
I'm using debian though. And vim can fix up shit like >>53705946 in a jiffy.

qa07xA<bksp><bkxp><esc>jq to record a macro then apply it with n@a as much as you need.

>>53705923
Rule of thumb, almost always only indent for a new layer of scope. Then the scope topology of the program is immediately obvious. Also are you really hating on Egyptian braces?
>>
>>53705650
i made the pic you used in this too
as well as >>53705124

am i a meme master?
>>
File: 5412.png (19 KB, 180x158) Image search: [Google]
5412.png
19 KB, 180x158
>>53705949
>coworker who makes almost double what I do and has a masters in CS asked me to explain remind him again the difference between the heap and stack
I so fucking wish I was joking
>>
File: ibi.jpg (33 KB, 419x761) Image search: [Google]
ibi.jpg
33 KB, 419x761
>>53705983
>And vim can fix up shit like >>53705946 (You) in a jiffy.

And then I've broken the office "coding standard" :(
>>
>>53705983
>vim

emacs or fuk off
>>
>>53706056
Well you can write code in a sane way then fuck it up with vim in a jiffty.
Fyi my macro was slightly wrong, it should be
qa0w6xA<bksp><bksp><esc>jq

To fuck it up it would be
qaIecho "<esc>A";<esc>jq
>>
>>53705772
Install Vim
>>
>>53706029
iktf
I'm working an embedded dev job atm, and one of the other programmers is some guy who used to work at Microsoft and thinks he's pretty hot shit.
He's been here for 4 months so far and he hasn't written more than 50 lines of code because "hardware is weird".
He also tried to read 64KB of data from something all at once, when we have 8KB of RAM total, 400B of stack, no heap, and he didn't understand why his shit would break.
>>
>Two code paths
>one is faster but uses >1GB RAM
>Defaulting to faster option is hell on EC2 Nano or RPi
>Making the user choose is too much user effort

How can C code easily identify available RAM?
>>
///DES in C

#include <stdio.h>
#include <stdlib.h>

typedef unsigned char byte;

byte plaintext[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
byte key[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};

byte ip[] = {
57, 49, 41, 33, 25, 17, 9,
1, 58, 50, 42, 34, 26, 18,
10, 2, 59, 51, 43, 35, 27,
19, 11, 3, 60, 52, 44, 36,
63, 55, 47, 39, 31, 23, 15,
7, 62, 54, 46, 38, 30, 22,
14, 6, 61, 53, 45, 37, 29,
21, 13, 5, 28, 20, 12, 4
};

byte key_plus[7];

byte and_table[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};

void pc_1();


int main()
{
pc_1();
printf("K+\t");
for (int i = 0; i < sizeof(key_plus); i++)
printf("%u ", *(key_plus + i));
}

void pc_1()
{
for (int i = 0; i < sizeof(ip); i++)
{
if (key[(ip[i] - 1) / 8] & and_table[(ip[i] - 1) % 8])
key_plus[i / 8] |= and_table[i % 8];
}
}

Implemented this on my own. Can I make it past shitty codemonkey status?
>>
>>53706098
>when we have 8KB of RAM total

Jesus what hardware are you on?
>>
>>53706177
That's pretty common for embedded shit like refrigerators and mining equipment and whatnot...
>>
>>53706181

I guess I mostly think of "embedded equipment" being things like open source wireless antennas.
>>
>>53705772
Install older version desu
>>
>>53706167
Weak/10. Half the code is magic number bullshit that you precomputed with like a calculator or something. Write some key generating code man.
>>
>>53705923

>The third is clearly the most readable
Are you on drugs, Anon? You should consider quitting. Drugs are bad, mmkay?

> and the second is the least readable.
Which is why it is one of the most commonly adopted coding styles.
>>
File: pepe_angry_enough.jpg (5 KB, 252x161) Image search: [Google]
pepe_angry_enough.jpg
5 KB, 252x161
>reading some online explanation of some documentation
>"Now, I don't want to get into the specifics of how this actually works, but suffice to say..."

NO YOU STUPID FUCKING CUNT I SWEAR TO GOD I'LL FUCKING KILL YOU

I WANT TO ACTUALLY LEARN SHIT I'M NOT JUST HERE TO SURVIVE I'M HERE TO THRIVE YOU STUPID BITCH

REEEEEEEEEEEEEEEEEEEE
>>
>>53706314

GNU and whitesmiths braces are absurdly bad.
>>
File: 439181.jpg (26 KB, 680x583) Image search: [Google]
439181.jpg
26 KB, 680x583
>>53706396
>going through some hard to follow code trying to understand it
>author thinks he's being cute and funnay by using memes in his comments
REEEEEEEEEEEEEEEEEEEEEEEEEE
>>
>>53706454

Hence why Linus Torvalds recommended to print out a copy of the GNU coding guidelines and burn it.
>>
>>53706465
I use memes in all my unit test sample strings.
>>
File: vomits internally.png (28 KB, 1689x345) Image search: [Google]
vomits internally.png
28 KB, 1689x345
>>53706454
jesus fucking christ how horrifying
>>
    name "factorial"

factorial:
mov cx, 05h
mov ax, cx
fact_loop:
dec cx
cmp cx, 0
je done
mul cx
jmp fact_loop
done:
ret
>>
>>53705973
#include <iostream>

using std::cout;
using std::endl;

int main()
{
for(int iter = 1; iter <= 100; iter++)
{
if(iter % 3 == 0)
{
cout << "fizz";
if(iter % 5 == 0)
{
cout << "buzz" ;
}
cout <<endl;
continue;
}
if(iter % 5 == 0)
{
cout << "buzz" <<endl;
continue;
}

cout << iter << endl;
}
}
>>
File: bwanker.png (104 KB, 931x1080) Image search: [Google]
bwanker.png
104 KB, 931x1080
I thought i would teach myself c.. I simple program I like to do to start with and eventually move it to a database to help learn with DB programming and so on, so forth is a 'banker' program. Anyway, imediately run into a program where after input the program hangs for a second or 2 and throws out this exit code... Cant seem to find anything for it?
>>
>>53706544

Oh yes, it's the worst.

>>53706469

I still don't forgive Torvalds for shitting on C++, though he's not a bad guy.
>>
>>53706831
active = 1 should be ==
input == "N" is wrong, read about strcmp function and string.h header

about your error idk, the program shoud at least run
>>
>>53706831
First off,
while (active = 1)
should be
while (active == 1)
.
>>
>>53706831
char input[1024];
>>
>>53706908
Shit... My bad.

>>53706904
Right, assuming that string compare, I will have a gander.

While I am here, is it worth using C structs or just moving straight to c++ with classes? I thought C would give me a better underlying understanding.
>>
>>53706831
Look up string comparisons in C. What you're doing isn't going to work.
>>
>>53706946
Gives input undeclared.

>>53706963
On it right now,
>>
How else is best to capture input in C?
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

int main() {
char* input;

printf("%d", strcmp("Hello", "Hello")); // just testing strcmp

scanf("%s", input); // This scanf is throwing some serious shade

return 0;
}



On the scanf the program just hangs and terminates with status -1073741510
>>
>>53707105
http://stackoverflow.com/questions/14546018/using-scanf-function-with-pointers-to-character
>>
>>53706949
I think C is ok for now, you can always switch to C++
>>
>>53707186
Cheers

>>53707180
malloc worked fine, I did try initializing it as "" thinking that might work... So limiting the user input is one feature I will have to think about. Sweet deal.
>>
Are classes objects in Java?

I'm new to programming and am trying to create some minigames of boss fights.

Plan on prompting the user to choose role(ie: tank, heals, dps), then they'd get to use abilities dedicated to said role.

I'm thinking the way its done is creating different classes for each role and also for the boss and ultimately calling the methods to function within the public class.

Am I on the right path?
>>
>>53707367
Kind of, a class is a template to an object.

You declare a new object of that type and pass constructor parameters if required.

Player myPlayer = new Player("Titan");

or you could have a base player class, then 'Titan', 'Mage' and 'Rogue' that all extend 'Player'. This will probably be the best way to handle enemies, have a base enemy class with all base attributes such as health, damage, etc. Then enemy specific that extend it, like 'animal', 'humanoid' or 'bear' and 'rat'.
>>
Trying to parse a xml with rapidxml

string x("SalesRevenue");
for(xml_node<> * P_node = root_node->first_node(x); P_node; P_node = P_node->next_sibling())
{
... code
}

won't work

for(xml_node<> * P_node = root_node->first_node("SalesRevenue"); P_node; P_node = P_node->next_sibling())
{
... code
}
will work

What is happening????? THREE FUCKING HOURS
>>
>>53707416
Classes are totally objects even in Java but that's advanced and involves reflection and shit.
>>
File: blow.jpg (177 KB, 1280x720) Image search: [Google]
blow.jpg
177 KB, 1280x720
How do you guys feel about Jonathan Blow's new language?
>>
>>53707655
I don't think Jonathan Blow invented retard.
>>
>>53707655
It blows.
>>
>>53706081
ayy gtp know what up
do you use emacs on Windows now?
>>53707655
pretty okay for what it does. the metaprogramming looks really nice, it seems to have a good balance of templates, mixins, and macros (although i think all 3 need to be refined to be easier to used more productively)
>>
>>53707655
Well, it's certainly interesting. I'd love to hear any criticism of it.
>>
>>53707832
>do you use emacs on Windows now?

It depends what I'm doing. For most text editing tasks, I use it. I typically use CLion for C/C++ now, though.
>>
Pike might be retarded on some things, but he's got a few good points:

The following data structures are a complete list for almost all practical programs:

array
linked list
hash table
binary tree
>>
>>53707983
Shut your whore mouth, Pike is a goddamn genius.
>>
>>53707983
i'd add stack explicitly, but since it can be implemented as either an array (list) or linked list i guess it's fine to leave it as is
>>
>>53708037

Actually, there is that: stack (and queue) ((and in a more convenient sense, deque)) are really useful.
>>
Which should I use?
This routine (more complicated in actual implementation) is going to be called a lot with a lot of different 'n's, and I don't want to fuck up the heap. Are variable stack allocations efficient?
void target (int n, int* array);


void routine_1 (int n)
{
int array[n];
target(n, array);
}


void routine_2 (int n)
{
int* array = malloc(sizeof(int) * n);
target(n, array);
free(array);
}


#define REASONABLE_MAX 8
void routine_3_aux (int n)
{
int array[REASONABLE_MAX];
target(n, array);
}
void routine_3 (int n)
{
if (n > REASONABLE_MAX) {
return routine_2(n);
} else {
return routine_3_aux(n);
}
}
>>
>>53708151
Yes. They're fuckin' speedy. Oftentimes they won't even be stored in ram and will only exist in the registers before dying, whereas malloc'd data has to be between ram and registers for sure 100% of the time and then you have cache coherency and access times and yuck.
>>
>>53708173
Okay yeah I looked into it and they do seem pretty efficient. I'll just use them, thanks.
>>
>>53708078
I bet a high-level language that implements all arrays as resizable circular deques would be efficient enough for most all purposes.
>>
So... last thread, someone posted a challenge from a programming competition that they didn't manage to get right at the time. Idea is you've got a rectangle with given width and length, and you need to pack it with n squares of equal area. The problem is to solve for the maximum area of one of these squares. I came up with an initial greedy solution to the problem, but realized it wasn't quite correct. I've tweaked it just slightly, and am rather sure this might produce an ideal solution. I know (and can prove) that a sub-rectangle generated by the inscribed squares must have either a length or width equal to the respective length or width of the given rectangle. Given some testing, I have determined that fitting it to the larger of these dimensions only seems to be optimal if the side length of the squares is not smaller than it would be if I were to increase its fraction of the smaller side length. Or, to put things into perspective with an example...

Imagine fitting 4 squares into a 1x1 rectangle. I can't have the squares fit to the length of this (1), but can fit it to the width (1) by making the dimensions 0.25 x 0.25. But that isn't optimal. I can easily increase the number of squares fit to the length (2), so that each is 0.5 x 0.5. So this is greedy but possibly optimal:

def optimal_area n, length, width
min = [length, width].min
max = [length, width].max
npack = 1.0
loop do
# Try side length to maximally fit min side of rectangle
side = min / npack
if side * (n / npack) <= max then
return side * side
end

# Try side length to maximally fit max side of rectangle
# Note that we avoid side lengths that are particularly small -- those that
# are smaller than the next smallest level of packing.
side = max / (n / npack)
if (side * npack <= min) && (side * npack >= (min / (npack + 1.0))) then
return side * side
end

# Increase amount of packing
npack += 1.0
end
end
>>
>>53708212
You're not wrong. I rarely have to whip out the vector library in Scheme. Performance critical code is rarer than people seem to think.

>>53708272
What do you mean by a "greedy" solution? The question is about optimization anyway. The point is to find the solution with the largest areas.
>>
>>53705359
>notepad
>indentation
This is bait and I hate all of you.
>>
File: test.webm (1 MB, 646x428) Image search: [Google]
test.webm
1 MB, 646x428
How do i learn shader coding in HLSL?
I got this tool and im just spaghetting the default shader
>>
>>53708334

A greedy algorithm is one that makes the most optimal decision at every opportunity and does not do any backtracking. Maybe not the best word to use here, I suppose, but it's mainly because the algorithm doesn't seem to consider any in-betweens, and just keeps getting smaller and smaller, grabbing the first valid solution it can find.
>>
>>53708440
google 'hlsl'
>>
>>53708151
>Are variable stack allocations efficient?
uh, stack allocations are simply incrementing stack pointer.
>>
>>53708440
>D3DPD
Cancer
>>
>>53709058
There's glsl but i don't have sdl ready for it

:^)
>>
>>53709073
>using the smiley with a carat nose
>>
>>53709145
>carat
caret
>>
>>53707598
~~polymorphism~~
>>
>>53709155
>caret
carrot
>>
>>53709225
No modern Java really can treat classes as a type of object that can be manipulated like any other old piece of data. One might say that Java classes are ~~~first class~~~

https://codegolf.stackexchange.com/questions/28786/write-a-program-that-makes-2-2-5
>>
>>53705772
Get the professional version from Kat

>inb4 muh piracy , rootkits, RATs and keyloggers memes

Get Qt open-source if you don't eat VS anymore, you can still use the VC compiler and it's more lightweight

Otherwise use mingw with any text editor or just Clion master-race
>>
Kill me, I'm using visual basic to parse a table, calculate a running sum, and then take out the running sum every hour to summarise a days work done by a machine.

I hate visual basic with a passion
>>
mememememememememememememememememememe
>>
>>53709373
Get over it senpai. Do you duty and get it done.
>>
>>53709477
I'm probably just going to skip reading the table looking for the running total as the hour ticks over and just display the rate and the days total instead
>>
Does anyone know any module or command line utility that allows you to extract table data from images?

If something like that already exists I don't want to reinvent my own shitty version of it.
>>
>>53709602
Python preferred for module, but I'm open to working with anything.
>>
>>53709602
http://tabula.technology/
>>
>>53705772
How about you just do what the error message tells you to, register the program and continue using it without an issue for free?
>>
How bad is the overhead with throwing shit on the heap?
Like, if I have a possibly large array of strings (100 to 1m strings), should I just put a huge array on the bss segment or should I just deal with memory management.
It's on a desktop environment, so memory shouldn't be a problem, but speed might be if managing memory and accessing that memory is noticeably long.
>>
>>53705786
7-8 seconds. Then a couple of more seconds to open a project. Fuck, I really should switch to Notepad to save those precous 15 seconds every day.
>>
>>53709879
>Justifying using Bloat Studio
>>
>>53709879
Why not Notepad++?
>>
File: 1458389132183.gif (474 KB, 127x139) Image search: [Google]
1458389132183.gif
474 KB, 127x139
>>53709890
I don't mind it, but in what way did my comment justify it?
>>
>>53709905
The whole comment?
>>
>>53709623
I have images, not text in PDF's.
>>
>>53709796
I hear that most of the problem with the heap is either allocation taking a long time because it has to find a place to allocate, or fragmentation, when all of your different heap objects are located all over the place and memory can't be cached easily. I think you'll be fine as long as theres enough memory to allocate
>>
>>53709796

It is generally not good to be constantly allocating and freeing memory. That said, if it's a large flat array of strings, you could probably do it in one contiguous allocation.

>>53709879

Took me about 3 minutes to launch from the start menu to having an actual window open. It also uses more memory than Skype with no projects open, despite Skype being full of asshat friends who feel like spamming the chat with images.
>>
>>53709986
Do you even SSD? After closing it and starting it again, it literally takes 3 seconds to get to the start page.
>>
>>53710002

>Do you even SSD?
If your program requires an SSD to achieve decent load times, that's a good sign that it's bloated.
>>
>>53710153
VS is not light-weight by any means, but SSDs (and they're so cheap that you can easily put them in anything but the absolute low end setup, right?) make load times a non-issue.
>>
File: image_0.jpg (121 KB, 762x613) Image search: [Google]
image_0.jpg
121 KB, 762x613
>>53705124
>tfw want to continue programming my program
>tfw have to solve bazillion integrals in a week to not fail uni
Life is cruel.
>>
>and they're so cheap that you can easily put them in anything but the absolute low end setup, right?

Now, my laptop isn't particularly old. About 2 years or so, but I don't think you should design an IDE to only run well on the newest computers. Most computers currently in use don't have SSDs, because for the longest time, they've been rather expensive compared to HDDs.

Visual Studio is full of MANY useless features. A C++ programmer does not need web design features. A web developer does not need C++. Honestly, the only redeemable part of Visual Studio to begin with is Intellisense. Everything else is crap, including and especially the compiler they ship with it. They should just ship an editor with Intellisense, a plugin system for different language features, and not design it in JavaScript. Done. You've got a better development environment system than Visual Studio.
>>
>>53710235
Write a computer program to solve integrals.
>>
File: 4970334.jpg (40 KB, 250x250) Image search: [Google]
4970334.jpg
40 KB, 250x250
>>53705124
>>
File: 1458992047912.jpg (42 KB, 250x250) Image search: [Google]
1458992047912.jpg
42 KB, 250x250
>>53709622
>>
>>53710321
>and not design it in JavaScript
That's so '99.
>>
>>53710321
read
>i'm too poor to upgrade to the clearly superior SSD
>>
>>53706396
lol, you'll love this then (even though this is a brilliant talk)

https://youtu.be/d1uraoHM8Gg?t=50s
>>
>>53705786
what

are you literally a linux neckbeard running a toaster from another millennium
>>
>>53710498

I shouldn't need to upgrade. Hardware doubling in speed every couple of years is not an exchange to make software three times slower in the same time period.
>>
>>53705359
money says this poster's around 40 years old, lives with his mom, and can hardly put a computer together
>>
>>53710321
you should be happy that you can even run professional productive software on your outdated low-end laptop and not need a $10,000 workstation for it
>>
>no one in this thread is using Rust
>>
>>53710601
This is what pisses me off about websites having 5mb of JavaScript these days. My computer is a couple years old, i5 CPU, 8gb memory, decent mobo for the time, SSD. And it struggles and sputters and stalls when I use the web. Even though I have uo and ghostery installed. It should be fast as fucking lightning to browse some fucking text and images, but web design dickheads have made the web slower than it was 15 years ago despite the improvements to hardware speeds.

On my phone it's unusable.
>>
>>53710652
Rust is not ready for prod and probably never will be.
>>
>>53710671
webshit is a whole other issue. web "devs" are fucking retards
>>
>>53710652
>no one has made a compelling argument as to why anyone should use rust
>>
>>53710678
Honestly I wish I could disable JavaScript entirely but then most of the sites I use wouldn't work at all.
>>
>>53710697
s-safety
>>
>>53710697
No HKTs, and it's probably too late to add them properly.
>>
I was wondering why my toy Haskell program was going unexpectedly slowly... turns out I had it set to use all possible cores (+RTS -N), so it obliged and tried to use 8 cores for an XML file reading and processing task. Turning it back down to just 1 core thanks increased speed by about 3 times. (wew)
>>
uint width = uint(sqrt(area));

for(auto i = std::make_pair(0, glyphs.begin()); ;i.first+=(++(i.second))->w) if(width >= i.first) { width = i.first; break; }


is there a less retarded way to do this without polluting code with more variables/brackets?
>>
>>53710778
Yeah, use a more modern language.
>>
>>53710671

And of course, we keep hiring bigger and bigger idiots. We don't need to think about performance, because computers will keep getting faster. All that matters is that the product works and looks nice. Nobody needs to know anything about mathematics or data structures, or anything covered in a computer science classroom. Expecting me to be able to FizzBuzz? OMG Math!

>>53710735

Why does Rust need higher kinded types?
>>
multi-stage programming is the future.
everyone should try terra
>>
>>53710847
>Why does Rust need higher kinded types?
Because they're very useful.
>>
>>53710778
don't codegolf "real" code retard
>>
>>53705124
Breaking into forty-five government owned satellites.

Resistance is futile, I'm a genius programmer.
>>
File: lambert_vs_orennayar_g22.png (152 KB, 782x782) Image search: [Google]
lambert_vs_orennayar_g22.png
152 KB, 782x782
>>53705154
>>
File: zKhlsz5.png (936 KB, 1899x970) Image search: [Google]
zKhlsz5.png
936 KB, 1899x970
is it possible to write a game in pure C?

what are the alternatives to inheritance and polymorphism in C?
>>
>>53710847
Rust needs full-blown HITs tbqh.
>>
>>53711064
>TYOOL 2016 using inheritance
Most OOP fanatics have given that up
>>
>>53711082
well then how do you structure your code so it's not retardedly tangled and complex?
>>
>>53711098
>OOP
>not retardedly tangled and complex
>>
>>53705863
vim or emacs are better editors than the VS one.
>>
File: 1449756574386.jpg (3 MB, 3264x2448) Image search: [Google]
1449756574386.jpg
3 MB, 3264x2448
>>53711064
yes
>>
>>53711109
even pajeet has no problem with it

you're just retarded
>>
Anyone have any good papers/books on evolving neural networks?
>>
>>53707416
You have no familiarity with game development nor the concept of metaclasses.

Java's classes are objects as you can reflect on them, but you can only read data, not modify it at runtime.

Inheritance hierarchies are a terrible idea for game development, google "entity component system".
>>
>>53711123
but seriously, emulate OOP using structs with function pointers or functions with struct name prefixes that operate on structs if you must use C.
>>
>>53711098
Don't put the cart in front of the horse.
Worry about structure after you have some code to structure. Don't force your code into some mold you thought would be great before you wrote a single line of code.
>>
>>53711132
>even pajeet has no problem with it
Pajeet will fuck up everything.

>>53711123
>void UseItemFromBag
>AdjustBellySize()
>RemoveItemFromBag()
All the side effects, my eyes!
>>
>>53711182
...they're effects
>>
File: 1399661257648.jpg (116 KB, 375x476) Image search: [Google]
1399661257648.jpg
116 KB, 375x476
>>53711191
>>
>>53711201
how else are you going to structure it, retard

are you going to put the entire game in a monad and then tip your fedora about it being "pure" because you put everything in the function parameters
>>
Why does /g/ act like OOP is bad? It makes writing certain things so much easier.
>>
>>53711210
let gameLoop state =
let newState = update state
draw newState
gameLoop newState

gameLoop initialState
>>
typedef struct
{
char ch;
} rendering_component;

void rc_init(rendering_component *rc)
{
rc->ch = '@';
}

typedef struct
{
rendering_component rc;
} player;

void pl_init(player *pl)
{
rc_init(&pl->rc);
}

int main(void)
{
player p;
pl_init(&p);

printf("%c", p.rc.ch);
}



should i do stuff like this?
>>
>>53711211
memes + retardation

Ctards are literally spergs that are too dumb to understand higher-level language features, and they're delusionally smug about using C as if C programming takes more than just writing endless fizzbuzz-tier functions
>>
>>53711256
>are you going to put the entire game in a monad and then tip your fedora about it being "pure" because you put everything in the function parameters
yep

your function will still update the "state" just that you have it as a parameter. still the same complexity just with more clutter in the function parameters
>>
>>53711256
You need some way to exit from the game
>>
>>53711280
The function will create a new state, not update the existing one.

>>53711292
You have to disable tail call optimization and then blow the stack to exit the game.
>>
File: IMG_20160303_174720.jpg (176 KB, 922x1152) Image search: [Google]
IMG_20160303_174720.jpg
176 KB, 922x1152
>>53711280
>actually being this retarded
Just use switch or while jesus christ
>>
>>53711334
Can't you use ContT?
>>
>>53711292

The method of exiting the game is that the user sends SIGKILL to the game.
>>
>>53711334
>The function will create a new state, not update the existing one.
fucking retard, it's just a way of "modelling" it, same as with the retarded michio kaku meme quote, creating a new one and throwing out the old one achieves exactly the same as modifying the old one turning it into a new one
>>
>>>53711292
>You have to disable tail call optimization and then blow the stack to exit the game.

I can't fucking breathe
>>
>>53711344
Whatever you like, I wanted to keep the snippet as simple as possible.

>>53711368
You need to read the Psalm of Immutability.

https://www.youtube.com/watch?v=1PhArSujR_A 2:05 onwards. I think we can agree that this lad is not a meme game programmer.
>>
>>53711403
Of course Haskell can be used to rewrite a 30 year old game. It has no chance of being fast enough to run even a 15 year old game though.
>>
>>53705786
>using hardware from early 2000s
>>
>>53711493
>using modern, NSA-approved spyware hardware
>>
>Refactor my code out into a class
>Memory leak
class MenuBar final : public QMenuBar {
Q_OBJECT
public:
explicit MenuBar(QWidget *parent = nullptr);
signals :
void open();
void quit();
};

MenuBar::MenuBar(QWidget *parent)
:QMenuBar(parent)
{ // Memory leak attributed to this line (the open bracket)
auto fileMenu = addMenu("&File");
auto openAction = fileMenu->addAction("&Open");
connect(openAction, &QAction::triggered, this, &MenuBar::open);

auto quitAction = fileMenu->addAction("&Quit");
connect(quitAction, &QAction::triggered, this, &MenuBar::quit);
}


Can anyone work out what the fuck I'm doing wrong here? MenuBar's destructor does get run (and only once) so the actual MenuBar object isn't being leaked.
>>
>>53711064
It certainly is possible but you will end up with a lot of redundant and repetitive code.
>>
>>53711524
How do you know there's a memory leak? Perhaps it's attributed to the application event loop or the stack in which case it's not really a memory leak.
>>
>>53711537
I'm trusting QtCreator's default filter on the valgrind output, there's a fucking massive load of memory 'leaks' and other memory issues from AMD's graphics driver and Qt internals, but this is the only one it thinks is from my code.

I mean, it's a single leak at startup of ~100bytes, no major issue to leave in, but fucking annoying.

78 (32 direct, 46 indirect) bytes in 1 blocks are definitely lost in loss record 6,300 of 9,587
in MenuBar::MenuBar(QWidget*) in /home/gareth/src/PR/MenuBar.cpp:5
1: operator new(unsigned long) in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so
2: 0x108d77bc
3: QMenuBarPrivate::init() in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.4.2
4: MenuBar::MenuBar(QWidget*) in /home/<USERNAME>/src/<PROJECT>/MenuBar.cpp:5
5: MainWindow::MainWindow() in /home/<USERNAME>/src/<PROJECT>/MainWindow.cpp:10
6: main in /home/<USERNAME>/src/<PROJECT>/main.cpp:10
>>
>>53711574
Ha I'm fucking retarded and didn't remove my name from the copy-paste. Teach me not to be a tinfoil-hatted retard.
>>
guys i made a checkbox in zenity (you can select three things) and $1, $2, $3 return boolean values. how can I make the script to accept one True? my approach was to store the values in an array and check for true in a for loop.
>>
File: 282.png (111 KB, 304x332) Image search: [Google]
282.png
111 KB, 304x332
#include <iostream>
#include <cstdlib>

int main()
{
std::string fuwa_fuwa{"fuwa fuwa"};
decltype (fuwa_fuwa) timu{" time"};
auto fuwa_fuwa_time = fuwa_fuwa + timu;

std::cout << fuwa_fuwa_time << '\n';
return EXIT_FAILURE;
}


:!g++ test.cpp -o test -std=c++11
>>
>>53711902
Please use std::endl instead of \n unless you're outputting a lot of messages in bulk.
>>
>>53705973
A hobby of mine is to push a language to produce the shortest source possible:
i;main(){101-++i&&printf("%d\n\0FizzBuzz\n\0Fizz\n"+(7*!(i%3)+4*!(i%5))%9*2,i)&main();}


What do you think of a recursive main?
>>
>>53706081
>emacs
I tried that distro a while back.
my only issue with it is its lack of a decent text editor.
>>
I love python, but as a job and within a team, even with PyCharm, I really wish the language was somehow explicit about things, rather than throwing shit around with the assumption that that shit contains or has the functionality of things you need to make a function work for the duration of the project and leave it as is. I know unit tests can catch that sort of thing out using isinstance or hasattr, but it still ain't enough for me
>>
File: ss (2016-03-27 at 01.39.36).png (26 KB, 538x774) Image search: [Google]
ss (2016-03-27 at 01.39.36).png
26 KB, 538x774
C++
not even once
>>
File: 442x587.png (295 KB, 442x587) Image search: [Google]
442x587.png
295 KB, 442x587
>>53712017
My book says main cannot be recursive.
>>
>>53712067
idiot, good low-level math code should look like shit in any language, and most developers aren't supposed to look at this stuff
>>
File: ss (2016-03-27 at 01.52.35).png (27 KB, 549x777) Image search: [Google]
ss (2016-03-27 at 01.52.35).png
27 KB, 549x777
>>53712140
C++fags will defend this
>>
>>53712067
>gee why does the standard use reserved names to avoid collisions
>>
>>53712155
look at GHC code or whatever flavor of meme you're into retard
>>
>>53712067
With normal names without a thousand of underscores (no idea why they name shit like that, I thought c++ has namespaces) it would look much better.
>>
File: anally annihilated.jpg (834 KB, 1214x1239) Image search: [Google]
anally annihilated.jpg
834 KB, 1214x1239
>>53712140
>>53712173
>>53712183
>>53712199
Not surprised tbqh, there's always a bunch of shit-eaters to come to rush to defend their piece of poo.
>>
>>53712067
>>53712155
What colorscheme, font and editor is that by the way? Lookin pretty sweet.
>>
I have a set of some structures in c++, lets call it foo and I can search the set with the find member function and it returns an iterator pointing at the element it found, but I need a pointer to the element I found, so I do something like this:
&(*(iterator))
and it does return a pointer.

But the catch is that I have to insert that pointer in some other set (bar), and the pointer is const, while the set is a container of regular pointers, not const ones. Can I somehow get a regular pointer to the element from foo or do I just change bar to be a container of constant pointers? I mean it doesn't change much, but is it smart to adapt my code to the syntax of the language, and not the other way around?
>>
>>53712230
fucking retard, tell us which is YOUR meme of choice, i can guarantee it has ugly math library code
>>
>>53712258
How about:
return const_cast<const Foo *>(&(*iterator));
>>
File: ss (2016-03-27 at 02.04.30).png (108 KB, 1440x900) Image search: [Google]
ss (2016-03-27 at 02.04.30).png
108 KB, 1440x900
>>53712232
hybrid_reverse
Consolas
GVim on Windows

>>53712273
Visual FoxPro
>>
>>53712296
Thanks man.
>>
>>53712296
>Visual FoxPro
literally who

>Microsoft
inb4 its standard math library isn't even open source or it doesn't have binomial distribution or whatever glibc++ code you quoted
>>
>>53712333
>literally who
holy shit how old are you
>>
>>53711334
>You have to disable tail call optimization and then blow the stack to exit the game.
kek
>>
I know 4chan hates people who need help with Homework but I am fucking dying with a program I am trying to code. I cannot get a for loop (C++) to execute a set amount of times, storing inputted data once for each repeat of the loop.

For example, on the first run, it stores the inputted information as related to Input 1, the second pass it stores as Input 2, etc. Then another for loop runs through again and displays all the data as a list.

I could post the code but it is a shitload of code. I've spent 3 days trying to get it to work but it continues to ask for inputted data on loop without coming to an end and moving onto the next blocks of code.

Thank you.
>>
>>53712338
>Version 9.0, released in 2004 and updated in 2010, is the final version of the product.
>The current version of Visual FoxPro is COM-based and Microsoft has stated that they do not intend to create a Microsoft .NET version.
how old are you
>>
>>53712350
41
>>
>>53712081
Oh, it can. That doesn't mean it should be done.
>>
>>53712357
why are you using visual foxpro instead of C++ or some other reasonable language this is the first time i've ever seen it mentioned in /dpt/
>>
File: monvisage.jpg (20 KB, 281x267) Image search: [Google]
monvisage.jpg
20 KB, 281x267
>>53712350
>current year
>millennials are now allowed on this site
>>
>>53712375
see >>53712273
>YOUR meme of choice,
>>
>>53712383
if it even has binomial distribution in its standard library the source code probably looks as "bad" as the glibc++ code
>>
>>53712346
You mean you can't do something like this?
#include <iostream>
#include <string>
#include <vector>

constexpr unsigned int Iter = 10;

int main(int, const char **)
{
std::vector<std::string> data{};
data.reserve(Iter);

std::string line{};
for (unsigned int i = 0; i < Iter; ++i)
{
std::cout << "Input " << i << ": " << std::endl;
std::getline(std::cin, line);
data.push_back(line);
}

std::cout << "Output: " << std::endl;
for (const auto &line: data)
std::cout << line << std::endl;

return 0;
}
>>
>>53712283
I think I either explained wrong or I can't follow what you showed me here, but the pointer returned is already const, no need to const cast it and foo is the name of the set, not the structures within. I wanted to ask can I somehow de-const it? This is more of a theoretical qustion now, since I fixed the problem by changing the bar set to contain const pointers, not regular ones. It's probably for the best that way.
>>
File: grin.png (105 KB, 257x234) Image search: [Google]
grin.png
105 KB, 257x234
>>53705809
>Importance: lowest trivial
>>
>>53712418
> I wanted to ask can I somehow de-const it?

The same way you const it? As in use const_cast without the const keyword in the template parameter.
>>
File: bait.gif (3 MB, 300x252) Image search: [Google]
bait.gif
3 MB, 300x252
>>53705923
>>
File: 1455921347166.gif (80 KB, 424x240) Image search: [Google]
1455921347166.gif
80 KB, 424x240
I'm messing around trying to learn some OpenGL stuff.
At this point, I'm trying to use textures. I can't really be fucked with image loading, so I'm trying to use ImageMagick to convert images to raw RGB values and embed the file into the executable.
convert image.png -resize 256x256 image.rgb
ld -r -b binary -o image.o image.rbg

and then link it into my program like any other object file.
Also, in the C file itself, there is
extern uint8_t image_size[] asm("_binary_image_rgb_size");
extern uint8_t image_start[] asm("_binary_image_rgb_start");
extern uint8_t image_end[] asm("_binary_image_rgb_end");


However, when I print (size_t)image_size or even
stat image.rgb
, I get a size of 175104 bytes, instead of the expected 196608 (256 * 256 * 3) bytes. Obviously with this smaller than expected size, I get a segfault when I try to use the image for an OpenGL texture.

Does anyone know why this is happening and anything I can do to fix it?
>>
>>53712588
I'd suggest you use stb_image header-only library which will let you load common OGL texture formats, and the use is very basic, it's just something like this:
int width = 0, height = 0;
int bpp = 0;

unsigned char *data = stbi_load("path", &width, &height, &bpp, STBI_default);


So it's not really much effort. As for your actual problem, I've no idea.
>>
>>53712588
There is a simple little function used to load png files called picopng. I think it ain't too complicated. If you can't figure it out, just look up on youtube a channel makinggameswithben or something like that, he has a video which shows how to use that picopng function.
>>
>>53706831
Would just like to point out that this approach is fine if you scan in a character and compare to a character rather than a character pointer which is what is currently happening.
>>
Why is there no good text editors?

Sublime Text is abandonware that's hard to integrate with anything.
Vim's buffers are shit.
Atom is a damn web browser not a text editor.
Emac would require me to turn into an octopus.
Nano doesn't cut it.
>>
>>53712753
>2017
>not wanting to become an octopus
shiggy doodit
>>
>>53712753
microsoft word
>>
>>53712753
>Vim's buffers are shit.
what do you mean?
>>
If I don't know what the type of variable passed into a function is in C, what do? For example I wanted an in_array function where by it simply returns true or false as to whether it is in the array, but l get incompatible argument when I try and void the variables.

What do?

bool inArray(void, void*);

int main() {
double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0};

printf("%d", inArray(3.4, balance));

return 0;
}

bool in_array(void needle, void *haystack) {
int i = 0;

for (i = 0; i < sizeof(haystack) -1; i++) {
if (haystack[i] == needle) {
return 1;
}
}
return 0;
}
[/code[
>>
>>53712809
That it cannot achieve the same thing as Sublime Text view/buffer wise.

In ST, I can split the view into two panes, then each pane can have tabs that are switched independently.
>>
>>53712753
emacs with evil mode (or spacemacs)
>>
>>53712821
C has no generics, consider upgrading to C++.
>>
>>53712753
Atom is better than it used to be and has decent plugins for many languages now. Still slow at times, but nothing any vim user should complain about.
>>
>>53712821
Just use templates.

Oh wait, you're not using C++. Nevermind.
>>
>>53712821
Use generics.
>>
>>53712823
vim allows you to have tabs with (v)splits. The other way around is only possible using multiple terminals.
>>
>>53712821
Use reflection.
>>
>>53712821
Use parametric polymorphism.
>>
>>53712821
Use typeclasses.
>>
File: Untitled.png (11 KB, 1170x674) Image search: [Google]
Untitled.png
11 KB, 1170x674
>>53712827
I'll look into it, hopefully it can support views/tabs as I described in >>53712823

>>53712856
It might be better than it used to be but it's still not good performance-wise, in fact, it's quite terrible for a text editor, but that's what you get when you use a web technology to make a desktop program.

>>53712862
Yep, unfortunately I haven't been able to achieve pic related with Vim which is the most optimal setting for my workflow.
>>
>>53712821
Use implicits.
Thread replies: 255
Thread images: 44

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.