[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vr / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / asp / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / qst / sci / soc / sp / tg / toy / trv / tv / vp / wsg / wsr / x] [Settings] [Home]
Board
Settings Home
/g/ - Technology



Thread archived.
You cannot reply anymore.



File: 1484484066916.png (389 KB, 934x1000)
389 KB
389 KB PNG
What are you working on, /g/?

Old thread: >>63352920
>>
>>63362407
making my first android app according to the android tutorial
I plan on making a DnD character creator
>>
r u s t
>>
>>63362446
is shit
>>
So now that wasm is in every major browser
how should we btfo javascript?
>>
>>63362473
god bless you idio-rust-kun
>>
trait PrintIter
where Self: std::iter::IntoIterator + std::marker::Sized
{
fn print<V>(self, buf: &mut V) -> std::result::Result<usize, std::io::Error>
where Self::Item: std::fmt::Display, V: std::io::Write
{
self.into_iter()
.enumerate()
.map(|(i, v)| (i + 1, v))
.map(|(i, v)| writeln!(buf, "The {}th item is {}", i, v).map(|_| i))
.fold(Ok(0), |ret, val| ret.and(val))
}
}

impl<T> PrintIter for T
where T: std::iter::IntoIterator { }

fn main() {
vec![1, 35, 64, 36, 26].print(&mut std::io::stdout()).unwrap();
}
>>
>>63362483
wasm is still hacky shit, give it a few more years.
>>
>>63362493
Reminder to ignore Rust false-flaggers. Everyone knows Rust really does tend to look that way the moment you go beyond fizzbuzz and vector iteration.
>>
File: Capture.png (57 KB, 648x107)
57 KB
57 KB PNG
i sure hope you aren't using shared* in your code, /dpt/.
>>
>>63362532
If they had been using shared_ptr for the purposes it was intended for (shared ownership of memory), they wouldn't have been able to replace it with raw pointers/references easily without a major redesign of the entire system. So I guess the moral of the story is that you shouldn't just mindlessly put everything inside a shared_ptr, because reference counting and locking has some overhead?
>>
>>63362572
>B-but muh z-zero cost obstructions...
What a typical sepplescuck response.
>>
>>63362572
Use the superior intrusive_ptr. weak refs can be kept in ordinary pointers, and convert back to strong refs anytime.
>>
Currently working on a program for my university that allows students to put in a bunch of classes and times that they're available to be at school that will just spit out a few different schedules for them to choose from. Does anyone have an experience doing anything like this?

From my little bit of research it seems like an evolutionary approach is the way to go for this problem, and earlier tonight I implemented a simple evolutionary algorithm that generates pretty damn good schedules, and while I'm happy with it, I want to know if theres a better way.

I figured that I could represent the classes that the student is interested in as nodes in a graph, where the edges of the graph represent the LACK of a conflict between two classes, which means that I would be looking for cyclical groups that for cyclical groups with every other member of their group. Does such an algorithm exist? My genetic implementation actually seems to work really well, but it seems like such a Jerry-rigged way of putting it together.
>>
>>63362587
>implying anyone ever said shared_ptr has no cost
Shoo, retarded Rustlet.
>>
>>63362572
this
>>
>>63362643
But Rust uses recounting, more often than C++ due to borrow checker limitations.
You're talking to a Cnile.
>>
>everyone's too busy talking about rust to discuss anything else
whelp, better learn this fucking meme language so I'll be employable in the future
>>
>>63362752
employable at reddit
>>
>>63362752
>everyone
it's literally the same 3 people, and idiomatic-poster just shitposts with it.
>>
>>63362763
>>63362773
So what are you guys working on?
>>
>>63362782
learning vulkan
>>
File: govnocode.webm (924 KB, 600x336)
924 KB
924 KB WEBM
What does waits beyond the horizonts of govnocode?
>>
>>63362787
What are you gonna do with it?
>>
>>63362797
Write a wrapper and eventually a modular library focused on games since I'm tired of settling for shitty SFML bindings.
>>
>>63362813
godot 3 is decent tho
>>
>>63362863
I don't want to work with !python and engine-bloat. Plus it's more satisfying and better in the long-run to roll my own everything.
>>
I'm trying to make simple stick figure do jumping jacks.
First I thought to only change location of one arm and it worked but old location and figure of the arm remained on screen. Why? I'm changing location of the line now drawing new one.

public class Guy {
private Circle head;
private Line leftArm, rightArm, leftLeg, rightLeg, torso;
private int _x, _y;

public Guy(int x, int y){
head = new Circle(x,y);
_x = x;
_y = y;
torso = new Line(x +30,y + 60, x+30, y+140);
leftArm = new Line(x +30, y+90, x-10, y+110);
rightArm = new Line(x +30, y+90, x+70, y+110);
leftLeg = new Line(x+30, y+140, x+10, y+180);
rightLeg = new Line(x+30, y+140, x+50, y+180);
}

public void fill(java.awt.Graphics2D aBrush){
head.fill(aBrush);
torso.fill(aBrush);
leftArm.fill(aBrush);
rightArm.fill(aBrush);
leftLeg.fill(aBrush);
rightLeg.fill(aBrush);
}
public void move() {

leftArm.setLocation(_x -10, _y+70);
}
}


And Line
public class Line extends java.awt.geom.Line2D.Double{
private int _x, _y;

public Line(int x, int y, int a, int b){
super();
_x = x;
_y = y;
this.setLine(_x, _y, a, b);
}

public void fill(java.awt.Graphics2D aBrush){
aBrush.setColor(java.awt.Color.black);
aBrush.setStroke(new java.awt.BasicStroke(3));
aBrush.draw(this);
}

public void setLocation(int a, int b) {
this.setLine(_x,_y,a,b);
}
}
>>
>>63362871
I thought they added ==python.
>>
>>63362895
I don't want to work with script shit.
I'd rather have the choice to easily embed any language i want like an Idris. But that's getting way ahead.
>>
>>63362639
a group of nodes that share an edge with every other node in the group is called a clique. finding whether a clique of a given size exists and finding the largest clique(s) are all np-hard problems, but there are decent heuristics available.
>>
>>63362879

Cause you're drawing to the same framebuffer as the previous frame. It's like taking a piece of paper, drawing a picture, and then drawing a new picture right on top of it. I'm not familiar with that particular graphics library but their should be some function like "clearscreen" somewhere. I've only used openGL to do graphics but it's GLclearcolor in that world, I reckon it's something similar in yours.

Just to preempt your next question, there is something called double buffering where you fully render to the framebuffer and then swap with the active one that is rendered to the screen to prevent screen tearing
>>
>>63362990
Yeah there is, "repaint". I'll fiddle with it more, thanks
>>
>>63362741
>You're talking to a Cnile.
But Cniles use refcounting a lot too.
In mpv, in linux, etc.
>>
>>63363045
Talking more about fizzbuzzers than actual developers here
>>
>>63362407
Rust is truly the nicest language to do pointer arithmetic in. It's very capable of it, does not have nearly as many gotchas while doing it as C++ and makes it easy to write custom allocators or convenience pointer wrappers.

Also, you get to trigger some people with unsafe blocks. It's perfect.
>>
>>63362879
>>63362990

Oh yeah, I'm not really sure you understand what your "line" object and your "fill" function really represent.

Your line is just a set of numbers that represents relative position in coordinate space. When you call fill on that line it translates that coordinate space to the actual pixels in your framebuffer and fills them in so to speak via a process known as rasterization. Same deal if you were projecting 3d coordinates onto the framebuffer but the math would be slightly more complicated (not much more complicated than you would expect though).

So, when you draw and then move your line, the rasterization has already happened and you are merely moving the representation of your line in coordinate space again, the rasterization remains. You probably figured this out but it's good to know it explicitly and to know some of the terms in case you have to look something up in the future.
>>
File: Clipboard01.jpg (10 KB, 469x315)
10 KB
10 KB JPG
Let's peep what kind of people are downloading my app...


Most of them are burgers as expected, but i have some pajeet users too and holy shit a nigerian prince has installed my shit as well, breddy cool

And how many niggerians are using YOUR code anonchans? .. Yeah i thought so.
>>
>>63363064
>Rust is truly the nicest language to do pointer arithmetic in.
false. give me your example of "nice" looking PA.
>>
>>63363064
>Rust is truly the nicest language to do pointer arithmetic in
>
unsafe {
*ptr.offset(n) = x;
}

>compared to
>
ptr[n] = x;

