/dpt/ - Daily Programming Thread

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

First for C++ is crap.

C-tards are gonna deny this.

You shouldn't be dealing with impure anything in the first place.
You either return the read file and then the parsed config, or you return read nothing because it was invalid.

OK, makes sense.

DELET THIS

that's a pretty shitty pen tattoo

1. If you want to map arbitrary string representations to types the mapping has to go somewhere. Don't think this can be addressed without baking format specifiers into the language.
2. Debatable. If you really care, just use an intermediate data structure for random access.
3. Not sure what this is complaining about. If it's not an ABI issue, stop bitching and fix the compilers.
4. See (3). Also if you are doing string formatting on a hot path you need to rethink your life anyway.

More template masturbation is never the answer. Real solutions to real problems please.

Don't embed the read code in the parsing code. Purity doesn't enter into the decision at all; it's just basic modular principles: you may want to parse something that was not obtained from I/O.

t. imperative brainlet

I agree
rust's macro solution is a lot nicer

Yeah, that's my current plan.
My main class does all the I/O (disk, network). The rest of the code is split up into modules which transform data.

post a better color scheme, i dare you

>Dev C++

People still use this shit?

>Dev-C++ 5
I remember using it back in 2003-2004 to write my own Lisp interpreter, it was a good time.

Possible alternatives? Where it's simplistic yet advanced enough.

looks gross.

yeah i like looking at neon green text all day thats for sure

Code::Block, if you can stand its ugly gui.

...

>he doesn't use rainbow-indentifiers-mode

it's the greatest IDE ever, so simple to install and use yet so efficient and customizable.

black/grey/white/green is objectively the best color scheme, use anything else and you'll look like a starbucks drinking, tight pants wearing, macbook using javascript dev

desert

Yeah, that's how I'd do it. Keeping all the IO code together is often very helpful since it makes it easier to reason about interacting side effects. IO happening in multiple disparate places is a major asspain to debug.

pure colors are terrible on your eyes and you'll get strained faster.

eye cancer

That's way too much coloring.

that's a pretty fitting scheme for rust

it's actually the opposite for me

...

You don't have special eyes.
Pure colors are objectively more obtrusive. Saturated colors are less stressful to look at by definition.

>What are you working on, Sup Forums?
Go thumbnailing library. It now auto-rotates based on EXIF.

Yeah, but for some reason, I find it comfortable, specifically, it's easier for me to read code when all the identifiers have the same, unique colors. I guess it's highly subjective.

>not tatooing the cia niggers hello world

Bully my makefile /dpt/
BINARY = name
OBJECTS = o files
HEADERS = headers

CXX = clang++
CXXFLAGS = -std=c++11 -Wall -Wdeprecated -pedantic -g
LDFLAGS = -g

.PHONY: all clean

all: $(BINARY)

clean:
rm -f $(BINARY) $(OBJECTS)

$(BINARY): $(OBJECTS)
$(CXX) $(LDFLAGS) $^ -o $@

%.o: %.cpp $(HEADERS)
$(CXX) $(CXXFLAGS) -c $< -o $@

The pic reminded me of this

Is there anything else to estimating how much time would something take other than experience?

>using namespace std

