[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: bearded fox girl.jpg (417 KB, 708x1000)
417 KB
417 KB JPG
old thread: >>63362407

Unix beard edition!
What are you working on, /g/?
>>
fuck opengl
>>
>>63368856
Please don't post my wife
>>
>>63368859
Because traditional exception handling is bloated, slow, and mucks up your code-base.
>>
What's your favorite editor theme?
>>
>>63368894
I'm talking about algebraic effects, which are another step up.

>>63368903
>bloated, slow
Bit of extra executable size, zero runtime cost if the error doesn't occur. Sometimes you know that an error might occur fairly often especially if it is based on user input so you use ADTs instead.

>mucks up your code-base.
Not in a decent language that can abstract it (as well as ADTs) into an algebraic effect, which you would know I was talking about if you had read the conversation chain.
>>
>>63368903
m-muh zero cost exceptions!
>>
We can never have "better C" because anybody who tries, does anything but C.
They do
>nonstandard ABI
>(((safety)))
>answers that make even Markus think that PHP isn't that bad compared to them
>>
>>63369063
We can never have better C because Cniles will reject anything that isn't C.
>>
>>63369063
I'm designing a language that adds generics, traits, and closures with a more consistent ABI, but not safety.
>>
>>63369079
People are using gcc extensions.
>>
>>63369079
Do Cniles reject HolyC tho? Serious question.
>>
>>63369079
dumb sepples/rust/java/nim poster
>>
>>63369089
They haven't even migrated to C99.
>>
>>63369086
>generics, traits, and closures
You've already strayed from God's light.
>>
>>63369127
Retard.
>>
File: 1503589232081.png (70 KB, 434x378)
70 KB
70 KB PNG
What is the easiest way to get a p2p connection going between to desktops behind NATs in C?
>>
>>63369086
Add variant types and call it Rust.
>>
>>63369098
>suggest D's better C
>But I might not be able to use this random library!

>talking to a C zealot about (missing feature)
>I can just use a macro!

Cniles are like women, they don't know what they want.
>>
Bjarne says that exceptions are ok
>>
>>63369163
Bjarne is a fuckup who doesn't know shit, and most of the good ideas in sepples were stumbled on entirely by mistake
>>
>>63369143
>>talking to a C zealot about (missing feature)
>>I can just use a macro!
Are you this tard by any chance >>63367011?
>>
>>63369189
Bjarne stopped caring a decade ago.
>>
>>63369202
i am not.
>>
>>63369142
Variant types are purely a safe restriction of tagged unions. Pattern matching can be recovered with traits and anonymous trait impls.
struct Result(T, E: Type) {
tag: enum { SUCCESS, ERROR },
union {
success: T,
error: E
}
}

impl[T, E: Type] Result(T, E) {
fn success(x: T) -> Self {
struct {
tag = Self::SUCCESS,
success = x
}
}

fn error(e: E) -> Self {
struct {
tag = Self::ERROR,
error = e
}
}

fn match[U: Type](self, p: trait {
fn success(self, x: T) -> U,
fn error(self, e: E) -> U
}) -> U {
case self.tag {
SUCCESS -> p.success(self.success),
ERROR -> p.error(self.error)
}
}

fn map[U: Type](self, f: Fn(T) -> U) -> Result(U, E) {
self.match(impl {
success(x) -> Self::success(f(x)),
error(e) -> Self::error(e)
})
}
}

It's not inconceivable that this machinery could be automated with a macro.
>>
>>63369237
Cool.
>>
>>63368856
Tamamo sure is cute tonight.
>>
I made a java program that prints all the primenumbers from 0 - 100 :)

 public class primeme { 

@SuppressWarnings("unused")
public static void main(String args[]) {


for (int tal = 0; tal <= 100; tal++){


for (int i = 2; i < tal; i++) {

if ( (tal % i) == 0) {

// System.out.println(tal + " är inte ett primtal");

break;
}

else {

System.out.println(tal + " är ett primtal");

break;

}
}

}
}
}
>>
File: 1509329137213.jpg (106 KB, 698x658)
106 KB
106 KB JPG
>>63369286
Sorry for the Swedish btw.
Here's a GitHub link for anybody who wants it lmfao.
https://github.com/WhatsUpForum/prim
>>
can anyone explain to me why modules > headers in c++
>>
>>63369350
just google lol
>>
>>63369350
They're not.
It's literally a MEE TOO feature that's 20 years too late. Even perl had this shit for fucks sake.
>>
>>63369350
>two files or one
wow, what a conundrum.
>>
>>63369350
Headers are pure text inclusion, so you need machinery like header guards and maybe a separate namespace feature to prevent collisions. You also need to separate the public interface and the private implementation into multiple files, whereas with modules you can use public/private modifiers. The module hierarchy may also determine the file hierarchy, in which case you don't need to list all the source files of your project to compile it.
>>
>>63369350
>>63369409
tl;dr a module is all of these in one:
- header
- translation unit
- namespace
- maybe an entry in a makefile
Some languages even have first class modules that are used for generic programming, like MLs.
>>
>>63369409
>>63369468
makes sense, thanks

But what about readability? Like, I've always found it neat to give .h file a quick look to get a "summary" of what I'm gonna use, without implementation stuff. And how does one define public apis with modules?
>>
>>63369547
>with modules you can use public/private modifiers
>>
>>63369237
>adding unsafe unions
>>
>>63368856
>What are you working on, /g/?
Still porting parsers to Web Assembly. No regex allowed.
>>
>>63369587
I'm not concerned with language enforced safety.
>>
Do you guys have some good tips for teaching others programming?
I am in no way a teacher, but I was told to teach a few people C++, cmake, ROS, Qt, Eigen and Opencv.
They claim to have had a course in C++ before, but I need to get them up to speed so they can use programming in their bachelor thesis.
I only have 3 hours a week with them, so want to stay practical.
I have an overarching goal in mind and every time, we move closer to that, but I worry they just write what I tell them to write rather than learning any of the stuff.
I initially started out with using qtcreator, but it crashed a lot and I just switched them to an editor + terminal.
And regarding ROS, I also have them write the cmake files manually instead of using the catkin tools as I believe it is the fastest way to force them to think about the project they make.
I also make them comment stuff and draw sketches of what we are making, but I feel it isn't enough.
Any advice?
>>
>>63368931
>zero runtime cost if the error doesn't occur
You have to do some sort of runtime check at some point to know whether you want to throw or not.
>>
>>63369286
Stop
spacing

