[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 311
Thread images: 25

File: DPT.png (389KB, 934x1000px) Image search: [Google]
DPT.png
389KB, 934x1000px
Old thread: >>61643903

What are you working on, /g/?
>>
Writing a kernel sans I/O in Haskell for my employer
>>
Deciding whether I should use WolfSSL instead of OpenSSL for my encrypted chat app
>>
>>61649431
What the fuck does it do then?
>>
>>61649424
>Are we luddites anon?
No being philosophically conservative has nothing to do with being opposed development. It's just a more careful attitude to things. And in this instance we have plenty of ground to stand on so you're not even being conservative. You're just being enlightened.
>>
>0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1==0.8
>False

Floating point numbers were a mistake.
>>
>>61649507
No they do their job well. You're just not demonstrating use of them doing their job.
>>
>>61649507
Go ahead and come up with a new standard for representing floating point numbers that doesn't have this problem, Anon.
>>
>>61649541
https://en.wikipedia.org/wiki/Decimal_floating_point
>>
What are good resources to learn C# and Java, coming from C++?
>>
File: huehuehue.png (30KB, 831x713px) Image search: [Google]
huehuehue.png
30KB, 831x713px
I'm working on a bookstore application in C that communicates with a text file. I'm currently trying to check the price of a book that exists inside the text file.

I want to iterate through the file but every time I run my readRecords() function; which is supposed to return the value of fscanf, I only receive -1.

In every other aspect of the whole application I get the return value of 5; which is the amount of arguments I want to scan.

How do I fix this?
>>
File: tty.gif (33KB, 659x360px) Image search: [Google]
tty.gif
33KB, 659x360px
>>61649395
ttygif renders a bit too fast but it works!
>>
>>61649549
In base 12:
>0.4+0.4+0.4 != 1
Decimal floating point numbers were a mistake.
>>
>>61649507
Isn't significand *2^scale be more efficient than significand*10^scale on binary computers?
>>
>>61649672
Yes of course. You end up with meaningless wasted states with binary encoded decimal, since you need 4 bits (max 16 states) to encode a digit (10 states). It's impossible to have it fit perfectly since no powers of 2 are divisible by 10.
>>
>>61649672
Er, though I should clarify
>It's impossible to have it fit perfectly since no powers of 2 are divisible by 10.
Base 8 and base 16 fit nicely into base 2:
https://www.wolframalpha.com/input/?i=m+%2F+log_2(8)+%3D+n+diophantine
But base 10 cannot fit into base 2 perfectly:
https://www.wolframalpha.com/input/?i=m+%2F+log_2(10)+%3D+n+diophantine
>>
File: works.webm (273KB, 640x360px) Image search: [Google]
works.webm
273KB, 640x360px
signal(SIGPIPE, SIG_IGN);
>>
>>61650054
What the fuck is this?
>>
>>61650123
It's https://www.glorioustrainwrecks.com/node/9231
>>
>>61650127
You can also use a language with support for ratios like Scheme.
>>
where b is 4 a is 3


(+ 2 (if (> b a) b a))

why does this only add the value to b (making it 6) . really what i mean is why is it ) b a ))? i get the predicate part
>>
>>61650272
(> b a) => t
(if (> b a) b a) => b => 4
(+ 2 4) => 6
>>
>>61650272
Structure your code better when you're still learning.
(+ 2
(if (> b a)
b
a))


If you wanna write it C style:
(+ 2
(if (> b a)
b
a
)
)
>>
((call/cc identity) (call/cc identity))
>>
>>61650378
Nice infinite loop nerd. You implement anything fun with satan's control structure yet?
>>
I'm trying to make a P2P network where data is signed, which is all very well except for the possibility of a peer adopting the ID of a peer who hasn't joined the network yet, and creating keys on the behalf of that peer.

Is there a way I can prevent this?

For technical reasons, it's impractical to have peers ping each other to verify that someone has the IP they claim to have.
>>
>>61650465
Make the ID of someone BE his key.
>>
>>61649573
lol C is autistic as fuck
>>
>>61649573
>//Define a variable int rv = 0
>int rv = 0;
Stopped reading there.
>>
>>61650516
when your cs professor tells you to add more comments
>>
File: 1497832251953.png (206KB, 2724x2200px) Image search: [Google]
1497832251953.png
206KB, 2724x2200px
>>61650516
More like
>C
Stopped reading right there
>>
>>61650465
By the way, having a trusted peer who is the only peer that can assign new peers to the network is an option (there has to be a first peer that people connect to anyway), but I don't see any way of preventing people from faking their identity as they connect to that trusted peer.

Aside from pinging of course, but the type of network this is makes it very awkward to do that.
In terms of packet speed and accuracy, it's not unlike the pigeon-based internet described in RFC.

>>61650479
That's impossible.
If it was possible to have a predetermined public key which was then used to produce a private key, ANYONE could make the private key.
>>
File: chopsticks.jpg (328KB, 600x619px) Image search: [Google]
chopsticks.jpg
328KB, 600x619px
Why is programming in Ruby so much fun?
>>
File: occlusion_query_v1.png (438KB, 827x624px) Image search: [Google]
occlusion_query_v1.png
438KB, 827x624px
>>61649395
Working on occlusion querying. Right now the querying is really primitive. As you can see there's a little glitch where the chunk the player is in isn't drawn. I'm happy with that glitch as it shows occlusion querying is working. Easy to fix. I have 2 choices, temporarily turn off winding-based culling or just exclude the chunk the player is in from occlusion queries.

The current occlusion querying is also extremely inefficient:
diorama_test_occlusion(d);
glBeginConditionalRender(d->occlusion_query, GL_QUERY_WAIT);
draw_compiled_diorama_solids(d);
glEndConditionalRender();

The current lazy implementation only works on the solid blocks and not water. The usage of GL_QUERY_WAIT also creates execution bubbles in the GPU pipeline. Even then the performance benefits are pretty decent.

