Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "c is black magic"
-
When it comes to the idea of programming and magic, or the comparison between software developers/engineers, computer scientists etc as magicians or wizards, nothing brings the idea much more close to hearth than the C programming language.
A while ago I read the R.A Salvatore books concerning Drizzt, the dark elf. I loved the books, have not continued reading them but I remember them vividly. There was one book in which a human magician came about wielding extremely explosive magic, humans were capable of channeling large amounts of it through explosive and unwieldly ends.
This is the same feeling I get from C
Consider:
int items[] = {1, 2, 3};
printf("Third : %i\n", 3[items]);
and fuck me if shit like the above is not dangerous, it makes sense, arrays have the first items of it server as the pointer address to a first element, doing the above operation returns the third element of the array of 3. But holy shit if I don't think this is dangerous and interesting as fuck
there are many more examples I have that I am finding through me fucking around with: language development (compiler, interpreter), kernel programming as well as net sec. C is the most powerful and devastating thing we have in our hands indeed.7 -
I'm doing a project for uni in Omnet (C++ framework that should facilitate working with networks of queues, simulating and displaying statistics).
I needed to retrieve a random value from an exponential distribution, and the function to do so requires a random number generator as input. The framework has 2 implementations of the RNG and I picked the first one.
I spent 3 hours trying every possible thing, using both the exponential() function and its class wrapper (both provided by the framework), it was always returning 0 or NaN.
The RNG was spitting out values correctly, so I thought it was okay.
When I was almost ready to give up, I figured I could try and change to the second implementation of RNG, expecting nothing to change. And it fucking worked.
Zero reports on this behavior on Google, no apparent reason why it would work with one and not with the other when the two RNGs literally implement the same abstract class and spit out the same exact numbers... Just black magic...
Oh and cherry on top, it works with the raw function but not with the class wrapper on that same function... IF YOU GOTTA IMPLEMENT SOMETHING IN YOUR DAMN FRAMEWORK THAT DOESN'T WORK, FUCKING DON'T! 1 combination working out of 4 is not good! Or at least document it!
Sorry just had to share my pain -
OK, I could maybe write a quick app in C++ and cross compile it so I can send it to my friends who use windows, what is wrong with you I am ashamed for us all.
But why do that? Let's just go the EXTREME route and do things in a very inappropriate way that is natively """portable""" so we can say that (((It Just Works™))).
So if you haven't guessed already, it's 100% js rawdogging and I'm doing the graphics in SVGOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO uoykuf OoOOOOOOOOOOOOOOOOOOOOOOoOOOOOOOOOOOOOOOOOOOOO it's not so bad but here's things I've learned:
If you're using inkscape to convert your lazy 8x8 pixels per frame spritesheet.png into an svg file, and don't know how to use inkscape, you have to stack each frame on top of one another. Yes.
Erase the layers, erase everything that isn't the paths you want. Also erase invisible paths generated by the pixelart mode of the trace bitmap thingy, sometimes these ghosts exist for mysterious reasons.
Then, neatly stack everything into one square big enough to hold all the frames, select all the frames, resize to selection. OK, now double check that the names of your layers werent changed to generic path94958509 out of the fucking blue AGAIN, all good.
Also double check that inkscape hasn't changed the name and extension of your output file AGAIN then make sure inkscape hasn't changed the dimensions of your export AGAIN and then AGAIN and AGAIN...
OK, so you've exported your svg, now we start doing even more stupid and questionable things. We go into the file and delete the header, specially the comment at the top that clearly states this file was made with inkscape, because my experience was so DELIGHTFUL that I very much require some abstract form of petty vengeance. Also a cigarette.
Hold on. Patiently erase useless tags such as defs and g and shit, all you want is the svg and paths. Then, painstakingly convert each <path id=$ .../> into <symbol id=$> <path .../>.
Why didn't I write a perl script for this part? Actually that's a good idea, goes on the todolist, I didn't write a todolist app though, because I have a textfile. I mean, just what kind of negative IQ troglodyte would do something like that? ;>;>;>;>;>;>;>
Anyway, now utilize your black-magic-infused devilspeak q$p e r l$ script to fasten together an entire webapp into a single html file, all done with duct tape and clown jizz of course, see previous rant for VERY technical details. Also I jjust time traveled and wrote the previous paragraph while writing this one everything is out of order oh noes.
No matter it works now me is happiee.
I got heart icon for health bar but no health bar implemented not aproblem.
Uh also outlines. Here, let's keep it topical, this is rom.rol:
```rol
# vars:
$:%peso;>
let sprite,"$.elems.srpite";
$:/peso;>
# css:
$:%asis;>
path {
· stroke: $080808;
· stroke-width: 0.1;
· stroke-linejoin: round;
· paint-order: stroke;
}
$:/asis;>
# html:
$:%asis;>
<svg width="2.1166811mm" height="2.1166601mm" viewBox="0 0 2.1166811 2.1166601" xmlns="http://www.w3.org/2000/svg">
<symbol id="{$$.%sprite}_hp_0">
<path d="M 0.264594,0.26458 V 0.52916 H 1.1e-5 V 0.79375 1.05833 1.32291 H 0.264594 V 1.5875 H 0.529177 V 1.85208 H 0.793761 V 2.11666 H 1.058344 1.322927 V 1.85208 H 1.587511 V 1.5875 H 1.852094 V 1.32291 H 2.116677 V 1.05833 0.79375 0.52916 H 1.852094 V 0.26458 H 1.587511 1.322927 V 0.52916 H 1.058344 0.793761 V 0.26458 H 0.529177 Z"/>
</symbol>
<!--NOW DO THE OTHER NINE FRAMES-->
</svg>
$:/asis;>
```
so now I can say (in base.rol):
```rol
$:%peso;>
lib "[based]";
rol "rom.rol";
let hud,"$.elems.hdu";
$:/peso;>
$:%asis;>
<svg viewBox="0 0 23.283329 2.1166601" width="16%" height="16%" fill="#880808">
<use id="{$$.%hud}_hp" href="#{$rom.%sprite}_hp_0"/>
</svg>
<script>
document.getElementById("{$$.%hud}_hp").setAttribute('href',"#{$rom.%sprite}_hp_" + n).
</script>
$:/asis;>
```
Where `n` is just some frame counter this is duct tape now request animation frames REQUEST THEM YOU MUST.
Anyway this is immensely stupid but it made me giggle so I share.
AAA RPG with full svg graphics when?1