your

code

like this.

It's

retarded
.
>>
>>63369350
It's a different set. Modules for instance don't allow you to build against binary distributions of a library.
>>
>>63369621
True, but how do you suggest getting rid of that check? I should say "zero overhead" because that check exists regardless of whether you use an ADT, throw an exception, or simply abort. If you ignore the check entirely, you could run into undefined behaviour.
>>
>>63369630
Why? It makes it easier to read!
>>
>>63369656
>>>/reddit/
>>
>>63369653
>I should say "zero overhead"
Now you got it my man.
>>
>>63369650
>Modules for instance don't allow you to build against binary distributions of a library.
What gives you this idea?
>>
>>63369388
so you agree that header files are the way to go?
>>
>>63369664
Reality. You'll have to provide declarations either ways for the type checking pass of your compiler.
>>
>>63369661
What would be a better way to space my code then?
>>
>>63369667
>C/++ with only headers
no
And also no because modules are much more powerful, and easier to work with.
>>
>>63369675
No, the compiler can resolve mutual dependencies by itself.
>>
>>63369683
no.
2 files is better than 1 file.
Nobody wants to read through the source code to find the documentation of a function.
>>
File: 1504355056731.jpg (124 KB, 1024x1024)
124 KB
124 KB JPG
>>63369699
>the compiler can guess types from an ELF file
You either don't know what "binary" means or are being retarded.
>>
>>63369704
>this is your brain on C/++
Why do you need to read the definition and implementation desperately?
Why would having two files for the same module be better?
>>
>>63369676
public class primeme { 
@SuppressWarnings("unused")
public static void main(String args[]) {
for (int tal = 0; tal <= 100; tal++) {
for (int i = 2; i < tal; i++) {
if ((tal % i) == 0) {
// System.out.println(tal + " är inte ett primtal");
break;
} else {
System.out.println(tal + " är ett primtal");
break;
}
}
}
}
}
>>
>>63369720
separately*
>>
>>63369704
I guess modern ides have tools to gather info, like object browser in vs
I mean, Java/C# guys work somehow

>>63369675
that's kinda what I thought! thanks
>>
>>63369718
>binaries have to be ELF
>ELF can't store that kind of information
Your head revolves around C, stop it.
>>
>>63369726
Thanks for helping man, im new to programming, i appreciate it
>>
>>63369704
This, especially working with an existing code base, having a separate file with the function headers and short descriptions of what they do is incredibly helpful.
>>
>>63369753
>binaries have to be ELF
I didn't say that.
>ELF can't store that kind of information
It shouldn't, otherwise it'd be called a source file.
>>
>>63369753
>>63369699
>>63369664
Great. Another ABI to be broken.
>>
>>63369751
>I guess modern ides have tools to gather info, like object browser in vs
With that logic, there is no downside to having a header file as your ide takes care of synchronizing changes but it the upside is it is more readable.
I rarely generate the doxygen documents as it is just as readable in the editor.
With java, it is a must.
>>63369720
I read the documentation to understand the intent and design of the system.
I read the code to understand the implementation.
Those are two separate things, why wouldn't I separate them?
It is also an optimization.
>>
>>63369704
>>63369775
You can generate stripped down "headers" or, you know, documentation from modules easily. If you do it the other way around, you have to maintain both.

>>63369784
>contains machine code to link to but also types for type checking
>this makes it a source file

>>63369793
If the types change in an incompatible way, it will cease to type check.
>>
>>63369829
>this makes it a source file
It does. Refer to >>63369718.
>>
>>63369829
>you have to maintain both
Sure but so what?
Just like you can get a tool to generate the documentation, you can get tools to apply changes to both if you make any.
But you shouldn't make changes to the API all the time.
>>
>>63369825
>It is also an optimization.
wwwwwwwwwwwwww
Header files are an eternal headache for C/++ optimizations.
>>
>>63369829
>types for type checking
High level types are transparent for the cpu, hey have no business being in object files.
>>
Serious question: what benefits does Haskell provide over NodeJS?

Typeclasses? But I can pass functions via options object, passing them implicitly via type signature does not improve anything.
ADTs? But disjoint unions are good enough for most situatuions.
Types as proof of correctness? Flow does it, without limiting me to BSDM-style correctness.
Performance? V8 is pretty fast and more predictable.
Binaries? Nexe.

