/dpt/ - Daily Programming Thread

Previous thread: What are you working on, Cred Forums?

Other urls found in this thread:

stackoverflow.com/questions/12953127/what-are-copy-elision-and-return-value-optimization
docs.python.org/3/contents.html
docs.python.org/3/
learnxinyminutes.com/docs/python3/
wiki.python.org/moin/BeginnersGuide/Programmers
edx.org/course/introduction-programming-java-part-1-uc3mx-it-1-1x-1
udemy.com/java-tutorial/
gcc.gnu.org/onlinedocs/gcc/Link-Options.html
tu-braunschweig.de/Medien-DB/sec/pubs/2016-ccs.pdf
opengl-tutorial.org/
twitter.com/NSFWRedditGif

do you use a virtual machine to set up a dev environment for each project?

No. Only reason to use a virtual machine is if you're developing for another ISA or Operating System than you're developing on, or if you're developing malware.

you wouldn't want to have a clean installation for each project?

How often is this actually needed?

Something fucky is going on with my Windows install, but I don't feel like reinstalling.

Install Linux. Any Linux.

Reposting from old thread:
Haven't done much on my Chip-8 compiler for a while. Talked to my programming instructor recently, and he gave me advice that's actually reasonable and helpful. Just finished a very basic implementation of checking the symbol table (only checking so far, verifying code validity).

Errors still print as if on line 0 because I forgot to keep track of each tree node's line in code. Should be an easy fix.

I'm going to [spoiler]Install Win10[/spoiler] once I upgrade to a [spoiler]6700k and 1080[/spoiler].

I am sorry, Ruby.

This is truly shameful.

>his OS isn't werking
>tells him to install an OS that doesn't werk

no. i develop for windows, but i use a VM because i prefer using linux for actually writing the code.

>Only reason to use a virtual machine is if you're developing for another ISA
why would you do that? cross-compilers exist, you know

oh, you use windows, nvm

I'd just like to interject for a moment. What you're referring to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.

Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called "Linux", and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.

There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called "Linux" distributions are really distributions of GNU/Linux.

Help me, Cred Forums. I'm building a Pascal compiler using Haskell. Currently I have to decide on the AST data structure design. The root node contains an Identifier, which holds the name of the program, but there can be additional optional Identifiers as well. Should the root node look like this:
data AST =
Identifier String |
Program AST Maybe AST |
....


Or more like this:
data AST =
Identifier String |
Program [AST] |
....

Hi there!

You seem to have made a bit of a mistake in your post. Luckily, the users of Cred Forums are always willing to help you clear this problem right up! You appear to have used a tripcode when posting, but your identity has nothing at all to do with the conversation! Whoops! You should always remember to stop using your tripcode when the thread it was used for is gone, unless another one is started! Posting with a tripcode when it isn't necessary is poor form. You should always try to post anonymously, unless your identity is absolutely vital to the post that you're making!

Now, there's no need to thank me - I'm just doing my bit to help you get used to the anonymous image-board culture!

I'm not saying you're going to be doing the compiling in the virutal machine, just the testing. Like if you're developing the Linux kernel for PowerPC. Chances are, you're going to be developing on an x86 machine (because every PowerPC machine these days is either an old Mac, or a $10k+ mainframe), so the best way to test the kernel would be in a virtual machine.

Unless you're developing something like drivers, use Wine if you want to develop Windows applications on Linux. It's a bit more convenient than a VM.

Hi there!

You seem to have made a bit of a mistake in your post. Luckily, the users of Cred Forums are always willing to help you clear this problem right up! You appear to have used a tripcode when posting, but your identity has nothing at all to do with the conversation! Whoops! You should always remember to stop using your tripcode when the thread it was used for is gone, unless another one is started! Posting with a tripcode when it isn't necessary is poor form. You should always try to post anonymously, unless your identity is absolutely vital to the post that you're making!

Now, there's no need to thank me - I'm just doing my bit to help you get used to the anonymous image-board culture!
i use a Linux VM on a Windows host, though

That's retarded. Just use MinGW on Windows.

MinGW barely supports anything

I want to learn programming faster Cred Forumsuys. I know Java, PHP(rusty), bit of Python and a bit of Pearl.

I am currently learning C++ and R at uni. It's all going too slow if you ask me. Got any exercises or something?

why not allegro?
I've heard people saying that it is fast.

You're cross compiling from Linux for Windows. You've been using MinGW, because VC++ doesn't run on Linux. Also, MinGW supports C11, VC++ doesn't. Strictly speaking, MinGW > VC++ for standards compliance.

>You've been using MinGW, because VC++ doesn't run on Linux
not the other user, but I've made VC++ (8 or 9 IIRC) run on wine. I simply copied the binaries from windows to the respective wine folder...

hi hello c# people

I have a base class with a method that does things() and I want to add more steps to things() in its derivatives without overriding the steps things() already is doing. What can I employ to achieve this?

What is the easiest parser to implement for the grammar of simple logical expressions?

A => A || B
A => B
B => B && C
B => C
C => -D
C => D
D => (A)
D => id

why on earth would your host be your testbed and your VM be your development area?

create a new method in the base class that things() can call which does nothing and is protected. Then override that in the child classes with what you want to do.

class A
{
public void things()
{
// do stuff

extraThings();
}

protected virtual void extraThings()
{

}
}

class B : A
{
protected override void extraThings()
{
// do extra stuff
}
}

perfect, thank you user!

