[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: 27
File: DPT.png (389 KB, 934x1000) Image search: [Google]
DPT.png
389 KB, 934x1000
Old thread: >>54463714

What are you working on /g/?
>>
>>54469966
Nice doubles dubs
>>
>>54469966
int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
>>
Please do not use an anime image next time., thank you.
>>
Thank you for using the traditional Yuki image.
>>
>>54470018
xD
>>
>>54470018
>wants 7 year old tradition to die
kys

A macrokernel for ARM64 written is assembly anon, thinking of making some 3d games for it that use purely the SIMD instructions
>>
I'm learning C++ and i'm doing problems on Project Euler to motivate that. I've noticed that every problem will overflow int and most will also overflow long long int. I made my own class of ints as vectors of digits but its clunky and probably slow so now I just use a BigInt header. Do C++ devs often experience this problem or is my situation rather synthetic
>>
scheme edition
>>
>>54470109
its a common problem in project euler, less so in real life. its not confined to C++, other languages will overflow in similar situations
>>
>>54469966
So my emulator still has a black screen. I created a WebView project on my desktop and it has a black screen too. I have 90 minutes to finish this. I am really pissed off.
>>
Rewriting the Linux kernel in a mix of C and assembly
>>
File: 1351337803079.jpg (20 KB, 236x237) Image search: [Google]
1351337803079.jpg
20 KB, 236x237
>>54469966
>>54469977
>>54469988
>>54470100
>>54470144
I hope thats not a script.
>>
Just started to learn how to use wireshark and that shit is amazing.
>>
>>54470457
Forget to say the rest, What are some good projects I can work on that involve wireshark? I am working in C++.
>>
Any good opengl tutorials?
>>
>>54470472
Try intercepting game packets, perhaps make a simple bot
>>
>>54470472
Implement your own network protocol on top of UDP, play with sockets and write a Wireshark dissector to check the fields of your protocol packets.

Remember: you should not send POD structs through the sockets, since padding and order in the case of bitfields is implementation-defined. Only exchange array of bytes that you may mask then to get the value of each field.
>>
Is =< slower than plain <?
>>
>>54470632
On bad architectures? Yes.
On good architectures? No.
>>
>>54470518
NeHe is super ancient retro antique opengl from the early '00s and '90s but it's still worth going through. You can learn the modern opengl shit afterwards though.
>>
>>54470144
>its not confined to C++, other languages will overflow in similar situations


No, it's pretty much confined to shitty outdated languages like C and C++.
>>
>>54470632
Never seen it. If you are worrying about the performance difference between ja and jae you are worrying about the wrong thing.
>>
What's the rationale behind Python's PEP-8 E731?

> Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier.

Using a lambda conveys that the function is pure, so I always prefer it over def, if possible.
>>
>>54470769
i would figure that jae requires more logic and more processor cycles to evaluate than ja
>>
>>54470775
f = lambda x: print(random.randint(0, x))
>>
>>54470813
Nope. Being greater than and being equal to are computed in parallel by hardware.
>>
>>54470833
Sure, it does not enforce it, but semantically, it conveys that is should be pure. So just don't use it for print & random.

In any case, even if you were to use it for impure functions, what's the argument for forbidding it? PEP-8 does not say?
>>
what do you think about concepts, since gcc 6.1 now supports them.
>>
>>54470813
>>54470862
More specifically, on x86, any comparison is made by subtracting the two arguments, that's where most cycles are spent. The difference between ja and jae is just that ja check the Zero Flag while jae does not. Shouldn't have an impact on performance.
>>
>>54470878
>but semantically, it conveys that is should be pure
I'm still unconvinced of that, especially since this is Python we're talking about.

>what's the argument for forbidding it? PEP-8 does not say?
As written, the argument is just for a slightly better backtrace and "no need for it".

I don't think anyone would shoot you for just using a lambda, but I wouldn't bother with it myself.
>>
File: textboard2.png (164 KB, 1912x919) Image search: [Google]
textboard2.png
164 KB, 1912x919
>>54469966
Making 4chan moot.
>>
>>54470273
Okay, I deployed the app and it works, but I still need to fix the emulator for future work.
>>
>>54470100
What's a macrokernel? A monolitic kernel?
>>
C++ or Java?
>>
>>54471233
Definitely C++.
>>
>>54471233
100% c++
>>
>>54471191
Yes, it's a monolithic kernel.
>>
>>54471233
Java jobs pay better if you're gonna do it for the money
>>
whats a good persistent linux OS i can put on a flash drive and boot "anywhere".
as in i can go to some computer and plug in my flash drive and have it boot from it and have it -persist- so software and files I download or install STAY on the next time I boot up.
>>
>>54471287
What language has the best impact on your sanity for the money.
>>
>>54471313
Java is less nightmare to work with than C++
>>
>>54471302
Puppy Linux
>>
>>54471302
everything but tails.
>>
>>54471323
>>54471313
Oh, sorry, I wasn't the Java, C++ guy. I meant in general.
>>
>>54471302
Driver issues might be a pain. Why not carry portable programs on there? That's what I do.
>>
>>54471365

Depends on you really. Some people hate brackets and love the white space in Python, other's vice versa. Some people like dynamic languages, others don't. It depends on what kind of development you like and what fits in with your 'flow' what will make you the happiest to work in.

I love working in Python but I have a job doing .NET with C# because there's just not a lot of Python jobs where I am.
>>
>>54471233
For what purpose?
>>
>>54471525
For being a programmer
>>
>>54471633
By that criteria alone then both are suited to the task.
>>
>assignment due in <12 hours
>havent started yet
>estimated time to produce is 40-60 hours
>dont feel like doing fucking anything
help
>>
What language should I learn if I want to make 300k/year starting?
>>
>>54471663
Drop out.
>>
>>54471663
Better order a waifu pillow, because you're gonna become neet soon enough.
>>
>>54471730
You need to learn an entire stack, not just one language
>>
>>54471746
>>54471750
i dont want to fail though, i want to be productive
>>
>>54471805
Should have started being productive 40-60 hours ago
>>
>>54471822
i didnt have the will power
>>
What is /dpt/ consensus regarding template metaprogramming?

https://www.youtube.com/watch?v=Am2is2QCvxY
https://www.youtube.com/watch?v=a0FliKwcwXE
>>
>>54471860

Pretty cool, even if it was never intended.
>>
>>54471663
What's the assignment, I'm curious.
>>
>>54471851
>He doesn't have the spark
>>
>>54471985
just some C++ assignment meant to test our knowledge of data structures, testing, etc, fairly dull shit desu

>>54471995
this stuff doesnt excite me anymore, anything C# or C++ bores the shit out of me. the AI modules were fun as fuck, but this stuff is dull by comparison.
>>
>>54471860
it's honestly pretty cool, but I think Jonathan Blow might've made something better: https://www.youtube.com/watch?v=iVN3LLf4wMg
>>
What SO do you guys use in your work machine?
>>
>>54472128

Tbh, I'm a little excited for Blowlang. I don't think it's revolutionary, but it does look nice to write in.
>>
why are ML-like functional languages so based
>>
>>54472165

>SO

I use Felicity Jones.

But really I run Windows on my office computer with Linux Mint in a VM and use OS X with Windows in Bootcamp at home.
>>
>>54472199
desu i dont even know why i like ocaml as much as i do, it's just better than almost everything else
>>54472168
me too. it feels like it'll be sort of an in-between for Rust and C, so that when i dont want all the extra shit Rust adds i'm not limited to using C/C++. although im kinda doubtful about performance at this point
>>
I have no idea why SDL still fucks me over here.
SDL seems to think I still have locked surfaces even after the surface unlocking loop in there.
Looking through the implimentation for SDL_UnlockSurface gives no clues.
http://pastebin.com/NHAm780P

The output goes
 $ ./test
load BMP
blit
Surfaces must not be locked dusring blit
$
>>
>>54471233
C++11/14
>>
>>54471663
>>54472022

No data structures assignment could possibly take 40-60 hours unless it was a fucking term project that lasted the entire quarter/semester. Fuck what you've been told. Make yourself a pot of coffee, because you're going to do this entire fucking assignment in 6-8 hours.

Or at the very least, you'll have a product that can earn partial credit.

>>54471860

An excellent application of black magic.
>>
>>54472326
>struct Window *win = &(struct Window){.win=tmp_win, .surf=tmp_surf};
this shouldnt compile
>>
>>54472353
yeah, looks simple enough, ive just gotta knock up some simple node and relation data structure, a few simple query functions, and write a report on performance testing it
>>
File: 1345747299180.jpg (2 MB, 1475x3548) Image search: [Google]
1345747299180.jpg
2 MB, 1475x3548
>>54472407
Too much fuckery with pointers and "obscure" assignment syntax?
Any sugestions? I'm still new to this.
>>
>>54472445
you are taking the address of a temporary object, which should be an error.
you need to allocate some memory for that struct.

struct Window *win = malloc(sizeof(*win));
*win = (struct Window){.win=tmp_win, .surf=tmp_surf};
return win;


and in destroy_window function you need to free that memory once you are done with it.
free(win);
>>
>>54472440

You sure it was 40-60 hours? Not 40-60 MINUTES?

Because mate, my symbol table took about 12 hours of work this weekend, and a portion of that was spent multitasking, and about a half hour to an hour of that was just spent reading YACC documentation.
>>
>>54472510
I don't even know of an assignment that would take that long, unless he had the entire semester to do it.
>>
>>54472510
im fairly new to C++, so i imagine its for the mistakes im likely to make on the way

>>54472609
well, kinda, im fucking awful for procrastinating
>>
Honestly, is there anything python can't do besides be fast? It seems good at everything
>>
>>54472488
You're a legend mate.
This has been plaguing me since last night.
>>
So /dpt/,

When you start a new project, how much time do you spend prototyping things and identifying data relationships on paper before actually coding the stuff?

Or do you code into your text editor immediately like what most Open Source losers do?
>>
>>54472659
pypy is fast
>>
>>54472693
PyPy is still stuck in 2.7
>>
Any of you nigs do swift and ios dev? I just got hired to work on an ios app and wtf man, xcode is gay as shit. How do people make apps on that shit? Fucking thing kept crashing and maxing out the 1 core it uses and giving me the spinning beachball of death when just doing some trivial auto layout tasks. I have and i7 in my macbook pro so it's not like I'm using a complete garbage system.
>>
>>54472709
Lots of things are still stuck in 2.7, using 2.7 isn't much of a price to pay if you want excellent performance from python.
>>
>>54472709
>implying any good code has been written in python 3
2.7 for lyfe nigga!
>>
Can someone explain why in c++ switch statements with strings isnt allowed.
>>
>>54472689
>how much time do you spend prototyping things and identifying data relationships on paper before actually coding the stuff?

No time, and that's why all my projects are half baked.
>>
>>54472799
What fucking language allows strings in switch statements? Swift?
>>
>>54472819
c# for one
>>
>>54472819

Pretty much all of them designed sometime within the past millennium, thereby excluding C and C++.
>>
>>54472819
D
>>
How my professor teaches algorithms:

1. Go over formal rules of algorithm with abstract examples
2. Maybe give a concrete example in the end

How I learn:

1. See a concrete example of the algorithm being used
2. Figure out the formal rules based on what it appears to be doing
3. Check against the actual formal rules later to get a better understanding of what the fuck we're doing.

>>54472689

Depends on the nature of the project. I typically do a back and forth of jumping into code and reading documentation, and many times I do jump straight into a text editor, if nothing else to get a skeleton framework going.
>>
As far as C++ not allowing strings in switch statements, the branch table is generated the same as in C, which does not have real strings.

Really unfortunate too, because switching on strings is very nifty.
>>
>>54472849
I agree, I can never understand a complex algorithm until I see a worked example.
>>
>>54472799

Same reason you also can't use a switch statement with a float. The intention is to make it easier to create a jump table, which requires integers. Otherwise, whatever you're writing is just going to be syntactic sugar for a bunch of if/else statements.
>>
While we're on the topic of C, make sure you demonstrate to prospective employers that you are a 10X programmer via liberal application of longjmp.
>>
How do I learn C++?
>>
>>54472799
for you.
i was bored
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct foo { const char *str; void *lbl; };
int foocmp(const void *lhs, const void *rhs) {
return strcmp(((foo*)lhs)->str, ((foo*)rhs)->str);
}

int main(int argc, char **argv) {
__label__ sfoo;
__label__ sbar;
__label__ sbaz;

if (argc != 2) return 1;
foo jmp[] = {
{"bar", &&sbar},
{"baz", &&sbaz},
{"foo", &&sfoo}
};

foo tmp = {argv[1], NULL};
if (foo *res = (foo*)bsearch(&tmp, jmp, 3, sizeof(*jmp), foocmp))
goto *res->lbl;
printf("no match\n"); return 1;
sfoo: printf("foo matched\n"); return 0;
sbar: printf("bar matched\n"); return 0;
sbaz: printf("baz matched\n"); return 0;
}
>>
>>54472953
I hope no one actually deploy this in their products
>>
>>54472953
>GNU Extensions

farkin dropped m8
>>
whats the min requirement level for employable status ?
>>
File: filename.png (184 KB, 2500x2000) Image search: [Google]
filename.png
184 KB, 2500x2000
Hi /dpt/, does anyone here have experience with Matplotlib, or more specifically, pyplot, in Python3? I'm doing an assignment for university and I'm having trouble with making a bar chart where the categories line up properly, as shown in the image. I actually suspect it might be something to do with numpy's arrange method. I can provide code on request.
>>
>>54472807
this, my projects ARE the prototypes
>>
whats the most sensible way of splitting a CSV file in C++? id normally split once on newline and for each line again on ',', but it seems C++ has no string split method. i cant use any libraries other than the ones that come with MSVC++ 2013
>>
>>54473163
really low for most companies
hardest part is getting an interview since you need to stand out among the other 300+ people
>>
When copying a file with C++, how do I handle special characters like n with a tilde and what not.
I get
>Vijñāna
to
>Vijรฑฤna
Which is even worse because its rendered as A+A
>>
>>54474061
probably an encoding issue, try using utf-8/16 instead of ascii
>>
How do I split a lookup table across 2+ lines?
Currently, I have a single string literal that's 97 characters long and I'd like to split it in half for readability.
>>
is this sensible?
    //just assume these are good
fstream finPlaces(fileNamePlaces);
fstream finLinks(fileNameLinks);

//compose vector of places
vector<vector<string>> output;
const int buffersize = 255;

while (!finPlaces.eof()) {
//get line
stringstream ss;
char lineBuffer[buffersize];

finPlaces.getline(lineBuffer, buffersize);
ss << lineBuffer;

//compose place vector
vector<string> line;
while (!ss.eof()) {
char wordBuffer[buffersize];
ss.getline(wordBuffer, buffersize, ',');
line.push_back(wordBuffer);
}
output.push_back(line);
}
>>
>>54474171
you can use strings instead of char[]
also some other stuff.
string line;
while (getline(finPlaces, line)) {
stringstream ss{line};
vector<string> lines;
while (getline(ss, line, ','))
lines.emplace_back(move(line));
output.emplace_back(move(lines));
}
>>
>>54474454
could you explain the changes youve made, senpai?
>>
>>54474171
>is this sensible?
>C++
No.
>>
>>54474469
i know man, but an assignment is an assignment, even in a language with no proper fucking string splitting method or function out of the box
>>
>>54474487
Fucked up the whitespace.

>>54474166
Assuming C
char str[] = "abcdefghijklm"
"nopqrstuvwxyz";[/code]
>>
>>54474171
string line;
while (getline(finPlaces, line)) { // store line in `line`, returns false if eof or some other error.
stringstream ss{line}; // initialize streamstream with said line
vector<string> lines;
while (getline(ss, line, ',')) // same as above getline but with , separator
lines.emplace_back(move(line)); // move line to end of lines vector
output.emplace_back(move(lines)); // move lines to end of output vector.
}
>>
>>54474468
>>54474509
whoops
>>
Can someone give me a hand with this? It should be fairly straightforward but I'm struggling.

int degrees = 32;
double minutes = 9.35;


How do I combine these variables to get something like 32.0935? It should also return 32.1035 if minutes was set to 10.35 for example
>>
>>54474533
its C# btw
>>
>>54474533
double val = degrees + minutes / 100
>>
>>54474509
oh rather, streams have an
operator bool
which returns false if there is an error.
>>
>>54474542
thank you, i knew it was something simple
>>
>>54471233
Lisp.
>>
>>54471233
depends

>>54471365
>>54471287
java
>>
How do you catch errors the command prompt throws.
So if system(stuff) fails how do I catch the error.
>>
File: qutesql01.jpg (136 KB, 1373x850) Image search: [Google]
qutesql01.jpg
136 KB, 1373x850
>>54469966
Lightweight QT5-based SQL Manager.

Progress has been slow lately.
>>
>>54474509
does that terminate on eof though?
>>
>>54474632
if you're calling a process, and it fails then it'll return an abnormal exit code and based on that exit code you can know what error it encounters https://en.wikipedia.org/wiki/Exit_status
>>
>>54474650
Look awesome!
>>
>>54474653
ya. trying to read a stream when its at eof sets its fail bit, which makes it return false when converted to a bool.
>>
>>54474650

Looks really fucking slick. What lang?
>>
>>54474726

Dude said QT5, so C++.
>>
File: 85.gif (992 KB, 389x259) Image search: [Google]
85.gif
992 KB, 389x259
>>54469988
>>
>>54474650
That looks really slick senpai.
>>
>>54474739
>QT5 automatically means C++

It's 2015, fella.
>>
>>54474650
Q U T E
U
T
E
>>
>>54474751
muh aliens
>>
>>54474751

Tbh, if you're using a binding, you can probably find something more efficient in the language of your choice.
>>
So I made a really cool program that does the stuff I want. But how do I give it an icon. Furthermore I changed the associated files to open with this program and I want to change their icons as well.
Is this easily done or is it an os dependent programming thing.
>>
File: file.png (35 KB, 608x362) Image search: [Google]
file.png
35 KB, 608x362
Anyone here an expert in computer destoyeering?
>>
>>54474788

Probably, but still, it's worth asking.

>>54474786

Everybody thinks Heaven's Gate were crazy cultists, but they were probably right.
>>
>>54472894
Not really.
There are smarter ways to do things like string switches.
>>
>>54472894
why is that a bad thing
if/else look uglier anyway
>>
>>54474810
>Everybody thinks Heaven's Gate were crazy cultists, but they were probably right.

About what? The earth being recycled or them ascending to hale bopp to hang out with ayy lmaos?
>>
>>54474798
should add its in visual studio for c++
>>
>>54474862
>them ascending to hale bopp to hang out with ayy lmaos?

This part. We are now living in purgatory. I wanted to go on the secret hale-bopp space ship, but I was too young to know.

Wherefore art our ayylmao overlords? I pray their return before I've shuffle'd off this mortal coil.
>>
>>54474891
I see you a lot around these threads, who are you? What do you do?
>>
>>54474952
He's just some filthy racemixer from /o/. You shouldn't take anything he says seriously.
>>
File: gnllab.png (30 KB, 762x438) Image search: [Google]
gnllab.png
30 KB, 762x438
>>54474952
>who are you?

Professional racemixer.

>What do you do?

Design memelangs by stealing ideas from Clojure.
>>
File: shoko-asahara.jpg (33 KB, 400x527) Image search: [Google]
shoko-asahara.jpg
33 KB, 400x527
>>54474810
>Everybody thinks Heaven's Gate were crazy cultists, but they were probably right.

Superior 90's cult incoming.
>>
>>54474997

I don't discriminate.
>>
File: iamafaggot.png (52 KB, 1308x653) Image search: [Google]
iamafaggot.png
52 KB, 1308x653
Okay, so I have two laptops. Both running AMD graphics cards. One running OpenGL 3.1.11653 with GLSL 3.30 and one running OpenGL 3.1.13416 and GLSL 4.40. The shaders I created on the 3.30 laptop won't run on the 4.40 laptop. Can I get some suggestions? I'm not good with portability.

Pic related is one of the shaders. As I said it works on the 3.30 but not on the 4.40. The application itself runs but nothing renders so I am more than certain it is a problem with the shaders. Am I using something that was removed or changed or some shit between those two verions?
>>
>>54475122
since when are float literals supposed to have the f? try removing the f like 1.0 instead of 1.0f. and you can use glGetShaderInfoLog or shdr.bkcore.com
>>
>>54475171
I'll give it a shot.
>>
File: qutesql02.jpg (113 KB, 1373x850) Image search: [Google]
qutesql02.jpg
113 KB, 1373x850
>>54474650
It's in C++.

Hoping to have it stable in about a month.

After that, I want to add tabbing for the table explorer and queries.

Will post here when it's done.
>>
Dicking around with SVMs in python for an uni project.
Glad python has a shit ton of libraries for this kind of stuff
>>
Quick what's your title on your business card? Can't choose between "Guru" or "Ninja"
>>
continue testing
>>
>>54475237
>what's your title on your business card?

Software Engineer & Jewish Racemixing Propaganda Expert
>>
>>54475280
> Racemixing Propaganda Expert
> Jewish
superfluous
>>
>>54475237
>his job title isn't Software Magus

Stay pleb.
>>
>>54475280

I'd hire you for having balls.
>>
>>54475698
The fact that you'd hire someone that tripfags on 4chan is probably part of the reason you'll never be in the position to hire anyone.
>>
>>54475698

Don't be so sure of that. I'm only an expert on the propaganda because I fell for it.

There is no cure.
>>
File: thanks C++.png (49 KB, 2158x201) Image search: [Google]
thanks C++.png
49 KB, 2158x201
wat
ignoring the stupid warning ive created, what on earth is causeing these errors?

static vector<vector<string>> ComposePlacesList(fstream &finPlaces)
{
/*
* iterates through CSV til EOF, composing vector of vectors as it goes along
*/

//compose vector of places
vector<vector<string>> output;
const int buffersize = 255;

while (!finPlaces.eof()) {
//get line
stringstream ss;
char lineBuffer[buffersize];

finPlaces.getline(lineBuffer, buffersize);
ss << lineBuffer;

//compose place vector
vector<string> line;
while (!ss.eof()) {
char wordBuffer[buffersize];
ss.getline(wordBuffer, buffersize, ',');
line.push_back(wordBuffer);
}
output.push_back(line);
}

return output;
}

static vector<Node *> BuildPlaces(vector<vector<string>> placesData)
{
vector<Node *> nodeList;
for each(vector<string> ni in placesData) {
nodeList.push_back(new Node(ni[0], stoi(ni[1]), stoi(ni[2]), stoi(ni[3])));
}
return nodeList;
}


calling function
bool Navigation::BuildNetwork(string fileNamePlaces, string fileNameLinks)
{
fstream finPlaces(fileNamePlaces);
fstream finLinks(fileNameLinks);
if (finPlaces.fail() || finLinks.fail()) return false;
// Add code here
// todo: refactor into a BuildNodeFactory

vector<vector<string>> placesData = BuildNodeFactory::ComposePlacesList(finPlaces);
vector<Node *> places = BuildNodeFactory::BuildPlaces(placesData);

return false;
}
>>
>>54475122

Target ONE OpenGL version (3.1 for example), you can set the opengl version during context creation.
Then write all your shaders in the corresponding shader language.

They should work even if you have a newer version opengl. As long as you create a opengl 3.1 context.

Also don't use if statements in shaders if you don't have to.
>>
>>54475938
This is a prime example of why c++ is shit and you should stick to C
>>
>>54475951
i know man, but deadlines and shit
>>
>>54475938
"for each" isn't written like that in C++.
And you need to qualify your static functions:

ComposePlacesList should be
BuildNodeFactory::ComposePlacesList

in your first snippet, if it's a static method of BuildNodeFactory.

lrn2c++
>>
>>54475938
Also, if BuildNodeFactory is actually a namespace, then the static keyword shouldn't be there, since it won't be linkable.

Actually, the static keyword should be only in the class declaration, remove it from the definition.
>>
>>54475944
I'm kind of noob when it comes to portability.

So do I just set major to 4?
        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,1);
glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_ANY_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT,GL_FALSE);
>>
>>54475944
you still need to get the shader code right, implementations vary a lot, and some can allow things that are not part of the standard, so if it works on your machine it might fail on other machines
>>
>>54476008
>>54475992
sorry, ive been up a while and im being retarded
i basically just want a factory class
>>
>>54476018
Try setting GLFW_OPENGL_PROFILE to GLFW_OPENGL_COMPAT_PROFILE
A core profile removes all pre 3.3 stuff.
Though opengl should create a compatibility profile by default iirc but like >>54476043 said, implementations might vary.


Also, Do you output errors when you compile and link your shaders?
>>
>>54475951
>stick to C

Where string manipulation is even more onerous.
>>
>>54476081
Not if you know what you're doing.
>>
>>54476091
>Says the person who took a dump on C++ for being confusing
Not if you le know what your doiong.
>>
>>54476099
>confusing
But C++ legitimately is a fucking mess. I'm saying this as a lifelong C++ programmer who switched to C for personal projects after years of C++.

C strings might indeed be a little more error prone if you're not paying attention, but everything is still straightforward and easy to understand.

A string type in C would indeed be on top of my C wishlist, but it's not worth using C++ for imho.
>>
>>54476125
>A string type in C would indeed be on top of my C wishlist
Yeah, that's probably never going to happen, at least in standard C. It doesn't really 'fit' with the rest of the language, and the C standard committee tries to avoid duplicated functionality.
>>
>>54476164
I know
>>
>>54471302
Porteus
>>
>>54476055
Okay I tried that as well as changing all the operators to straight up assignments rather than +/- assignments. Also the infolog is returning 0. For all intents and purposes this shit should work, but it doesn't.