LMAO
>>
>>63362639
You the annoying kid with brown hair in seng265
>>
>>63363144
get ye gone ESL
>>
>>63363074
My software is used by millions of people all over the world.
My github: https://github.com/torvalds
>>
>>63363163
Don't be silly, about 0.0001% of Linux users compile their kernel from the git.
>>
https://www.youtube.com/watch?v=XsFQEUP1MxI

What editor does Fun Fun Function use?
>>
>>63363178
And about 100% of linux users had their kernel originate from the git, which is written by me.
>>
>>63363178
How many smartphone users compile their own programs again?
>>
>>63363163
I wish linus would come here and talk about programming with us
>>
>>63363186
>jump cut almost every 5 seconds
how the fuck do people actually watch these types of videos
>>
>>63363197
Sepplefags and rustfags beware, Linus is gonna rustle your jummies.
>>
>>63363229
His WHAAAATS UP EVERYBODY voice was more grating, desu. Will never understand how people can """""learn""""" things from these people.
>>
Why are the Rust devs so schizophrenic? On the one hand, its devs tout "explicitness", on the other hand, it is full of bizarre implicit conversions:

type Crappy = Fn();

fn foo() {
}

fn main() {
let ch: u8 = 0;
let int: u32 = ch; // error: expected u32, found u8

let bar = || println!("i am useless");

let tmp1: Box<Crappy> = Box::new(foo); // this is perfectly fine, for some reason
let tmp2: Box<Crappy> = Box::new(bar);

foo(); // this is also perfectly fine. foo doesn't get moved into the box.
bar(); // this is not fine. bar got moved into the box.
}
>>
>>63363244
Has Linus talked about the rust menace anywhere? I'm curious what he thinks of it.
>>
>>63363244
Linus' opinion on C++ is outdated as evidenced by that rant. He'll just embarrass himself as he gets BTFO'd.
>>
>>63363229
Part of it is a character bit from the previous episode.

>>63363247
He did a really good functional programming series, kind of just stuck with him after. But yeah, it's obviously hit and miss peppered with youtube cringe antics.
>>
>libraries which define NDEBUG in their headers and fuck with my debugging
>>
>>63363295
Just C things
>>
>>63363295
>headers
Laughing_modern_langs.webm
>>
>>63363186
read the video description
> Inline evaluation plugin https://quokkajs.com/
so judging from the layout either VS code or Atom
>>
>>63362483
I tried playing with wasm and.. fuck

Getting a string from C into a Javascript variable (ie, doing anything with it) is a horrible fucking drama.
>>
So when i'm making dlls i am always confused on how do i call the namespace.
Like if i have a class called poopmaker and the neamespace is also poopmaker then it's retarded because invoking it in projects as
new poopmaker.poopmaker();
looks like shit
>>
File: 1507399710936.jpg (32 KB, 600x600)
32 KB
32 KB JPG
If interpreted program means just in time compilation,
so that means the interpreter will pause waiting for the compiler to run mid-program,
and also the compiler pause waiting for the parser to run mid-program.

then isn't that means code golfing is really good for interpreted language??
>>
>>63363535
>1 dll per class
Wintards everybody
>>
>>63363579
ahead of time is the future.
https://www.ponylang.org/discover/
>>
>>63363579
time doesn't matter in code golf
>>
>>63363579
>interpreted program means just in time compilation
no
>>
>>63363535
What lang? C# (the absolute state of)?

First of all: "looks weird to me" is the weakest argument you can have against a programming construct. "It does what it's supposed to do so deal with it" is a more-than-sufficient counterargument.

Second, in my eyes, namespacing should be orthogonal to linking. How you write down symbols shouldn't depend on how they are resolved down the line, otherwise you'd have to change all your code to switch from DL to SL, which is proof of lack of abstraction. So something is wrong either with your toolchain or with the way you've set it up. In any case you should fix this. Java doesn't have this issue, GNU/Linux C doesn't have this issue, even Python arguably doesn't have it, so wtf?
>>
>>63363735
Third, don't you have some kind of let-notation or import or idk in your shitland? Stuff like let poopmaker = the "poopmaker" class in the dynamically loaded library "poopmaker"? That would alleviate the problem in point 2. Or just import poopmaker.*?
>>
imagine earning money programming
>>
>>63362526
>vector iteration.
It's called range manipulation, you smelly cnile
>>
>>63363265
his two main arguments are still valid.
>>
File: gamu.webm (1.3 MB, 848x544)
1.3 MB
1.3 MB WEBM
>>63362407
This little gem :)
>>
>>63364020
No they aren't, and haven't been for a while.
>>
What are the odds of my programming professor browsing these threads? I've gotten very specific advice here before at very specific times, and he also shares a lot of specific tinfoil hat type opinions I've seen here.

I'm scared.
>>
>>63364020
What two arguments? Which rant? He made several, let's just make sure we're talking about the same document.
>>
>>63364054
c++ still does a lot more in your back than c
c++'s social software engineering cost is still higher than c.
>>
>>63364062
like what?
>>
>>63364071
>c++'s social software engineering cost is still higher than c.
>Implying
C programmers are fucking retarded.
>>
>>63364087
I can't say in case he's lurking and finds out it's me.
>>
>>63364094
>you are the only person in your class who looks like a 4chan stereotype
nah lad
>>
Hi, professor!
>>
>>63364062
BOOOOH, Brandon. Yes I know you browse 4chan you fucking white supremacist, and you're going DOWN! I was only pretending, but you scum you truly feel home on paleoconservative troll websites, so now you're going to fling out of college if you don't amend your ways. THINK FAST, I've already written an e-mail for the dean!
>>
>>63364092
>C programmers are fucking retarded.
most programmers
>>
>>63364094
>I can't say in case he's lurking and finds out it's me.
How come he will identify you?
>>
>>63364122
>you fucking white supremacist

That's something he would unironically say, yes.

>>63364112
Other one is the fat indian manlet with a pepe folder and custom weeb loli waterfox background.

>>63364139
Because I asked for homework advice in here, and the next day he randomly mentioned the exact same thing in the exact same specific way.
>>
File: indiedev.png (250 KB, 523x372)
250 KB
250 KB PNG
>>63363735
>What lang?
As if anyone serious about programming use anything else than C#
>>
>>63364218
I'm not a pajeet.
>>
File: 1497823928537.png (174 KB, 962x543)
174 KB
174 KB PNG
>>63364218
12 rupees have been deposited to your online microsoft evangelism campaign, rakeesh. Please keep doing the needful.
>>
File: 1509985919524.png (346 KB, 483x701)
346 KB
346 KB PNG
>stack overflow
>interesting and useful discussion about the ups and downs of different techniques used to achieve the same goal
>"closed as not constructive"
>ask question
>"hey, how do i do X without an external library"
>"i recommend library Y its really great, you can find it here. written by me btw"
>"+1 for recommending library Y!"
>>
>>63364362
I had many more problems with
>ask question on SO
>locked as duplicated question LINK HERE
>click link
>the question is not duplicate at all, only similar but completely useless to me
>>
>>63364462
Me too!
I also had
>ask a question about whether it's okay to glue 2 pages of my passport together to hide parts of my past to my employer
>Rajeesh, based on details in your message, you seem to be a Pajeet working in the middle-east. Do not, I repeat, do not, under any circumstances, hand your passport to your boss. They have no grounds to make that request and in this particular country they have a documented habit of effectively holding your passport hostage, striping you of your legal existence and forcing you into slavery under them. Report this to the police and remember to keep your passport safe.
True story.
America remotely saved my ass in the middle east without any military involvement.

This is why I shill for Microsoft.

Ssssh ;^)
>>
>>63364578

are you memeing or do we actually have pajeets in this thread?
>>
>>63364679
ranjevs and rajeets lurk around and even post here.
You can tell by the various ESL posts. Every region has their own distinct style of broken english.
>>
>>63364462
my gripe is that I don't ask obvious questions that could be answered by taking a look at the docs.
I tend to look at pretty obscure problems. And the thing is that whenever I find a SO entry relevant to the problem it's most likely closed because no one had a definitive answer but in the comments there was a discussion that could have given some hints. But those fuckers close that down as inactive or whatever.
SO is only good for pajeet/normie tier questions. For anything else it's useless.
>>
File: 1457983333895.png (48 KB, 1920x1080)
48 KB
48 KB PNG
>>63364679
I am meming indeed, but I am actually an Indian computer engineer with a sense of humour. I do find these memes funny especially given that I have personally experienced them. And inb4 no I do poo in the loo and I meet the western standards for personal hygiene, or at least I try.

