/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

magicpackets.net:3000/proudfeet/netrunner
sstewartgallus.com/git?p=qlock.git;a=blob;f=tla/StackLock.tla;h=6884d808b5ffd605e912f4b12ae38928fd9b8313;hb=HEAD1
bisqwit.iki.fi/wspeed/
en.wikipedia.org/wiki/Metasyntactic_variable
phoronix.com/scan.php?page=article&item=gcc7-clang4-jan&num=1
twitter.com/NSFWRedditGif

Been fucking around with the Destiny API for fun. Why is their documentation so fucking shit?

a

you're doing it wrong.

Check the assembly in gdb.

ternary operators can only contain expressions, not statements.
You write this like
x = (a < b) ? c : d;

x=c IS an expression.

the ?: probably compiles into a cmov, the ifelse probably compiles into a cmp+jump
2 instructions versus 1, linus torvalds once wrote about cmov on a mailing list, it's not any faster just because it's less instructions.
idk about modern x86 but i would bet that cmovs still aren't faster, so if you compiled with optimization it'd probably make them both cmp+jumps.
assignment is an expression

x = c is an expression in C dumbass. I don't know about C++ tho.
x = c evaluates to c in this case.

So what you're saying is (? :) as opposed to (if else) have no advantages other than being more concise? (no performance advantages)

x = c; is a statement
c is the expression

?: lets you assign from the result

Web browser with security in mind and working from a terminal (without Xorg) magicpackets.net:3000/proudfeet/netrunner

Developers wanting to participate send an email

x = c is the expression
x is also an expression.
so is just c.
x = c; is a statement.

i don't know it for a fact but yeah, basically.
i would imagine the compiler is a lot more willing to do certain optimizations with ternary operators, but i'm not a computer scientist, compilers are outside of my scope.

x = c; is a statement! x = c is an expression! It's not that difficult to understand, jesus.

Are you still insisting that a

>rewriting this in a functional language lets you ensure immutability of state and that lets you reason about the program and prove it's correctness in a logical and mathematically sound way

It always cracks me up when limp-wristed javascript webdev cunts try to LARP as mathmaticians.
Why do programmers have such delusions of grandeur? Especially the CS grads.
You're writing bottom of the barrel garbage CRUD code that glues other people's libraries together, stop pretending you're a mathmatician.

It literally is.
x=c is itself an expression, that's why you can chain them like y=x=c; That's why in C++ you overload = by returning *this.

Well, it's not due to the ?: having a stronger precedence than =, so it ends up being
((a < b) ? (x = c) : x) = d;
which is wrong. Placing () around the assignments fixes it, though.
(a < b) ? (x = c) : (x = d);

No errors, no warnings. Output is 7.

why do you care so much? you sound like someone who tried to get into development but failed horribly.

Ararararagikun

You got a weird version of emacs there.

very lean vim with a few plugins and a small config file. I don't use it very often.

Yeah well you sound like a piece of dookie butt that smells like I put my hand in my mother's butthole.

Pardon me, that song is stuck in my head really badly.

It's quite similar to my emacs (in gui)

Anyone know why mailx won't send me anything?

echo "why the fuck isn't this sending" | mailx -s "shit" @vtext.com

/dpt/, I'm sick of this "girl (male)" meme.
Homosexuality is ALWAYS wrong.
Ooh, you think you're so fucking edgy with your "it's not gay if it's a feminine penis."
How is "it's not gay if it's a passable tranny" any different from "it's not gay if it's a child," WHICH, IF YOU'LL RECALL, is exactly the sort of attitude that was why Lord Jesus Christ our Savior and God damned the ancient Greeks?
I hate everyone in this thread. Fuck you.

not programming related

like it or not, bash scripting is technically systems programming -- although, granted, of all the possible valid uses of the term, it's probably one of the cringiest

I'm using mailx as part of a program that I'm implementing that's supposed to send mail periodically. I just can't get it to work. What I posted was an example of how it's not working.

Got it to work. Had some fucked up SMTP settings

C++ or Rust?

Programming Challenge
Write a routine that prints "Hello, world!"

Programming is an inherently feminine and secular activity.

See sstewartgallus.com/git?p=qlock.git;a=blob;f=tla/StackLock.tla;h=6884d808b5ffd605e912f4b12ae38928fd9b8313;hb=HEAD1 for the code.