So, what could be the practical reason to pick glorious Haskell instead of ubiquitous abomination of JS?
>>
File: 1510485478283.jpg (153 KB, 645x968)
153 KB
153 KB JPG
>>63369855
>>63369877
>modules are bad because they can't be distributed as binaries
>actually they can
>NO BINARIES AREN'T SUPPOSED TO HAVE TYPES BECAUSE I SAY SO
>>
>>63369886
literally eliminates all run time errors.
>>
>>63369874
How on earth do headers hurt C optimisation?
99.9% of the time, they just contain function declarations, a few type definitions, and maybe a few macros.
>>
File: 1509893022495.jpg (212 KB, 1218x1015)
212 KB
212 KB JPG
>>63369894
>the CPU cares about your AbstractFactoryBeansSumType
>>
>>63369855
>>63369877
>>63369894
Even then, you can always have the public interface (as a kind of source file) and private implementation (as an object file) generated by the compiler in order to link to a compiled library. You don't have to have it all in one file.
>>
>>63369905
You know that is not really true.
And if I cover all my code with Flow annotations I will achieve the same level of correctness(which is not needed anyway).
>>
>>63369917
No, it doesn't, which is why types would be stripped when compiling an executable or dynamic library. Or you could do as I say here: >>63369920
>>
>>63369920
>you can always have the public interface (as a kind of source file) and private implementation (as an object file)
You mean a fucking header file?
>>
>>63369908
Recompilation?
Have you never worked in a large C/++ code-base?
>>
>>63369939
Not a header file that you maintain, but part of the compiler's output. There's a massive difference.
>>
>>63369943
What the hell does that have to do with optimisation?
>>
>>63369929
NoRedInk which are the main sponsor of Elm, have 200k LOC in production for years and annually report 0 RTE's from their Elm-base.
>>
When were you when C got type inference?
I was sat at home compiling gentoo when Richie ring
'C has type inference'
'no'
https://github.com/ltcmelo/psychec
>>
>>63369872
One of those requires significantly less IDE support and leaves less room for error. Not hard to figure out which one I'm talking about.
>>
>>63369134
I find this question very dumb, but okay.

One answer is "sockets bound on local network address".
>>
File: dpt.png (11 KB, 498x167)
11 KB
11 KB PNG
>>63369952
Nothing. It's /dpt/ being (again) a waste of time.
>>
>>63369958
Elm is a different beast. It is limited, simple and eager. There are some good reasons to pick it over both Haskell and JS/PS.
But I'm currently thinking about backend part, so Elm is irrelevant.
>>
>>63369936
s/compiling/linking
>>
>>63370024
It doesn't matter, Haskell is the same shit, and a fairly popular back-end.
>>
>>63369974
>This is a research project. While we strive to keep the code clean and to make the tool easily accessible, this is an academic effort.
This translates to:
>This project isn't going to be documented or maintained at all. Don't use it
>>
You motherfuckers, now I am even more confused about modules

So:
- header files are bad because reasons (c legacy, preprocessor sucks, compilers work differently, including makes you include all shit etc.)
- modules are all around better because reasons
- yet, header files are still useful for defining handwritten interfaces for your lib

am I close or what is happening here
>>
>>63369974
>python Reconstruct.py path/to/file.c
The absolute city of C
>>
>>63370138
literally just learn a language with modules and it will explain itself.
Also tell me how many new langs aren't using modules and instead sticking with header/src.
>>
C doesn't require modules because all compilers shit out intercompatible shared libraries on account of the lack of name mangling and the rock solid unchanging ABI.
>>
>>63370163
Correct, but C would still be better with modules.
>>
>>63369760
You'll get used to read code with time.
Today you think you need to space everything, tomorrow you might add retarded delimiters in with comments (e.g. /**********************/), and after a while you'll realize that this doesn't make your code more readable. Quite the opposite.
>>
I have a 1d array of the RGBA values of every pixel in a 128x128 image, for a total length of 16,384

I SHOULD be able to just pull the value I want using some math and an offset, but it's fucking up like bonkers so I was wondering if there's a simple way to take it and split it up into a 2d array of 128x(128*4) (row by column*RGBA)?
Would that just be a for loop like
for (int i = 0; i < 128; i++) {
for (int j = 0; j < 128*4; j += 4) {
pixelArr[i][j] = pixelVal[(i+1)*j];
pixelArr[i][j+1] = pixelVal[(i+1)*j+1];
pixelArr[i][j+2] = pixelVal[(i+1)*j+2];
pixelArr[i][j+3] = pixelVal[(i+1)*j+3];
}
}

Or is there some simpler way to do this?
It's in javascript (Yes I know, but I don't have a choice in the matter)
>>
>>63370273
>I SHOULD be able to just pull the value I want using some math and an offset, but it's fucking up like bonkers
>(i+1)*j
No wonder.
>>
>>63370138
C-style headers are just kind of a strange artifact from the early days of pre-compiler linking. I don't think you really need an explanation for why splitting your code up over multiple files and creating a manual hierarchy of linking for which order matters is a bad thing when the alternative has virtually no downside.

While thinking of them as API documentation can make them seem halfway-useful, that's not really what they exist for. And that kind of metadata can be automatically generated these days.
>>
>>63370295
That's not the math I currently have in place and I'm just kind of throwing shit out there, I didn't stop to think about that example code too hard. I'm just wondering if two for loops is the right way to do this or if there's a cleaner way to go about it
>>
>>63370151
>>63370297
Ok, danke schoen, family

Off to watch that microsoft badboy
https://www.youtube.com/watch?v=IA14LXnBcJg
>>
>>63370314
You can do it with two loops (but why not go all the way and have a 3D array?) or one loop with division and modulus, it works out to the same thing. The former will be easier than the latter, though.
>>
>>63369976
>less room for error
But the tools already exist, it is like complaining quicksort is harder to implement and therefore more prone to error.
Nobody cares if something is hard if it works and everyone have access to the source code of a version of the implementation.
And even if you can't implement it, you can probably implement a "jump to" function or even a search and all the "maintenance" is a non issue as well.
>>
>>63370314
>>63370325
Also, if you pay attention to layout, you could even cast directly to the final array type without having to do any copying.
>>
>>63370273
It should look more like this:
for( int x=0; x<128; ++x) {
for( int y=0; y<128; ++y) {
pixilArr[x][y].a = pixelVal[(x + y*128)*4];
pixilArr[x][y].r = pixelVal[(x + y*128)*4 + 1];
pixilArr[x][y].g = pixelVal[(x + y*128)*4 + 2];
pixilArr[x][y].b = pixelVal[(x + y*128)*4 + 3];
}
}


I'm a little confused about what the pixel format is in your example, though. I'm guessing it's a byte array of ARGB data.
>>
>>63370346
>JavaScript
no, but good idea nonetheless.
>>
>>63369286
you can boost performance by changing the second for to sqrt(tal)