It was a pleasure fighting the meme war with you :v)
>>
What are some good tutorials on cmake? I need to convert a complete project from a monster Makefile I wrote.
>>
https://github.com/majestrate/XD/commit/c999eb7da2512edaac37805a03d7aca760dc7a4b?diff=unified


r8 my commit
>>
File: 1504625719410.jpg (10 KB, 255x255)
10 KB
10 KB JPG
>>63362493
That looks horrendous.
>>
File: clusterfuck.png (17 KB, 891x216)
17 KB
17 KB PNG
I'm trying to implement the unix pipe, but the code is a mess. I'm not even sure if regex is the right way to parse it
>>
>>63363197
>claims C is the best language
>always extremely hostile for no reason
He would fit right in
>>
Can someone duncepill me on what 'testing' means when it comes to programming? I keep reading Uncle Bob (that smug bastard) talk about it in his book with smug illustrations about good coding practices and it's much easier to ask you guys what 'testing' is instead of using Google to find the answer.
>>
>>63365214
do you really think the average /g/ is capable of testing his convoluted and overly complex sepples code ?
>>
>>63364218
>indiedev.png
That's actually a respected NSA employee. That man is reading your emails right now.

https://www.youtube.com/watch?v=xXVDi15kZvA
>>
>>63365214

Most basically you pretty much define various inputs and the expected outputs, test your functions, and make sure that your function does indeed return the correct result given the input. You also do boundary value analysis to make sure your function does the right things given kooky inputs like, 0, -1, -500000, MAX_INT, MIN_INT, or if it takes an array what happens when you give it a fuck huge array or a real big linked list or a broken list etc.

For test driven development you develop the tests before you write any code and then write the code to pass all the tests.
>>
>>63364958
its alright
>>
>>63365214
It means test your shit to make sure it works. Manually and automatically.
>>
I feel like I've reached a level in python and java where I feel comfortable with OOP and like pretty much all the basics of programming down confidently, but I haven't reached a level of confidence to really contribute to open source projects because I don't really know the projects well enough/don't use that many projects that I can consider contributing to. I also have found inspiration for solo projects constantly fleeting.

What do /dpt/
>>
>>63362493
In Rust, it's just
fn main() {
println!("{:?}", vec![1, 35, 64, 36, 26]);
}
>>
>>63365668
[1, 35, 64, 36, 26].writeln;
>>
>>63365457
>open source projects
Why? Get a real job. Put some ads out and go freelance if you have to. Business skills are more important than "muh open sauce".
>>
>>63365695
>D fag
Hi, I was wondering how does the compiler evaluate what function (++ or --) am I going to use in the runtime? What magic is this?

See the picture, 4chan is blocking my post.
>>
struct with atomic fields or just making every function that operates on it use spinlock?
>>
File: 1475561360616.gif (1.84 MB, 480x360)
1.84 MB
1.84 MB GIF
>>63365744
>>
>>63365807
First off, stop putting ()'s after function calls. You don't need them if you aren't taking any args.

Also, what exactly are you doing?
>>
>C
How to I pass a command line argument without the option?
E.g.,
>myprogram param
how to get that param?
>>
>>63365823
atomic is without doubt better but restrictive, depends if context allows it
>>
>>63365826
>Business skills are more important than "muh open sauce".
let me rephrase it for you
>unless you have a highly successful opensource project or "be able" to have one, you better off going the normal paid-for-code route
>>
>>63365845
getopt()
>>63365851
Please fuck off, kike.
>>
>>63365807
>mixin
it's compile time
>>
>>63365845
argv[1]
>>
>>63365867
This won't work if I have more params, e.g.
>myprogram -o something blah
>>
>>63365807
Happens at compile time
++q

is lowered to
opUnary!"++"(q);


which is then mixed in
>>
>>63365875
use getopt to process your options, then process arguments
>>
File: 13782248.jpg (6 KB, 268x212)
6 KB
6 KB JPG
>>63365842
Two of the things I don't like about D:
1. No ::
2. Being able to drop parens, even in void functions and functions with side effects in general

>what am I doing
Doing an exercise from the book. See below:
>>63365865
I know but how does it know whether I'm going to invoke ++ or -- during program execution. Does it go through all the possible conditions?

If so this is insane! And powerful.

>>63365882
Hmm, what if the operation is not known at compile time? For example, the user will decide whether to ++ or --
>>
>>63365909
>no cons is a bad thing
gb2sepples then if you want that shit.
>and functions with side effects in general
It's not like I see you using pure
>For example, the user will decide whether to ++ or --
do you understand what mixins are m8?
Go read some more.
>>
>>63365929
this.can.either.be.a.long.ufcs.chain.or.just.calling.a.deeply.nested.function
>>
>>63365909
no, you choose which you're calling my using ++ and --
>>
>>63365946
Context is everything.
And technically idiomatic D is supposed to look like
thing
.fun
.fun2
.fun3

But it looks like shit, if you have trouble discerning between the two, l2structure&name things.
>>
>>63365909
>Hmm, what if the operation is not known at compile time? For example, the user will decide whether to ++ or --
Not much you can do then, mixins are purely compile-time and are mainly for the programmer. If you want the user to decide at runtime then you'll probably just need normal if statements
>>
>>63364462
True story of searching answer in SO:
>google how to do something
>open the first link //link A
>no answer
>this question is a duplicate go to link B
>link B: "this question is a duplicate go to link C"
>link C: "this question is a duplicate go to link D"
>link D: "this question is a duplicate go to link A"
>all of them have no answer or incorrect / deprecated answer

Is this a circular reference problem that causing lots of GC broken?
>>
>>63365858
neet life ftw!
>>
any opinions on vmware vs virtualbox? is one objectively superior to the other somehow? i'll be using it to run ubuntu
>>
File: 1510241247682.png (311 KB, 885x381)
311 KB
311 KB PNG
>>63366175
Why are you outside the oven?
>>
>>63366188
Why, does your distro not have GCC?
>>
Working in C, is there any good method of writing arbitrary built in types from one memory location to another? The issue is that a size variable is used for the offset calculation and to handle reallocations, therefore mixed types will not increment the size counter reliably.

I don't want to write a function for each type used, nor do I want to make it a preprocessor macro. The only approach seems to be receiving a void pointer and a length, casting to the smallest used type, then a for loop. At such a point I might as well be using memcpy with a wrapper, though it might be slower for very small copies.

It all feels bad. I've drifted into a state of paralysis.
>>
>>63366199
>using gcc
>>
>>63366188
ummm qemu?
>>
>>63366209
So your distro doesn't have the compiler of your language?
>>
>>63366201
>mixed types will not increment the size counter reliably
clarify?
>>
>>63366228
not him, but i would use clang if i used C.
>>
for anyone who's used react, what are your opinions on it?

I think it's the first webshit technology I actually like but I've been so caught up in the circle jerk aspect of it I might not be seeing some obvious flaws
>>
>>63366243
Thanks for your tweet, anon. Can we go back to the conversation we were having?
>>
>>63366192
I’m sneaky :^)
>>
>>63366259
that is the conversation.
GCC is trash.
>>
>>63366188
QEMU or chroot or docker.
>>
>>63366270
Go shill applel somewhere else, faggot.
>>
>>63366282
>using an inferior compiler even though both are FOSS
>>
>>63366199
i'm on windows
>>
Finally finished my programming logic lab. I had to make different methods for operations, and then output the result every time it did an operation. It took way too long because I wasn't concatenating the string right to output the result.
>>
>>63366237
Size and pointer to uint16_t is passed. Size is used as an offset to figure where to write, which is pointer + 2 * offset. Size variable is incremented. uint8_t is passed, uses the same offset, doesn't write in the correct place, increments.

The meaning of +1 changes.

>>63366243
I've found MSYS2 clang to generate inferior code.
>>
>>63366300
And in the wrong thread.
>>
>>63366310
>MSYS2
>>
>>63366325
Yes. Never tested a native build, whatever that might mean.
>>
>>63366201
Dude no generics lmao
>>
>>63366201
I'd probably do void* and datasize and wrap calls in a macro
>>
>>63366310
I don't really get it, but i think your problem could be fixed with union
>>
>>63364362
kek too accurate. aren't discussions allowed on the software engi exchange?
>>
>He hasn't blocked stackoverflow with his adblocker yet.
Plebs everywhere
>>
>>63366511
>adblocker
>>
>>63366310
seems like something along the lines of
#define my_op(p,s,x) ({ \
void* _p = (p); size_t _s = (s);\
*((__typeof__(p))(_p+_s)) = (x);\
s+=sizeof(*p);\
})

