/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?


Previous Thread:

Other urls found in this thread:

lfe.io/
en.wikipedia.org/wiki/LFE_(programming_language)
roborealm.com/help/Convolution.php
github.com/brndnmtthws/conky
youtu.be/rRbY3TMUcgQ
youtube.com/watch?v=5kj5ApnhPAE
github.com/nlohmann/json
digip.org/jansson/
roartindon.blogspot.be/2014/10/compile-time-murmur-hash-in-c.html
twitter.com/SFWRedditImages

First for Java is shit.

Second for AOP

It was an OP image for /fpt/, baka.

Erlang > Haskell, stop using that meme language

And /fpt/ is kill now. Try again later, when there's more than 2 people on Sup Forums who use functional programming.

>What are you working on, Sup Forums?

Exploring the deepest, darkest corners of Racket by doing Advent of Code 2016.

Thank you for using an anime image.

This.

lfe.io/
en.wikipedia.org/wiki/LFE_(programming_language)

Sign me up

I was told to create "my own class library", for a very specific task.

What would be a good style to do it? Create a folder of its own, with classes? Something else to consider?

make it header only

what does that mean?

desu it looks messier than pure erlang

it means you put all the code in a single (header) file
this way if someone else wants to use your library they only need to include one file into their project

Another thread on functional programming:

mkay. i thought the style convention is to have a file for every class, but that sounds reasonable.

Ok, fuck...
AGAIN.

We are STILL getting errors!

This wxWidgets is making me lose my fucking mind!

But hell, we're down to only 1 error!
Maybe someone can help with this last one and get me up and running?

Please? It's been 5 hours since I did my LAST (4th) rebuild of this fucking library...
||=== Build: Debug in testHello (compiler: GNU GCC Compiler) ===|
ld.exe||cannot find -lwxmsw30u|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 5 second(s)) ===|


JUST THAT (hopefully)
What do I need to do to get THAT to work?

>le omg how do i link a library?!?!?!?!
What the hell are they teaching kids these days.

you're asking it to look for a library called wxmsw30u
but it can't be found
make sure it exists and is in a folder which you have told it to include

This means that there is no libwxmsw30u anywhere in the linker's search path. You need to find the WxWidgets library files (should have a file extension of .a, .so, or .dll), and copy them into whatever folder ld is searching from. Alternatively, you need to use the -L option to tell ld to add a directory to its search path.

...

>/dpt/ - My Personal Google

There are almost 7500 files in this library....

but...
I did just notice something here....
This file does not in fact exist at all. But there is one called:
lwxmsw31u.a
How do I make it STOP searching for 30u and start searching for 31u?

you have this setting somewhere in your IDE
>-lwxmsw30u
change it to
>-lwxmsw31u

lmao

Use the -lwxmsw31u flag instead.

And for fuck's sake, run man gcc or man ld before asking stupid questions.

I'm building a collection of basic image filters in C.

Everything works fine, but I was wondering if there's a better way than a basic double for loop to iterate through all the pixels.

I don't know the answer but I'm wondering how you loop through the pixels?

>how you loop through the pixels?
Nested for loop (height, width). You get the RGB values for that pixel.

Then, for each pixel, you take its neighbors by a kernel and you add those values to the original pixel.

Each filters has it's own kernel, so basically the kernel for a intense blur is :
int kernel[5*5] = {
0, 0, 1, 0, 0,
0, 1, 1, 1, 0,
1, 1, 1, 1, 1,
0, 1, 1, 1, 0,
0, 0, 1, 0, 0
};


roborealm.com/help/Convolution.php

thanks buddy

Shouldn't you be using more than one thread for something like this?

Ok, I found it finally. Apparently, it was under the project itself and not the global compiler/linker settings...

so, now it searches for the right thing, but it gives me like 50 errors saying a ton of stuff is an undefined reference.