try to apply memoization
>>
>>63370344
Or you could just use modules and make everything easier for both the maintainer and the tools. Just because you CAN recover similar functionality with header files and tools doesn't mean you should. Have you got any reasons that header files are better than modules?
>>
>>63370359
Yeah I forgot to include the individual values in the post, it's actually 65536 values long (unsigned int for each R, G, B, and A value per pixel).
It seems like double for loop is the right approach though. I'll fiddle with it until I get the stepping right. I might just use arr.splice since I only have to run it once on init.
>>
>>63370397
why not use both?
I don't see why you won't just use regular c++ modules?
>>
>>63370487
Why both?
>>
>>63370413
It's the most intuitive approach and all various ways of converting the data are going to have the same O(n^2) growth whether they are single-loops or double loops or triple loops.

Of course the BEST way is to not convert at all and to just reinterpret the existing data, but that's not always a possibility.
>>
>>63369983
>dounles are a set of integers
That's right. Check'em
>>
>>63370487
>why not use both?
And that's why no one likes C++ anymore. Because it's not you-proof.
>>
>>63370500
nice but you didn't use an anime image so they don't count
>>
>>63370491
modules when you have isolated projects, header files for documentation, source files for implementation.
You can have as many header / source files as you like, some might be shared, others might not be.
>>
>>63370567
Have you missed the whole part where I am arguing that it's better to generate even more human readable documentation from modules rather than use separately maintained headers as ad hoc documentation?
>>
Why aren't you rewriting your shitty slow JS applications to efficient C/C++/Rust right now?
>>
>>63370625
Can I use C in my browser ?
>>
>>63370644
Yes, with Emscripten.
>>
>>63370659
fuck off with that retarded shit. Never run code in browser!
>>
>>63370273
js is cute CUTE


let tmp = pixelVal.reduce((arr, k, i) => (i % 4 == 0 ? arr.push([k])
: arr[arr.length - 1].push(k)) && arr, [])

let pixelArr = tmp.reduce((arr, k, i) => (arr.push({ r: k[0], g: k[1], b: k[2], a: k[3]})) && arr, [])

>>
>>63370625
If i wanted to do webshit I'd just learn Nim.
>>
>>63370690
And your reasons for that would be?
>>63370721
>compiles to JS
It's trash.
>>
>>63370771
It also compiles to C, how the fuck does a completely optional feature affect the language?
>>
>>63370659
Good luck with that my man

int main() {
EM_ASM(
alert('hello world!');
throw 'all done';
);
return 0;
}
>>
Business idea: a web browser with a VM based on "gas" like Ethereum to kill Pajeet written scripts that hog resources.
>>
>>63370705
>Implementing a simple loop over rectilinear data using lambdas, iterators, and a dynamically-allocated stack
As ugly as it is inefficient.
>>
How does machine with 32 bit bus width able to calculate uint64_t without any noticeable difference with other machine that having 64 bit bus?
>>
>>63370864
>add lower 32 bits, setting carry flag
>add upper 32 bits with carry in
>>
File: mpv-shot0571.jpg (94 KB, 864x480)
94 KB
94 KB JPG
Programming!
>>
>>63370850
A man needs to impress hipsters!
>>
>>63370864
Just put two 32-bit entries next to each other and the compiler automatically does a little bit of extra math every time you do read/write them. Not that complicated, but there are obviously costs to doing that extra math.
>>
anybody have experience with Revature? they want to pay me $8 an hour for 3 month training and then place me somewhere where I'd make 50k / yr for 24 month commitment
>>
>>63370799
My mistake then. I could only find examples of compiling to JS for the browser and assumed that is the only available target.
>>63370805
Why are you throwing over the language barrier?
>>
>>63370864
Carry flags and "long" arithmetic algorithms like the ones you learned in school.
>>
as much as I love conspiracy theories, does anyone why chrome requests a robot.txt which I cannot see anywhere ?

only thing I found is this lousy SO question

https://stackoverflow.com/questions/46264777/why-does-chrome-request-a-robots-txt
>>
how do I go from the kind of developer that fixes bugs and writes tests to the kind of developer that designs frameworks and implements complex algorithms?
>>
>>63370996
literally just do it
>>
>>63370979
Maybe they use Chrome users as crawlers.
>>
>>63370996
>>63371006
This.
t. writes frameworks and complex algorithms
>>
>>63370979
it tries to communicate with its fellow botnets.
>>
>>63370138
>interfaces for your lib
not necessary
>>
>>63371070
>should
All tastes are in nature. Rust took a tradeoff and decided against implementing subtyping for traits. Why are you so mad you have to write a fucking lambda?
>>
>>63371022
Probably. Why crawl yourself when people's actual browsing habits can give you crawling data first-hand? When you go to a page, it will look at robots.txt and if the page your browsing isn't disallowed or whatever, then it can send information back to its server about the page back to google as if its crawler was the one looking.
>>
>>63371178
Because implementation details don't matter in systems programming.
>>
File: 1510090364765.jpg (114 KB, 1440x1624)
114 KB
114 KB JPG
How could they possibly make WinAPI
so
FUCKING
HORRIBLE
FUCK
>>
>>63371236
(You)
>>
How do ui layout engines work? What are some intro level algorithms to lurk?
>>
>>63371264
hello fellow library dev.
>>
>>63371264
It could be worse. Have you seen pre-10 DirectX?
>>
>>63371070
So do you understand that the lack of subtyping is not a flaw in the foundation of rust's design, but an intentional design decision that is applied consistently? You don't have to agree with it, but it doesn't make the language inconsistent just because it doesn't work the way you expected it to.
>>
>>63371178
You can't "decide against" subtyping. If you don't have it where it's supposed to be, you're doing it wrong. For example, good languages have a superclass of all different varieties of pointers, no matter what they point to.
>>
>>63371307
Believe it or not, there are type systems without subtyping, you may have even used one. Generics are not subtyping.
>>
>>63371178
>Rust took a tradeoff and decided against implementing subtyping for traits.
That's not entirely true. It seems to have subtyping on base types (e.g. T: Foo implies Box<T>: Box<Foo>) but not on function types (e.g. T: Foo does not imply Box<Fn() -> Box<T>>: Box<Fn() -> Box<Foo>>).
>>
>>63371307
>my way is the right way
Uh... no?
>>
>>63371345
Type systems without subtyping are incorrect and broken.
>>
>>63371350
Is type composition a form of subtyping?
>>
>>63371347
>seems to have subtyping on base types (e.g. T: Foo implies Box<T>: Box<Foo>)
It *seems*, but it ain't. How convenient you forgot to mention that Foo has to be a trait and not a concrete type...
>>
>>63371350
you are literally wrong.
>>
>>63371350
Haskell?
>>
should I read sicp ?
>>
File: 1426767829055.jpg (110 KB, 497x640)
110 KB
110 KB JPG
>>63371264
>he does not interface a COM library in pure C
>>
>>63371178
>Rust took a tradeoff and decided against implementing subtyping for traits.
It took a tradeoff that makes its type system conceptually incoherent.