Also I made it with MinGW on Windows 7 and am trying to get it to work on 8. Earlier applications I made work on the Windows 8 machine but have bare bones shaders that basically do nothing but straight up render what is passed to them.
>>
>>54474650
>>54475208
Looks really nice.

That being said, I'd never trust a 3rd-party SQL manager unless it was already super vetted, like SQL Yog.

I'm curious to see how yours works as far as GUI goes. Is each tab a separate connection?

If so, why is there only one query tab per connection?
>>
>>54476125
>everything is still straightforward and easy to understand.

Sure, that's why things have to be deprecated every once in a while when someone realizes they're awful.

Enjoy your strtok, I guess.
>>
>>54474805
>babby's first fork bomb
>doesn't affect *nix

1/10, see me after class.
>>
>>54476209
Honestly I have no clue. The only thing I can think of is that it doesn't support older opengl versions which would be EXTREMELY odd.
You could try an opengl 3.3 context and glsl 330 shaders.

Why are you going for opengl 3.1 anyway? It's an odd version to support anyway. People usually either support 2.1, 3.3 or a later version if they need certain features.
>>
>>54476273
Those are just the version that are on these two machines.
>>
>>54476315
No, you say you have glsl 3.3 on one machine. That corresponds with opengl 3.3
Meaning you can support at least opengl 3.3.
>>
cocks
>>
>>54476257
>Sure, that's why things have to be deprecated every once in a while when someone realizes they're awful.
Everybody knew that gets() was awful the entire time. They just had to standardise it because it was common at the time.

