/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

courses.csail.mit.edu/6.831/archive/2008/lectures/L16-constraints-layout/L16-constraints-layout.html
en.wikipedia.org/wiki/Cassowary_(software)
en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_establishment
dlang.org/phobos/std_stdio.html#.readln
ddili.org/ders/d.en/input.html
dlang.org/phobos/std_stdio.html#.readf
dlang.org/phobos/std_format.html#.formattedRead
github.com/Abscissa/scriptlike
twitter.com/AnonBabble

First for PHP

>tfw no fast (nearly C speed) and moderately expressive PL exists that isn't a clusterfuck of bad design

First for KISS!

There literally is no good programming language

Is Berkeley sockets the networking API for modern Linux distros? This book I'm reading is pretty old.

A good JIT and a good GC is all you need

Yes afaik. There are a few backwards compatible extensions and that's it. Why would they change it if it ain't broken?

-> man 7 socket

Will SCIP really help me if I bother to read it fully?

[autistic screeching]

What's stopping me from spoofing some guy's IP in the source address field of the IP header and spamming known cp honeypots with HTTP requests to get him v&?

a successful TCP connection is harder to fake than UDP because both parties talk back and forth. If you can't cause the TCPP packets from the server to route your way it won't work, and if you manage to it's basically your IP at this point. Besides, IP is not a reliable way to identify someone at all, and courts have been starting to recognize that. And if you get caught basically "swatting" the guy, which you will, you're in large trouble.

The average /dpt/ poster would benefit from reading any book at all, if only to practice reading.

I know you wouldn't actually be able to establish a connection (without actually intercepting the packets on the wire itself, which isn't really practical), but just sending the spoofed requests seems like it could get someone flagged by NASA.

Are there any UI toolkits that don't work based on pixels or percentage but just scale based on the widgets and the window size?
Whenever I google this I get random shit like
courses.csail.mit.edu/6.831/archive/2008/lectures/L16-constraints-layout/L16-constraints-layout.html
or
en.wikipedia.org/wiki/Cassowary_(software)

Wouldn't that just be scaling by a percentage of window size...?

>using a constraint solver to calculate GUI layout
And there I was, thinking I had an original idea...

Sort of? You'd still need a starting size defined for everything at the base scale though.

>Thanks for illustrating exactly what I'm talking about when I talk about your Stockholm Syndrome
i did say "in the context of the language". and again, i and every other C++ programmer can imagine a more ideal language. often languages already exist that do a given thing in a pretty agreeably more ideal way, but they compromise on performance (and, generally, control) which makes them worth considerably less (worth essentially jack shit even, in some application spaces). make a syntactically/semantically better language that matches or surpasses C++ in efficiency, and you bet your ass i'll be on board. hell, one of my long-term goals is to try and do just that. but in the meantime i'd rather use the best thing currently available than sit around bitching and waiting

