/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

r-word.org/
twitter.com/SFWRedditGifs

nice 3rd thread retard

Updating god knows how many scattered utilities to pull customer email addresses from a different source because rather than fixing the clusterfuck Visual FoxPro data source that limited to 35 characters, they created a new database for them and started migrating one side of the company over to using it without bothering to tell anyone.

I think of picking up Clojure again. It's more fun than Haskell because it just werks.

This miku walks up to you and splatters you with Principles of Object Oriented Programming! (POOP)

What do?

Teach her the way of FP.

>2017
>still using FrontPage
WTF?

I used that shit for my Playstation Portable fan site hosted on FreeWebs. Good times...

reddit is the front page of the internet

LOL
got me good there fampai :D

>wow, looks like you made a joke!
>don't worry, here i am to redirect you to reddit

Dumbass question:
why is the below code giving me an "Expected expression" error?

#include
#define TESTVALUE 100
int main(int argc, const char * argv[]) {

int var1, var2, var3; /* initialize three variables */
var1 = var2 = var3 = TESTVALUE;

return 0;
}

>var1 = var2 = var3 = TESTVALUE;
is that even legal in sepples

It's legal in C, and the code compiles when I take out the comment, so yea

It works on my compiler. What editor / syntax checker plugin?

XCode. Just re-typed the comment and it works fine now.

I guess it was a weird bug.

I I have C program that loads dynamic libraries.
And I load 2 modules compiled from same memory managed language like Go. There will be basically 2 go runtimes running at same time in one program. Is that possible? Even if it's possible wouldn't it be huge overhead?
Is there any point in programming shared libraries in any other language than?

>It's legal in C
didnt know that, god what trash.

Why are you surprised?

>trash
You mean yourself? I agree.

>It's a good thing, but I feel like it's too late.
for what it's worth, it definitely seems like Microsoft hasn't given up on it yet. i don't know if this is a factor for you, but it's worth mentioning that C# is actually getting very popular in the industry lately in a way a lot of people don't realize. i know people at a number of large/well-known companies which use it for all their tools, testing, automation, asset pipelines, internal servers, etc. often even when their actual public-facing products/services use other languages/tech altogether, so often times you'd never know it from the outside. it can be about as easy to use as Java when you're not trying to do anything particularly fancy, but you can also just turn off the safety and get about as much control as C++ should you need it. Java is so baby-proof it can just get in the way if you know what you're doing and wanna break the rules, while C++ would be way overkill and a nightmare to maintain for things like internal tooling and such. that's why i really do see C# as something in between, as opposed to just Microsoft's Java knockoff. it has a very valid application space that it's extremely well-suited for

Genuinely curious, how is that trash?
It allows you to condense three lines into one line (that may be a bit difficult to understand at first), and can be used inside test conditions to condense otherwise longer code.

You'd rather put it on 3 separate lines?

Unless go is retardedly programed it should work.
>There will be basically 2 go runtimes running
Go can't compile?
>Is there any point in programming shared libraries in any other language than?
Just compile your shit.

Why isnt ALGOL there?
var,var2,var3 = TESTVALUE
assert(var,var2,var3 == TESTVALUE)

It allows the ol' if(x = y) bug that trips up thousands of beginners every second. Languages where either x=y must be a statement, or its an expression that evaulates to something non-boolean (usually the unit type), then you won't have this issue.

C people like to abuse this, though, a do stuff like
while ((c = getchar()) != '\n') ...
under the guise that "less characters = elegance" (which is simply not true)

>he thinks that the garbage collector somehow dissapears after compiling

encrypted network in erlang akin to HTML4. No JS/CSS poo, like the Internet back in the early 90's.

xDDDD

>muh garbage collectors
They're not so bad.

This isn't C abuse, it's idiomatic and highly encouraged because of how the assignment operator works.
Look at the stdio functions, most of them return values conducive of inclusion in higher order conditional statements like this.

>abuse
you're retarded

damn boi

No but there would likely be 2 different instances of go garbage collector running at the same time.

I understand that it's idiomatic, but it really convolutions the control flow of the program by putting a slew of side affects in a short amount of space. And it doesn't really help that order of evaluation within function arguments is undefined, so if you try to do these kinds of shortcuts in arguments, you're asking for UB. Modern languages have better solutions to stuff like
if ((status = do_operation(...)) != 0)
goto cleanup;

lol thanks, I'm planning it to be a mix of BBS and IRC

>no CSS
user I wouldn't want to have to specify the laundry list of properties of a tag every time. There's nothing wrong with tag classes and ids.

Also what's the syntax of the markup?

You better be using an S-Expression based markup.

Sorry I'm low on sleep so my grammar is pretty bad

>order of evaluation is undefined
Are you retarded?
In the example you posted, do_operation() is called, it's return value is assigned to status, then the entire expression is reduced to the return value of the assignment operator and this is then compared to 0.
It's extremely concise and I wish more people would program this way.

well it doesn't matter what you want, I'm doing this for people who want style-less HTML back. I'm aiming for a purely informational system. The syntax could be something like the github .md markup, or S-expression as you said.