C string handling is much nicer if you allow yourself to use non-standard functions (particularly those from POSIX), but even then, it's not terribly difficult to implement good C string handling yourself,
>>
>>54474891
>Wherefore art our ayylmao overlords?
If you were attempting to mimic Juliet's quote in R&J, 'Wherefore' is actually used as 'Why?'

As in, "Why are you Romeo?", lamenting the fact that he was a Montague.

>>54475938
What is this code supposed to accomplish?

My hunch says you're just retrieving data from a CSV, but surely it's not that complicated in C++, right?
>>
>>54476333
Not according to glGetString.
OPENGL VERSION: 3.1.11653 Compatibility Profile Context
COMPANY: ATI Technologies Inc.
RENDERER: ATI Mobility Radeon HD 4200 Series
GLSL VERSION: 3.30
>>
>>54476339
ive been up for 25 hours and i skipped most of my lab work, it aint hard, im just bordering on braindead and going off what i can remember from lectures
>>
>>54476354
Because you set GLFW_CONTEXT_VERSION_MINOR to 1.

If you specify nothing you get the highest version available on you machine.
Try setting GLFW_CONTEXT_VERSION_MINOR to 3.
>>
>>54469966
Math expression parser.
>>
Nim seems like everything I want in a programming language. Is it too obscure to be of any real use or is learning it worth it.
>>
File: 1344368028629.jpg (102 KB, 450x442) Image search: [Google]
1344368028629.jpg
102 KB, 450x442
>Year of the God Emperor of Mankind MMXVI
>still no support for enums in SQL
>>
File: tls.webm (3 MB, 854x480) Image search: [Google]
tls.webm
3 MB, 854x480
/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA).