>The only C++ "programmers" who are aware enough use it as a glorified C and avoid the vast majority of its features
you're supposed to pick and choose what features to use based on your use case; that's part of the core philosophy of the language. i can't imagine a project which would genuinely demand the use of all or really even most of the features anyway. they're there if you want/need them. that's kind of the point. most of the programmers of the sort you're referring to are just autistic as fuck and avoid even features that would benefit them at no cost if they knew what they were doing, though. i certainly pick and choose features, and even uphold a "should match or surpass analogous C in performance" restriction for much of my code, yet still i find that it affords me the use of quite a few high-level features (sometimes even requires it, particularly in the "surpass" case) and allows me to write relatively concise and expressive code that looks very little like C (and thanks largely to modern features, i don't mean template hell)

>Every user of every piece of trash language says this
the difference is that when C++ programmers say this, they aren't lying about the "efficient" part

I don't really get what you're going for. You want a control to scale with the window size, but you don't want to define its scale as a percentage of window size?

>make a syntactically/semantically better language that matches or surpasses C++ in efficiency, and you bet your ass i'll be on board.
Better keep an eye on Rust then. Discounting the borrow checker (and all the &mut 'static ref that comes with it) it does seem to nail this concept.

>You want a control to scale with the window size, but you don't want to define its scale as a percentage of window size?
Yes. I'd like to be able to just add widgets and have it automatically figure out the sizes for them depending on how many many were added.

>i did say "in the context of the language"
And what you mean by that, of course, is that every badly designed misfeature of C++ is the lesser of multiple evils given all the previous design errors, which you've come to accept over time, because you can no longer imagine a language with solid foundations. Thanks for illustrating exactly what I'm talking about when I talk about your Stockholm Syndrome. Go ahead and repeat this "context" argument again.

>often languages already exist that do a given thing in a pretty agreeably more ideal way
>they compromise on performance (and, generally, control) which makes them worth considerably less
>worth considerably less
Cool opinion. Not an actual argument, though.

>make a syntactically/semantically better language that matches or surpasses C++ in efficiency, and you bet your ass i'll be on board
Any moderately competent programmer could make a more coherent, more expressive language that matches C++ in efficiency. The problem is that moderately competent programmers have no need for a better C++, and the people who need a better C++ are too dumb to come up with one themselves.

>you're supposed to pick and choose what features to use based on your use case; that's part of the core philosophy of the language
Nice deflection. This doesn't address the fact that many companies avoid most of the features of C++ simply because those features are horribly designed.

>the difference is that when C++ programmers say this, they aren't lying about the "efficient" part
Irrelevant. The point is this: pick any shitty programming language and ask its users why they use it, and they'll give you a completely analogous "it's not perfect but it gets things done and seems better than the alternatives" argument.

Sending a FIN packet to a honeypot isn't even criminal activity because there is no CP in a FIN packet. (assuming TCP because HTTP and almost everything else is) (assuming again that you can't intercept packets) And I don't believe you can maintain the fakeness while not receiving the response packets and having them go in the wild. Additionally, that's a long way from getting someone convicted - inconvenienced maybe, and I don't know about the US because I'm not in it - because whatcha gonna do? Storm the IP guy's house and take him away, then bring him to the judge (yknow, due process and all this unproductive crap that prevents us from dropping pedos on the spot) and say "yeah, we set up a CP server and it looks like he connected to it based on the IP", well first off if you're dealing in CP congrats for embarassing yourself, secondly if there's actually no CP on the server then what's the crime exactly, and thirdly the guy is going to vehemently deny seeing the CP and rightfully so, and in our hypothetical scenario they have no actual evidence, so what's going to happen? Bottom line is: the main concern of the NSA is "common sense" crypto control, not CP, and when it comes to CP, law enforcement aims primarily for the platforms because it's easier and more effective, not the IP guy because it's not efficient, and even if they flag the IP guy they will try to silently wiretap him or search his harddrive for more evidence, not hang him on the stop, so...

TypeScript will save systems programming

>TypeScript

What's the point? It's annoying enough dealing with the 923947829716 required packages in every JavaScript project without having to deal with an entire additional syntax on top of that. Does TypeScript even find any transpile-time errors that the millions of JavaScript error-checking tools won't find?

Also, they've actually been trying to make JavaScript not as shit lately, so it'll probably implement anything TypeScript brings to the table on its own eventually.

I thought wasm was supposed to save us from this retardation anyways. Whatever happened to that?

>replying to bait
I shiggy DIGGY

Actually, let me correct myself: the people who you'd think would want a better C++ don't actually want a better C++, because they make a career and gain job security out of how fucking bad C++ is. This is why there will never be a better C++.

>go on the site yourself via a proxy while recording all your outbound traffic
>change the source IP in all the recorded packets to Bob's IP
>replay the entire session
>Bob gets arrested

Should work if there's nothing fancy going on with scripts or encryption or sessions or anything.

I'm a programming tutor at uni and I can't believe how many people just don't understand how inheritance works in java.
I explain it to them a million times and draw diagrams of the connections between interfaces and classes but then when I give them an exercise they don't know where to begin.
Does anyone have any suggestions on how to deal with this? I'm starting to think brute forcing it doesn't work.

>2011+7
>still using inheritance

All the cool kids use type objects these days

I have to show them, it's in the curriculum that I didn't design. Not my choice.

Working on a project in Rust.

dmd -betterC

Then just use the superficial examples you see in books about dogs being animals or whatever.

KRunner for KDE that does TOTP (Google Authenticator) shit.
Building a GUI for proper token management in Qt + QML but still not sold on QML. There's a lot of memory overhead there - application basically takes 30MB RAM minimum. Also, you have to write a lot of extra code to tie QML C++. Very painful. Very disrespectful.
Anyone else worked with QML? I kind of think the approach they've taken there is a mistake. Don't really like the fact it has to load a JS engine, would've rathered they kept it all C++.

You must be doing something horribly wrong. If you think about it, the most insidious thing about Javaesque "OOP" is precisely the way it appeals to peoples' irrelevant real-world-based intuitions with cutesy examples like "a carp is a fish, so carp is a subclass of fish".

Without seeing the exercises you've prepared I wouldn't know how to give advice.

Show us how the exercises look like.

Not even sure that would work. You would not receive the B number as described in [1]. Besides the routing equipment is going to chimp out imho. Altho the only way to know is to show a working proof-of-concept, I'm speculating right now. In addition to that, plain HTTP CP servers in 2011+7? Not plausible. And as I said there's no such thing as Bob's IP address

[1] en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_establishment

I've used QML for some hobby projects, but I had the same issues. Binding with C++ and vice versa felt very unnatural. QML itself is pretty cool though.

No, you're not.

>Qt

All the cool kids are using Electron these days.

Yes, I am.
I'm currently trying to get input handling to work using termion. That crate is a bit weird though.

There are no Rust projects therefore you are not working on a Rust project. Stop trolling.

Go to bed, Bjarne.

If he's worried about memory overhead he probably doesn't want to use anything Chrome related.
Tried wxWidgets? It's a nightmare to work with but it runs great.

I doubt Bjarne or anyone in the sepples core are afraid of Rust. It really has no staying power, nor will it ever get close to dethroning sepples.

>It really has no staying power
That's what they said about PHP and it's still being used.

>they

Who's that? You nodejs fag friends in highschool?

yeah, i'm planning to give it more than a cursory look once i'm done with my current project. as far as i can tell so far (from what relatively little i know about it, and giving it the benefit of the doubt in terms of what i don't know), it seems (potentially) theoretically possible that it could eventually match C++ in performance, but realistically if that does happen i don't think it'll be any time particularly soon. it'll be pretty major if it pulls it off, though

kek. okay

Nobody is making new websites in PHP. Nobody is making new PHP frameworks. PHP is legacy.

PHP is largely irrelevant though.
Banks and the government still use fortran, it doesn't mean fortran is relevant.

>implying I'm a SJW
We (the company I work for) still uses PHP for all back end related work. Sad, but true.
My point is: languages don't just die.

Haha, what are you smoking? PHP is still by far the top language for webdev. It's actually Node and the other hipster garbage that are shrinking in usage after their "boom". Modern PHP with a modern framework like Laravel absolutely shits on anything else.

>Electron
so that's where all this soyware is coming from

Stuff like traits can often be more efficient than C++ equivalents like abstract base class interfaces. Just depends on what you're doing. In many ways it feels like they took the best ideas of modern C++ (e.g. RAII and move semantics) and tried to make a new language out of it, unencumbered by historical mistakes.

>My point is: languages don't just die.
Yes, and if you weren't incredibly thick, you'd realize that's not what I'm saying.

>Write a group of interfaces and/or classes that represent these geometric shapes:
>Rectangles (rectangle, square)
>Triangles (equilateral, right, isosceles)
>Circle
>Each of these must have a method which calculates the shape's area and a modified toString method that prints out relevant information about the body (the edges, area, in the case of circle the diameter)
>Then, try writing a group of classes that represent right prisms with these shapes as their bases (they must include a toString and volume and area methods as well)
>Keep in mind that you can do this whichever way you like, but try to be as efficient as possible

JAVASCRIPT WEBSITES
JAVASCRIPT BACKENDS
JAVASCRIPT DESKTOP APPLICATIONS
JAVASCRIPT OPERATING SYSTEMS

THE FUTURE IS JAVASCRIPT

pls no senpai

Trying to input and output a string in D. Problem: input gets blocked after the string input, I don't know how to terminate the input string other than press C-D, which makes the program to skip the second readf altogether.
Any advice?
import std.stdio;
void main() {
write("How many students are there? ");
char[] groupid;
stdin.readf(" %s", &groupid);
write("How many students are there? ");
int studentCount;
readf(" %s", &studentCount);
writeln("Got it: in the group ", groupid, " are ", studentCount, " students.");
}

the future of web is haskell and idris trans-piled JS.

Not all quadrilaterals are rectangles.

I tried explaining inheritance trees in math tutoring at some point, but it didn't work.

What if we made a CPU with hardware javascript support?

PHP is still being used for legacy and new applications. It's on the 9th place in the TIOBE Index. I wouldn't call that irrelevant.

nigga what are you doing
dlang.org/phobos/std_stdio.html#.readln

I was translating so you know, it's not gonna be 100% accurate

Not an argument, kiddo. Enjoy LARPing as a "systems programmer" with your trashlang while the rest of the world moves on from the botched abortion you're stuck shilling for.

JavaScript bitcoin

Shapes are a bad idea for teaching implementation inheritance I think.
If you were to ignore inheritance of implementation with classes and only allow inheritance of interface then I think you could arrive at an intuitive explanation.

>breaking yonkoma into 1-3koma

Learning D the hard way I suppose ;_;
using this book ddili.org/ders/d.en/input.html

Thanks for the tip!

Still, is there a way to get *my* version working, that is, with stdin.readf
?

Go for stdin.readln tbqh. input functions ending in f that try to mirror output functions ending in f were a mistake.

What if we wrote a Javascript interpreter... in Javascript?

>char[] groupid;
don't do that.
string groupid = readln;

but you should really input the proper types so you don't have to convert later.

this is exactly why I started using buffered readers literally everywhere, it's much more easy to control

What if your wife interpreted my dick?

I looked at the docs but it's fucking shit. It doesn't explain how input fstrings are handled at all.

dlang.org/phobos/std_stdio.html#.readf
"see formattedRead"
dlang.org/phobos/std_format.html#.formattedRead
doesn't explain shit and redirects you to the output formatting facility.

Shit that's even worse than the C counterpart.

>using wikipedia as sauce

D is even more inconsistent than C++, it's just that it isn't as bloated and overloaded. Better templates and UFCS are good but it's not worth it.

Your point being?

>Microsoft: fuck C, C++ only!
>all the low level Windows APIs are blatantly C-like

This is actually a classic illustration of misuse of inheritance. e.g. you could think of a square as a special case of a rectangle, but does that imply an is-a relationship? Probably not, because it makes perfect sense for a rectangle to have setWidth/setHeight methods, but not for a square. I guess you could file all of them under a 2D shape interface that lets you calculate the area/circumference, but that has nothing to do with inheritance.

Thanks. The book I'm reading is actually not so good, but my prior C knowledge helps a bit. The explanations are sometimes misleading or strange or inconsistent. E.g. the author recommends using size_t for counts, but then in examples there's "int count".

Do you mean the readln function?

I suppose I fell for things like github.com/Abscissa/scriptlike and its seemingly simple nature.

It sounds doable. I remember doing similar exercises at uni during OOP brainwash classes.
I think that your students fail to see the relationship between different shapes.

>generating UI using procedural methods is hard
What a dummy. Sure if you're gonna write your UI as draw calls in opengl it's hard. But that's just silly.

>I think that your students fail to see the relationship between different shapes.
I think you fail to see that there is no sensible relationship between the different shapes, besides their all being 2D shapres.

>another chan deployed a fork of my imageboard engine
Feels good, man.

>Shit that's even worse than the C counterpart.
At least there's a way to find the answer - analyze the C code D translates to.

>the only thing 2d shapes have in common is being 2d shapes
t. 3dpd

It could work if they were immutable then? But yeah, representing a square as anything other than a rectangle that happens to have w == h is silly. I think the problem asks for only three classes (Square, Triangle and Circle) tho.

It wasn't meant to be "everything is in a relationship", that's why I said "write groups of interfaces and/or classes".
I wanted them to make multiple interfaces for those grups separately but I guess I should make that a bit more obvious next time.

t. brainlet

Doesn't it translate directly to ASM? If so your method could fail because the actual code might not be a call to scanf at all.

>world modeling
Worst idea ever.

QtQuick and Qt in general, to some extent.

which one?

>analyze the C code D translates to

What exactly is the expected answer to the problem you posted? (apart from "fuck you your teaching is bullshit" obviously)