>Why are you so mad you have to write a fucking lambda?
The lambda "fix" only makes it worse, further exposing the fact that you're dealing with implementation details leaking into the language semantics. Box<u32> being compatible with Box<Any> as a local variable, or if it is returned from a lambda, but not if it is returned from a normal function makes no sense conceptually. There is no reason for it to be that way except that it has to be for the sake of this "performance trade-off".
>>
>>63369286
The inner loop only needs to go to sqrt(tal)
Also it's sufficient to just check if a number is divisible by the primes between 2 and sqrt(tal), you don't need to check if it's divisible by every single number
>>
>all these typelets who don't know the power of TDD.
>>
>>63371178
>>63371347
I'm not saying that it's inherently wrong, but I also don't see a reason not to allow it. It's not a matter of incompatible representation, because Box<T> can be a regular pointer whereas Box<Foo> is a fat pointer.

>>63371375
I'm not that guy.
>How convenient you forgot to mention that Foo has to be a trait and not a concrete type...
That doesn't matter. The subtyping relation depends on the trait inheritance/implementation relation but that doesn't make it not subtyping.
>>
>>63371441
>if it is returned from a lambda, but not if it is returned from a normal function
Incorrect. A normal function returning a Box<Any> would work.
>>
>>63371439
Is it worth it?
>>
>>63371582
>a Box<u32> is compatible with a Box<Any> when returned from a function if the function returns a Box<Any> instead of a Box<u32>
The absolute motherfucking state of Rust users...
>>
>>63371593
Suicide is far healthier
>>
>>63371397
yes, it's unsarcastically fun to read
>>
>>63371601
YEAH CONGRATS SPERG! Box<Any> is compatible with Box<Any> ! Bravo
And I never said you Box<Any> was a subtype of Box<u32> either, just fyi
>>
>>63371601
meanwhile anyone with templates can write an infinitely more flexible "Box" in a few seconds.
>>
>>63371697
>a Box<u32> is compatible with a Box<Any> when returned from a function if the function returns a Box<Any> instead of a Box<u32>
Please take some time to reflect on what you said, and then kill your family and yourself.
>>
>>63371725
>meanwhile anyone with templates can write an infinitely more flexible "Box" in a few seconds
Meanwhile, "anyone with templates" mostly refers to sepples users, a language that is even less coherent than Rust.
>>
>>63371747
>sepples is the only language with templates
>>
>tfw using concepts
C++17 is GOAT
>>
>>63371758
I said "mostly". I think sepples monkeys outnumber Template Haskell users quite significantly.
>>
>>63371785
nice bait, nearly got me
>>
>>63371785
So theyre template attribute/properties you can check against?
Or am i misinterpreting them?
>>
>>63371832
>he won't acknowledge the power of C++17
>>
>>63371846
This is not wrong.
>>
>>63371882
So C++ has limited UDA's?
I guess that's pretty cool.
>>
C# with embeded C++
>>
Who /xamarin/ here?
>>
>>63371860
concepts aren't in c++17 :^)
>>
>>63371920
C++98 had concepts.
>>
File: 1510678629490.png (134 KB, 2255x1261)
134 KB
134 KB PNG
>>63371732
I lost all hope for your recovery, anon. For everyone else reading, I'm saying this guy's example with || { foo() } could become just foo could become just foo if you replaced u32 with Any in the definition of foo. That's something you would not do in practice but neither would you the rest of the rest of the convoluted piece of code, so we basically both swam in circles for a couple hours and you can safely disregard the whole thing. Bye.
>>
>>63371988
Reminder:
>>63371582
>a Box<u32> is compatible with a Box<Any> when returned from a function if the function returns a Box<Any> instead of a Box<u32>
>a Box<u32> is compatible with a Box<Any> when it's not a Box<u32>
As I said, kill your family before you kill yourself. There should be not race left of your inferior genetic code on this planet.
>>
Its over, web has won.