>>54475951
>>54476091
reproduce this in C

#include <iostream>
using namespace std;

string cat(string a, string b)
{
return a + b;
}

int main()
{
cout << cat("123","456") << endl;
return 0;
}


https://ideone.com/YeF8H8
>>
>>54476459
Just a warning Nim unstable as fuck and has a ton of gotchas.
>>
>>54476491
Thanks man.
>>
>>54476385
Is that what you're doing though?

Just reading data from a CSV?

I know you're in a C++ class, but that's a one-liner in C#.

var data = ReadAllLines(@"C:\temp\Faggotry.csv").Select(row => row.Split(','));


I'm curious if the C++ solution is much simpler.
>>
>>54476480
By reproduce, I assume you mean write a program which exhibits the same external behaviour.
#include <stdio.h>

int main()
{
puts("123456");
}
>>
>>54469966
Implementing file system(ext2 subset) for a simple self-made OS.
>>
>>54476525
yes

i know, however C++ hates convenience, so i have to parse that shit manually it seems
>>
>>54476531
Try the webdevs.

>>>/g/wdg
>>
>>54476563
Oh, thanks. I missed that thread.
>>
File: ano.jpg (250 KB, 1200x1350) Image search: [Google]
ano.jpg
250 KB, 1200x1350
>>54476550
no
>>
>>54476575
xD
>>
>>54476550
Do this, then.
#include <iostream>