Out of all the problems with C you complain about that?

The biggest problem with C is the lack of sane operator preference. Ideally you should write if statements and not need so many damn ()'s

Go is perfect for you then.

Go is not even a programming language.

>style-less HTML
So no font choices, no font color, no bold, no italics?

Only tables? God why?

Yes but if you have something like
do_operation(x, x++)
it's completely unspecified what values will be passed to the function. But I guess if you try to mix assignments inside expression ONLY in conditionals like above, then you'll be okay. This is why I strongly believe that C is only a decent language in the hands of a very careful and deliberate programmer.

It's not horrible but it's lackluster compared to variant types.
As for operator precedence, I'm of the opinion that unambiguous code is better code, this is why I'm a lisp weenie. The operator precedence rules for bitwise operations in C (and thus carried into many other languages) are so strange that GCC actually emits warning when you don't put enough parenthesis.

I'll add sane defaults (aka good looking tables and whatnot), there will be bold, italic etc styles but no CSS as I mentioned.

The browser will be in ncurses so no styling will be required. As I said a combination of IRC and BBS's of that time.

what do you mean by that?

I don't see how this is any different from calling
do_operation(x, (x = x + 1));

It's equally as stupid and ambiguous as to which value X will have, compilers are free to interpret this any way they want.

I need to a build a binary sequence out of 4 possible values. Right now I have the idea of just using a case/switch and a string-builder to just append 00/11/01/10 as appropriate and then converting the whole thing to a long or bigint from binary at the end.
Am I overthinking this? Is there a more efficient method that doesnt involve fucking around with strings?

how do I get practice after I've actually learned the basics of C++ and Java. When I mean the basics I mean I can do shitty command line programs.

My point was that assignment-as-expression only works if you constrain your expression to really simple cases, and it's easy to get carried away and violate that if you obsess too much over concise code

>buzzword spew
>zero understanding of what he's talking about
>your brain on lisp
lmao

>there will be bold, italic etc styles but no CSS as I mentioned.
I have no idea why you wouldn't let people specify bold, italics and other styles in a CSS type region other than out of sheer dogma. It originally was just a macro.

Yeah user, writing
(center color: black bold: background-color: red "text ...")

Every time makes me feel sooo legit instead of doing
(center style: ugly-style "text ...")

>expects different values from the same variable
How is the compiler supposed to guess what you want?

Are you retarded?

>C people like to abuse this,
>While assignment result != condition
Are you retarded?

>no arguments
>your brain on C
lol

I want to learn how to make software. Where do I start?

why go thru all that effort when you can just use things like b or i? think efficient user

Is there proper lisp without GC?

The C standard could easily just say "evaluate the arguments from right to left", which would make it easy to guess what you want

r-word.org/

That's naming and not concepts user. My argument still applies.

The OG lisp was originally collectorless. It was awful. The inventor of lisp invented the garbage collector because lisp sucks without a garbage collector.

Learn PSP.

>m-my argument still stands i swear
lel

i am saying, why bother making another file and writing 12 letters to make something bold, when you can just use a tag like b? if the markup was json based:

{
"h1":"This is a heading",
ul: {
"li":"one",
"li":"two",
"li":"three"
}
}

efficiency user, learn it

Why didn't I learn to use emacs earlier, this shits amazing with evil mode.

Best C++ book for someone who's already decent?

You're a total brainlet user. My point is not having a means of abstraction is retarded.

Stop getting in technical details like json vs s-expressions or the name of the bold tag.

My example was the desirability to replace many properties with one property. Not the name of the bold tag brainlet.

h1 This is a header
ul one
| two
| three

the standard specifying a strict parameter evaluation order could eliminate potential compiler optimizations, while the only benefit would be the ability to mutate and refer to the same variable in multiple parameter expressions, which presumably, at least at the time the standard was formalized, was not considered a significant use case

>resorted to namecalling
that was easy, thanks for the ego boost user

my argument was that it'll be unnecessary to have the feature you said if the short tags apply the styles anyway, removing the necessity for CSS, thanks for exposing who's the real brainlet here though ;)

Bjarne, Meyers, Alexandrescu
read erryday

thats another way to do it but JSON is more structured and newlines / tabs have cross platform issues so I'll stick to JSON for now.

JSON is trash.
More things need to adopt SDL

you are thinking beauty instead of efficiency, just like a woman, its kinda cute desu

SDL is beauty and efficiency though.

What's it about? ToC says nothing except it's something about planning and design of software which only partially answers my question.

>i definitely most assuredly didn't mock first so I have the moral high ground
Sure.
>writing tags like b, c, etc every single time is super fun. I would never want to abstract out of this
Please lookup what a turing tarpit is. It's okay though keep being dogmatic.

>What's it about?
It's about what the ToC says.

>only partially answers my question
In order to fully answer your question, I'd have to know what you don't know. I assumed you already knew programming.

>trash
It's perfectly fine. Why would you repeat yourself?
You write normal expressions with multiple operations all the time why not do the same with assignment operator?
Don't tell me you're one of those pedants that do SSA form for everything. That's so fucking onerous.