are you using GNU make?
you can do
SOURCES = $(wildcard src/*.c)
OBJECTS = $(patsubst src/%.c,src/%.o,$(SOURCES))

using declarations are fine if they're properly scoped

The only acceptable use of using declarations is typedefing

>all objects depend on all headers

Pig disgusting. Use -MMD with clang to generate dependencies for each object.

ez

...

What theme, fellow spacemacs user?

Ask someone who's done it before. Make sure they take into account who will be doing it (senior dev shouldn't estimate for a junior dev the same as if they were doing it themselves).

When in doubt, take a wild ass guess and multiply that estimate by 2. Make it clear to anyone who asks that you are making a wild ass guess.

I do this professionally; good bosses/customers will understand.

material-light, it's in the themes-megapack

like an Agda-esque type system

don't force a specific compiler, pick one via "CXX=clang++ make"
add required CXXFLAGS with +=, extras can be requested via "CXXFLAGS=-g make"
use -MMD -MP for sane dependency tracking
no need to override object creation
BINARY=name
OBJECTS=object files

CXXFLAGS+=-std=c++11 -Wall -Wdeprecated -pedantic -MMD -MP

.PHONY: all clean

all: $(BINARY)

clean:
rm -f $(BINARY) $(OBJECTS) $(OBJECTS:.o=.d)

$(BINARY): $(OBJECTS)
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)

-include *.d

thanks lads

If we're going to be picky about hard coding the compiler, pretty much all of CXXFLAGS need to go too, since anything other than g++ or clang++ won't understand them. And that is going to make the makefile pretty useless.

Really, if you care that much about portability just give up and prepare to sink a few days into learning autotools.

so, this is the power of C++

>map over 1 character length strings

u wot m8

>python style
There's nothing Python to it.

Can anybody tell me what, exactly, is wrong with PHP?

I guarantee its because you're using the K&R book. That shit is so outdated that the new versions of C require more declarations than that book shows you. After two minutes of trying to get it to work and googling, I tossed that book in the trash and moved on to "C Programming for the Absolute Beginner" 2nd Ed. Much better and clearer. Plus the challenges at the end of each chapter are really helpful for learning and practicing what you've learned.

google "a fractal of bad design"

K&R 2 (ANSI C) is still bretty gud. C99 didn't add a lot and C11 is barely even used.

>anything other than g++ or clang++ won't understand them
it's not about something different than g++ and clang++ (and intel compiler), those are pretty much the only ones that matter anyway in a posix environment; it's about the different names of the tools you might want to use for compilation: you might not want to use the system g++, but arm-linux-gnueabihf-g++, x86_64-w64-mingw32-g++, or whatever the fuck the name of the compiler is for the system you're targeting

>C99 didn't add a lot
kek

And what exactly makes this furry's opinion in any way credible?

Because he itemizes everything objectively wrong with it. Who cares if he's a furfag?

>it's the greatest IDE ever
It's the most exquisite feces ever! I could gobble it all day!

This, if you're not using VLAs or flexible array members you're doing it wrong

>python doesn't have switch statement
what were they even thinking

Half of his blog is about making mario maker and doom levels. I doubt that he has any experience in designing programming languages.

how's that twelve gb visual studio treating you?

Well that was easy.

nothing wrong with this

clearly it's there to demonstrate how to match on strings, not to be as efficient as possible :)

My whole point was that IDEs are intrinsically shit, so obviously I wouldn't use the worst of them all.

>VLAs

Enjoy your complicated stack depth analysis. alloca by any other name smells as bad; that's why C11 made VLAs optional again.

>flexible array members

Just codify the struct hack that already worked on most pre C99 compilers.

you use notepad to write programs?

No, I use a real text editor. Currently Emacs, but I'm not ideologically bound to that particular choice.

Anyone here use SFML? I'm trying to get window resizing working properly in my program and it works fine under Windows but on Linux my code just goes in an infinite loop.
#include

int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
window.setFramerateLimit(60);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);

while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Resized)
window.create(sf::VideoMode(event.size.width, event.size.height), "SFML works!");
else if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
}

>pre C99
deprecated and irrelevant

>struct hack
undefined behavior :)

>vim/emacs cucks
top kek i should've figured

fuck off hipster

>complicated stack depth analysis
what is rbp

Why do you even ask if you aren't going to accept any answer other than "nothing"?
PHP is universally accepted to be one of the worst popular languages right now, and the post is a detailed enumeration of exactly why. If your first reaction is denial and ad hominem attacks then you probably should go back to your containment thread.

>universally accepted
[citation needed]

I wasn't the one who asked; nor do I write PHP. I just didn't find your cut-and-paste response to be particularly useful.

Tomorrow Night Bright everyday

>that's why C11 made VLAs optional again
No, that's because there are embedded architectures that don't have user-readable stacks. VLAs aren't difficult to implement on ordinary architectures.

Molokai

msvc only supports pre-c99, so sadly it's not irrelevant

>fuck off
Certainly, wouldn't want to be around the feces-eater anyway.

Please tell me more about these architectures.

>Trying to compile C with a C++ compiler.
Found your mistake.

rustc doesn't support pre-c99 tho

MSVC has a clang frontend now. I'm using C99/C11 natively.

it has a C89 mode, no?

yes, because rustc is the most popular compiler on the most popular desktop operating system

(What (the (fuck (did (you (just (fucking (say (about (me, (you (little (shit? (Ill (have (you (know (I (graduated (top (of (my (class (in (the (Navy (Seals, (and (Ive (been (involved (in (numerous (secret (raids (on (Al-Quaeda, (and (I (have (over (300 (confirmed (kills. (I (am (trained (in (gorilla (warfare (and (Im (the (top (sniper (in (the (entire (US (armed (forces. (You (are (nothing (to (me (but (just (another (target. (I (will (wipe (you (the (fuck (out (with (precision (the (likes (of (which (has (never (been (seen (before (on (this (Earth, (mark (my (fucking (words. (You (think (you (can (get (away (with (saying (that (shit (to (me (over (the (Internet? (Think (again, (fucker. (As (we (speak (I (am (contacting (my (secret (network (of (spies (across (the (USA (and (your (IP (is (being (traced (right (now (so (you (better (prepare (for (the (storm, (maggot. (The (storm (that (wipes (out (the (pathetic (little (thing (you (call (your (life. (Youre (fucking (dead, (kid. (I (can (be (anywhere, (anytime, (and (I (can (kill (you (in (over (seven (hundred (ways, (and (thats (just (with (my (bare (hands. (Not (only (am (I (extensively (trained (in (unarmed (combat, (but (I (have (access (to (the (entire (arsenal (of (the (United (States (Marine (Corps (and (I (will (use (it (to (its (full (extent (to (wipe (your (miserable (ass (off (the (face (of (the (continent, (you (little (shit. (If (only (you (could (have (known (what (unholy (retribution (your (little (clever (comment (was (about (to (bring (down (upon (you, (maybe (you (would (have (held (your (fucking (tongue. (But (you (couldnt, (you (didnt, (and (now (youre (paying (the (price, (you (goddamn (idiot. (I (will (shit (fury (all (over (you (and (you (will (drown (in (it. (Youre (fucking (dead, (kiddo.)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

Tcl

>the most popular compiler on the most popular desktop operating system
csc doesn't support pre-c99 either, for the same reason

>Please tell me more about these architectures.
Have you never used PIC µc? It's got a few dedicated registers for the return-address stack, which is only used by the call and ret instructions, and not accessible in any other way.
I'm sure you could set up a dedicated data stack using global variable as a stack pointer, but the standard ABIs don't.

Well, yes. However it worked historically and modern compiler writers would be insane to break it now. In any case it's not a widely used feature.

I mean worst case analysis. It's easy, provided you can rule out recursion, until alloca or VLA are introduced. After that you're forced to prove that allocation doesn't depend on unbounded input, which sucks.

Whut, got a source for that? Would such fantasy architectures not also have issues with fixed size arrays allocated on stack?

>Whut, got a source for that?
See >Would such fantasy architectures not also have issues with fixed size arrays allocated on stack?
It's been long enough that I don't know it by heart, but I'm pretty sure the standard ABI just allocated function-local variables in the data segment, as global variables. Standard C doesn't mandate that functions must be reentrant.

Writing a paster in haskell (maybe something else also, gibe ideas)

picrelated original content

I could also add that this is the same reason why GLSL doesn't support recursion. It's not at all implausible that part of the reason why VLAs were made optional in C11 was to cater to potential GPU implementations of C.

A pajeet code generator that spits out the absolute worst haskell code imaginable.
Or just make a new language called Jeet.

1. If unique ptr is not a pointer, why does C++ call it a pointer?
2. If traps are men, why aren't trap boobs SFW?

mp3 to chiptune converter

Such an implementation would be incredible horseshit. Never mind reentrancy; such an implementation wouldn't even allow for functions recursing at all.