using namespace std;

string cat(string a, string b)
{
return a + b;
}

int main(int argc, char **argv)
{
if (argc == 3)
cout << cat(argv[1], argv[2]) << endl;
}
>>
File: 1407143717153.jpg (105 KB, 328x495) Image search: [Google]
1407143717153.jpg
105 KB, 328x495
>>54476575
>A valid solution is offered
>Reject it because you're a fucking idiot who didn't phrase the question properly
You're one of the worst posters in this thread.
>>
Who const nazi here?
>>
>>54476477
How would that work?
>>54476563
.boardBanner {
position: fixed;
}

>>54476600
Heil!
>>
>>54476592
#include <stdio.h>

int main(int argc, char *argv[])
{
if (argc == 3)
printf("%s%s\n", argv[1], argv[2]);
}

I don't know why you're bothering with your pointless cat function.
>>
>>54476597
>Interpret question however you want
>YOU DIDN'T FRASE IT CORRECTLY, HERE IS SOMETHING THAT DOES SOMETHING ELSE ENTIRELY BUT PRODUCES THE SAME RESULT THEREFORE IT'S THA SAME
>>
>>54476616
>BUT PRODUCES THE SAME RESULT THEREFORE IT'S THA SAME
Yes?
>>
>>54476600
I just can't forgive that const isn't default.
You should signal mutability, not the other way around.
>>
>>54476477
>enums in SQL
?
>>
https://play.google.com/store/apps/details?id=eu.depa.captionr