Why would anyone run wine in a Linux VM on a Windows host though?

or you can just do this

public class Foo
{
public virtual void Things()
{
// stuff
}
}

public class Bar : Foo
{
public override void Things()
{
// more stuff

base.Things();
}
}

oh, it was an out-of-context answer. I'm , and as you could be able to tell, I'm sleepy and not making sense already...

Sorry, first one should be:
data AST =
Identifier String |
Program AST Maybe [AST] |
....

You guys ever just do something and in your mind you're just thinking 'this shouldn't work', but you're desperate.

So what's the power level difference in terms of speed between c++ and el python?
Bonus points if you have data science or ml experience and used pandas.

>I'm sleepy and not making sense already
I can understand the feeling. Try not to stay up too late.

...

Trying to write a SMILES (simple molecular input line entry system) parser in F#.

Why won`t VS2015 recognize my Bond type in my namespace??

Object-oriented programming is popular in big companies, because it suits the way they write software. At big companies, software tends to be written by large (and frequently changing) teams of mediocre programmers. Object-oriented programming imposes a discipline on these programmers that prevents any one of them from doing too much damage. The price is that the resulting code is bloated with protocols and full of duplication. This is not too high a price for big companies, because their software is probably going to be bloated and full of duplication anyway.

Object-oriented programming generates a lot of what looks like work. Back in the days of fanfold, there was a type of programmer who would only put five or ten lines of code on a page, preceded by twenty lines of elaborately formatted comments. Object-oriented programming is like crack for these people: it lets you incorporate all this scaffolding right into your source code. Something that a Lisp hacker might handle by pushing a symbol onto a list becomes a whole file of classes and methods. So it is a good tool if you want to convince yourself, or someone else, that you are doing a lot of work.

Here's a rare pepe.

Beginner programmer, how would I optimize this for speed?


#include

// Finds the largest prime factor of a number

int main()
{
long long int a = 600851475143, b = a - 1, i;
// Begins the loop
printf("Working...");
while(b != 0)
{
if(a % b == 0)
{
// Begins checking if it's prime
printf("Checking %lli...", b);
for(i = 2;i

i think types begin with lowercase

True, unless you`re doing simulations programming which is why OOP was invented in the first place. Why do you think SIMULA is called SIMULA?

Perl is very comfy. Love it