No occlusion culling:
OpenGL "FPS": 149.809816
OpenGL Frametime: 6675130
OpenGL "FPS": 149.809816

Shitty trash-tier absolutely terrible baby's first occlusion cull:
OpenGL "FPS": 187.805066
OpenGL Frametime: 5324670
OpenGL "FPS": 187.805066

Stats are for render distance of 4 chunks. Benefits should scale cubically.

>>61650587
The idea is you exchange your public keys with someone just as you exchange names with someone. People do it all the time with encrypted email.
>>
>>61649541
https://en.m.wikipedia.org/wiki/Ampere
>>
>>61650689
It was designed to be fun.
>>
>>61650318
>>61650371
of course, i keep on thinking of if statements in the style c++ uses
>>
>>61650707
Is this written in sepples?
>>
Give me something fun to program.
>>
>>61650793
Fuck no. C and Scheme.
>>
>>61650833
"git clone" based package manager.
>>
>>61650707
That's some pretty nice progress
>>
>>61650859
What Scheme implementation do you use? I did not find anyone good an wrote everything in Common Lisp (to avoid embedding).
>>
>>61650889
I use chicken. It's compiled and has a nice ffi.
>>
>>61650912
Chicken translates itself to C and then compiles itself. Guile is good but bytecoded. I couldn't find anyone native like Common Lisp implementations.
>>
>>61650912
Why Scheme instead of CL?
>>
File: bb8.png (57KB, 1654x740px) Image search: [Google]
bb8.png
57KB, 1654x740px
https://github.com/hyper-pokemon/hyper-star-wars
>>
>>61650977
What the absolute fuck. Programming was a mistake.
>>
>>61650977
thank god there's javascript in my terminal now
>>
>>61650971
Not him but CL is not good for embedding because of its big footprint (ECL exists, but it's still big). If you are using C, Scheme is the way to go.
It's (+ C Scheme) or full CL.
>>
>>61650954
Yeah it does but it still runs better than interpreted schemes. Also the ffi is really, really nice.

>>61650971
One of my goals is for it to be an educational game desu. Scheme's a pedagogical language.

There's kids programming courses that are minecraft programming but I think I can do better with a game that has an in-game repl and in-game compiler and that was designed to be moddable from the ground up.
>>
htdp or sicp?
>>
>>61651043
htcp
>>
File: huehuehue.png (18KB, 885x436px) Image search: [Google]
huehuehue.png
18KB, 885x436px
>>61649573
Figured it out; here's the solution in case anyone wanted.
>>
>>61651092
change if (fp != NULL) to if (fp)
>>
>>61651092
>//open file for reading
Stopped reading there.
>>
https://hackernoon.com/why-we-rewrote-lua-in-js-a66529a8278d
>>
>>61651112
lmao, but my prof that previously hired people for McCain fries said to comment all your shit even if it's stupid.

idk what I'm doing desu.
>>
imagine using a language that doesn't support parallelism with threads
>>
>>61651154
name one
>>
>>61651164
ocaml
>>
>>61651164
Your mom because she can't multitask but she sure can take multiple threads at a time
>>
>>61651154
Fortran 1
>>
>>61651171
don't (use | care)
>>
>>61651178
rofl xDDDDDDDD lelelelele


did you just?
>>
File: Sepples.png (128KB, 2560x1440px) Image search: [Google]
Sepples.png
128KB, 2560x1440px
>C++
>Tuples
Top fucking kek
How do I make this code look better?
>inb4 switch to whatever retarded language you suggest
>>
>>61650707

You're progressing too fast and making everybody else here look bad. Why don't you take a break from this project and relax for a little bit?
>>
>>61651217
>vim
>windows
nyoro?
>>
>>61651217
You should really just not use tuples in c++, even if that means creating structs / classes that only get used a few times.
>>
>>61651290
It's fun how (any) Lisp most basic structure (cons - list) can be horribly implemented in C++-style.
>>
>>61651290
But this is exactly what happen when my code executes and the templates get instantiated. Small classes/structures get created.
>>
>>61650707
My problem though is that someone can use someone else's name as they share a public key.
Which is only a problem if that someone else isn't yet known to whoever they're talking to.
>>
>>61651342
what are you talking about?
>>
>>61651342
gee I wonder what you think those "Lisp most basic structures" get compiled down to...
>>
>>61651358
gee I wonder what you think those "C++ templates" get compiled to...

I wouldn't write something a computer can write for me. It's the same principle you are using C++ over assembly.
>>
What's the most powerful line of code?

public static void main(String[]args) {

This line starts any Java program you can think of.

It can launch missiles, play chess, run a global business, and many more things.

This one [line] can trigger billions of lines, whose power soon adds up.
>>
>>61651417
autism
>>
How come I can't return this implicitly?

fn main(){
let p = "Title name - ";
let book_title = String::from("Title name - Return of the Two Towers.");

let book_name = skip_title(&p, &book_title);
println!("{}", book_name);
}

fn skip_title(prefix: &str, title: &String) -> String {

let to_skip = prefix.chars().count();
let result: String = title.chars().skip(to_skip).collect();
return result; //works
//title.chars().skip(to_skip).collect::<String>();
//won't work?
}
>>
>>61651417
>missiles
>Java
Just Pajeets and their space programs
>>
>>61651441
Oh shit nevermind, I was including a ; at the end
>>
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
);



whats _In_ and _Out_ ????
>>
>>61651417
pajeets can't into ada
>>
>>61651538
penis in your ass
>>
File: 1498855111293.png (207KB, 403x433px) Image search: [Google]
1498855111293.png
207KB, 403x433px
>>61651550

n-no bully
>>
Does Ada use GC?
>>
File: 1501469441886.png (153KB, 403x433px) Image search: [Google]
1501469441886.png
153KB, 403x433px
>>61651651
optimized image
>>
>>61651692

i didnt give you the permission to do that didnt i?

also how did u do it
>>
>>61651713
png optimizer with lossless compression
>>
File: myrogue2.png (3KB, 305x272px) Image search: [Google]
myrogue2.png
3KB, 305x272px
Working on my rogue like. So far I've got a working game window and map gen. Which is to say I've got the easiest parts out of the way.
>>
Got my occlusion working right! 373 FPS.
  int start = 0;
for(int dst = 3;; dst+=2) {
int max_drawn = dst*dst*dst;
int q = dst + 2;
int max_tested = q*q*q;
for(int cursor = start; cursor < max_tested; cursor++) {
if(cursor >= renderorder_size)
break;
triple * cur = renderorder + cursor;
if(cursor >= 27) {
float result = vec4_mul_inner(camera_angle, cur->normed);
if(result <= 0.0f) {
cur->render = false;
continue;
}
}
diorama * d = finite_getdiorama(f, cur->x + px_dio, cur->y + py_dio, cur->z + pz_dio);
if(d == &nulldiorama) {
cur->render = false;
continue;
}
if(d->region_starts[FIRST_LIQUID] >= d->vbo_size) {
cur->render = false;
continue;
}
cur->render = true;
}
for(int cursor = start; cursor < max_drawn; cursor++) {
if(cursor >= renderorder_size)
goto end_drawing_solids;
triple * cur = renderorder + cursor;
diorama * d = finite_getdiorama(f, cur->x + px_dio, cur->y + py_dio, cur->z + pz_dio);
if(!(cur->render))
continue;

glDeleteSync(d->solid_fence);
if(cursor >= 27) {
GLuint result = 0;
glGetQueryObjectuiv(d->occlusion_query, GL_QUERY_RESULT, &result);
if(result == 0) {
cur->render = false;
continue;
}
}
diorama_clean(d);
draw_compiled_diorama_solids(d);
d->solid_fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
}
start = max_drawn;
for(int cursor = max_drawn; cursor < max_tested; cursor++) {
if(cursor >= renderorder_size)
break;
triple * cur = renderorder + cursor;
if(!(cur->render))
continue;
diorama * d = finite_getdiorama(f, cur->x + px_dio, cur->y + py_dio, cur->z + pz_dio);
diorama_test_occlusion(d);
}
glFlush();
}
end_drawing_solids: ;

>>61651261
But I must.
>>
>>61651774
>using gotos


why
>>
File: 06a.png (242KB, 510x346px) Image search: [Google]
06a.png
242KB, 510x346px
>>61651774
>But I must.

Nice occlusion culling.
>>
>>61651809
>being afraid of a 4 letter word
>>
>>61651827
goto hell
>>
>>61651809
To break out of a nested for loop of course.
>>
>>61651726
I-Is it possible to learn this power?
>>
>>61651863
Yes.

just download one like i did.
>>
>>61651863
pngcrush and pngout
>>
File: B_mOsG4WYAEKRlI.jpg (26KB, 599x375px) Image search: [Google]
B_mOsG4WYAEKRlI.jpg
26KB, 599x375px
how do i learn "lamb the calculus" if i have only ever used "two ring my sheen"
>>
>>61651911
http://www.inf.fu-berlin.de/lehre/WS03/alpi/lambda.pdf
>>
>>61651464
Nitpick: it's probably more idiomatic to use &str instead of &String, in basically all cases except for &mut String
>>
File: dictator.gif (3KB, 128x112px) Image search: [Google]
dictator.gif
3KB, 128x112px
In C++, I'm trying to pass a class' own method to another of its methods (specifically, passing an instruction to an addressing mode method that applies the former to some member variables), but I can't for the life of me figure out how to get it right. Does anyone know how this works, or if this is even possible?

At the moment, I'm getting
>expression preceding parentheses of apparent call must have (pointer-to-) function type
>>
>>61651441
>>61651464
>>61651996
fn main(){
let p = "Title name - ";
let book_title = String::from("Title name - Return of the Two Towers.");

let book_name = skip_title(&p, &book_title);
println!("{}", book_name);
}

fn skip_title<'a>(prefix: &str, title: &'a str) -> &'a str {
&title[prefix.len()..]
}
>>
>>61652071
>Pass a class
"Extend -> to method not class"
>>
>>61652106
>&title[prefix.len()..]
>&
Isn't that supposed to find the address of title? Also, isn't title already an address?
>>
>>61652106
Nice

