Previous thread: What are you working on, Jow Forums?
/dpt/ - Daily Programming Thread
fuck opengl
r8 my idiomatic fizzbuzz:
#![feature(inclusive_range)]
use std::borrow::Cow;
fn fizzbuzz(n: usize) -> impl Iterator "FizzBuzz".into(),
(0, _) => "Fizz".into(),
(_, 0) => "Buzz".into(),
_ => n.to_string().into(),
})
}
fn main() {
for fb in fizzbuzz(100) {
println!("{}", fb);
}
}
>rust
0/10 into the trash
>{}
>Imitating vulva syntax
stop oppressing women with your code you shitlord
i can't tell if you're shilling for or against lisp, but you're sure not singing it's praises with that
>0iq
>rust
makes sense
hackerjews is also made in CL
in c++ but actually in any oop language, is it bad to use forward class declaration to hide cyclic dependencies?
using modulo is so last year, come up with an actually creative solution that solves the problem in an unique way instead of repackaging the same shit over and over again
fn benis(fug: i32) {
match fug {
8=> {}
}
}
Rust interests me desu
This is a nice way to do it, but what's this Cow
don't mind my reddit spacing
It's a copy-on-write string. It'll contain a reference to a &'static str (a string literal) (The fizzbuzz cases) or a string that it owns (the other cases).
>rustcuck
>reddit spacing
pottery
rewrew
>waah Rust is bad xD
>Do I fit in now?
does fizz own buzz? what if 15 goes out of scope of the lifetime of the pair (fizz, buzz)?
>rust shills ruining yet another /dpt/
When will Mozilla run out of money?
Jokes on you, i do it for free.
>brainlet couldn't learn a type system more advanced than rust
stop insulting akariposter's legacy
>I understand; when I started with Rust, its expression orientation and ability to omit return statements at the end of a function seemed a gimick. But as I’ve used Rust I’ve come to realise that it isn’t, it really isn’t. It’s great.
so how about your stupid ass explains why it's not a gimmick and it's great instead of just spouting an opinion
It just keeps things ergonomic. For example you no longer need the ternary operator, because you can just use if. You can also do the same thing with a match statement. Closures can be much shorter and simpler. It's not a gamechanger, it's just nice to have.
it's fine
Never!
I wrote a EBNF parser yesterday, but after struggling to write a so called scanless C parser learned about context free grammers vs regular grammars so now I'm using it to write a regular expression compiler.
I wasn't really asking why, I was just angry that the author of the blog post basically posted "so you have an opinion, and I have a different opinion, and my opinion > your opinion, and that's it, let's continue with the post". Instead he should either have clarified it right after or in a separate blog post or just omitted such a comment because it doesn't really bring anything to the table in the context of the post.
>tfw Thursday (Friday) night in listening to death grips and hand optimising assembly code while half drunk
Imagine being this mad at a programming language.
Hi, Jow Forumsdpt/
I want to emulate CD-ROM behaviour by plugging Raspberry Pi IO pins into pins through which CD-ROM should send data to PC and pass ISO image this way. How would you approach this kind of task?
that's not the only thing you're hand-optimising
What's a good learning resource for making a simple language that compiles to, say, a custom VM?
SICP chapters 4 and 5
but I thought you liked having no modern tutorials or rather all tutorials that can be found are either shitty videos or things from the last fucking decade.
dragon book
I find it useful for writing in other blocks, not so much functions. For example, you can do let x = match var { 1 => "One", 2 => "Two" } instead of let x; match var { 1 => x = "One", 2 => x = "Two" }. Nice to have, anyway.
reminder that python is faster than java
s/is/starts/
how do you slowly move an integer from high values and drag it to 0?
int independence; // declaration of independence
the fuck are you talking about
let go; // plz, user
basically I have a paddle I can move left and right and I want to slowly stop.
add friction
but the paddle bounces when It reaches 0
using ball_velocity_type = int; //preferably float but whatever
ball_velocity_type ball_velocity = 20;
ball_velocity /= 2;
Really though you should be using a float so you can get proper smoothing going on and then just drop it to zero after a certain threshold.
>java iterators doesn't implement Iterable
collections implement iterable you mong
iterators implement iterator
redpill me on recursive descent parsing
Should i use SFML or SDL for a 2d game?
I especially want to have as little input latency as i can since it's going to be a rhythm game and have heard a few people here say that SFML has a lot of input latency.
use godot faggot.
is open source and free.
I use SDL personally. I used to know how to do 2D and made a couple shitty games before I learned OpenGL. I really would recommend you use OpenGL though. Most of those sorts of libraries have very simplistic rendering features.
I dont want to use an engine, it's part pet project and part learning either one of the libraries.
I also don't want the overhead that a full on fucking engine adds to the project; in both boilerplate and "I want minimal latency".
there's none
Is using OpenGL really worth it for a 2D game? Every single time i've looked at learning OGL the amount of boilerplate has really put me off. 200 odd LOC just to render a triangle doesn't set the best impression.
Someone previously told me to use vulkan but i never really looked into it.
>someone told me to use vulkan
Never listen to that guy ever again. If you though opengl was a lot of boilerplate... Vulkan is less of a graphics API and more of a graphics card API.
But yes it is. 2D games aren't really 2D. Not even NES games are. OpenGL will give you easy layering. It will give you easy rotations and such. You'll hate yourself if you write up a game in some basic bitch 2D blitter and decide you wanna add particles or color transformations later.
I mean at least in vulkan you know what everything is doing explicitly vs fucking shit tons of hidden state like all the other apis. For a complete beginner I'd tell them use anything else though..
Ah, layering is pretty important, particles are kind of as well.
Do you have any recommendations for "I'm pretty good at C++ but have never done graphics before" in terms of books/online tutorials?
Perhaps it will red pill me into taking the graphics modules my uni offers next year.
learnopengl.com
gl/hf joining the autism that is working on a graphics render
there is nothing more comfy than ue4. even if every compiling is russian roulette because a white space can make the header tool shit itself.
There aren't any really good thorough modern opengl web tutorials as someone was bitching about earlier, but there is the opengl superbible and the opengl red book. Never read the red book, but from what I know it is more of a reference and I know the superbible is more of a tutorial.
dumb nigger
I like my boilerplate and writing everything in plain C.
++ gives me the eye strain.
A script to rip audio files from some weeb site.
Turns out encrypted audio streams aren't that secure when the key is available in plaintext to anyone visiting the site.
dumb frogposter
Does anyone here actually program? No one I know in real life actually cares this much about language as the people here seem to. What are you working on? What are you building?
>Does anyone here actually program?
I think you're in the wrong thread bro.
>programming thread
>do people actually do this nerd shit xxddddd
he's an /agdg/ autist, ignore him.
currently pulling my hairs out to get a raspberry pi to work as a local wlan access point and client
yeah yeah java is POO and all that but don't just straight up lie. Java is faster than {Haskell (actually pretty much any FP language), Javascript, Python, Ruby, C#}
I care about languages, although not in the sense of caring about which one you choose to use.
I'm working on a set of tools for a sort of niche documentation database specification. It's used where I work, but there was basically nothing FOSS available for it, so it's been an interesting project.
This is similar to asking in linguistic forum about whether they actually make anything other than debating over language
Oh wait...
I don’t think language discussion shouldn’t happen here, it just seems to be really centralizing and attracts a lot of memes and shitposts.
neither do meta-posts like these bitching about it. And then the meta-posts about your meta-post bitching about you and so on.
Language wars are a part of /dpt/, fuck off somewhere else if you don't like it or atleast add to the thread in the way you want others to.
Trying to up my SQL skills.
We got 3 things I can make scripts in at the office.
>Access
>TOAD
>MS SQL Server MGMT Studio 2008 CE
Which is best? I like Access.
Thanks
That’s fair.
I’m writing a library in C to solve CSP problems. When completed it should be able to solve all sorts of logic puzzles.
Your favorite IDE?
Goddamit, wrapping C function to python is a fucking nightmare. Dynamic typing is so retarded.
hello senpai,
in c++ how do I get an ' if ' statement to check if a certain string is contained within an array?
for(int i=0;i
>for int i = 0; i < SIZE;
pls no
std::vector retards_data{ "asd","Fasdf","asd" };
std::string desired_string = "asd";
for (auto& str : retards_data)
{
if (str == desired_string)
std::cout
Look at the shit C++17 adds and tell me its not retarded gimmicks. Same thing about rust.
for example?
>tell me simplifying meta programming is a gimmic
You're gonna make me go get the list of main features now aren't you.
> is a gimmic
>std::string_view is a gimmic
>assorted others
I'll admit c++20 has more generic useful features though.
Guys. Guys hear me out.
Problem: High-level languages are easy to read & prototype, but slow. Low-level languages are faster, but require more management.
Why not have a language where you can manually set the language features/ flags for the compiler? I'll use Python as an example:
Compiler flags
+const +argument-type +
Code
const pi = 3.141592
def degToRad(float x):
return x * pi / 180
That way you can make your code as high or low level as you want.
okay, so what's wrong with using for loops?
it is a for loop it's just a range based for loop which started being a thing iirc in c++11. typically before you'd want to use iterators instead of an index since it would be less prone to errors than manually indexing. Granted that implies that you don't need to use the index/iterator specifically for something else that you're doing in the for loop.
>its easier to remember more flags than language features
>this would make it easier to program guys
>guys pls
Hear me out.
Programming languages are all just abstractions upon logical gates. Why don't we just make better compilers?
If only it were that easy.
>learn multiple languages
>learn one
A blog in django for school :(
>every language has the same syntax
>lisp reads like haskell reads like rust reads like c languages
>Why don't we just make better compilers
Hence the flags dufus. Compilers are dumb.
I've been using Pale Moon because it uses less RAM and I have a million tabs open but unloaded, so they use up just a little bit. I keep about 10 loaded at a time, constantly unloading and autounloading the rest. Still, as I keep browsing, used RAM begins to mount until it eats up almost all of it. Minimizing memory usage dondu nuffin.
Is there a chance this is anything but a memory leak? Or is this inevitable when "powertabbing"? Isn't tab unloading supposed to free all the RAM used up except for a token amount any unloaded tab requires?