Pinned toot

old code new question: can you spot the undefined behaviour? omg! and how can I ever recover from this?

Show thread
Pinned toot

false dichotomy - rejected half the time

false equivalence relation - rejected once per the number of equivalence classes

false total order - accepted most of the time

Pinned toot

guess the language! 

unnecessary indirection,
unnecessary allocation,
unnecessary bound checks,
runtime type information,
overuse of abstractions,
global state in libraries,
long names.
repeated half-assed reference counting,
repeated half-assed implementations of common data structures/algorithms,
tons of fragile platform specific code.

this is why your math-scientific always canonical pure algebra implementation doesn't cut it, rationals have much wider scope - to keep track of and delay division until it's convenient/necessary

Show thread

a fixed point number is just an optimization of a rational with fixed denominator

wasted hours patching it up before learning to read and finding it alive and kicking on github, no more auto_ptr, still a mess in general, but doesn't segfault quite as often as the ancient release

Show thread

compiler bugs, will they ever stop harassing me?

aka another reason to never use built-in arithmetic types.

Look at me ma, my library is going to have a matrix type, a row vector type and a column vector type, isn't that wonderful? I read a math book. I study math I'm so smart ^-^






2's complement representation of negative integers follows directly from the definition of basic addition, stop teaching it as if it's some special clever bit twiddling scheme. The most significant bit is not the sign bit, and you do not convert between negative and positive by flipping the bits and adding 1, what bizzaro world do you exist in?

Undefined behaviour means "if you do this, anything may happen", and even though you most certainly shouldn't do it, it doesn't mean "don't do this", hence if you actually define it to something specific, you create a subset and not a superset of the programming language.

clang is infinite looping and/or crashing on me again -_-

- hello, library that handles X, I would like to do the most obvious thing one would ever want to do in context of X, could you tell me how, please?
- ah yes, of course, our library could never work for X without handling such fundamental problems... however our API is shit, so just look at these internal implementation details, copy them into your project, and integrate them with the API yourself. Keep in mind though the API is parametrized on all the wrong things for no reason, so you'll have to do it in the most backwards ways.

Show thread

JUCE framework is a freakin joke. Here I thought it's a comprehensive toolkit for low level audio programming, but turns out it's a useless Qt wannabe.

You know what's important for audio programming? Threads. Can you please thread safety, a framework that takes away my main() and handles GUI with a custom freakin build system? No? Apparently that's fine because 32 bits ops are atomic on x86, hurr durr. Also the only sample type is float, cause you know C++ is known for no generic code whatsoever, none, not a part of the language, never been. Wanna playback a standard pcm data from memory? How about a backwards file stream API that has a specialization to read from memory, and a audio callback that is going to convert it to float regardless of what it is and what the sound hardware supports? And don't forget to bring your own ring buffer, pleb. If you don't have one go to our community forum, where you will be told to git gud.

namark boosted

#cpphttplib is a #singleheader #HTTP client and server #library for #Cpp.

cpp-httplib implements HTTP client and server functionality with a straightforward interface. Starting a server is as simple as defining an action for a specified path and listening on a port. Server paths support regexes for more complex behaviour. cpp-httplib supports #HTTPS and quick static file serving.

Website 🔗️:

#free #opensource #foss #fossmendations #programming #networking

ergonomics > safety guarantees

It is very much possible for you to fall when sweeping the floor, but how often do you? Or feel the need to lean against a wall? If cleaning the roof is made just as convenient, with a bit of diligence you wouldn't fall from it either. Neither would you poke your eye with a soldering iron, or drill into your own scull, not because it's impossible, but because the tools are easy for you to use properly. Instead of trying to build sophisticated all encompassing systems that allow you to ignore real problems, learn to tackle those problems comfortably and develop tools that make the solutions obvious.


but now it look a lot more like the cppreference example implementation... so much for trying to be original and stylish...

Show thread

of course I notice a horrible out of bound read right after positng -_-

but it passed the tests, even with address sanitizer :v

because tests were on c-strings that and null terminators saved them -_-

Show thread

so since we don't have a proper search till c++20:
gotta love the do-if-while.

shame html doesn't highlight the if though, so maybe

the rage type is just a simple aggregate that holds the two iterators and provides the usual begin-end interface, no magic there.

why do bit operations on bool return an int? doesn't that defeat the whole point of bool? do I have to redefine every single fundamental type to not be insane?!
it's like beads on a string, so lets call it... a forest... of course... following in the footsteps of std::vector -_-

so you look up a-law and mu-law, and they are upselling them so freakin hard, with all the terminology and the sophistication of the study of the human hearing, and nature of audio signals, and speech in particular, and then follow up with formulas so backwards and mathy you have to wonder if logs are base 2 or base e... and of cource you have classic "you don't need to understand this stupid programmer, just use this lookup table" scaremongering

then you read up on the actual standard codec spec
and it turns out it's basically just

float compress(long long value)
{ return value; }

except smaller and simpler

Show more
Qoto Mastodon

QOTO: Question Others to Teach Ourselves. A STEM-oriented instance.

An inclusive free speech instance.
All cultures and opinions welcome.
Explicit hate speech and harassment strictly forbidden.
We federate with all servers: we don't block any servers.