>>61652187
title[n..] gives you a slice, and &title[n..] gives you a reference to the slice. It's kind of silly, but you practically will always write it like &some_array[a..b]

>>61652071
https://isocpp.org/wiki/faq/pointers-to-members
It's quite a mess.
class CPU {
typedef void (CPU::*IntOutFn)(int);

void mov_a(int a) { }
void mov_b(int b) { }

void clr(IntOutFn f) { (this->*f)(0); }
void clr_a() { clr(&CPU::mov_a); }
void clr_b() { clr(&CPU::mov_b); }
};


Alternatively you can use std::function and std::bind but that might incur overhead, or you can use lambdas and templates and let type inference figure it out
>>
>>61650516
declare
>>
Is there I can read a file output faster in C ?
I want to read the whole output to see the changes directly and see what I can fix, notepad++ doesn't seem to do the job.

if I use fread function, is there a way I can make the console read the whole file?
>>
>>61652212
>&title[n..] gives you a reference to the slice.
O yea, thanks for clearing that out
>>
>>61652262
Why don't you just use less or cat?
>>
>>61652212
Your help is appreciated. Thanks!
>>
>>61652106
Another question, my &String example didn't need lifetime annotation but your &str example does.

Why is that?
>>
>>61652457
You make a whole new string, so you don't need to worry about the lifetime of the original.
My one returns a reference to the old string, so it's only valid as long as the old string is valid.
>>
explain the y-combinator to a brainlet
pls
>>
>>61652782
Y takes a function and applies it to a replicated version of the same function applied to itself
>>
File: Guile.jpg (318KB, 960x1270px) Image search: [Google]
Guile.jpg
318KB, 960x1270px
>>61652212
>
class CPU {
typedef void (CPU::*IntOutFn)(int);

void mov_a(int a) { }
void mov_b(int b) { }

void clr(IntOutFn f) { (this->*f)(0); }
void clr_a() { clr(&CPU::mov_a); }
void clr_b() { clr(&CPU::mov_b); }
};