Mine
>>
File: 1429377768083.jpg (15 KB, 225x225) Image search: [Google]
1429377768083.jpg
15 KB, 225x225
>>54476600
I literally never use const
>>
>>54476625
You're right. Okay I'll make a more efficient program in C++.
#include<iostream>
using namespace std;

int main()
{
cout<<"123456";
}

There you go. It doesn't do what the original program did but who gives a shit, it produces the same result. I win.
>>
>>54476625
Do you not know the difference between a process and state function?
>>
>>54476629
Given that C++ is old as shit, I'm just grateful they added it.
>>
>>54476650
>it produces the same result.
It's missing the newline.
>I win
Win what? Was there supposed to be some sort of competition?
>>
>>54476480

// assumes valid c strings and that buf if big enough
void cat(char *buf, char *s0, char *s1)
{
char tmp;
size_t ind = 0;
while(tmp = *s0)
*(buf + ind++) = tmp;
while(tmp = *s1)
*(buf + ind++) = tmp;
*(buf + ind) = '\0';
}

int main(void)
{
char s0[4] = "123";
char s1[4] = "456";
char buf[7];
cat(buf, s0, s1);
puts(buf);
}

>>
>>54476669
The aim of the original program wasn't to just produce "123456" by any means you fucking sped.
>>
>>54476597
i never said anything about output, i asked him to "reproduce this" where "this" is the code.
>>
>>54476480
#include <stdio.h>
main(){return puts("123456");}
>>
>>54476612
>formatted printing for a simple format

Disgusting.

But you make a point, I shouldn't have based off his example.
The obvious thing is that I can't ask you to reproduce a program, since you can just extract its external behavior and reproduce it.