those guys. there's also a bunch of good shit online. check out:
Herb Sutter's GotW series
Jason Turner's C++ Weekly series
CppCon and BoostCon videos on YouTube

its not about moral, but about controlling one's emotions. you lost your cool first which i take guilty pleasure in. you should work on your emotional reactions and self-control.

calling me "dogmatic" reminds me of when tumblrinas call people dogmatic, you should try to think more critically, friendly advice.

why abstract it out if its a performance hit? just to say it's more 2017? i want the users to have as much as control over the system as possible.

If I was you I'd start taking HRT since you got the brain to go with it, I'm not trying to insult you either

This should be a decent starting point.

Look at whatever project looks interesting and start working on it.

forgot Sutter-sama
shame on me ;_;

internal void AkarinResizeDibSection(
int width,
int height
) {

if (bitMapMemory) {
VirtualFree(bitMapMemory, 0, MEM_RELEASE);
}

bitMapWidth = width;
bitMapHeight = height;

bitMapInfo.bmiHeader.biSize = sizeof(bitMapInfo.bmiHeader);
bitMapInfo.bmiHeader.biWidth = bitMapWidth;
bitMapInfo.bmiHeader.biHeight = -bitMapHeight;
bitMapInfo.bmiHeader.biPlanes = 1;
bitMapInfo.bmiHeader.biBitCount = 32;
bitMapInfo.bmiHeader.biCompression = BI_RGB;

int bitMapMemorySize = (bitMapWidth*bitMapHeight)*bytesPerPixel;
bitMapMemory = VirtualAlloc(0, bitMapMemorySize, MEM_COMMIT, PAGE_READWRITE);

int pitch = width*bytesPerPixel;
uint8 *row = (uint8 *)bitMapMemory;
for (int y = 0; y < bitMapHeight; ++y)
{
uint8 *pixel = (uint8 *)row;
for (int x = 0; x < bitMapWidth; ++x)
{

//Blue
*pixel = 0;
++pixel;


//Green
*pixel = 0;
++pixel;

//Red
*pixel = 255;
++pixel;

*pixel = 0;
++pixel;

++pixel;
}

row += pitch;
}
}

what is wrong with this? it gave me access violation error for *pixel but i already supplied that i want to read and write the memory?

because while a bit more verbose:
int x = 10, y = 10, z = 10 is more concise and doesnt leave room for confusion.

>he's concerned about macro expansion being a performance hit
wew

not allowed in C89

int x, y, z;
x = y = z = 10;

>calling me "dogmatic"
Unless you're some sort of Markov Chain bot trained on Sup Forums, you're irrelephant and off-topic here.

I know, just saying.

I don't agree with oop and I don't agree with protected memory.

Except that declares 3 variables. And has the same amount of 'confusion' probably since they both amount to zero.
x=y=z;

is super obvious. They're all the same value now. Z was never assigned to since it was the rightmost.
x=y=z*2;

Would also be fine. Is there any confusion?
x=y*2=z;

This is where there could be confusion but this is illegal because you can't assign to y*2.

Explain why you're confused beyond just being bad?

>I don't agree with protected memory.
why

Because he's a C programmerlet.

nvm im just retarded, need to omit one ++pixel

>writing a microkernel in Crystal
>unintentionally using a shit ton of C-bind calls
>don't know if it will compile
>terminal is just frozen

Wish me luck

>probably since they both amount to zero.
what?
And im not confused by anything, just pure subjective way of doing things. And setting variables works the same. Although that amount of mutation is a little much, id probably just make new immutables.

>he

thats not what I called you though, read slowly and absorb bit by bit, I think you're hellbent on losing this argument.
im concerned about useless features being implemented because they are "pretty"

>means of abstractions are useless
>I can't think of a way to implement macros without it being a performance hit to the user
I don't think you're cut out for software development user. I'm sorry. I'd advise you switch to database entry.

>It's about what the ToC says.
So analysis and design?

>I assumed you already knew programming.
Only imperative programming but it's something I guess. And I haven't even gone very deep with OOP, just the basics. At this point my primary language is C.

I don't know how to analyse the problem, design a system that solves it, think out all the use cases, model software and implement it based on all the previous steps, though I've been learning all these in uni (some of the courses related were complete shit, others though good, didn't force you to learn and I was lazy). I only know few basic design patterns provided I haven't forgotten them.
I know how to write clean, well defined code that I and others can easily maintain and extend (that's pretty much the only thing I learned at the courses I mentioned + I read Clean Code) but I don't feel like my knowledge is enough / I tend to not pay enough attention when in hurry and I tend to put off the work until very close to the deadline.
I don't know how to write defensively, optimize things, write portable code, I don't know TDD, how to design algorithms and data structures to solve my problem and prove their correctness, complexity, stability.

please /dpt/ I am losing my sanity, why does a while loop that fgets the stdout (proc_open) of a "docker run -t --rm -v ..." never finish? the code has no problem with normal shell commands.