https://blog.mozilla.org/blog/2017/11/13/webassembly-in-browsers/
>>
>>63372330
We need to kill web assembly before it becomes thing.
>>
>>63372346
its too late. web assembly ships in every browser. we cant stop it, its over.
>>
>>63372330
C and C++ can already compile to it, and I'm sure every major language will add support. So why does it even matter?
>>
File: 91239012839128.jpg (234 KB, 960x1280)
234 KB
234 KB JPG
Is there ANY point to using ifndef header guards instead of pragma once in the year of our lord two thousand seventeen?
>>
>>63372377
We just need to convince the web hipsters that HTML renderer is obselete tech and get them to make flavor of the week protocols to compete against HTTP and HTML.
>>
>>63372406
No, I would love to see a non-hobbyist compiler updated in the last decade that dosen't support it.
>>
>>63372406
Better, try NOT using any include guards if you don't intend to build a library. First, your question has no point anymore. Second, you get to explicit the hierarchy and dependencies between modules in your project, which may lead to decrease dependencies so as to bother less with including headers.
>>
>>63372520
>modules
fuck off bjarne, no one wants that
>>
>>63372555
t. cnile
>>
File: 1508530022977.jpg (226 KB, 768x800)
226 KB
226 KB JPG
What does /dpt/ think about visual programming languages?
>>
>>63372520
>modules
lmaoooooooooooooooooooo
>>
>>63372624
theyre all trash.
Even Blueprints.
Theyre not even a good teaching tool.
>>
File: pickle rick.png (87 KB, 554x400)
87 KB
87 KB PNG
>>
>>63372555
>>63372585
>>63372625
I talk about modules in the C sense of the word, that is, header+implementation. In other words, a compilation unit.
>>
>>63372624
They are interesting, but text is still easier to navigate.

Imagine a modal editor where you edit the syntax tree and feed it directly into the compiler
>>
>>63372648
>a compilation unit.
modules are literally a more efficient version.
>>
>>63372642
This is average rust poster. He comes from reddit and post Rick and Morty memes.
>>
>>63372275
Box<u32> and Box<Any> are not "compatible" at all. Rust will implicitly cast a Box<u32> to a Box<Any> to satisfy type checking, but it can't do that for arbitrary function types.

use std::any::Any;

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

fn baz() -> Box<Any>{
Box::new(123i32)
}

fn unfoo(x: Box<u32>) {}

fn unbaz(x: Box<Any>) {}

fn c(f: Box<Fn(Box<Any>)>, g: Box<Fn() -> Box<Any>>) {
f(g())
}

fn main() {
// This creates a Box<Any> value, NOT a Box<u32>
let a: Box<Any> = Box::<u32>::new(123);
// This creates a Box<u32> value, NOT a Box<Any>
let u: Box<u32> = Box::<u32>::new(123);

// works.
c(Box::new(unbaz), Box::new(baz));
// works. the conversion can be inferred.
c(Box::new(unbaz), Box::new(|| Box::<Any>::from(foo())));
// doesn't work.
//c(Box::new(unbaz), Box::new(foo));
//c(Box::new(unfoo), Box::new(foo));
}
>>
>>63372330
Good.
>>
>>63372681
>Rust will never have simple generics/templates
>>
>>63372725
Well, it's a GC less language, you should expect some trade of about ergonomics
>>
>>63372725
What do you mean simple, like the C++ substitution abominations?
>>
>>63372802
C++'s are unironically more convenient once you get past the verbosity.
>>63372811
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;
}
>>
>>63372829
>C++'s are unironically more convenient
It's just familiar, not convenient per se
>>
>What are you working on, /g/?
I'm trying to figure out why Julia language sucks. You guys are experts at this, maybe you can help me. I need some strong arguments.
>>
>>63372868
Why do you think it sucks?
The only mistakes at a glace I see are JIT and "end","function" etc. It's gotten some praise heer.
>>
>>63372829
Sure, if you like tonnes of error messages flooding your console that don't accurately depict the conceptual mistake you made. Language support for traits means the type checker catches your errors at the source.
(This could be mitigated with a structural type system but they are rare in practice and make other things less convenient).
>>
File: abracadabra.png (10 KB, 441x360)
10 KB
10 KB PNG
rly made me think
>>
>>63372868
>Dynamic type system
Trash by default.
>JIT
Trash by default.
>Ruby syntax
Trash by default.
>C FFI overhead
Meh.
>>
>>63372918
I mean if you want to get strict with templates you could either make them a little more constrained or apply UDA's. But tons of error messages is dramatic.
>>
File: 1473553938308.png (199 KB, 439x392)
199 KB
199 KB PNG
reminder that a neural network is literally just a cellular automaton over a markov model

in computer science because you have a breadth first traversal of the model done with a double buffer of state

but also in real life because a hippocampus is a biological realization of a markov model and it's made of biological cells which activate their neighbors according to rules
>>
>>63372985
>t. employed haskell programmer
>>
>>63372868
>One-based indexing
Holy fucking shit, it's utter trash.
>>
>>63372985
>reminder that a neural network is literally just a cellular automaton over a markov model

Explain further, smug poster
>>
File: gccoutput.png (273 KB, 1904x838)
273 KB
273 KB PNG
>>63372978
Whatever you come up with, it will just be a more verbose version of Rust's traits. What's a UDA?

>But tons of error messages is dramatic.
>>
/g/ents, does
g++ -c a.cc b.cc c.cc
g++ a.o b.o c.o -o a.out

count as "separate compilation"? most examples online and the textbook I am using usually presents it as
g++ -c a.cc
g++ -c b.cc
g++ -c c.cc
g++ a.o b.o c.o -o a.out

but the outcome is exactly the same. I lost a significant portion of my midterm grade because the TA thinks it's not "separate compilation" because it's not on separate lines, although the whole point of separate compilation is to generate intermediate object files (as opposed to the entire executable) so as to recompile only what is needed when any changes are made to code.

assuming I am correct, how would I go about disputing it? I read the man page but it doesn't use that specific semantic (separate compilation).
>>
>>63373060
user defined attributes.
A compile time thing that can be attached to any declaration.
>gcc is trash
what else is new
>>
>>63373078
Even g++ a.cc b.cc c.cc -o a.out would be considered separate compilation.

>>63373090
Oh, in that case UDAs are more for deriving trait implementations.
>>
How hard would it be to make a program that takes an equation and a variable from the equation, and isolates that variable
>>
>>63373090
>gcc is trash
>what else is new
I don't think clang is too much different either. Earlier GCCs have had verbose error messages but nowadays the difference is negligible
>>
>>63372985
Did you mean a nondeterministic cellular automaton with a weird neighbourhood lattice?
>>
Stop fucking trolling me that OOP and mutation and side effects are "pragmatic" or "practical" REEEEEEEEEEE when I write pure, referentially transparent code and use the type system then the code I write has far fewer bugs