rewrite instead the cat function with char * instead of string, note that the parameters are mutable copies, you can use the stdlib of course.
>>
>>54476678
>>54476693
If I am going to reimplement a program, why do I have to stick to the horrible design decisions in the original? All that matters is that the output is the same.
>>
>>54476699
Mine is shorter. I win.
() => "12345\n"
>>
>>54476722
>>formatted printing for a simple format
>Disgusting.
Format strings is way fucking better than meme++ streams. There is a reason why pretty much every language besides C++ uses format strings.
>>
>>54476729
>12345
>>
>>54476673
lel, wtf
>>
This thread made me realize that I will never again willingly choose to program in C or C++.
>>
What is the API for fuuka archives like rbt.asia?
>>
>>54476629
>You should signal mutability

>You should literally prefix all of your declarations with "mutab" except for a few of them.
>>
>>54476740
Printf is an equal part of c++ alongside streams.
>>
>>54476812
If the vast majority of your state is frequently changing, you are doing it oh so wrong.
>>
>>54476480
<code>
#include <string.h> /* memcpy() */
#include <stdio.h> /* printf() */
#include <stdint.h> /* uint*_t */
#include <stdlib.h> /* malloc() */

char *cat( const char *a, const char *b )
{
uint64_t len_a = strlen( a );
uint64_t len_b = strlen( b );
char *ret = malloc( len_a + len_b + 1 );
memcpy( ret, a, len_a );
memcpy( ret+len_a, b, len_b );
ret[ len_a + len_b ] = '\0';
return ret;
}

int main()
{
printf("%s\n", cat("123", "456") );
return 0;
}
</code>
>>
>>54476747
:^)
>>
/g/ what are your thoughts on Firebase for mobile apps (beyond all the troll and meme replies)?
>>
>>54476837
Nice code tags, nerd.
>>
>>54476722
Lets add an obscure C feature.
#include <stdio.h>
#include <string.h>

void cat(const char *s1, const char *s2, char out[static strlen(s1) + strlen(s2) + 1])
{
while (*s1)
*out++ = *s1++;
while (*s2)
*out++ = *s2++;
*out = '\0';
}

int main()
{
char s1[] = "123", s2[] = "456";
char buf[strlen(s1) + strlen(s2) + 1];

cat(s1, s2, buf);

puts(buf);
}


>>54476824
C++ users encourage you not to use it, despite the fact that the C stdio is clearly better.
>>
>>54476848
I've been seriously considering a Firebase + FireSharp + Xamarin solution for a while.

It's certainly an easy way to let someone else deal with all of the little 'gotchas' of DB I/O.
>>
>>54476854
>gnu extension
>obscure c feature
>>
>>54476854
not equivalent.

C++ strings are movable, your solution doesn't exhibit this behavior, since your string is allocated on the stack.
>>
>>54476878
my potential setup is
NativeScript on Node.js + Firebase

was learning Java then heard of NS and now checking it out. thinking NS + FB = smooth dual/tri/quad deployment.

what is still unclear to me is whether i need to write in js or angular2 or both.
>>
>>54476889
>gnu extension
It's not a GNU extension.
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1570.pdf
>6.7.6.2 Array declarators
>Page 131
It's right there in the grammar. I can't really be bothered finding the semantics though.

>>54476900
>since your string is allocated on the stack
My string can be allocated wherever it wants to be.
User-supplied buffers are a much better idea than handing a new one back. It's far less restricting.
My version is better because it CAN have automatic lifetime, while yours can't.
>>
>>54476937
touché
>>
>>54476854
warning: ISO C90 does not support ‘static’ or type qualifiers in parameter array declarators [-pedantic]
>>
>>54476673
>>54476837
>>54476854
those are really shitty compared to c++, you have to manage the lengths of the strings by yourself, you have to manage the output size or rely on dynamic memory, you have to parse the strings, ... the complexity of the code is definitively much higher than with c++.
>>
>>54476971
use c11 gramps.
>>
>>54476971
Mate, the current standard is C11. Get with the fucking times.

>>54476982
>you have to manage the lengths of the strings by yourself
>you have to manage the output size
Not hard. Also, the function doesn't give a fuck about the string lengths, only that the output is big enough.
>rely on dynamic memory
No? My code doesn't use dynamic memory. Also, what do you think std::string uses?
>you have to parse the strings
There is literally no parsing going on in my code.
>the complexity of the code is definitively much higher than with c++
A fucking array copy is hardly 'complex'.
Here is a slightly nicer version for you then.
void cat(const char *s1, const char *s2, char out[static strlen(s1) + strlen(s2) + 1])
{
sprintf(out, "%s%s", s1, s2);
}

I have now hidden the complexity behind a function.
>>
>>54477031
>use c11 gramps.
>>54477034
>Mate, the current standard is C11. Get with the fucking times.

your code is not portable. period.
>>
>>54477049
>your code is not portable. period.
It's portable to any C11 compiler. My program doesn't rely on any implementation defined behaviour.
Your shitty C89 code isn't portable to my strict C11 compiler.
Thread replies: 255
Thread images: 27

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.