||=== Build: Debug in testHello (compiler: GNU GCC Compiler) ===|
U:\Programming\Tests\Random\testHello\testHelloMain.cpp||In constructor 'testHelloDialog::testHelloDialog(wxDialog*, const wxString&)':|
U:\Programming\Tests\Random\testHello\testHelloMain.cpp|62|warning: 'wxFont::wxFont(int, int, int, int, bool, const wxString&, wxFontEncoding)' is deprecated (declared at A:\wxWidgets-3.1.0\include/wx/msw/font.h:114): use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants ie: wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD [-Wdeprecated-declarations]|
obj\Debug\testHelloApp.o||In function `WinMain@16':|
U:\Programming\Tests\Random\testHello\testHelloApp.cpp|21|undefined reference to `_imp___Z7wxEntryP11HINSTANCE__S0_Pci'|
obj\Debug\testHelloApp.o||In function `Z11wxCreateAppv':|
U:\Programming\Tests\Random\testHello\testHelloApp.cpp|21|
[AND MANY MORE]


I'm on Windows, sadly. I can't man shit.


So... any ideas on this? Why does it say all of these are undefined?

I'm including the libraries. But, even when I comment out the libraries, it shows the exact same number of errors... As if including the big include file doesn't mean shit...

you posted only one warning, warnings do not prevent compilation
you need to post the error(s)

oh, nevermind there was an undefined reference error in there too
that means it couldn't find a function in any of the included libraries
I think you're in over your head here

I don't know. The basic implementation that I have, takes around 2 seconds to render the edges detection in Then I ran to improve the clarity of a giant bmp map, (350MB). It took 2 minutes. I'll try with more than one thread to see.

They have two different purposes.

I just want this fucking library to work, man...
It contains almost 7.5 THOUSAND files, and even something like just including the global include file thing they made gives me errors as fuck...

fuck...

Is there another cross-platform GUI widget library I can try?
Or, do you know of any good sites to check up on making semi-transparent widget things using purely OpenGL or SDL?

Why are you using C++ for this?

Inline post expansion.

What else would I use..?

I know:
-Web Markup
-PHP
-JS/jQ
-C/C++
-Java
-VB/VBA (which I hate)
-SQL (MySQL and Oracle)

(among a few scripting and other languages like Bash, Rainmeter, AutoHotKey, some PowerShell, and some Batch)

I can't think of what else I'd use. And I'd prefer to use C/++ anyway. It's the best language... as long as the fucking libraries work, which is much more often my problem than anything else...
(I'm better with handling the code than the tools used to build the code)

What are you trying to do?

What is the end-goal of your project?

I really just wanted to make some gadgets to run on my desktop atm...

Things LIKE Rainmeter that I can port to BSD when I get a new machine

What C library should I get if I want to utilize GPIO on a Pi 3?

Would this fit your needs?
github.com/brndnmtthws/conky

Although I never had any issues with wxwidgets on any of the platforms I used it on (FreeBSD, Windows, MacOS). I'm not sure what's going on with your project.

I had considered this.

It won't run on Windows, though, so I can't get any practice with it, atm.

On the other hand, I'm gonna go back to some other things atm. I can't keep bothering with this right now.

Besides an unrelated problem just came up, and I am fucking losing my shit.
Thanks, though, bookmarked

Test in a VM ontop of Windows.

C with gcc extensions or C with clang extensions?

clang c > gnu c

Should i focus more on C or C++, lads?

This is topical.
youtu.be/rRbY3TMUcgQ
(and mildly amusing for a wide range of people)

C.
Even the C++ community is now openly accepting the flaws and has made it clear they're remodeling c++.
So why learn something that will be considered problematic practice in the future?
C knowledge will always be relevant though.

what are some common java exceptions i could include in my project to show employers

guyse, i am such a l33t pr0 dev. i know exc3pti0ns, xD

>they're remodeling c++.
yeah while c keeps ignoring 50 years of PLT.
>C knowledge will always be relevant though.
>C knowledge
kek. C is a programming language for the programming techniques of the past.

I'm a fucking moron and still can't get past these linker errors.

Header.h
#pragma once
int whatPage;

void Menu();
void Game();


main.cpp
#include "Header.h"
#include
using namespace std;

int main()
{
whatPage = 0;
while (whatPage == 0)
{
Menu();
}
while (whatPage == 1)
{
Game();
}
}


functions.cpp
#include "Header.h"
#include
using namespace std;
void Menu()
{
system("CLS");
cout whatPage;
}

void Game()
{
cout LNK 2005: "int whatPage" already defined in functions.obj (file: main.obj)

>LNK1169: one or more multiply defined symbols found (file anime.exe)

>exceptions
I don't know much about them but they're just error messages essentially right? So why would you care about having error messages if they're not relevant to your program?

Also a more general question:
How can C++ have exceptions if 'you don't pay for what you don't use'. Surely exceptions would be a feature that creeps all over the program as long as they're somewhere? How else could they run up the stack and destroy objects like that?

every time i read "using namespace std" that reminds me how glad i am that i ditched c++ for java.

such a cancerous line.

>public static int main

shouldn't you just include functions.cpp in main.cpp?

>PLT
And look at what good that has done. I'm sure you're in a position where you absolutely love everything that's going on.
>programming language of the past
Sadly, it's one of the few languages that actually allow you to do things easily, efficiently and without tons of uneccesary mental model overhead that comes with most abstractions.

C++ is similar in that but only when you use certain subsets.

public static void main.
its void, my dear stroustrup groupie.

>void
Annoys the living crap out of me that they did that.
I need to find some motivation but it's not like java programs don't have exit status.

>allow you to do things easily, efficiently
no, not at all. everything in C is tedious, boresome, errors prone. Try to implement a generic dictionary in C, for example.

>stroustrup groupie.
Rob Pike, actually.
youtube.com/watch?v=5kj5ApnhPAE

If that means changing main.cpp to look like this, it doesn't work.:
#include "Header.h"
#include "functions.cpp"
#include
using namespace std;

int main()
{
whatPage = 0;
while (whatPage == 0)
{
Menu();
}
while (whatPage == 1)
{
Game();
}
}

nigga you ain't listening

>try to do pointless high level construct in C
Yeah well if your use case aligns well with python or something like that then you can of course use python.
C and other languages that promises or care for performance are not for doing stuff that would be completely bonkers in that field.

I wouldn't ask a python programmer to try and do intrinsics well. It's just not what they are supposed to do.

Languages shouldn't be as general as they are honestly. They should have more specific use cases. PHP and JS are good examples of that. They're not good languages but they are where they are because of how they work in their own area.

what is the go-to file structure, if I want to create a list of custom objects?

i have no clue how I will use them - yet.

>try to do pointless high level construct in C
not pointless at all. ever heard of json or xml? do you have any experience outside of cs101 assignments?

What do you mean?

>have you ever heard of inefficient ways of storing data in text
I've heard of plenty of ways of doing that yes. But again, not the way you go about things if you want speed.

In C you'd have a clear input boundary where you take the JSON (hopefully you don't even need to take JSON), translate it into something for proper ladies and then work with it. If it absolutely has to go back to JSON then I could say you probably didn't choose the right language.

And C++ doesn't really do much better.

>And C++ doesn't really do much better.
wrong
github.com/nlohmann/json

Why aren't you guys programming in C and why do I love C so much?

Because you've never had a job.

nevermind, i figured out i should use an arraylist.

why do you love Cock so much? faggot

I still fail to see what it is I'm doing wrong here. I did try to remove Header.h from main.cpp as well, but that just doubled my linker errors.

that's strange, I did the exact same thing you did, then I compiled main.cpp and it just werks.

Does that make me gay if I like it when the male character is drawn as a girl?

if liking means being sexual aroused, yes

You can look at wave (RIFF) for inspiration. The model they have for storing data is pretty good for a general case. And it's a very simple file format.
>wrong
digip.org/jansson/
Wrong?
Really user,
>there's a library I prefer
Is not an argument you can pull.
And I can see how you're just a fresh programmer so I know this will go down the route of
>but look at how in one of these libraries I write stuff just like I would with dictionaries
As if that's a good way to go about things.

...

Because its easy to understand. You'd probably feel just the same about LUA if that's where you started.

are you retarded? something like
json j2 = {
{"pi", 3.141},
{"happy", true},
{"name", "Niels"},
{"nothing", nullptr},
{"answer", {
{"everything", 42}
}},
{"list", {1, 0, 2}},
{"object", {
{"currency", "USD"},
{"value", 42.99}
}}
};

or
// create object from string literal
json j = "{ \"happy\": true, \"pi\": 3.141 }"_json;

// or even nicer with a raw string literal
auto j2 = R"(
{
"happy": true,
"pi": 3.141
}
)"_json;

// or explicitly
auto j3 = json::parse("{ \"happy\": true, \"pi\": 3.141 }");


is light years ahead of what you could do with standard C.

Is it possible this is a incremental recompile issue?

>not generating object models based on the JSON structure in the API so you can assign values to fields with type safety, autocompletion, and enums for limited selection options

Make whatpage static, famalamadong.

System.out.println("Take it Easy");

>ahead
Again. This toxic perspective. Hopefully you will grow out of it.

As an aside if you're declaring a lot of json in your programming language you're probably doing something horribly wrong. Seems like a very problematic environment to work in.

Why wouldn't you just keep a couple json files on disk and parse them? Instead of having it all littered throughout your code.

>he said that in 2007
>he hasn't wrote code since git
>linux is now awkwardly using oop

what's matter here is the abstraction techniques offered by c++.
another example of C++ destroying C
roartindon.blogspot.be/2014/10/compile-time-murmur-hash-in-c.html

>is it important to type fast
Not really no.
As long as your thoughts aren't held back by your typing.
It's rare for that to be the case.

why is popular programming culture so juveline and childish?

it all revolves around meme arguments and buzzwords. oh, and look at how architects of programming languages look and dress like, like fucking teletubbies.

no wonder that people with social lifes stay away from coding, as it reeks of the same flavours as anime and gaming.

>no wonder that people with social lifes stay away from coding,
Good. Normies ruin eveything.

That worked, thanks a bunch!

does it make sense do save dates in text files as Date objects in Java?

I think it's something related to memes and the idea that it's almost impossible to create all knowledge from scratch.

It's really any male dominated industry user. You find it anywhere.
People arguing about drillbits, screwdrivers and what type of foam is best to use when there's clear data on what's actually correct.

I FACKEN HATE CURRYOVERFLOW

THEY DOWNVOTE EVERYTHING I ASK

REEEEEEEE

Why would you ever ask shit on SO?
Everything's already answered there or can be found out by RTFM

Why aren't you posting everything on /dpt/?
We have the best devs

i asked what a good way to arrange my first custom library is.

should i implement it as package?
should i put all the classes in one file?
or every class in its own file, and these files into a folder?