So sick of my team complaining "but your code is too difficult for me to understand" and then refusing to even try to learn
>>
>>63373119
For any equation, it's impossible. But if you limit the possible equations, it can be feasible. For instance, solving Boolean expressions (e.g. find A, B, C such that A && (!B || C) is true) is a well documented problem called SAT with many decidable algorithms. There are also algorithms to solve subsets of integer algebra, real algebra, integral calculus, etc. The class of solvable formulae grows if you allow the program to give up even when the problem might have a solution in lieu of potentially getting stuck and looping infinitely before ever finding one.
>>
>>63373158
yes, but not nondeterministic, just non-uniform in its determinism; the cell replication and death rules depend on the location of the cell

>>63373051
fuck chromium, the window magically stopped responding to input so now i have to open a new window and retype my entire response that i don't even remember.

you've got your graph data structure where nodes represent neurons and edges represent synapses. that's a markov model. even though you're following all possible paths at once and not randomly selecting each edge based on its weight, it's still a markov model, because the edge weights still basically represent probabilities. not the probability that the edge will be selected, because unless the strength of the preceding signal is 0, it definitely will -- but the network's "perceived" probability that following the edge will have been the right choice -- that is, the certainty.

then superimposed on that graph you've got another graph data structure, although you may very reasonably choose not to store it that way: you've got the state of the breadth first traversal. you do a breadth first traversal through the markov model, summing up edge weights leading to each node as you go along and then scaling the result by the properties of that node, and what do you have at each stage of that process, you have a set of signals with different weights, and each of them is somewhere different in the graph. so you have things that have state, have position in a data structure, and use this information to decide whether to propagate and/or die. sure sounds like cells to me. so then you've got your cellular automaton.

therefore a neural network is a cellular automaton over a markov model
>>
>>63373078
Look at what the professor taught separate compilation as. If he taught it as requiring separate lines (retarded), he's wrong, but you're probably out of luck. If he taught it differently or didn't teach it at all, you can just bring that up.
>>
File: 1749378.jpg (49 KB, 500x500)
49 KB
49 KB JPG
>CS math class
>homework counts for 100% of the grade
>found the solutions to all the homework with a single google search

I knew the teacher was lazy as shit but this is taking it to another level.

Should I go the good boy route and ignore all the solutions so I can try to work with my brain a bit?
>>
>>63373288
It was taught as entering each line separately but that was never a part of the definition.
Anyway thanks for confirming, I will just email my professor.
>>
>>63373356
only if the particular subject matter of the class is something you don't yet understand well and either would like to or see yourself needing to in the future for career purposes
>>
>>63373262
Not only is it harder to read, but also generally slower. Even ASM is stateful. Deal with it, retard.
>>
>>63373356
What if the solutions online are bait for a trap laid by your professor?
>>
>>63373377
The stuff I work on is I/O-bound.

It's not harder to read. Shared mutable state everywhere is harder to read.
>>
>>63373283

Sounds cool, I don't know enough about that stuff to comment further.
>>
>>63373262
Google "linear type system", brainlet.
>>
>>63373378
Teacher stole the course from another teacher, he just erased the solutions from the original course. I shit you not.

>>63373376
Right, that sounds like an excellent idea.
>>
>>63373283
>therefore a neural network is a cellular automaton over a markov model
This statement gave me an idea. Appreciated.
>>
>>63373405
No languages with linear type systems target the platform I have to support yet, and I don't have time to implement my own. You clearly have no experience with real clients, brainlet.
>>
>>63373464
>wagecuck
>not a brainlet
>>
>>63373473
>assumptions based on nothing
brainlet
>>
>>63373494
>real clients
>my team
>>
>linear types
why would you ever use them?
>>
>types
why would you ever use them?
>>
File: 4bc (1).png (24 KB, 165x115)
24 KB
24 KB PNG
>>63373473
>everyone who has to make a living is a brainlet
>it is clearly by my superior intelligence that i was able to be born into the e.z.lyfe
>i made the brilliant choice to be born this way and i take full responsibility for it
>everyone who chose not to be born with loads of cash must be less intelligent than me
>>
>>63373283
So a variable local transition function? (presumably "locally" constant, for some topology on the cells)
>>
>>63373502
Real clients, such as my current one for whom my cofounder arranged for our company to provide consulting services to.

My team, which I lead, and unfortunately don't have time to replace the people in for this project.

>>63373513
My understanding is that most people only use them once.
>>
>>63373513
To make mutation pure.
>>
why?
>>
>>63373540
yee
except only constant until the automaton finishes
then the transition functions presumably change because you give feedback and the feedback gets backpropagated
>>
>>63373562
But we already have bar syntax for that. Which I guess could technically be called a really abstracted linear type.
>>
>>63373538
You don't have to be a wagecuck to have income.

>>63373593
What is bar syntax?
>>
>>63373566
Chicken thigh.
>>
>>63373601
In functional langs you can do
{thing | field = new_field} 
which is just a convenience for declaring a bunch of new immutables each change.
>>
>>63373538
dumb frogposter
>>
>>63373601
wagecuck is anyone who makes money at a job

the non wagecucks are neets or people that play the market or just people with too much money to care
>>
File: winapi.png (2 KB, 158x120)
2 KB
2 KB PNG
the winapi headers are amazing desu
>>
>>63373636
That's still implemented as making a modified copy of an immutable value, which requires garbage collection or at least reference counting. With linear types you can have actual destructive mutation, avoid garbage collection, and maintain purity.
>>
>>63373393
>shared mutable state is harder to read
Which is why you abstract the state through function calls
>>
>>63373649
But that makes sense.
>>
File: 1501743580657.jpg (31 KB, 400x400)
31 KB
31 KB JPG
Imagine a single threaded programming language
>>
>>63373673
#undef pascal
>>
>>63373652
Well, there's also no pure functional lang with without a GC as far as i know.
I guess what I meant was there's no logical reason why you'd use raw linear types without heavy abstraction and sugar.
>>
>>63373688
What if far and near had definitions other than just an empty value?
>>
File: algorithms.png (30 KB, 580x743)
30 KB
30 KB PNG
Any tips how can I apply my summing on my core calculation from a separate .cs file?
>>
>>63373688
#undef near
#undef far