On many-core machines spin locks can be slow because the cores ping each other constantly. To improve on this people often use test-and-test and set locks as loads from a memory location are often cheaper than exchange and compare and exchange operations. However, there is still a small amount of intercore communication which can be expensive on machines with a whole lot of cores. To improve on this the MCS and CLH queue locks were invented. Basically, in these algorithms each waiting core spins on its own separate memory location which is linked into a queue. This may possibly be faster in some scenarios although for little-core machines the added complexity is often slower. A deficiency with these algorithms is that the waiters are ordered in strict FIFO queue order and no other scheme is possible. For example, one might want to use a priority queue (for hard real-time scenarios) or a stack (for better raw performance.) I came up with an algorithm (which I think is new but might possibly not be as I am not really an expert on this topic) that allows the ADT details to be easily replaced by any structure that offers push, pop and isEmpty functions. This algorithm can then be used with stacks or priority queues.

I implemented this algorithm in Rust (with the specific case of a stack) and then formalized the abstract details in TLA+ which led to me discovering and fixing a deadlock bug. So far, I have run and tested the model under a number of threads but past 4 or so threads the model checker becomes very slow.

This, just look at programmer talks, half of those scrawny ass fuckers probably take it up the ass and dress like women on the weekends. It doesn't help that they have the vocal fry and that annoying upward inflection when speaking.

What shitty fucking programming talks do you listen to?
Rust talks? Javascript talks?

>routine

int main() {
anus
}