would do just fine, depending on whether size should be in elements or in bytes
could you maybe provide some more details as to what you're trying to do?
>>
Graphics progamming/pipelines ,game engines and game development yeah!
>>
>>63366170
This never happened. Prove otherwise.

>>63366511
>blocked stackoverflow
What's the point? Why not just not visit the website?
>>
>>63366592
If you notice, you never actually get a good advice from the site.
>>
>>63366606
>you never actually get a good advice from the site
That's patently false.
>>
my portfolio website
>>
>>63366577
I'm replacing zopfli's memory allocation and writing system.

#define ZOPFLI_APPEND_DATA(/* T */ value, /* T** */ data, /* size_t* */ size) {\
if (!((*size) & ((*size) - 1))) {\
/*realloc size if it's a power of two*/\
(*data) = (*size) == 0 ? malloc(sizeof(**data))\
: realloc((*data), (*size) * 2 * sizeof(**data));\
}\
(*data)[(*size)] = (value);\
(*size)++;\
}


It uses this same macro to mostly write chars, but occasionally, it'll write shorts to the same array. I do not understand why this works, offset calculation should be wrong.
>>
fn foo() -> Box<u32> {
Box::new(123)
}

fn main() {
let a: Box<Any> = Box::new(123); // This is okay
let b: Box<Fn() -> Box<u32>> = Box::new(foo); // This is okay
let c: Box<Fn() -> Box<Any>> = Box::new(foo); // Compiler error
}

Is there any language with templates/generics out there that just works as expected and doesn't vomit details of it incomplete and poorly thought out implementation all over you? If generics were viable, surely someone would've figured out how to do them right by now.
>>
>>63366840
what even is that mess
>>
>>63366840
I likes chapels idea that you can pass the type as parameter.
proc test(type t, x:int) {
var tmp:t = get_object(t);
tmp += x;
return tmp;
}

var x = test(X, 10); // creates object of type X and adds 10 to it using overloaded operation
var y = test(Y, 20);
>>
File: 1493628826225.png (34 KB, 666x666)
34 KB
34 KB PNG
>>63366840
Using a closure works somehow
use std::any::Any;

fn foo() -> Box<u32> {
Box::new(123)
}

fn main() {
let a: Box<Any> = Box::new(123);
let b: Box<Fn() -> Box<u32>> = Box::new(foo);
let c: Box<Fn() -> Box<Any>> = Box::new(|| foo());
}
>>
Trying to create a dictionary in python using zip, but without overwriting existing values:

x = [1, 2, 3, 7, 3, 1]
y = ['a', 'b', 'c', 'd', 'e', 'f']