Format your code properly and maybe then I`ll read it.

How do I change the directory that a CodeBlocks project uses?
Not the save directory, but where it looks for the include and lib folders and stuff.

Why is C#/.net missing?

>goto

going through k&r, on the arrays section
I don't understand this particular part in the code
if (c >= '0' && c

>Muh goto is bad guys
>That's what someone at stack exchange told me

It's the only to break from a nested loop in C/C++

Because '0'!=0, but if c='0', we have c-'0'=0, placing it at the first location of the array (etc.)

k tard

c is an ascii character. The ascii character '0' is actually equal to 48.
The ndigit array is only 10 ints long, so ndigit['0'] (read ndigit[48] would be an illegal operation.

because, '0' is the ascii value for the digit 0, and c is the char.

since ascii numerals begin somewhere around 40 or 50, you need to "offset" it by that amount, so that the index is in the range [0,n]. hence, if c==0, c-'0' == 0, if c==1, c-'0' == 1, etc.

>t. Pajeet

er, i should have said, if c=='0', c-'0' == 0, if c=='1', c-'0' == 1, etc.

i see now
thanks

What data structure and algorithm do you use to keep 2 trees in sync, that support insertion, deletion and modification?

Picture two trees of browser bookmarks as an example, that are synchronized aperiodically.

wtf I hate pajeets now

Sounds a bit like git, but instead of files trees

You will essentially need a three way merge as you can't know whether a bookmark A has but B doesn't was created by A, or removed by B, without an older, common parent.

>whether a bookmark A has but B doesn't was created by A, or removed by B
What if one stores every action, i.e. creation and deletion, with a timestamp and UID?

Global settings are in Settings/Compiler/Search directories. Per-project settings are in Project/Build options/Search directories.

Search directories is empty though!
It should say something, if it's already looking somewhere, right?

Reading on c++14 and optimizations...
Meh, im not sure how i feel about it...
Good thing is return by value is optimized so no need to return & or *...

But freaking setters and constructors now need rval overload

class A {
private:
std::string foo;
public:
//so same as in c++98
void set_foo(const std::string foo);
//but now i need to write rval setter as well for temp objects
void set_foo(std::string&& foo) noexcept {
this->foo = std::move(foo);
}
};

yes

well if it just ends up writing a
this->foo = std::move(foo);
inside the class i am happy with it, it means cleaner code

>Good thing is return by value is optimized so no need to return & or *...
how?

help
I tried fixing it manually but it caused my c file to change into a cpp file and it doesn't want to change back

stackoverflow.com/questions/12953127/what-are-copy-elision-and-return-value-optimization

Python is one of the slowest languages around and it gets slower as time goes on.

allright thanks for the input, i still have to learn python and pandas for a class i am taking, does anybody have a source for learning python made for someone wich can already program?

Learn one language at a time. Easier and you learn more.

you're aware that reyling on this means you don't understand the performance of your program, right?
that optimization isn't done everywhere.

docs.python.org/3/contents.html

>C++
>clean

Python is a rather bloated language. Its syntax is rather simple though, once you learn the basics of the language you really only need the manual so you can find what functions to use.

I can't think of any tutorials off the top of my head.

youre aware that he was asking what it was, not whether it should be relied on, right?
people should think before they write.

I have decided to try a PureScript. The first line of HelloWorld example I see:
ui :: forall g. (Functor g) => Component Unit Input g
Oh god, the Haskell-et-al community is a caricature of itself.

Getting into android development.
What should I build first?

>you learn the basics of the language you really only need the manual so you can find what functions to use.
You're talking about java.

docs.python.org/3/

Python has a million goddamn functions.

you are confusing the programming language with its implementations.

>Python is a rather bloated language
not really.

learnxinyminutes.com/docs/python3/
wiki.python.org/moin/BeginnersGuide/Programmers

You are confusing the python programming language with the python standard library.

Alright, that's fine now, but I still have the problem that I want to change it to look for files in a folder of a different name.

Java too.

allright boys, thanks have a good sunday

No, that's retarded and a waste of resources.

Are you employed?

Its pretty much only that. Also guidelines highly recommends usage of auto. Which is kinda cool since it avoids silent casts (cast always incurs a copy) Another cool thing is auto f = whatever; wont ever(almost) copy. While Usertype foo = f() can.

macOS does not have this problem.

If you are using win10 i recommend ltsb version. Its so much better.

Yep.

>It's the only to break from a nested loop
there are different ways to break from a nested loop
create a function, not the whole code must necessarily go in the main, you can also use flags to prevent that or even you could use recursion instead

A function or recursion would bring unnecessary overhead.
This is the way faster option.

Compilers do in fact optimize tail recursion. This is not java...

I need to decide how I move forward.

I learnt C quite well, but quite a few years ago now.
I learnt the basics of Java, but never really got my head round it.
I want to learn iOS/Android dev.

Do I brush up on my C first? Do I just find an app development course to work through?

The largest prime factor of a number is going to be at most sqrt(n). You don't need to check numbers bigger than that.
You don't need to check any even numbers besides 2, as it is the only even prime number.
Otherwise prime factorisation is actually a really hard problem, and any implementation is going to take ages.

The main argument against goto is that it makes the program flow much more complex.
But wouldn't you say that in this particular case the goto is actually more readable than having to write a recursive function?

I didnt say anything about that. I adressed claim that recursion is slow. I dont mind goto in C in some cases.

Something like a log structure. Sure, it would work. You can then replay the actions and end up with what you started with.

Nice

> MinGW
vomit.jpg

No, don't do that. Go virtual ffs.

I want to learn Java from scratch. I've only done C so far. What are the most important books/manuals I should study?

Also found this free course on edx, does the syllabus look any good? Any courses you would recommend? Or would you recommend just sticking to manuals?
Any help would be greatly appreciated. Thanks lads.

I have a project which contains its include folder inside this folder.
However, I want to rename the folder.
How can I rename the folder yet still allow the project to find it?

Don't do manuals, use them for reference. Do a course.

What do you think of Haskell?

i would like this except over the course of a week and replace java with php

i've been an active c++ and c# developer for like six years if htat helps
also i'm a drunk if that helps

Then suggest a course please?

I find learning OOP to not make much sense before you have tried to create any non-trivial program, and you end up with fruits and animals inheriting from base classes, which isn't very illustrative.

That guy who replied rudely wasn't me.
I would appreciate a course if you did know one though.

edx.org/course/introduction-programming-java-part-1-uc3mx-it-1-1x-1
it says it's a 35-50hr course

This one on udemy seems interesting
udemy.com/java-tutorial/

Thoughts on this then?
udemy.com/java-tutorial/

You can't really do Java without OOP.

i think you may have responded to the wrong user as i am the user who is asking for immediate help with PHP(NOT JAVA(i made a typo several times and have to remind my self to correct it))and has a background of being a competent developer in c-like langauges

If you would be so kind as to help me find a tutorial that is good, aside from the ones that I found via google and the worlds 'php tutorial' and 'php tutorial documentation implementation'

thank you for your time and i hope you have a constructive day

I'm pretty sure that's you, I've only replied to posts that had replied to my post in the first place.
Can't help you with any of that though, sorry

that's okay user i still love you

plz help
I can't find info on what to do anywhere

close the application
rename the folder
if you added the root directory as your project folder than the application will just read all of the folders in there already

What I need to know how to do is to change the root directory.

Why would anyone use code blocks? On windows you have visual studio which is pretty much best ide and on linux you can have better feauteres even wit vim and plugins...

What should I learn for practical projects/uses: F# or Haskell?

detail: I'm on arch linux

FOSS

>detail: I'm on arch linux

You're a meme.

Clojure

Except it's pretty much just like using any other distro, only that I get AUR and others get something else.

Your starbucks coffee is getting cold, macfag.

kill yourself

...

>(you)

Neither but I'd lean towards F# if I had to choose because it's backed by multi billion dollar company so it's more likely to have any traction in the business at all.

just so you know, the fox and the grapes is really a metaphor about a depressed person who lacks the will to kill himself because it would be too much work, despite severe depression and desire to die

Nope, it's a fable about how user is too stupid to make things work. See

return value optimization was already a thing before rvalue references and move semantics, but now move semantics can apply often even in cases where RVO wouldn't happen, and compilers do it automatically (xvalues/rvalues are always returned by move, lvalues are returned by move if possible, etc)

>But freaking setters and constructors now need rval overload
>but now i need to write rval setter as well for temp objects

fortunately, this is not actually the case. a const reference parameter can take an rvalue reference, and it will be moved automatically. returning an rvalue/xvalue will move automatically. the compiler will automatically generate and use move constructors and assignment operators for trivial types. the only times you really need to explicitly use an rvalue reference parameter is if you want a function to behave differently when supplied with an rvalue reference as opposed to an lvalue reference (which doesn't come up much), or when explicitly defining a move constructor or assignment operator for a nontrivial type. and you rarely need to explicitly invoke std::move(), too; really just in nontrivial move constructor/assignment operators, or when you want to move an object mid-scope like

foo a;
...
foo b = std::move(a);
...


which is for the best, because move constructing b from a invalidates a, which isn't something you should be able to do by accident, and the semantics help to make it more clear what's happened to a, which is now still in scope, but invalid. anyway, the nice thing about move semantics and the new value classifications is that they give even more precise control *when you need it*, but in average code you generally don't have to worry about them because a lot of shit is just automatic. most code looks the same as it did before

VS Community demands you register a fucking microsoft account.

CodeBlocks allows you to work with the MingW toolchain, which is nice if you're working cross platform.

VS IntelliSense is really nice though.

So if web dev is for Pajeets, and software dev is for cucks, then what area is there left for a non-cucked westerner, where you can make decent money?

Embedded systems

Ooh thats great to know, i figured id have to add move operators for all my custom types...

I use it without ms acc, its optional as far as i can see. What about clion, uses mingw and cmake and has much better intelisense than codeblocks

>I use it without ms acc, its optional as far as i can see

IIRC it's optional for the trial period (30 days), after which you'll have to get an MS account for the Community edition. Memory could be serving wrong though.

networking is for cucks of the nsa, embedded systems and by extension electrical engineers are cucks of software devs (or marketing or the general public etc), it's cucks all the way down until you hit pure maths in which case you'll be a cuck to not finding a job

just pick what you want but if you want a "pure" field then pick electrical engineer and design bitching hardware for decent architectures

so everyone is a cuck?

How do header files know what library file to look for?
glfw.h needs libglfw.a, but libglfw is mentioned nowhere in glfw.h

Yep, this.

Weird, third time I've gotten a 33 get in this thread.

Header files don't care about library files.
Header files are essentially just a bunch of declarations.
It's the responsibility of the linker to make sure the implementations become available during the compile process.

in their own right but some people are less cucked and other people do more cucking to others

oh my fucking god how do I get GLAD to work
If I don't link glad.c, no matter where glad.c is; include, lib, src; I'll just get an undefined reference error for a GLAD function.
If I do link glad.c, no matter where glad.c is it'll say it can't find glad.h, which is sitting right where it should in include/glad/glad.h

-lglad

In what universe does that constitute a meaningful answer?

yeah, i had the same worries when i first learned about it, but i've since come to understand that c++ compilers are much smarter than people give them credit for. don't worry about move semantics at all for simple trivial/compositional types, because the compiler-generated semantics will work. and if you derive from or include as a member a type that has deleted move semantics, they won't be generated for your type, at which point you can explicitly define them if you want (make sure you do it correctly if you do) but you're certainly not required to (it's usually not that big of a deal anyway; copies aren't as expensive as people think, and funny enough, RVO often still applies, so having no move semantics doesn't even necessarily mean a type will return by copy). and some types just conceptually shouldn't be copied or moved, in which case you can delete copy or move constructors and assignment operators in order to enforce logical restrictions on the use of your type. unique_ptr, for example, can be moved but not copied (for very sound reasons)

-Ipath_to_includes

(that's a capital eye, not ell)

In mine universe. And I'm sure it's the correct answer.

You need to read up on how to use your compile chains linker.

That's the flag to link glad with gcc.

You use the wrong operating system, have you tried using
GladOS

Clang vs G++?

For windows here.

Everything I can find though suggests that it's a trivial process to get it working.
It's almost certainly something trivial that I've missed, rather than something well beyond my current understanding of C.

>glfw

Let's say your folders are like this:
src/
main.cpp
include/
glad/
glad.h

And you want to include glad.h from main.cpp.
You add -Iinclude (capital eye) to the makefile, and you'll be able to use #include in main.cpp (which should solve the second problem you posted).

What the other user posted () will also work if you compile and install glad as a system library.

Pick your poison.

GLFW is hella nice.

gcc.gnu.org/onlinedocs/gcc/Link-Options.html

(The first solution is also assuming that your makefile is located in the folder above src and include)

>GLFW is hella nice.
No. It's fucking useless and poorly designed.

What do you use then?

I wish my folders looked like that, with everything under the same root directory.
Unfortunately there is no fucking documentation telling you how you change your folder structure in CodeBlocks; I've got one folder with the project file and the main.c file, and one folder (that I can't even rename) with everything else.

Also, I presume I'm already including glad.h correctly; given that it makes a difference if I don't include it. My problem is with glad.c.

So you'd rather waste time and reinvent the wheel by implementing platform specific window, context and input based on WinAPI, X11 etc?

SDL + OpenGL
It's elegant and you can have a proper event loop. Not a shitty loop from where you can quit only using dirty hacks.

what's GLAD?

The most undocumented library I have ever had the misfortune to try and use.

Does /dpt like Scala?

But SDL is just a more bloaty GLFW.

Well still, you just need to provide headers path (which the -I option does) but using code blocks instead, not sure where that is in CB because I don't use it. After you've done so, glad.c should be able to include the header.

No it's fucking clean, elegant, minimal and portable.

I do learn one at a time. R is just for the purpose of statistics.

nigga what fuckin planet do you live on, glfw is one of the best apis i've seen

>It's fucking useless
literally how? it's by far the best cross-platform windowing/context creation library out there

>SDL
there it is. sdl is ugly and bloated as fuck. it tries to do way too much

>Not a shitty loop from where you can quit only using dirty hacks
this is literally what an event loop is

>implying any sane person would ever want to handle their own windows context

Welcome to programming. I can almost guarantee you it'll get worse.

I can't offer you any specific help, but it seems to me that you're looking for answers in the wrong place. Instead of reading the library docs, you should be reading up on linking static libraries in general.

>there it is. sdl is ugly and bloated as fuck. it tries to do way too much
Ok, you're stupid.

You too.

It's my fault I should not argue with code monkeys of Cred Forums.

You just described what i think of GLFW.
SDL is bloat.

>calling people code monkeys while using shitty hold-my-hand bloatware

CodeBlocks clearly knows the path of the headers though.
It is successfully including everything, glad.h included.

That'd make sense if it was a case of:
>do thing
>works
>do different thing
>doesn't work

But this is a case of:
>do thing
>works
>do same thing
>doesn't work

My other headers and libraries don't need any manual linking.

Thinking a by callback design is superior to SDL.
Typical of code monkeys.

>It is successfully including everything, glad.h included.

Yeah but that's only the relative path which obviously glad.c cannot resolve as you yourself have said.

You should just use native api if everything is bloat. So use win32 and Xlib or even better write it in assembly you pretentious fucks.

Muh my dad is better than your dad

no

Then how do the other libraries do it?
Something within the library that lets them resolve the paths by themselves?

Though anyway, how would I get glad.c to be able to find glad.h, when it's told to look for glad/glad.h?

I use the minimal, clean and portable api, ie SDL.

I have a class with a bunch of internal config variables. What's a nice way of letting the user configure the objects?

A bunch of setters?
One setter with a param list?
Some other exotic way i haven't thought of?

>SDL
>Minimal

>Something within the library that lets them resolve the paths by themselves?
No, libraries are just installed in paths that are implicitly searched by the compiler (Like /usr/include or compilerpath/include).

>Though anyway, how would I get glad.c to be able to find glad.h, when it's told to look for glad/glad.h?
You'd either need to have the glad folder in the folder where glad.c is located, then have glad.h in that folder or again, as I've already told you, add the header option that points to the folder that contains glad/glad.h (which in case of CB is right here, pic related).

Yes.

are you even reading this shit? the primary reason glfw is better is that it wraps the native libs cleanly and concisely. it does what it's supposed to do without going overboard. if i wrapped those libs myself i would have basically glfw, but i don't wanna do that and i'm glad as fuck somebody did it right already

Actually yes. I'm slowly moving in that direction.

Doesn't change the fact that GLFW is nice.
Also, everything in software development is dirty hacks if you just go deep enough.

Neither approach worked.

What I've added in the project build options:
>Linker settings:
..\..\..\..\..\Program Files (x86)\CodeBlocks\GLFW\src\glad.c

>Search directories:
..\..\..\..\..\Program Files (x86)\CodeBlocks\GLFW\include (glad\glad.h is inside include)

oh my god
i quit

>Windows
Why don't you try developing on a sane operating system?

what the fuck

I'm not psychic and I only have several hours experience with CodeBlocks, what here is horribly horribly wrong?

no such thing

Why did I cast the return value of realloc

Are you ever going to switch computers?

Because you presumably want to actually DO something with that memory.

When a good OS comes out.

Windows:
>Sure, we could have stopped at 2000/XP then only worked on security, compatibility, and appearance, but what would our Pajeets have to do without adding and removing code in a way that causes the OS to slowly break down into an almost unusably bugg mess?

Mac:
>We are the definition of capitalism's awful trait of giving-the-customer-worse-service-for-more-money

Linux:
>Using me because you want to set a few things up in a precise way? How about I make you set EVERYTHING up in a precise way?

Well, if you only ever develop and compile on one computer, then I don't see any harm in it...

for(int i=0;i

>>We are the definition of capitalism's awful trait of giving-the-customer-worse-service-for-more-money
Macs are pretty great though, and macOS is decent

About everything.

ignore the second brace

Why would you write such horribly dense code?

4 spaces indentation
disgusting

how about i ignore the entire idiotic post instead :)

What the hell? Why are you putting glad.c in Program Files?! That's *NOT* where it goes! You put glad.c (and glad.h and whatever other files comes with it) in the same directory where the rest of your project files are. GLAD is generated specifically for the project you're using it in, so you don't turn it into a library.

Now don't tell me you've placed all your libraries, includes and other pieces of code in Program Files too.

(This is what we get when kids these days no longer grasp simple concepts like "directory" and "file". They don't understand how to organize their stuff. All they know is "cloud this" and "cloud that".)

n-no bully pls
I just wanted to know what the right way to do it is

also, braces - should they start at the end of the line or on a new one?

it's not a library, it's a source file. put the glad files in your project's source tree and add glad.c to your project's source files so it builds into your application. currently glad.c isn't getting built into an object file for linking because, though glfw ships with it, it doesn't actually build it into the library

for( int i=0; i

Codingstyleisverysubjective,butatleasttrytomakeitreadable.Nothavingspacesjustmakeseverythingcluttered.

>that first space
absolutely disgusting

>space after the first brace but not before the last one
fuck you

>Space after opening bracket
I never understood this style. It's completely retarded.

are you doing a bit or are you actually this terrible

I've tried to move that stuff out of program files, but it won't compile if I do. Something in CodeBlocks is telling it to look inside CodeBlocks\GLFW for everything, and no amount of searching has revealed how to change it.

Do you have any idea how I'd do that in CodeBlocks?

Been working on a textboard that supports markdown for some reason.

Come try and break it:

textboard dot esy dot es

put the glad headers in your project directory where the header files for your project are stored, and glad.c where the source files for your project are stored, and then add glad.c to your codeblocks project if that's a thing you have to do in codeblocks

Funny you mention it, I worked on a textboard for fun a few months ago and just recently decided to get back to it so I've added markdown support as well.

My problem is that I can't move anything out of CodeBlocks\GLFW, because it looks there to compile.

I want to get into 3D programming, so I've started to follow OpenGL and Blender tutorials. I've haven't wrote anything yet other than following the example codes, my main focus is at the moment to understand the basic idea of working in 3 dimensions.

There's one topic, however, which I can hardly find any resources on. That would be animation.

The obj format, which Blender produces, "just" describes the vertices. Reading that for the program to use doesn't seem to be such a hassle. Moving an object like this around the 3D space should also be relatively easy with matrix transformations. But what about the "actual" animation? When, for example, a character raises its hand? When I export an animation with Blender, it just produces a ton of obj files, one for each frame. I could, of course, load all of them into the GPU and then loop trough them, but that just doesn't feel right. I've got some ideas from other anons, which mainly says that I should have the transformations between each frame. So I would transform the body to the next position (frame) first, then transform it to the correct location. But how can I get this information? Should I just code it after I get the basic model from Blender, or is there a way in Blender to export these information? Or should I visit /3/ with this question?

Oops, forgot a space.

It airs up the code, makes the groupings easier on the eyes.

it should also be looking in a project directory, otherwise it wouldn't be able to build your application. your own source files wouldn't find your own header files unless codeblocks tells the compiler to include the directory where the headers for your project are located. unless they're all in the same folder i guess

Read on skeletal animation.

Unfortunately, what you will have to do is implement skeletal animation into your OpenGL project, whether manually or with a library.

There may be libraries out there that can read files to do with Blender skeletons and stuff, but I have no idea.

You won't need a library though if you can understand how Blender's skeletons work. Mathematically, they're very simple, and it may be possible to implement the skeleton transformations into the vertex shader.

CodeBlocks tells the compiler to look in CodeBlocks\GLFW for the include folder; this is not the project directory.

If I put the include folder in the project directory, it cannot find the include folder.

you need a rigged model. you have to define bones, to which vertices have weighted connections. given a rigged model, animations themselves become simplified to a series of frames of bone transform data. your application can then compute vertex positions in a shader by cycling through and interpolating between the bone transform frames, and transforming each vertex by a weighted blend of the transforms of the vertex's connected bones. the i have no experience rigging myself, but i know blender supports it

Also move away from wafefront object files.
They're nice for baby's first openGL model because they're easy to parse and human readable but they are not meant to include animations.

I'm not into vidya dev so I don't really know what a good choice would be.

>using Win32 to draw directly on the desktop

This is fun. :^)

does your project have any of your own header files in it? how does codeblocks know where they are?

How?

An OS that works purely on exceptions (event-driven), and allows you to access anything as long as that thing isn't allocated for something else / you'are in an exception level that you aren't allowed to do that like EL0

>using spyware

>skeletal animation
That's the keyword I was looking for. Thank you! With that I could find some useful guides. The one I'm currently reading suggests not to use obj because it doesn't support bones, but there are ones which do, so I guess my first mistake was that I wanted to stick to obj so much.

Thanks again!

HDC cnt = GetDC(0);
RECT drect;
GetWindowRect(GetDesktopWindow(), &drect);
int wid = abs(drect.right - drect.left);
int hei = abs(drect.bottom - drect.top);
int x = rnd(0, wid), y = rnd(0, hei);
SetPixel(cnt, x, y, RGB(rnd(0, 255), rnd(0, 255), (0, 255)));


Something like this. Modify as necessary to get the effect you're after.

All the header files are in a CodeBlocks directory, not the project directory.
CodeBlocks knows where they are with a dependencies file, but changing that doesn't achieve anything.

You're right. I should just be doing the same thing with the X11 api on Gahnoo/Lingus

in javascript, if i do

someArray.push(new someObject())

and then later

someArray.splice(indexOf(someObject), 1)

does javascript automatically delete someObject from memory

or

does javascript know to get rid of memory for which there is no reference in the code or do i need to clean up memory myself

What are some good sources to learn CMake?

JS uses GC so it'll eventually get purged when the GC decides it's time to.

i'm not referring to the header files of your dependencies, i mean the header files for your project, written by you, declaring the functions and types you define in your source files. where does codeblocks track the source files for your project? does it have a "project explorer" pane or something like that?

I'm kind of lost here, I think I'd really need help from someone who's familiar with CodeBlocks.
But what I definitely need now is sleep!

[spoiler]I masturbated to slim niggers yesterday. I felt good[/spoiler]

>does javascript know to get rid of memory for which there is no reference in the code or do i need to clean up memory myself
Yes, JS is garbage collected. It gets rid of stuff with no references automatically.

Cool, i'll try that out later.

That's the best.

finished a program that given a directory it displays thumbnails in a window of the pictures inside the directory

in python

How do i build my program so i won't have to deal with this?

Nice

Statically link to the library?

I don't suppose you know how to configure my project to do that?

This seems to be a Visual Studio specific problem so no however a simple query in a search engine lead me to pic related, I assume you have to check the non-DLL option.

Thanks. I'm also googling and reading around, but MS documentation is shit in the sense that it's kind of hard finding info on how to do anything but the most basic things, or if you want to do things a little differently than the official way.
The official solution is to have your users install the MSVC Redistributable.

>The official solution is to have your users install the MSVC Redistributable.

Ah, that makes sense, as far as I remember from using Windows most programs that you install on Windows will pop with the MSVR setup (same with most games on Steam).

Yep. But i just want to have a copy-and-run that i can send to friends and go "look, i did a thing".

Hey everyone, how hard is Python to get into if I'm already pretty comfy in Javascript, C#, F#, Java and Scala?

These really were the good old days. I wish I had a time machine.

So the non-dynamic runtime has no effect?

given those langs you might like haskell

I'm going to be doing an OpenCV project, so it's either Python or C++(And I have limited time to learn it).

Python is fairly straighforward, you'll find the typing similar to JavaScript, likewise you'll be able to find a fuckton of libraries that can be easily managed with pip and virtualenv. The only thing that might feel off is the enforced indentation and lack of braces but it's something you easily get used to.

for (int i=0 ; i

1. Include stdint.h and get rid of that shitty long long int
2. Restructure the code so there isn't a goto
3. Even numbers can't be prime, so don't bother testing them.
4. (This is more for C++ but is a good habit) always do ++VARIABLE since VARIABLE++ can create unnecessary overhead
5. Figure out a way to time how long your program takes AND how much memory it uses so you can actually see what works (not sure about the timing for C, sorry, but Valgrind in Linux is perfect for memory tests)

>always to ++variable rather than variable++
Your autism is killing programming

But he's right, when you deal with STL iteratos using pre-increment creates an unnecessary copy of the object. I'm not saying that post-increment is never useful though.

an int isn't a fucking object

That doesn't affect nor invalidate the two previous statements in any way or shape.

Let me highlight the keywords for you:
>since [...] /CAN/
>/WHEN/ dealing

How so?

C++ problem

please kill yourself

>trying to contrive Maybe :: * -> * into a * context
Pretty sure it shouldn't be so.
Perhaps Program (Maybe [AST])?
That lets you distinguish between "no statements" and "zero statements" without reinventing the wheel...

Zero statements is no statements, distinguishing between the two seems weird.

Can you explain more what you want to achieve?

Like posting some code of the language you want an AST for, to show as an example of the features the AST needs

>Zero statements is no statements, distinguishing between the two seems weird.
Then Program [AST] I guess. Again, don't reinvent the builtin linked list type, you'll thank me later.

>Zero statements is no statements, distinguishing between the two seems weird.
an empty list can sometimes not be the same as no list. I'm speculating on wtf user wants from Maybe tho.

But no list would just not use that constructor, surely

Can someone please explain to me what the fuck I'm doing wrong? I'm trying to make a simple fucking roguelike with libtcod in codeblocks, but apparently the library has no fucking compatibility? How ma I supposed to do this? I downloaded the horseshit library, include it in the compiler linker settings, so what am I doing wrong? why does NO LIBTCOD SHOW UP ANYWHERE

I'm going to fucking throw this thing

What?

What?

why even respond? The question is simple: why does libtcod not fucking work with codeblocks for me, and how do I get it to work?

>NO LIBTCOD SHOW UP ANYWHERE
directly contradicts your pic.

Are you pretending to be fucking useless?

I added the .a file, both of them, and nothing shows up

How

Do

I

Get

It

to

Work

Nothing

Shows

Up

In

Terms

OfLibraries

Or

Directories

Once

I

include

either

.a

file

>being this fucking stupid

have you tried googling it?

Blog software but I don't feel very inspired.

>nothing shows up
Where do you expect it to show up? Again: your pic is clear only to you but not to others...

Thanks for confirming this thread is just literally 16 year old faggots who don't know how to answer a simple query.

I'll post the answer I get from cripplekike tech soon, since you faggots need to be shown how to answer questions.

I expect it to show up in the big fucking list of headers and libraries when you type #include

I was joking about googling it, you seriously need to calm the fuck down

no, i compile on windows. i just prefer the linux environment for writing code

>libgen.h DOES show up in said list, and you dont #include .a files fyi.

isn't an *.a file for linux?

didn't mean to greentext it, but whateva I have to go

nobody but yourself is at fault for your incompetence :^)

not if you use Mingw

>query
Question*

is it a different arch?

Not him, but probably not. It's just that he cannot locate BRAIN.EXE

>What are you working on, Cred Forums?
GPUDirect RDMA benchmarking utility for InfiniBand and some proprietary PCIe-based interconnect.

Seriously dude, I'm repeating myself, but learn the difference between a header file and an archive, it could save your life. Learn how C gets compiled basically.

I'm trying to use sfml with opengl in c++ to draw the pixels of a screen.

This is where I assign the color of each pixel:
sf::Uint8 *pixels = new sf::Uint8[1920 * 1080 * 4];
for (register int i = 0; i < 1920 * 1080 * 4; i += 4) {
pixels[i] = 255;
pixels[i + 1] = 255;
pixels[i + 2] = 255;
pixels[i + 3] = 255;
}


And this is where I draw it on the window:
glDrawPixels(1920,1080, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
window.display();


It works, but it is really slow (15~25 FPS). How can I make it faster?
Why is drawing pixels so slow when AAA games can run over 60 FPS in bigger resolutions?

It's because games like that don't copy pixels to the display, they issue calls like glDrawElements, which copies less data(may not even have to copy anything). glDrawPixels probably copies everything directly to the framebuffer, and memory bandwidth isn't that high, so you get a bottleneck from copying the same 8MB buffer X times a second.

Also glDrawPixels is deprecated, so learn OpenGL 3.

If I want to learn java, should I learn Java 7 or Java 8? The only uses I can see for this knowledge is learning other programing languages, and developing android software

What book should I go for, if I want to learn WPF? How does "WPF Unleashed" compare to "Applications = Code + Markup"?

Stupid question but re you sure you don't generate the pixels array in each loop iteration?

I forgot to mention, I'm personally leaning towards 8, but android apparently doesn't utilize all the features the language offers

8, for the lambdas if nothing else.

Java 8 is the future. The only reason to learn Java 7 would be if you already know Java 8 and you plan on working on legacy software.

By the time you know Java 8 enough to work on actual software, nobody will use Java 7 anymore except for legacy stuff.

>I forgot to mention, I'm personally leaning towards 8, but android apparently doesn't utilize all the features the language offers
It will in time. See

>nobody will use Java 7 anymore except for legacy stuff.
so basically 90% of all Java work will still be in 7 or less for the next 10 years. Enterprise's aren't the fastest to update their code bases.

yes. I even removed the assignments from the loop to see how faster it would be.

No new projects will be in Java 7 and user learning his first programming language will not be working on enterprise software any time soon.

And by the time he will, he will -- as I said -- know Java well enough to learn Java 7 with ease.

tu-braunschweig.de/Medien-DB/sec/pubs/2016-ccs.pdf

>mfw all of those problems come from the fact that C is an obsolete garbage

>lambdas
I assume those are important?

Thank you, I never expected a confidence boost from this board :^)

Not that much in Java, but they're really really nice, compared to the horrid pre-8 alternative (inline objects).

I'm terribly sorry for interjecting another moment, but what I just told you is GNU/Linux is, in fact, just Linux, or as I've just now taken to calling it, Just.Linux. Linux apparently does happen to be a whole operating system unto itself and comprises a full OS as defined by POSIX.

Most computer users who run the entire Linux system every day already realize it. Through a peculiar turn of events, I was misled into calling the system "GNU/Linux", and until now, I was unaware that it is basically the Linux system, developed by the Linux project.

There really isn't a GNU/Linux, and I really wasn't using it; it is an extraneous misrepresentation of the system that's being used. Linux is the operating system: the entire system made useful by its included corelibs, shell utilities, and other vital system components. The kernel is already an integral part of the Linux operating system, never confined useless by itself; it functions coherently within the context of the complete Linux operating system. Linux is never used in combination with GNU accessories: the whole system is basically Linux without any GNU added, or Just.Linux. All the so-called "GNU/Linux" distributions are really distributions of Linux.

NEW THREAD:

That's what is meant, yeah

>learn OpenGL 3.
is there any book that you would recommend? opengl documentation isn't very friendly.

git gud fgt

My brain tried to read this and then settled on
"he's making pancakes".

I used parts of the OpenGL Programming Guide(8th edition), but mostly learned it myself.(also the basic tutorials at opengl-tutorial.org/ aren't bad)

lol what?

Is opengl the best way of doing it? wouldn't using the CPU instead of the GPU be faster in this case?

You really want to do software rendering?

So how is Vulcan? Did it turn out to be the second coming?

No, and no one should of expected it to be.

Dang, is it at least worth trying? I'd love to be able to add another section to my website.

>Vulcan
You're obv not kool enough to understand what it's all about.

It's literally 900+ lines to draw a triangle.

exactly

Who /react/ here?

sounds wonderful, I'll give it a shot

force of habit

I think it's only worthwhile if you want to do high-performance graphics.

I just want to set the pixels individually, and I don't know what's the best way of doing it.
I've seen some people saying that "setting pixels individually" isn't what opengl was designed for.

It isn't. I guess you could try SDL.

use blitting with SDL, not opengl

you should be familiar with opengl/directx or you probably won't really be able to take advantage of it even if you learn it

I know both.

well if you really have nothing better to do then sure learn vulkan if you want

It gives me something to do while couch surfing and spamming applications/cover letters.

I got around 50 FPS using this code with sfml. I'll try sdl later.

#include

int main()
{
sf::Texture texture;
texture.create(1920, 1080);
sf::Sprite sprite(texture);
sf::Uint8 *pixels = new sf::Uint8[1920 * 1080 * 4];

sf::RenderWindow window(sf::VideoMode(1920, 1080), "SFML works!");

while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}

for (register int i = 0; i < 1920 * 1080 * 4; i += 4) {
pixels[i] = 255;
pixels[i + 1] = 255;
pixels[i + 2] = 255;
pixels[i + 3] = 255;
}

window.clear();
texture.update(pixels);
window.draw(sprite);
window.display();
}

return 0;
}

I broke it.