Void main{}(
[foo]hello; world""
Return bar,
>

int maaaaaaaaaaaaaaaaaaain() {
puts("SPLAT!");
puts("ow that was a long fall");
}

even though this is the not dumb way to write it still does the same thing.

hello world

#include

void main() {
string occupation;
std::cout

Rust any day.

C++

>std::cout >>
fucking jej

Rust

the template syntax is not as ugly as C++, though it's still kind of ugly. Type traits beat multiple inheritance of virtual classes anyday.

Does rust require you to use braces even on single-line conditional statements?

What an ugly fucking language.

>Does rust require you to use braces even on single-line conditional statements?
no

I've found that running strings on EXEs (not stuff I wrote, mostly small freeware games) sometimes turns up absolute directory paths that are clearly nothing from my computer, and presumably are the path to the program project on the developer's computer. What's the point of this? Obviously they're not really useful to anyone but the developer, and doesn't it potentially present a security/privacy risk?

Debugging. The debugger needs a path to the source code. Personally, I strip such paths out of my projects for deterministic build reasons.

Yes, it does.
if (cond)
do_thing();
is invalid. They actually removed the need for () around the conditional, so it would be
if cond {
do_thing();
}

Is there any reason it isn't automatically removed from release builds? I mean isn't that kind of the reason to have separate build options for debug and release?

Good riddance

Developing an interactive webmap and integrating it into my businesses webmap.

If anyone has any past experience with this kik me at slickman130 plz, itd help

information wants to be free
art doesn't
a game is art
a game engine is information
therefore games should consist of nonfree content intended to be interpreted and presented by free engines

if you're more concerned with shit like this than with actual programming you should join the fsf
kick stallman in the fucking face for me if you have the honor of meeting him

>kick stallman in the fucking face for me if you have the honor of meeting him
Fuck you, retard.

...

>what is this """actual programming"""?

Ternary Conditionals are comfy AF

what's not to hate about him?
he's fat, which is both viscerally and morally repulsive
honestly that's enough reason to hate anyone, but as if it weren't, he's also a commie

>a commie
fossmunism has never been tried

@60921969
(You)

>he's fat,
>So I hate him xddddd
Parents need to beat up their children more often

wow what the fuck fuck you
yes fat slobs are disgusting but they're people too you prick
i mean i fucking hate them as much as you do but it's not like i actually endorse that hate, it's just something i let myself feel just because i can't not do so
everyone has their own reasons for being what they are dude, it's super fucked up to just hate whole categories of people and actively assert that every single one of them deserves it

Is there any functions in the C/C++ language that isn't in the header files?

Meaning I could call them even if I didn't included any headers?

eg
int main()
{
foo();
return 0;
}

No. Compiler built-ins don't count.

(x = c) also lets you assign from the result. y = (x = c); is valid.

why dont you guys program in lambda calculus
It only takes 4 lines of code
eval (\x. y) env -> (\arg. (eval y (x,arg):env))
eval x (y,b):env -> eval x env
eval x (x,c):env -> b
eval (x y) env -> ((eval x) (eval y))

C++ but save it to a .c file. If it doesn't compile with a regular c11 compiler then you're writing C++ wrong

How hard is to port a DOS program to Linux if my skills as programmer are virtually non-existent? Specifically I want to port this bisqwit.iki.fi/wspeed/

>Kate crashes each time I open the file picker dialog
The power of C++

Use dosbox or an emulator. You'd have to learn how syscalls work, then learn most of the DOS syscall library and then most of the linux syscall library, and that's assuming the dos program was written in C and uses the c standard library, which might be a problem

>C++17
>Still doesn't support non-trivial designated initializers.
What a fucking joke.

>C++
Found your problem

So is double work right? And if I want to pull this off, what resources can I use to learn about this stuff?

man dosbox

lol
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Aborted (core dumped)

Can someone explain what this foo bar crap is? I've been programming through highschool and college and still haven't seen this outside of tutorial examples.

en.wikipedia.org/wiki/Metasyntactic_variable

What if we had all the power and convenience of functional programming AND the speed of LLVM binaries?

Then that would be cool

But we don't, at least not in some form that comes without glaring issues

llvm binaries are slow though, gcc has way more optimization

Rust is the closest you'll get

How do I consistently get into the mindset to program?

I've been doing webdev stuff for the past year and a half. I've learned HTML, CSS, a bit of Javascript and PHP and will probably start python soon, but I'm an absolute shit programmer who can't problem solve their way out of a wet paperbag.

Thing is I need to do a literal meditation process where I examine my life, work my way through massive self esteem issues and burn some incense before I can even START programming when I'm at home. I have trouble concentrating on anything and have few inherent math skills.

I probably should throw in the towel and realize that this just isn't for me, but I've done that three times before in life and yet here I am back trying it again, and I've been doing it for a year and a half without giving up, so that says something. Also the way I see it it's pretty much the only way out of minimum wage hell at this point. I have NO social skills whatsoever and I don't really like people that much. I spend most of my time on the computer so it makes sense that my job should involve that in some way.

How do I do it?

Abuse amphetamines

Is there a way that wont fuck his shit up in 10 years?

No

Your mileage varies by application of course, but these days LLVM usually is comparable. In these benchmarks it wins more often actually ,but I'm cautious to generalize those numbers, since historically that hasn't been the case. phoronix.com/scan.php?page=article&item=gcc7-clang4-jan&num=1

But anyway, LLVM has been progressing fast.

You just have to push through and keep trying anyway. That doesn't guarantee results, but not trying guarantees no results. Programming was really frustrating when I first started too.

If you don't understand everything about programming right from the get go you were not cut out of this kiddo,

or life. you should kill yourself

*puffs vape*

I showed that script kiddie

Dumb frogposter, kill yourself.

What is XML used for? Is it just a file type? I'm reading about a DSP chip that stores it's firmware builds in XML files, and I don't really know what that means.

Any time you see "foo", "bar", "baz"... It's a pretty good indicator that the person can be safely ignored on any and every topic relating to programming because they are a dumbass cargo culting idealogue who probably still thinks goto is EVIL

Rate my first program (please don't judge on language):
# Prompt for input to "guess" variable [00,61]; input other than an integer
# is caught and ignored.
import time

x = int(time.strftime('%S'))
guess = None
while guess != x:
try:
guess = int(input('Guess an integer:\n> '))
except ValueError:
print('Not an integer! ', end="")
continue
if guess < x:
print('A little higher. ', end="")
elif guess > x:
print('A little lower. ', end="")
else:
print('Congratulations, you guessed it!')
if input('Guess again? (y/N): ') in {'y', 'Y'}:
x = int(time.strftime('%S'))
guess = None

Triggered, wojak?

It's a file type syntactically similar to HTML that's used for storing data in a format that's more or less readable to both machines and humans.

It's used less often these days cause it's bulky and annoying. But it's pretty easy to read if you already know HTML. It basically represents a tree of named data points.

Often people will set up their programs so that instances of objects can be serialized to and from tags in XML.

Interesting, thanks.