# if I go like this
dictionary = dict(zip(x, y)
# then when it gets to the second instance of 3 and 1, it overwrites the old values
# and adds a new one


What I want would be a dict like {1: 'a', 2: 'b', 3: 'c', 7: 'd'}. Any ideas?
>>
>>63366851
Trying to put foo inside a box that can contain (or so I thought) a function which returns a boxed value of statically unknown type. Clearly a Box<Any> is compatible with Box<i32>. Except when it's a function's return value. Then it's incompatible. This is sepples-tier shit.
>>
File: gggg.jpg (60 KB, 965x502)
60 KB
60 KB JPG
>try to uninstall vs2015
>it hangs
>microsoft released a tool to uninstall vs2015 because you can't uninstall it normally, ?
>tools hangs

?????????????????????????????????????????????
>>
>mfw C was my first programming language
>required to learn python on my class
>python is literally "Pseudocode: The Programming Language"
Can someone recommend me a good "highish" level language to complement with my C knowledge? Python is a complete joke of a language. It has it's uses, but man, it feels like a waste learning so many intricacies on C, to then move to python.
>>
>>63366682
>write shorts to the same array
I'm assuming you're talking about
(*data)[(*size)] = (value);\

when you call the macro with data of type char** and value of type short, the compiler knows that it's trying to put a short into a char array and will do the proper type conversion. So you're still just writing one byte.
>>
>>63366949
You may want to try with a for loop
>>
>>63366923
>Using a closure works somehow
Funny, that. A while earlier I posted >>63363258
What a clusterfuck.
>>
>>63366991
I know I can do that, but I'm looking for an elegant solution...
>>
C should have ability to iterate over enum and structs fields, something like

enum X {
X_0 = 0,
X_1,
X_COUNT,
};

enum ATTRIB {
X_0_ATTR = 100,
X_1_ATTR = 150
};


#each enum X, tmp {
printf("%d ", tmp ## _ATTR);
}

and would print "100 150 "
>>
>>63366980
The maximum value the short stores is 258. It implies it's been truncating the values.

Have to figure if it's intentional.
>>
>>63367011
okay that should give error because of no symbol X_COUNT_ATTR but you get the point.
>>
>>63367011
>iterate over enum and structs fields
Lisps and dependently typed languages can do that. Stay mad, C-cucks.
>>
>>63367033
There's no lisp or dependently typed language that has no GC and provides C ABI natively. ATS is pretty close though but I'm not sure how maintained or mature the language is.
>>
does this have memory leaks?


struct Person *personCreate(char *first, char *last, int age, char *email){
struct Person *person = malloc(sizeof(struct Person));
person->first = strdup(first);
person->last = strdup(last);
person->age = age;
person->email = strdup(email);
return person;
}

void personDelete(struct Person *person){
free(person->first);
free(person->last);
free(person->email);
free(person);
}

struct PersonList *plCreate(){
struct PersonList *db = malloc(sizeof(struct PersonList));
db->size = 0;
db->first = NULL;
return db;
}

void plDelete(struct PersonList *db, enum CopyType copyType){
if(copyType == PD_DEEP){
struct Node *temp;
while(db->first){
temp = db->first;
db->first = db->first->next;
personDelete(temp->value);
free(temp);
}
}
//else PD_SHALLOW
free(db);
}

void plAdd(struct PersonList *db, struct Person *p){
struct Node *pnode = malloc(sizeof(struct Node));
pnode->value = p;
pnode->next = db->first;
db->first = pnode;
db->size++;
}

void plRemove(struct PersonList *db, struct Person *p){
struct Node *itr = db->first;
while(itr->next && itr->next->value != p){
itr = itr->next;
}
if(itr->next){
struct Node *temp;
temp = itr->next;
itr->next = itr->next->next;
db->size--;
free(temp);
}
}
>>
>compiled
>no oop or meme fp features
>no garbage collection
>no generics, exceptions, or other garbage
>not bloated in any other way
>good compile-time expressions (like C++'s new constexpr)
>functions can create something like file descriptors which write() or similar functions can use
What language has these features? C has almost all except last two, Go has most of them but is garbage collected and produces fuckhuge binaries.
>>63367011
You'd have to unroll the loop, and use generics. Or use a lookup table, but you still need some kind of generics. If it's only one type, then you can use a regular array instead (union or pointer arithmetic if you want both)
Or you could use macros to achieve the same thing.
>>
>>63366188

Hyper-V
>>
>>63367084
>but you still need some kind of generics
No the preprocessor just needs to let me iterate over symbols that can be used in preprocessor.
>>
I don't understand how to make use of sigwait and sigsuspend on Linux. If I send USR1 the program unblocks, but terminates because it's the signal's default action. If I associate SIGUSR1 to SIG_IGN, sigwait ignores the signal and hangs.
  sigset_t mask;
sigemptyset(&mask);
sigaddset(&mask, SIGUSR1);
int sig;
sigwait(&mask, &sig);
>>
>>63367110
And then what? You have floats in half of the fields and int in the other half, how do you know what to do with them?
>>
>>63367011
I have some ambivalent news for you.
#define FIELDS(T, N, S) \
T(FOO) N(100) S \
T(BAR) N(200) S \

#define ID(X) X
#define NOTHING(X)
#define COMMA ,
#define SEMICOL ;
#define ASSIGN(X) = X
#define PRINT(X) printf("%d\n", X)

typedef enum Crap {
FIELDS(ID, ASSIGN, COMMA)
};

int main() {
FIELDS(PRINT, NOTHING, SEMICOL)

return 0;
}
>>
>tfw no memcpy function with the following behavior
 src                 dest
v___________________v______________________________________
[f0f0 f0f0 dddd dddd 0000 0000 0000 0000 0000 0000 0000 0000]
n = 16 bytes

result:
___________________________________________________________
[f0f0 f0f0 dddd dddd f0f0 f0f0 dddd dddd f0f0 f0f0 dddd dddd]
>>
>>63366840
Not a Rust shill and some of your complaints are probably valid, but in this case, I think memory layout is the reason this doesn't go thru. Subtyping isn't a piece of cake in a language with manual memory management (computer assisted if you want) such as Rust. It's true that in the abstract, the return type of functions is covariant. However, in the pratical case of Rust, the ->Box<u32> function will return a box that contains just the 4 bytes of the integer, whereas a ->Box<Any> function will return a box with a type tag followed by the contents[1]. This means those types are mutually incompatible because of layout, although in theory it should work. The fix, the seemingly-redundant closure, probably works because of some implicit conversion going on. Arguably it better be forced to be explicit given how stupid the resulting code looks like, but yknow nobody's perfect. Go ask the transgender otherkin gaylords if they want to fix this 'cause I wont go.

[1] https://doc.rust-lang.org/std/any/ "dynamic typing of any 'static type through runtime reflection"
>>
>>63367064
Does this homework do itself?
>>
>>63367143
Box is a pointer type equivalent to unique_ptr. The memory layout is irrelevant
>>
>>63367121
struct S {
int x;
float y;
};
S *tmp = get();
#each struct S, ident {
typeof(tmp-> ## ident) var;
printf("field %s size %d\n", #ident, sizeof(var));
}

Would print for example
field x size 4
field y size 4

It's using compiler extension typeof provided by at least gcc and clang.
>>
>>63367114
a dummy handler that does nothing could work
>>
>>63367170
actually you could do that without typeof.
Just have tmp-> ## ident in the printf.
>>
>>63367170
>It's using compiler extension typeof provided by at least gcc and clang.
So, generics. Great job, typeof was a fucking mistake.
>>
>>63367163
The memory layout of Box is irrelevant, but the memory layout of Any is. I wonder if the problem persists when the return value isn't Boxed tho?
>>
>>63367192
see >>63367188
>>
Yesterday I went to an interview for a junior C# programmer an got rejected.
Two programmers were screening me. They gave me a few challenges from codility.com and watched how I programmed it. I completed everything they gave me, but the lead programmer said that he wouldn't accept me because I "have to become a skilled hand", although I was good with algorythmic and have a mindset of a programmer.
He said to write at least 10k lines of code. And I can try again after a year or at least after 3 months and they will accept me without any test. He advised to find a GitHub project and programm it or farm reputation at stackoverflow or programm my own C# project.
But I neither have idea for a C# project nor do I know any GitHub C# projects that would be appropriate for a newbie c# developer.
What do? I need to find a job or I starve myself with no money :(
>>
>>63367170
https://natecraun.net/articles/struct-iteration-through-abuse-of-the-c-preprocessor.html
it ain't pretty
>>
>>63367139
You would have to define the macro for each enum...
>>
>>63367143
>Box<u32> function will return a box that contains just the 4 bytes of the integer, whereas a ->Box<Any> function will return a box with a type tag followed by the contents[1]
As far as I understand, both should simply contain a pointer to dynamically allocated memory owned by the box. Otherwise Box<Any> would've been completely useless, since its size would've been unknown at compile time. This is corroborated by the fact that it happily puts a Box<i32> inside a variable declared as Box<Any>.
>>
>>63367210
But you can't do anything of value with it as the types aren't known.
>>
>>63367216
Why can't they just fucking update the preprocessor specs when they make new standard versions?
>>
>>63367227
>You would have to define the macro for each enum...
As you can see, the macro mostly just contains the fields definitions, which you would have to define for each enum either way. This is by no means perfect, but your complaint is asinine.
>>
>>63367233
struct X x;
x.some_field the type is known by the compiler, hell the preprocessor could even add type parameter for the loop.
>>
File: 147627.png (158 KB, 1448x980)
158 KB
158 KB PNG
>>63362407
I am working on my top secret website that will hopefully buy me a ticket out of wagecucking
>>
>>63366956
Took a second because i don't use delegates much.
In D that would look something like:

auto foo(T)(T t)
{
return t;
}

auto box(T)( T function(x) thing)
{
x.thing;
}

void main()
{
import std.stdio;
auto a = 123.foo;
auto b = foo(a * 2);
b.writeln;
}
>>
>>63367238
They don't want you to do too advanced stuff with it, it's not a good thing in the long run.
>>63367256
Known by the compiler, yes. You're advocating for generics, which are needed for your proposal.
>>
>>63367229
https://doc.rust-lang.org/std/any
Any is not the wildcard type. See above.
>>
>>63362446
is b u s t
>>
How do you define your units of measurement in your games, /dpt/?

Defining a metre based on the height of the character in pixels or the number of pixels in a tile if it's a tile based game seems the most comfiest for me.
>>
>>63367229
>it happily puts a Box<i32> inside a variable declared as Box<Any>
I think it has implicitly freed the Box<i32> and allocated+constructed an Any. Rust, ladies and gentlemen.
>>
>>63367177
>a dummy handler that does nothing could work
I tried, that didn't work.
>>
>>63367250
Wrapping everything in macro fucks up most of development tools for at least code completion.
It also makes the code harder to read.
>>
>>63367206
>The memory layout of Box is irrelevant, but the memory layout of Any is.
`Any` doesn't have a memory layout. It's just a trait.
>>
>>63367271
>Any is not the wildcard type. See above.
Highly helpful explanation. It sure sounds like you know what you are talking about. Rust users...
>>
>>63367295
Depends on what type of game. I guess I would use the smallest unit I could conceivably deal with. In 2D games, a pixel, in 3d games played on a human-scale (e.g. FPS) 1 cm, etc.
>>
>>63367300
>>63367177
In fact not even touching the default handlers or signal dispositions, this code always hangs.
  while (!g_usr1) {
sigset_t set;
sigfillset(&set);
int sig;
sigwait(&set, &sig);
// sigsuspend(&set);
puts("signal arrived");
}
>>
Can I return something in a void function just to stop its execution?
>>
>>63367354
Just
return
>>
File: 14523869981273.jpg (69 KB, 600x600)
69 KB
69 KB JPG
>>63367295
Waifuunits.
1 = ((number of pixels) = (height of my waifu in cm))
meaning 150 cm
>>
>>63367299
>I think
Wrong
>>
>>63367303
>Wrapping everything in macro fucks up most of development tools for at least code completion.
>It also makes the code harder to read.
I never said it was a desirable solution. It's just the best you can do while you're waiting for the C committee to stumble upon your post and implement your feature request. This technique saved my ass quite a few times. You can use it to stringify enums, count the number of fields, have multiple T parameters that do different things (to customize each field), keep several different definitions in sync and many other things that you would otherwise have to do by hand or use a custom preprocessing step for.
>>
>>63363431
Use embind with C++.
>>
>>63367345
Using pixels on their own is supposed to be bad for scaling (don't know if it's true or not).
>>
>>63367427
fuck that, writing my own preprocessor.
>>
>>63363074
My imageboard is used by people from all over the world. The total count is small though.
>>
>>63367295
>How do you define your units of measurement in your games, /dpt/?
Pixels for 2D. Meters for 3D.
>>
>>63366949
Reverse both lists, maybe?
>>
>>63362407
Why are you not using Pony?

https://www.ponylang.org/

class Printer
var s: String
var e: Env
new create(env: Env, str: String) =>
e = env
s = str
fun ref setstr(str: String): String => s = str
fun ref addstr(str: String): String => s = s.add(consume str)
fun ref newenv(env: Env): Env => e = env
fun print(): None => e.out.print(s)

actor Main
new create(env: Env) =>
var pobj: Printer = Printer(env, "None")
pobj.setstr("Hello")
pobj.addstr(" World")
pobj.addstr("!")
pobj.print()
>>
>>63367443
Well, that's true. Have a measurement called points or something which maps to 1px on standard screen and 2px on hidpi.
>>
>>63367445
DO IT
Fuck, imagine the possibilities.
>linking in the preprocessor by #including a pair of .c and .h files, rename everything in the .c file to something random that won't collide
>auto var = val;
>constexpr
And more. Would be extremely nice with such a project. You could implement lots of stuff in it that would otherwise be compiler-specific (e.g. typeof), then have it spit out some extremely portable C dialect that any compiler will compile (e.g. C89, or make it vary based on settings)
>>
>>63367163
>>63367374

Actually we're both wrong:
https://play.rust-lang.org/?gist=35fe67803baeb0385752bcfc25456b76&version=stable
Holy shit wut? Seems like Any forces any reference/box that point to it to carry an additional pointer size field that indicates what type it contains. Interesting, and it does explain why ->Box<i32> functions aren't subtypes of ->Box<Any> functions.
>>
>>63367609
Pony should stop selling itself as an OO language, and more as a functional lang with OO aspects. People will just assume it's some shitty java variant.
And the syntax turns me off.
>>
File: 1509947669392.png (134 KB, 2255x1261)
134 KB
134 KB PNG
>>63367681
Yes, Any is a trait, therefore Box<Any> is a pair of pointers, one to the data, one to the vtable.
See also pic, upper right corner
>>
>>63367737
OK thanks a lot. Saving this chart.
>>
>>63367353
weird I tried it and a dummy handler fixed it, but maybe the rest of my program is different from yours, could you post a full example?
>>
>>63367681
Yeah, I'm not big on trait object layout. I think, ideally, instead of trait objects, there would be existential types that are represented by vtables when they're bounded by traits. E.g.
exists<T: Any> Box<T>
would be a pointer to the Any vtable plus a single-pointer Box.
>>
I just had a developer submit a PR that introduces two new layers in our integration test system just to parse CSV files in tests with error handling that uses console.error to report problems.

Anyways, how do I murder someone without getting caught?
>>
File: 1500751023899.jpg (67 KB, 1024x962)
67 KB
67 KB JPG
How do you remove graphical component form JPanel in Java? There is literal remove function but I can't get it to work
>>
>>63367681
>>63367737
This is just mind-bogglingly retarded, but what's the correct way to accomplish >>63366840 in Rust?
>>
>>63366840
>>63366923
>>
>>63367946
That's not what I need, though. I need something that works with both normal functions and closures.
>>
>>63367929
See >>63366923. I guess it works because wrapping it in a lambda allows the type checker to coerce it more or something.
>>
>>63367847
I've just found a solution, maybe non optimal. My goal is only to exit my process when either the child dies (SIGCHLD) or I get a termination signal.
I have blocked the set of interrupt signals+SIGCHLD at the start, and I call sigwait in a loop. On signal arrival I cleanup and call _exit(). I really have to use _exit at that point because exit() hangs, it is strange.
>>
>>63367966
Can't have it. You have to use a trivial closure.
>>
>>63363258
What exactly do you think is incorrect about this behaviour? `u8`s aren't implicitly converted to `u32`s. `foo` is a free function and thus is copied, not moved while `bar` is a closure and thus is moved, not copied. Why don't you think `foo` should be able to go into a `Box<Fn()>`?
>>
>>63367920
dumb frogposter
>>
>>63368023
>Can't have it
Guess I'll just have to add it to the list of trivial things Rust fails at.
>>
>>63367929
>>63367967
I guess the closure itself stores the vtable rather than the Box.
>>
>>63368030
lol
>>
>>63368030
What is Rust failing at? You can do exactly what you want, you just need a few extra characters.
>>
>>63368030
Would you prefer the trivial lambda to be implicit? Honest question.
>>
Daily reminder that language wars are for mongs and posers and that good programmers simply choose the proper tool for the job at hand.
>>
>>63367213
https://github.com/MediaBrowser/Emby/issues/1440
Most likely not that easy but you could earn some money.
>>
>>63368158
Brainlets choose the best tool for the job. Big boys make the optimal tool for the job.
>>
>>63368158
Right, which is either C or an high-level scripting language.
>>
>>63368172
>c is good for making a generic data structure library
>>
>>63368228
Yes, there are tons of them.
https://stackoverflow.com/questions/1138742/looking-for-a-good-hash-table-implementation-in-c/8470745#8470745
uthash is considered the best one.
>>
>>63368284
>Any C structure can be stored in a hash table using uthash. Just add a UT_hash_handle to the structure and choose one or more fields in your structure to act as the key. Then use these macros to store, retrieve or delete items from the hash table.
Disgusting.
>>
>>63368284
>macros
#define utarray_eltidx(a,e) (((char*)(e) >= (a)->d) ? (((char*)(e) - (a)->d)/(a)->icd.sz) : -1)

And I'm sure you are the same people who shit on Rust and oCaml for looking like shit.
>>
>>63368307
Is there a problem here?
>>
>>63368324
>you have to break ABI compatibility to add something to a hash table in C
>>
>>63368313
This looks good. All the operators mean something, unlike in rust where it's all just >><:;><<;>:>:::::::::::;>;:<<;:><:>; boilerplate
>>
>>63368342
>This looks good
Your are genuinely delusional or just pretending.
>>
>>63368340
or you can just make your own / use existing library that provides hashtable that doesn't touch your structure.
>>
>tfw mastering C++17
Time to rewrite all my projects with concepts.
>>
>>63368370
And deal with either disgusting macros or void generics? I'll pass and use a language that isn't from the 70s.
>>
>>63368051
>What is Rust failing at?
Being sane, consistent and usable:
use std::any::Any;

fn foo() -> Box<u32> {
Box::new(123)
}

fn baz() {
}

fn main() {
// Compilation error, despite both types being unsigned integers,
// and one always fitting inside the other.
// Implicit coercion is evil!

let ch: u8 = 0;
let i: u32 = ch;

// Retardedly, Box<Any> and Box<u32> have different sizes.
// This still compiles, though:
let a: Box<Any> = Box::<u32>::new(123);

// Compilation error. The different sizes suddenly matter.
let b: Box<Fn() -> Box<Any>> = Box::new(foo); // Compilation error. Presumably because Box<Any> and Box<u32> have different sizes

// Unless you do it like this, because sanity is ableism:
let c: Box<Fn() -> Box<Any>> = Box::new(|| foo());
}

This is the kind of behavior you expect from Javascript, not from a "systems programming" language.
>You can do exactly what you want, you just need a few extra characters.
That only makes it much, much worse.

>>63368069
>Would you prefer the trivial lambda to be implicit? Honest question.
No. I would prefer a language where Box<Any> is compatible with Box<T: Any>, and where being a lambda or being a local variable has no effect on this compatibility. Fuck Rust and fuck anyone who uses it.
>>
>>63368392
enjoy your nonstandard ABI, name mangling, huge runtime library.
>>
>>63368340
>struct
>abi
good joke
>>63368345
It's a macro, it's much better than the alternative which is going full GNU.
(((char*)(e) >= (a)->d) ? (((char*)(e) - (a)->d)/(a)->icd.sz) : -1)

let's break it up
if (((char*)(e) >= (a)->d)) {
((char*)(e) - (a)->d)/(a)->icd.sz;
} else {
-1;
}


if e when cast to char pointer is greater than or equal the member d of a then return the value of e cast to char pointer minus a's member d divided by a's member icd's member sz, else return -1
Now how much information is inside one of rust's <>:<>:,.;:;:>>:<>::<>><: abominations? none?
>>
>>63368395
Okay, yeah, that's good evidence of inconsistency.

>>63368405
Which language do you think I'm thinking of?
>>
>>63368405
>name mangling
Literally not a problem.
>tfw writing overwriting symbols in object files with their human readable names from the source language
>>
>>63368437
Well tell your super secret C alternative that export natively C compatible ABI and doesn't have GC?
>>
>>63368460
Rust with #[repr(C)] and #[no_mangle] as well as the language I'm working on with similar things.
>>
>>63368460
I can think of Nim.
>>
File: steve.jpg (19 KB, 300x300)
19 KB
19 KB JPG
>>63368469
rust is not programming language, it's shit.
>>
File: ayss.gif (594 KB, 382x298)
594 KB
594 KB GIF
I've been wanting to start working on software develepment and code in general for ten or so years now. Now that i finally have all the time in the world (bitch left), i asked my employer if they support engineering studies.

So far all lights are going green and they seem want enthuastic people to start developing mobile apps to control their products alongside their web-based desktop apps.

Could someone spoonfeed me some pointers what should i look into, concerning app development and engineering studies in general?
>>
>>63368511
Learn Swift.
And god help you if they want to support android.
>>
>>63368392
Why don't you look at the different alternatives then, instead of switching language since you dislike uthash? Lots of different alternatives in that link.
>>
>>63368524
Do you really think that I prefer Rust to C just because of hash tables?
>>
File: 1489491095718.png (740 KB, 1834x1200)
740 KB
740 KB PNG
>>
>>63368530
fucking retarded rust shill, fuck off already. Nobody wants you here. Nobody likes you.
>>
>>63368531
>namespaces
>exceptions
they need moved to brainlet-tier
>>
https://troydhanson.github.io/uthash/userguide.html
holy shit
C gets comfier by the day
>>
>>63368496
>>63368537
Fuck off.
>>
>>63368571
>implying error handling with algebraic effects using either ADTs or exceptions as back ends isn't the best
>>
>>63368594
>writing code intended to fail
b r a i n l e t
>>
>>63368594
>exceptions = error handling
Well memed
>>
>>63368600
How do you react to a file not existing because it was mistakenly deleted? That's not a normal condition but it's not unavoidable either.

>>63368601
I know. Exceptions are control flow. ADTs and branching are another form of control flow. Both can be used for error handling.
>>
>>63368611
>How do you react to a file not existing because it was mistakenly deleted?
return nothing
>>
>>63368395
very very slightly defensible tho:
let a = 1i32;
let b = 1i8;
let true = a == b;
let false = a << 8 == b << 8;
// not real code btw but youknowwhatimsayin.

if a and b are the same, how can applying the same operation to them possibly yield different results? Fucks with a fundamental law of mathematics, so maybe that's why no-integer-overflow Rust does it this way.
>>
>>63368634
Option types can be considered error types with unit as the error type. What about distinguishing the file being deleted and the file not permitting access?
>>
>>63368635
Actually, b << 8 should panic. Technically, no contradiction is made. The real reason is for type inference, particularly for looking up trait implementations.
>>
>>63368653
The point is run-time errors shouldn't exist.
>distinguishing the file being deleted and the file not permitting access?
return invalid file: deleted
return invalid file : locked
>>
>>63368395
>// Retardedly, Box<Any> and Box<u32> have different sizes.
That makes perfect sense tho.
>>
>>63368683
>The point is run-time errors shouldn't exist.
Well, sometimes they do and there's nothing you should do about it. To the processor it's all just control flow, though.

>return invalid file: deleted
>return invalid file : locked
So you have a function returning an error code AND a potential file. This is exactly what an ADT does. What I'm suggesting is to abstract even further so that you can switch between branching and exceptions for optimization without changing very much code.
>>
>business analyst and project owner just let a huge potential time bomb through that will cost users thousands of dollars because it's how the system behaved in 1.0
Why do they let brainlets who have never designed a system lead software projects?
>>
>>63368571
Good exception handling is not in the realm of brainlets
>>
>>63368635
>if a and b are the same
No one said they are the same, though. Just that assigning the value of a u8 to a u32 is always safe, and has very obvious semantics.

>Fucks with a fundamental law of mathematics
Assignment is not a mathematical operation. Either way, that's not even the point. The point is that after refusing the most trivial kind of conversion, it lets you assign a Box<u32> into a Box<Any>, despite them having different sizes, but a function returning one is incompatible with a function returning the other. It's like the compiler is having a schizophrenic episode.
>>
>>63368741
>exception handling
>good
>>
>>63368714
>Well, sometimes they do
they literally don't if you don't let them.
>So you have a function returning an error code AND a potential file.
It's not returning an error, it's returning a type of file.
in a functional world it'd just be something like:
type File = Valid | Invalid | Read | Written | Changed | Locked


And in your Read_File function, you'd just get back an empty invalid file if it happens Or something.
>>
>>63368758 (You)
>>
>>63368771
Now you're just being pedantic. Do you think "error" has some special meaning? It's just a way to think about the control flow and hint at optimization opportunities like always predicting the success branch or using Itanium exceptions.
>>
>63368754
>it lets you assign a Box<u32> into a Box<Any>, despite them having different sizes, but a function returning one is incompatible with a function returning the other.
Assignment is not a mathematical operation. It makes perfect sense if you understand the memory model, and Rust by design requires understanding the memory model to program in.

>schizophrenic episode
Stop with this forced meme thx.
>>
>>63368714
>AND
no, with an algebraic data type, you also have OR
i.e. an error code OR a successful file
>>
>>63366188
fwiw, i set up vmware and it's way faster than virtual box. it feels almost native.
>>
>>63368692
>That makes perfect sense tho.
It makes no sense semantically. It only "makes sense" in the context of Rust's implementation details.
>>
>>63368793
No, he's saying you can have a type that is equivalent to a tagged C union or C++ union, like this:

struct FileResult {
enum {success, failure} tag;
union {
Failure failureState;
File successState;
};
};


But you use a language where this is made safe:

data FileResult = SuccessState File | FailureState Failure
>>
>>63368806
Dynamic dispatch of traits is an implementation detail when you're using one, but its size isn't?
>>
>>63368754
>Just that assigning the value of a u8 to a u32 is always safe, and has very obvious semantics.
Say you have a generic function f. Now, a simple expression like f(x) where x is u8 has multiple valid typings with potentially different semantics: f::<u32>(x as u32) and f::<u8>(x). That's not to mention the myriad of other implicit conversions and conversion chains. Now the compiler has to go through all of them and decide which one to use. You can't have type inference and implicit conversions without some ambiguity that must be resolved.

>>63368821
I don't know why you think you have to explain this to me.
>>
>>63368806
The syntax for trait objects is misleading that way and something they regret doing the way they did. It may change in a future Rust epoch to explicitly signal to the programmer that there's extra information (a vtable) packed into a trait object alongside the body of the original struct itself.
>>
>>63368793
>Now you're just being pedantic.
no i'm not. errors interrupt your program. Romero said it fucking decades ago that runtime errors are stupid and shouldn't happen. If a game is missing a texture or can't load it. Why would you crash the whole thing or throw an error instead of just loading a default texture.

But it'd help if imperative langs had a Maybe type primitive. They get rid of any potential run time error, because if you can't match on a
Just value

Then you return Nothing
>>
>>63368841
you confused And with Or
>>
>>63368847
>Why would you crash the whole thing or throw an error
Why do you think that error handling means crashing or something like that? Using a default texture in the case of a file not existing is handling that error.
>>
NEW THREAD!!

>>63368856
>>63368856
>>
>>63368847
>But it'd help if imperative langs had a Maybe type primitive.
They do. Sepples has std::optional. Rust has full variant types built in. Nearly every POOlang has ghetto shit like null.
>>
>>63368847
>it'd help if imperative langs had a Maybe type primitive
const T* const
>>
>>63368858
I think I just poorly wrote that post, I was thinking of Go-style error handling (because I associate Go with morons) and then jumped straight to talking about ADTs.
>>
>>63368879
but the point is your point was wrong, you can account for errors and it is better
>>
>>63364750
poo in the loo
>>
>>63368840
>Dynamic dispatch of traits is an implementation detail when you're using one, but its size isn't?
I have no idea what you're on about. Calling a monomorphized function when the concrete type is known vs. looking it up in a vtable when it isn't doesn't leak any implementation details into the semantics of the language. Box<Any> and Box<T: Any> being incompatible under some circumstances while &Any and &T are always compatible leaks implementation details into the semantics of the language. How is that difficult for you to process?
>>
>>63368841
>You can't have type inference and implicit conversions without some ambiguity that must be resolved.
If you have a f::<u8>, you call that. Otherwise, you call whatever f is compatible with the argument. If there's more than one option, you generate an error. If that's too difficult for you, then at least don't have dozens of other non-obvious implicit conversions, some of them being completely ridiculous, e.g.:
fn foo(x: &Bar) {
}

fn main() {
let x = Bar::new();
foo(&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&x);
}
>>
I challenge you to create an array of representing all diagonals of size 5 in a multidimensional array of integers
>>
>>63365807
Font?
>>
>>63368794
You're a retard. When your implementation details leak into the semantics of the language, you are doing something wrong. You can say that this is "by design", but it just makes your design retarded. If &u32 and &Any are compatible, Box<u32> and Box<Any> should be compatible as well.
>>
>>63367158
;>)
>>
>>63369274
>If &u32 and &Any are compatible, Box<u32> and Box<Any> should be compatible as well.
But they are anon. Are you retarded or what?
>>
>>63369381
>But they are anon.
Then what's the deal with this? One way or another, Rust is doing something fucking retarded here, even if it's something other than what it looks like.
fn foo() -> Box<u32> {
Box::new(123)
}

fn main() {
let a: Box<Fn() -> Box<u32>> = Box::new(foo); // Okay
let b: Box<Fn() -> Box<Any>> = Box::new(foo); // Error
}
>>
>>63369611
It makes perfect sense and you have been explained why time and time again in this thread. Deal with it. There is no contradiction with regard to how &u32 and &Any behave versus how Box<u32> and Box<Any> behave either.
>>
>>63369731
>Box<u32> and Box<Any> are compatible!
>except when they are the return types of a function
Kill yourself.
>>
>>63369611
But this is consistent with the behavior of &u32 and &Any.
use std::any::Any;

static x : u32 = 123u32;

fn foo() -> &'static u32 {
&x
}

fn main() {
let a: Box<Fn() -> &'static u32> = Box::new(foo); // Okay
let b: Box<Fn() -> &'static Any> = Box::new(foo); // Error
}
>>
>>63369769
Neither are &u32 and &Any:
use std::any::Any;

fn bar(foo: fn() -> &'static i32) {
let b: fn() -> &'static Any = foo;
}


error[E0308]: mismatched types
--> src/main.rs:5:31
|
| let b: fn() -> &'static Any = foo;
| ^^^ expected trait std::any::Any, found i32
|
= note: expected type `fn() -> &'static std::any::Any + 'static`
found type `fn() -> &'static i32`

>>
>>63369776
>But this is consistent with the behavior of &u32 and &Any.
So convertibility between &u32 and &Any is itself inconsistent in Rust, which really only makes it worse.
>>
>>63369812
Try using your brain anon.
>>
>>63369812
Conversion != substitution. One type decaying implicitly to another type does not mean that they have the same representation in memory, nor does it mean they are equivalent in all contexts.
>>
>>63369822
>>63369840
Look, I get it: you have to be mentally retarded in the first place to stick to Rust and attempt to defend its horrendous design decisions, but being this retarded...? Semantically, if type T implements trait X, T is a subtype of X. The fact that sometimes it appears to be the case in Rust but sometimes it isn't so is just a consequence of Rust's poor design choices leaking implementation details into the language semantics.
>>
Anyone ever write a chatbot
>>
>>63368846
>The syntax for trait objects is misleading that way and something they regret doing the way they did.
Admittedly it's not the best design choice ever. Do you have to be a sperg to consider it a reason to completely dismiss the language tho? Yes. Absolutely.

Also it doesn't expose a detail that should be hidden, it hides a detail that should be exposed, namely that references to Traits carry an additional vtable pointer and thus are not substituable with references to types. At some point some anon on /dpt/ said C++ pointer ought to be written
virtual Class*
if they could trigger virtual calls, and it's a fair point.
>>
>>63370101
yeah
>>
>>63370168
>it doesn't expose a detail that should be hidden, it hides a detail that should be exposed, namely that references to Traits carry an additional vtable pointer
Ah, the Javascript mentality.
>>
>>63369970
>Semantically, if type T implements trait X, T is a subtype of X.
What's your point? Trait types are universally distinct from concrete types in semantics, usage and implementation. Trait references being distinct from concrete references is no more a leakage of implementation details than an array slice being distinct from a sized array reference.
>>
>>63370201
It's literaly a feature of trait references tho, see pic >>63367737. And Rust does indeed have a complicated memory model, but that's the tradeoff for not having a GC.
>>
>>63370214
>What's your point?
Gain 10 IQ points, then come back, read and actually comprehend my post. Then you'll know what my point was, because it's spelled out in a way that anyone with even a cursory understanding of computer science should be able to fathom.
>>
>>63370242
>Rust does indeed have a complicated memory model, but that's the tradeoff for not having a GC.
Exactly what does any of this have to do with GC, you tard? C++ doesn't have a GC and it gets subtyping right.
>>
>>63370352
Inheritance and intrusive vptrs are not "getting subtyping right".
>>
>>63370379
>b-b-but muh inheritence... muh intrusive vtables!
Cry about it all you like, but at least it has the correct semantics, unlike Rust.
>>
>>63370499
>sepples monkey fails to understand that not every language has identical semantics to sepples
>>
>>63370499
>the correct semantics
Totally subjective. There are no "right" semantics, it's just different type systems being internally consistent but not mixing with each other. It's like complaining 1 + 1 = 0 in a finite field of size 2. Again, just so you hopefully stop sperging, Any and u32 have no subtyping relations whatsoever, and it's perfectly correct. Implicit conversion doesn't imply subtyping.
>>
>>63370547
>falsely assuming that i care about the trash that is sepples
>failing to understand subtyping
Literally subhuman. It has nothing to do with C++ specifically. C++ just happens to implement it correctly, while Rust tries to fake it in a half-assed manner that makes no semantic sense.
>>
>>63370618
How do we fix Rust then? Denote trait references distinctively? The thing is: it's redundant, the compiler already knows which name denotes a trait and which name denotes a type, no?
>>
>>63370696
>How do we fix Rust then?
Destroy it completely. It cannot be saved.
>>
>>63370590
>Totally subjective
>There are no "right" semantics
There's nothing subjective about how subtyping works. Rust simply fails to adhere to its rules, opting for a nonsensical hack that only mimics it in some cases.

>Any and u32 have no subtyping relations whatsoever
Obviously not, fucktard, because Rust simply fails to implement it correctly. You have a retarded language where implementing the interface for trait Y doesn't make something a subtype of Y as expected, but rather only acts as if that were the case sometimes, depending on seemingly random factors like whether or not the function that returns the type is a closure. You are subhuman. Have a nice day.
>>
>>63370714
ok sperg, but only if you abide by your own rules, and consequently kill yourself because you can't be save, can you?
>>
>>63370714
1. Take the BC
2. Improve it
3. Re-write Rust without the ridiculous safety gimmick.
4. Carefully re-do its syntax, without any cons.
>>
>>63370696
>How do we fix Rust then? Denote trait references distinctively?
Implementing trait X should make the type a subtype of X. What Rust does is conceptually meaningless. It's just an implementation detail leaking into the language. I don't know how many times I need to repeat it before you understand it.
>>
>>63370738
Are traits even types per se in Rust? I'm not even sure. It's just syntax so calm down sperg.
>>
>>63370792
>Redo the syntax while carefully avoiding "leaking the implementation detail"
>Have Box<$Any>
>Decide we might as well make the sigil optional
>full circle.
It's a shortcut, not the end of the world. Take your pills please.
>>
>>63370797
>Are traits even types per se in Rust?
As it stands, probably not. They have no formal meaning. Like the rest of Rust, they're a half-assed imitation of something useful and well-defined.
>>
>>63370836
>conflating different posters
>still not understanding what subtyping means
>>
>>63370843
There must be a formal definition since RustC implements it. Maybe you can argue it's a useless definition, (spoiler: it's not) but it's still well-defined.
>>
>>63370865
Not everything has to be a type. Haskell typeclasses aren't, and afaict Haskell is not renowned for it's half-assed type system, so maybe try not being so stubborn?
>>
>>63370939
>Not everything has to be a type.
brainlet talk.
>>
>>63370749
>"make it better" without explaining what changes would make it better
You're literally telling a programming language to git gud
>>
>>63370913
>There must be a formal definition since RustC implements it.
You don't understand what "formal" means.
>>
>>63370965
Thank you sperg, it's so nice arguing with you. You really have cogent points.
>>
>>63370985
no u
>>
>>63370843
Rust does not have subtyping, how many times does this need to be explained to you? If you interpret the Any trait as a type it's going to be something like (forall a where a : Any), which is not a supertype of i32.
>>
>>63370939
>Not everything has to be a type.
No one said everything has to be a type. Rust's failure in this case has nothing to do with traits not being types per se. It has to do with traits deriving their properties from implementation details, instead of the implementation being subject to a desired set of properties.
>>
>>63370987
>repeatedly ignores the points made
>responds to obvious trolls
>i-i win
It's entirely transparent that you can't address the argument. Off you go, subhuman.
>>
>>63371013
>Rust does not have subtyping, how many times does this need to be explained to you? I
Why are you "explaining" to me that which I've been explaining to you the entire thread? Rust doesn't have subtyping where there should be subtyping.
>>
>>63371052
>everything being types is a troll
(you)
>>
>>63371078
Oh, so you're unironically retarded and can't tell apart different posters. Okay, then.
>>63371039
>>
>>63371039
that desired set of properties is "let's automatically have a vptr on the side of the reference iff the reference is polymorphic". It's a memory layout-aware specification and a design decision. Rust follows it consistently. What makes you say it's an implementation detail ffs?
>>
File: get-well-soon.jpg (80 KB, 640x640)
80 KB
80 KB JPG
>>63371118
>"let's automatically have a vptr on the side of the reference iff the reference is polymorphic"
>What makes you say it's an implementation detail ffs




Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.