That honest-to-goodness worked! Yes!

My main mistake apparently was trying to define the address mode method outside the class declaration. I felt like a dumbass moving syntax around trying to get the compiler to like me.

You've done me a great service. Have this rare, badly drawn Guile.
>>
>>61652782
It's a way (the most general way) of creating recursion with unnamed anonymous functions. Normally you need function name to do recursion. Example from SICP:
((lambda (n)
((lambda (fact) (fact fact n))
(lambda (ft k)
(if (= k 1) 1 (* k (ft ft (- k 1)))))))


AKA functional programming wankery because you no longer "need" a define or set! special form to loop. This means you can write an evaluator that doesn't have any filthy mutability as both define and set! require mutating the environment.
>>
>>61652901
>>61652890
cool
>>
When you make a classifying neural network for numbers, should you make 1 separate network for each number, or just separate output neurons?
>>
>>61649395
Making a Chrome extension to tag URLs for later use.
>>
>>61652782
https://www.ycombinator.com/about/
>>
>>61649395
Is there any common API that monitors GPU usage rate in *nix?
>>
newbie c++

whats happening here

#define X_INPUT_GET_STATE(name) DWORD WINAPI name(DWORD dwUserIndex, XINPUT_STATE *pState)
typedef X_INPUT_GET_STATE(x_input_get_state);
X_INPUT_GET_STATE(XInputGetStateStub)
{
return(0);
}
global_variable x_input_get_state *XInputGetState_ = XInputGetStateStub;
#define XInputGetState XInputGetState_


from what I understand
 #define X_INPUT_GET_STATE(name) DWORD WINAPI name(DWORD dwUserIndex, XINPUT_STATE *pState) 
would just change whatever on the right is effectively replaced with the right one upon compilation, also that name is a variable.

the rest is a mystery, the author said that the XInputGetStateStub is just a dummy function so that the program wont crash if the 'real' function cant be found (since we are using some xbox input that some OS dont support)
>>
>>61653109
That stuff is gpu vendor dependent. But a duckduckgo and https://askubuntu.com/questions/387594/how-to-measure-gpu-usage#387600
>>
So Piston is to Rust is what SDL is to C++, right?
>>
>>61650912
Has anyone managed to build Chicken on Windows?
>>
>>61653357
Pretty sure SDL is written in C
>>
>>61653357
Does Piston have the complete package, ie shapes and rendering, audio, networking etc?
>>
>>61653359
http://wiki.call-cc.org/portability
>>
I don't like Piston, it's not a well structured library IMO and the documentation is extremely bad right now. I'm tempted to just try to implement SFML for Rust, something just extremely simple like that instead of trying to get clever and overcomplicated like Piston
>>
>>61653411
That doesn't answer the question. What their wiki claims and what actually happens when you attempt to build are two different things.
>>
>>61653383
>>61653424
http://www.piston.rs/
https://github.com/PistonDevelopers/piston/wiki/Games-Made-With-Piston
Looks like the project is in early development. But it looks pretty professional. I have to look deeper.
>>
>>61653427
You're one of the few people in this thread who uses Windows. You're probably on your own. It's what happens when you're a minority.
>>
>>61653433
It irks me that you have to use piston_window instead of just piston, apparently you have to dump ALL of piston_window into the global namespace in order to use piston effectively (that's what the singular tutorial instructs you to do, and my attemps at singling out only the necessary libraries have been to no avail).

If you look at the docs you see
Reexports
pub extern crate texture;
pub use graphics::*;
pub use piston::window::*;
pub use piston::input::*;
pub use piston::event_loop::*;


That means when you're pulling in everything from piston_window you're also pulling in every thing from all of these libraries at once. Why does piston_window reexport all of these things? Shouldn't something named "piston_window" just be responsible for providing a window handle and maybe a few backends?

Upon trying to just draw a rectangle I became overwhelmed by the Java-tier over-abstraction and horrible naming (pic related). Libraries should be straightforward and orthogonal as much as possible, not this bullshit.
>>
>>61651464
>>61651441
>the return is completely dropped if you just add a ;
>since the return type is inferred this isn't necessarily checked
>completely invisible code breaking change

sasuga Rust
>>
>>61653662
>completely invisible code breaking change
It does not compile, types mismatch
>>
>>61653686
Only once it's used, what if you're writing a library?
>>
>>61653686
>>61653701
Plus what if you intended NOT to return anything?
Then even when you use it you wouldn't know
That could have a huge performance hit and would have implications for the lifetime system and shared resources and shit
>>
>>61653701
Which is why you have unit tests.
>>61653710
>what if you intended NOT to return anything?
It has a return type of String, yes?
>>
>>61653752
also, Rust provides a nice error handling with unrwrap() just in case.
>>
File: 1501436287549.png (594KB, 1000x950px) Image search: [Google]
1501436287549.png
594KB, 1000x950px
>>61649395
Went to /sci/ found this image. How can /sci/entists be better than /g/entoomen at photoshopping? Makes no sense.
>>
>>61653752
>its okay, unit tests will catch the shitty things my incompetent language will do
rust in embarrassing
>>
>>61653768
That's not really a language problem, and you are encouraged to do unit tests. Are you pretending to be an idiot?
>>
>>61652959
separate output neurons.
>>
>>61653752
>unit tests
>versus having a sane language

>>what if ...
>but that isnt the case
>>
>>61653782
Yes, it is a language problem, that a single, hard to see ; determines whether or not you return anything
Rust should have gone one way or the other, either have a unit value that you give, or by explicitly saying return.
Not half-way in between
>>
>>61653768
>>61653782
Also, here I am, not using it. Doesn't seem to compile
>>
>>61653820
That's because you explicitly gave the return type.
We already discussed this, you should have been listening.
>>
>>61653808
What?

>>61653816
It's an expression based language. So the last expression evaluated provides the return. You can use conventional return result; and the language does not stop you to do so. Hence it's not a language problem
>>
>>61653830
>That's because you explicitly gave the return type.
Anon, I don't think any void skip_prefix() function in this world
>>
>>61653768
Isn't that unit test are designed for?
>>
>>61653834
Aren't you reading my posts?
I said one or the other, not based on ";"

>>61653841
Type inference you idiot.
Or does Rust NEVER infer return types?
>>
>>61653854
that what*
>>
Does everyone here hate Java?
>>
>>61653862
auto as return type? I don't think so.
>>
>>61653816
>hard to see ; determines whether or not you return anything
1. Look up function prototype. if it has "->" it means that it expects a return value
2. The absence of `;` doesn't directly determine anything. Rust is an expression based language it functions look for the last expression yielded.
>>
>>61653864
I don't. I'd rather use Java than C++. With project lombok it's better.
>>
Is Clojure only useful for companies that have existing Java-based infrastructure? Would it make sense to use Clojure for a brand-new project without any dependencies?
>>
>>61653862
>infer return types
Rust doesn't even allow you to add an i32 with i8. What makes you think it'll infer return types?
>>
>>61653854
Unit tests are for your logic, not the compilers.
>>
>>61653925
Citation?
>>
>>61653904
>no one wants to switch languages
>the only way to write in new languages is for interops
>said interop language is prolonged

Fuck clojure and every other JVM shitfest that keep java on life support
>>
File: angry_face.jpg (76KB, 288x402px) Image search: [Google]
angry_face.jpg
76KB, 288x402px
Why are Rustlets so delusional? They are such zealots that they are like Jehovah's witness. I saw one Rustlet say that memory safety was just as important as privacy and free speech. It makes me sick.
>>
>>61653956
>memory safety was just as important as privacy and free speech
It isn't? Memory safety is pretty desirable. Walter Bright says that Memory Safety will kill C++
>>
>>61653956
Because Rust cant be shilled on merit so they have to be zealots and give it infamy buzz
>>
>>61653973
>Rust cant be shilled on merit
IDK about that, but I am interested in a _modern_ C++ successor that has no GC but has all the low level features
>>
>>61653862
Function signatures must have explicit types, type inference is local to the function body
>>
>>61653986
theres literally nothing good in execution or rust
>>
>>61654014
Explain please
>>
>>61654014
for*
>>
>>61654019
Try writing a linked list in rust. Pro tip, being able to make linked lists means you can implement advanced graph algorithms.
>>
>>61654019
whats there to explain?
the only good thing about rust makes it unusable.
>>
>>61654065
I'm cool with vectors, thank you very much,
>advanced graph algorithms.
I don't see why I would have to implement an advanced graph algorithm myself, I'd FFI into a library that I like
>>
>>61654083
>I'm cool with vectors, thank you very much,
Write malloc
>>
>>61654107
What point have you been trying to prove here, anon?
>>
>>61654126
Oh I'm not him. But linked lists have their uses.

2 example uses in low level programming:
>fast malloc implementations use linked lists to keep track of regions of free memory
>linked lists are used in graphics programming to construct a sorted pixel fragment list to iterate down for rendering transparent objects, since transparent objects have to be sorted from back to front
>>
>>61653917
>>61653998
Rust truly is awful

>>61653894
I know what an expression based language is.
Reread what I said earlier
>>
>>61654167
>awful
Why? It clearly defines that it's not going to allow you to do that. I think the usage of auto`s are overrated
>>
>>61654158
https://rustbyexample.com/custom_types/enum/testcase_linked_list.html
>>
>>61654182
Rust is really bad anon.
>>
>>61654158
Then I would look at http://cglab.ca/%7Eabeinges/blah/too-many-lists/book/ if I had to use linked lists
>>
>>61654194
My opinion is quite the opposite
>>
>>61654158
Question is what would stop rustaceans from writing safe linked-lists? I think anon is saying the lifetime system would block it, but I don't think so.
>>
>>61654211
Your opinion doesn't matter
>>
>>61654205
http://cglab.ca/%7Eabeinges/blah/too-many-lists/book/third-layout.html
>Seems legit. Rust continues to be a complete joke to write.
Rustfags on suicide watch.
>>
>>61654232
Exactly, anon.
>>
>>61654248
Can you drop the /v/ speak?
>>
>>61654254
What, can't deny your language is shit?
>>
>>61654264
Why is it shit?
>>
>>61654213
I initially didn't have any water in the rust conversation other than people insisting vectors are a replacement for linked lists trigger me. However, the fact that two rustlets linked me linked list implementations rather than just throwing one together has convinced me that it's kinda difficult and has pitfalls.

Also one of the links is a book dedicated to writing linked lists in rust. What the fuck?
>>
>>61654273
>being this stupid
People have been slamming rust the handful of posts in this thread and rustfags are flustered and can't come up with any reasonable argument.
>>
>>61654295
You were arguing? Where?
>>
>>61654309
Look through the thread you dumb retard. Or do you want your compiler to tell you where you fucked up?
>>
>>61654316
>Or do you want your compiler to tell you where you fucked up?
Well, that's one of the things compiler do already, right? Are you by any chance talking about the implicit returns? I thought this post clears up your confusion.>>61653894
>>
>>61654291
IDK someone implied (!) that linked lists are impossible to create in Rust, the book is pretty much an answer to that. It's a bit of an overkill, I'd say
>>
>>61654291
Guess the book goes into the details of language-enforced memory-safety and whatfugg. Just because something is more complicated won't kill the Rust hype. Don't roll your own, people would gladly use open source libraries anyway even if these libraries were trivial. We can reasonably get doubly linked lists in Rust so it's not an argument against it. Case closed.
>>
>>61654337
I'm sicking of arguing with a brainlet who keeps using a red herring.
>>
>>61654309
Rusts BC makes everything in the language C++ levels of tedious to write. As well as sheer irredeemably ugly code which makes maintaining rust ever harder and more time consuming.
>>
>>61654361
So have you got any argument left, now that your previous FUD has been thoroughly debunked?
>>
>>61654354
>>61654358
If the language you are using makes implementing something as trivial as a linked list difficult, then the language must be shit at expressing any sort of complex process.
>>
>>61654364
>Rusts BC makes everything in the language C++ levels of tedious to write
I agree. But, to me, honestly the BC is something you can get used to given the time and patience.
>Ugly code
Rust just makes everything more "apparent". This results into verbosity, it's not ``ugly`` per se, any language can be verbose
>>
>>61654384
Can you implement pattern matching as trivially as rust?
>>
>>61654369
You must not have any since you never debunked any argument.
>>
>>61654248
>feel free to try to prove this to yourself -- I sure won't
That book is garbage by and for brainlet Noir Femme Koders. K&R, why hast thou abandoned me?
>>
>>61654396
>you never debunked any argument.
That was not your argument. The proper term would be "lack of knowledge" on Rust, which is fine
>>
>>61654404
>Seems legit. Rust continues to be a complete joke to write.
... not. Sounds like one of us now. What gives?
>>
>>61654409
See, any time I provide an argument, you just move the goal posts or provide a red herring. I'm done arguing with a retard like yourself. You lost, get over it.
>>
>>61654430
Anon, I am genuinely curious to know what argument you ever had and or otherwise you still got left.
>>
>>61654358
>Don't roll your own
I'm sorry anon but if it requires a phd in rust to write a good linked list there's a problem. I'm looking through this book and it's insane. How can something so simple be so hard?
>>
>>61654438
That kinda sounds familiar, when wintoddlers bitch about Linux
>>
>>61654385
>its good if i force myself to think so
nah thats called delusion.
>, it's not ``ugly`` per se
so its ugly
>any language can be verbose
any thing in Rust will look much cleaner and is probably shorter in D
>>
>>61654438
There are all sorts of linked list disciplines anon, and the author is mixing them all up. It's logical that you can't have a persistent mutable list, but it flies above his head. The KISS solution would be a bunch of ll classes and you pick the one that fits your model IMHO.
>>
>>61654476
>its good if i force myself to think so
Well, Rust doesn't have the luxury of GC but I'm willing to pay
>Ugly
It's not, the term you are looking for is called ``verbose``, which is not inherently synonymous to ``ugly``
>>61654476
If you know Rust, you can like cleaner code.

t. ex D fag
>>
>>61654495
Verbose is ugly.
>If you know Rust, you can like cleaner code.
what?
theres literally no denying d is cleaner and shorter
>>
I just downloaded the little schemer. It's a very strange book
>>
>>61654525
>Verbose is ugly.
Verbosity and ugliness do not correlate
>theres literally no denying d is cleaner and shorter
Idris is even cleaner and shorter than D, what stops you from using it?
>>
>>61654525
Python is even shorter, but it has more overhead. Rust, D, and Python are on three different points of the tradeoff spectrum.
>>
Maybe I'll use D when -betterC actually becomes a thing
>>
>>61654545
Yes they do, you have no argument.
And i do use Idris.
>>
>>61654483
>There are all sorts of linked list disciplines anon
I don't know what planet you're from but where I'm from there's linked lists, skip lists, and doubly linked lists, and that covers pretty much everything.

But the last two are optimizations that share the same interface with singly linked lists, just with bonus interfaces that make them faster for certain tasks.
>>
>>61654566
>Yes they do
If a syntax tree has too many punctuations in ratio to characters, it may be ``ugly`` but it it's generally short and consist. Not beautiful to look at (see ML)

However, with C or Java or C#, the syntax is very verbose but it's pretty easily readable. This is because we are used to characters than signs/operators. Verbose, but not ugly
>>
>>61654601
>lets deflect to other languages
like clockwork
>>
>>61654624
Now this comment of yours is a textbook deflection
>>
>>61654631
You went off on something no related to rust.
>>
>>61654631
Not him, but you're dumb. You rustfags are so stupid and dogmatic, thinking that making a language good for the compiler is the only thing that matters. Well, guess what? Humans are the ones that have to use them and solve problems with them. And if you're language is so shit that I can't express myself properly, so shit that I want to gouge my eyes out every time I read it, so shit that I have to constantly fight the compiler, I'm sorry, if it smells like shit and looks like shit, then it is shit.
>>
>>61654662
>but you're dumb. You rustfags are so stupid and dogmatic,
Ad hominem
>making a language good for the compiler is the only thing that matters.
>only thing that matters.
Who said this? I'm curious
>And if you're language is so shit that I can't express myself properly,
Rust is not expressive as much as other languages. This includes C, C++ and even D.
>I have to constantly fight the compiler
Well, read the book. Babies don't learn to walk in their first day
>>
>>61654684
>read the book.
apparently the book is shit too
>>
>>61654684
>Rust is not expressive as much as other languages. This includes C, C++ and even D.
C is the least expressive language that I'm willing to tolerate, and most people can't even tolerate C's inexpressiveness. C's very inexpressive so that's very impressive that Rust is worse. Is Rust then some kind of sick joke? See how inexpressive you can go before memes no longer sell a product?
>>
>>61654684
If is so expressive, why can't I implement something as trivial as a linked list?
>>
Hahahaha, it is so much fun watching rustfags getting blown the fuck out.
>>
>>61654729
For you probably, I have been reading Rust essentials and the Rust book. Had a few problems but their IRC has been really helpful.

>>61654735
>that's very impressive that Rust is worse.
>Rust is worse. [less expressive than C]
I don't know if I actually agree. Where is Rust less expressive than C?
It has nice map, fold and filter to reduce most of your mundane tasks, has pattern matching, UFCS, lazy iterators etc. It's a sensible collection if you ask me.

>>61654741
I never used Linked Lists, and I am not familiar in using them. So I can't actually argue about that
>>
>>61654758
What language do you think is better?
>>
>Rustlets cant even implement linked lists
>>
>>61654741
If it's so inexpressive why can I implement pattern matching so trivially?
>>
>>61654795
>deflecting the subject away from shitty rust
HAHAHAHAHAHA
>>
>>61654803
Well?
>>
>>61654801
>deflecting this hard
>>
>>61654810
Not him but i originally told you D was better and you started talking about idris.
>>
>>61654810
>>61654801
Is the only thing rustlets know how to do is deflect whenever their language is criticized?
>>
Real world scenario: Rust is not too different from C++, but it does not burden itself with C source compatibility
    std::vector<unsigned> sevens; sevens.reserve(1<<14);
std::vector<unsigned> words; words.reserve(1<<15);
std::bitset<32> word; int len = 0; int ones = 0;
for (std::istreambuf_iterator<char> in(file), eof; in != eof; ++in) {

    let mut sevens = Vec::with_capacity(1 << 14);
let mut words = Vec::with_capacity(1 << 15);
let (mut word, mut len, mut ones) = (0u32, 0, 0);
for c in io::BufReader::new(file).bytes().filter_map(Result::ok) {


>>61654823
D has GC, Rust doesn't, of course it'll look ``cleaner``

>>61654828
I am looking for something to compare with, is that a bad thing now?
>>
>>61654846
Also, don't make me shit on D, I am trying to contain my ausim as much as possible and I really want to make D look bad
>>
>>61654861
>and I really want to make D look bad
The literal only argument against D is the GC.
>>
>>61654874
GC'd languages look cleaner, more news at 11
>>
>>61654874
Which is why D is no alternative to Rust, they are in different fields of usage
>>
>>61654891
>, they are in different fields of usage
Not really.
>>
>>61654899
Soft/hard realtime applications are not for D
>>
>>61654905
>Soft/hard realtime applications are not for D
There are plenty of realtime applications written in GC'd languages. And even if, malloc exists.
>>
>>61654938
>using malloc in language with GC
don't do that
>>
>>61654952
>don't use MM in a language with @nogc
"no"
>>
>>61654938
Last time I checked you can't use many iterators and range functions without GC, and of course, Class allocation recurses GC. There goes your Clock and BigInt.
>turn off GC
Yeah and enjoy your GC less programming. You do realise there is no documentation for it, right? DMD's -betterC is _just a placebo_.

The GC itself is shitty. 4GiB memory in the heap and it freezes for a good 20 ms, while Go has _submillisecond GC pauses_ and Nim _does not stop the world_
>>
>>61654967
Even Java has thread local memory heaps
>>
>>61649565
this
>>
I use Rust and I don't understand why some Rust users are so fucking stupid that they can't admit that Rust has flaws. I think Rust is so hyped that brainlets start using it thinking that it will stop them from writing shitty code. Rust is good because it has good concurrency and safety, yet the brainlets think that every other language is obsolete to Rust.
>>
>>61654967
std.range is @nogc
>>
>>61655007
Where in the thread has this been implied that Rust is flawless?
>>
>>61654959
That's the stupidest shit you can do, you aren't going to out smart the gc efficiency wise, you will fuck yourself over 99% of the time.
>>
>>61654967
>, Class allocation
use structs
> and it freezes for a good 20 ms
not if you keep frequent and small cleanups.
>>
>>61655016
The mentality? Whenever someone gives valid criticism of the language they will fight tooth and nail saying that it isn't a flaw and will start deflecting. You see it in this thread and it is really annoying because not everyone in the community is like that.
>>
>>61655037
>use structs
Do struts have encapsulated members? Polymorphism? No? Thought so.
But hey, at least that's better than having a bunch of global variable?
>>
>>61653454
I use both, but I want to write something that will be usable by someone other than a very tiny subset of computer users.
>>
>>61655042
Well if you are going to imply that it's impossible to create linked lists in Rusts, there are a plethora of proofs that claim otherwise

Now all you got left is an opinion that it's not "trivial" which I believe is just baby duck syndrome. You can implement lambdas in C too, not "trivially"
>>
>>61655065
>No? Thought so.
 struct base
{
import std.stdio: writeln;
void sayhi() {"hi from base".writeln;}
}

struct child
{
base b;
alias b this;
}

void main()
{
child c;
c.sayhi;
}


There you have inheritance.
>>
>>61655088
See? This is the mentality that reflects poorly on other Rust users like myself. I feel disgusted to even be talking to you.
>>
>>61649461
Simulating a universe.
>>
>>61655090
neat, i always wondered if any languages let you inherit this way
>>
>>61650054
Signals and threads were a mistake.
>>
>>61655097
Any false statement I made, anon?
>>
>>61655090
>>61655100
Why not accessing base members through composition then?
>>
>>61655112
Any false statement I made? You are completely disregarding everything I'm saying and basically confirming it at the same time. I wish Rust weren't so popular so we wouldn't have brainlets like you dragging the community down.
>>
>>61655122
What do you mean?
>>
>>61655123
Can you answer the question I asked first? Is there anything false in >>61655088?
>>
>>61655141
Just stfu, I'm done talking with you.
>>
>>61655037
>>, Class allocation
>use structs
Structure in D are value type, classes are reference type. They are not interchangeable
>>
>>61655162
Good. The entire notion of "reference types" should be wiped out of everything but scripting languages.
>>
Anyone else willing to deny >>61655141?
>>
>>61655162
>wanting reference types
Why?
>>
>>61655138
struct base
{
import std.stdio: writeln;
void sayhi() {"hi from base".writeln;}
}

struct child
{
base b;
}

void main()
{
child c;
c.b.sayhi;
}
>>
>>61655197
composition has different semantics to inheritance
>>
>>61655162
Also, does D structs have encapsulation?
>>
>>61655197
Your point?
>>
>>61655190
Whenever you want to use the heap instead of the stack
>>
>>61655209
Inheritance need not apply.
>>
>>61655205
Yes.
The only thing difference is "friends" are module-scope and dont exist otherwise. All your other keywords are there.
>>
File: anime_pointing_dance.gif (483KB, 243x270px) Image search: [Google]
anime_pointing_dance.gif
483KB, 243x270px
Why is Ruby so /comfy/?
>>
>>61653950
Why is the JVM so bad?
>>
>>61650689
Not mememing, but Ruby is probably the worst language I've ever encountered. It's the complete opposite of what I want: so much inconsistent syntax and so many ways to do the same thing. Perl and Python are probably steaming pieces of shit for similar reasons, but I haven't been forced to use them yet.
>>
>>61650859
>C and Chicken

This is as patrician as you can get
>>
>>61655280
>so much inconsistent syntax
Which parts were inconsistent?

>so many ways to do the same thing
That is because it was based on Perl. Larry Wall, the creator of Perl, was a trained linguist who believed that you could express many things the same way. Adding all these different ways to express logic means that you have the power to express something in a more natural way. That's the idea behind it anyway.
>>
>>61650859
Have you considered rewriting it in Rust?
>>
>>61655280
Python is actually orthogonal and consistent, unlike Memeby and PeRL. There once was a pic in this thread that said "il your favorite toy as a child was playdoh, you should pick Rubrainlet. If you prefered lego bricks, you should learn Snek." and I think that's accurate.
>>
>>61655334
True. Python be like "there should be one and only one obvious way to express one thing", much like Algebra. Both are for brainlets, just different species thereof.
>>
>>61655354
I don't understand the inconsistent part of Ruby? How is it inconsistent?
>>
>>61655372
Yeah, that is basically the Python way, along with being explicit about everything. I first started with Python but honestly, I prefer the way Ruby does things because I like the extensive use of iterators in Ruby and I like Ruby's OOP over Python's.
>>
>>61655340
Now that you said it, I will. Thanks.
>>
where would i even start to learn coding? What language would be the best start and what are some general tips/things i need to know.
>>
>>61655560
depends on what you want to write
>>
>>61655560
>where would i even start to learn coding
Depends what sort of learner you are, but ultimately you can't learn programming JUST by reading/watching videos. You need to write some code. Personally, I started off following tutorials (google rb whitaker c#) for C# and writing little toys. Whenever a tutorial or textbook or youtube video gives you sample code, make sure you change it around and see how that changes the behavior of the program, or how it breaks it or gives you a syntax error. Pay attention to what the computer is doing and the error messages it's giving you.

>What language would be the best start
As much as programmers enjoy shitposting about which languages are shit and which are 'the best', it doesn't matter very much which you learn first (unless it's something incredibly archaic and/or esoteric). I'd recommend something with a decently large community around it like Python, Java, or C#.

>what are some general tips/things i need to know.
Make sure you keep at it and don't fall out of practice. An experienced programmer can get rusty by taking a few weeks off. When you're a beginner you'll feel 'getting rusty' a lot harder, and it will probably take you longer to get back into it. When you get a bit more experienced (ie: can write shit without following a tutorial that tells you exactly how to write that thing, step by step), try to always have at least 1 side project at all times. This will keep you sharp and make you more marketable as an employee.
>>
>>61655560
>>61655642
>Python, Java, or C#
Don't learn those deprecated languages. You should only use Rust.
>>
File: scren.png (224KB, 740x447px) Image search: [Google]
scren.png
224KB, 740x447px
Anyone experienced with writing a math expression parser? By all standards -3^2 should be interpreted as -(3^2) = -9, not (-3)^2 = 9. But by the nature of my implementation of shunting yard algorithm, it is parsed as (-3)^2. I'm kind of stumped on how to fix this that will work for all cases (included complicated nested parenthetical expressions). Can anyone lend a hand?

https://github.com/nick-gits/calpy/blob/master/calpy.py

Handling negative numbers is done in _tokenize_expression(raw_exp) which starts on line 179.
>>
>>61655677
Ok
>>
>>61655677
You mean C89
>>
>>61655642
thank you, this is extremely helpful - you basically answered all questions i had.
>>
File: 1501472483383.jpg (108KB, 1000x564px) Image search: [Google]
1501472483383.jpg
108KB, 1000x564px
>>61655697
Alright, I think I fixed the issue. Can anybody download and run the test.py and see if you can find a math expression that is solved incorrectly? If somebody finds such a bug I will love you.

https://github.com/nick-gits/calpy
>>
>>61655098
kek
>>
>>61649507
When comapring floats dont use == nothing will work
 (sqrt(9.0f) == 3.0f) // false 

instead compare against an epsilon value
 (abs(sqrt(9.0f) - 3.0f) < epsilon) // true, yay 
>>
>>61649507
0.1 + 0.2 == 0.3

floating points were a mistake, fixed points are better
>>
>>61656467
Float like a double, string like a b*
>>
New thread: >>61656577
>>
File: 1499804168175.jpg (88KB, 1280x720px) Image search: [Google]
1499804168175.jpg
88KB, 1280x720px
>Year of 2025
>Modules finally get implemented in C++
>Now there are both header files AND modules
>mfw
>>
>>61655677
Don't learn Rust, learn scratch :)
>>
>>61652959
What's the point of a neural network having only a single output neuron
Thread posts: 311
Thread images: 25


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.