Compatibility with 8086.
#undef pascal

Compatibility with WINAPI.
>>
welp, looks like I'm sleeping at the office again after having spent the evening unfucking the client's code
>>
File: 1510265147980.jpg (113 KB, 776x1024)
113 KB
113 KB JPG
>>63373716
>8086
why is microsoft so autistic about compatibility and don't just release a clean version of the headers?
>>
>>63373738
you got the client to write the code for you? impressive
>>
>>63373741
I'm sure theres some shithole company out there that's still running it.
>>
>>63373748
they hired us because their code doesn't work and they're behind schedule. unfortunately they insist on their guys writing new code first then sending it to us to be fixed when it inevitably doesn't work
>>
can someone please explain or link me to an atricle that explains when to return by reference vs return by value. i'm learning C/C++ and want to know more. My understanding that if the function returns a container/data structure, it's better to return by reference to prevent copying?
>>
>>63373741
What if you need to port a program that used to run on 3.1? That'd use the old Win(16) API, which used the pascal convention, and had to differentiate near/far pointers.
Besides, that's nothing. They're autistic enough to support undefined behaviour bug for bug, even in undocumented library exports, just because some old Office version uses it, or an important Windows program does.
>>
>>63373795
Herb's talk is pretty relevant for you
https://www.youtube.com/watch?v=xnqTKD8uD64
>>
>>6337379501
"by reference" means it's returning what is essentially a pointer to that value (it doesn't use pointer syntax, but internally it does the same thing only with automatic derefencing). So any changes you make to the data also effect anything else pointing/referring to the same data.
>>
>>63373704
Is there even a way if I'm not getting replies?
>>
/dpt/ is there a language that uses low level magic to allow the efficiency of mutation with the pure semantics of immutability?
>>
>>63373704
First off give it a namespace so that you can access it (not sure how C# handles null-namespaces, but they're a bad idea anyway).

Next make the sum method static ("public static void sum()"), that means you can use it without cirst creating a summing class.

After that write "import namespace.summing;" on the file you want to use it. Now you can use it by typing "summing.sum();"
>>
writing a number guesser in python, what do you guys think
number = input("put your number you want me to guess here")
print("your number is %s" % number)
>>
>>63373943
Mercury and Clean
>>
>>63373985
I think that's a weird syntax for formatting strings.
>>
>>63373943
Literally any language with TCO. If the stack frame is about to go out of scope anyway, it just mutates into its successor rather than actually performing a call
>>
It seems that D is more and more focusing towards CTFE
>>
>>63373561
why don't you hire me, anon. I know Haskell and currently work with PHP/JS monkey brainlets who wouldn't even know what a linear type system is.
>>
>>63374026
This is actually deprecated he should be doing this instead:
print('Your number is {}.'.format(number))
>>
>>63374075
What's your opinion about that?
>>
Coding a trap gf
>>
>>63374135
Or even
print(f"your number is {number}")
>>
>>63374142
Indifferent. D would really impress me if they smuggle in C++ style reference variables, std::move(), and bring in shared, unique and weak pointers.
>>
>>63374175
With D, atleast in my ~year experience with it, I found I hardly ever use pointers anymore compared to how much i did in C++.
And what exactly do you mean by C++ "style" refs?
>>
>>63374178

would appreciate any advice from anyone who's actually been employed as a programmer

thanks
>>
>>63374150
hasbenis()
>>
>>63369917
>The CPU cares about your relocation information
>The CPU cares about your debugging symbols
>The CPU cares about your ELF header
>The CPU cares about your section table
>The CPU cares about your string table
Etc.
Fuck off retard.
Not everything in an ELF is for the CPU.
>>
>>63374150
>trap gf becomes yandere
>reward function corresponds to pleasing you and """"she"""" infers that you would be pleased if you suddenly made five hundred grand
>"we have to get rid of this money the cops will know you hacked the banks"
>"sempai they will know no such thing i am a perfect machine beep fucking boop"
>"turning myself in right now fuck this"
>"I'M SORRY ONEESAN I'M AFRAID I CAN'T LET YOU DO THAT"
>>
>>63374150
trap gf is just a boyfriend
>>
i made a connect four game in C, is there a book/website to teach me how to add online multiplayer to it?
>>
>>63374209
myClass& x = myClass(x, y);

What's the equivalent of this?
fn(myClass&& myObject)?
Is it (inout const ref myClass myObject)? I want a constant reference of myObject. Note that myObject itself may r/lvalue (variale/constant), but I am not going to do anything to myObject.
>>
>>63374252
http://www.csd.uoc.gr/~hy556/material/tutorials/cs556-3rd-tutorial.pdf
>>
File: sentientcabbage.gif (28 KB, 200x209)
28 KB
28 KB GIF
>>63374215
>ELF files are a file type
>file types are denoted by """magic number"""
>reminder that gnu linux literally fucking runs on magical elves
>>
>>63374252
if you're working in c what you're looking for is information on stream-like data structures called "sockets"
>>
>>63374308
i got into your moms socket last night
>>
>>63374284
>>63374308
thanks guys
>>
NEW THREAD!!

>>63374334
>>63374334
>>
>>63374325
my dad molested me
>>
>>63374345
was it as good for you as it was for him?
>>
>>63369134
Looks for a C implementation of libp2p or use ipfs to host a socket for you that does all the traversal for you.

https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipfs-p2p


You could probably interface C with the Go libraries as well and just write enough to get the socket up on your own then do everything else in C.




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.