Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
quiggy
Aug 7, 2010

[in Russian] Oof.



im currently saving up money to liberate my modules too, op

Adbot
ADBOT LOVES YOU

quiggy
Aug 7, 2010

[in Russian] Oof.



:suicide:

quiggy
Aug 7, 2010

[in Russian] Oof.


http://left-pad.io/

quiggy
Aug 7, 2010

[in Russian] Oof.


MononcQc posted:

That's IEEE Standard 754 on floating points.

±∞ × 0 => NaN
±nonZero ÷ ±0 => ±∞

Not a javascript horror.

well then it's a loving stupid standard :colbert:

quiggy
Aug 7, 2010

[in Russian] Oof.


GrumpyDoctor posted:

lol what was the bug

system("sudo rm -rf /");

quiggy
Aug 7, 2010

[in Russian] Oof.


BattleMaster posted:

maybe i just use C too much because i don't see what's wrong with null being 0

like maybe think about checking your pointers before you use them instead of using them and then checking the results, or not even checking and just hoping/praying it works

in c++ at least, the following code behaves very differently if you substitute 0 for NULL:

code:
uint8_t* x = NULL;
x++;
std::cout << *x;
if x is NULL, this segfaults because you can't increment past NULL. if x is 0, this will print the contents of the memory located at 0x8, which under certain compilers is a-ok

quiggy
Aug 7, 2010

[in Russian] Oof.


Plorkyeran posted:

this is completely wrong by both the standard and in practice

in practice NULL is #define NULL 0 everywhere, so they're obviously the same thing. per the standard NULL isn't required to be an all-zero bit pattern, but nonetheless 0 is defined to be a null literal, which means that uint8_t* x = 0; will result in x not having the value 0 if your platform uses something else for null pointers

gently caress me apparently youre right

its me im the terrible programmer

(well in c++11 it can also be std::null_ptr but w/e)

quiggy
Aug 7, 2010

[in Russian] Oof.


HoboMan posted:

pretend i have design skills and was making a webpage, "what program do i loving boot up to start crafting some html/css?" is essentially my question. all you've said in response is "be a designer". this is not helpful

grep and sed

quiggy
Aug 7, 2010

[in Russian] Oof.


Awia posted:

the answer is visual studio

same except vim and make

quiggy
Aug 7, 2010

[in Russian] Oof.


computer parts posted:

not in academia

academic code owns

quiggy
Aug 7, 2010

[in Russian] Oof.


Awia posted:

im the pointer named t

im Malloc

not malloc, Malloc

quiggy
Aug 7, 2010

[in Russian] Oof.


Awia posted:

what does Malloc do over malloc? why does it take a type and a random variable and return a pointer?

Malloc is a macro that performs a sizeof on the first element and then returns memory of that size. i dont remember what the random variable does

and no the macro is not parentheses-wrapped

quiggy
Aug 7, 2010

[in Russian] Oof.


i looked up the macro for you nerds

code:
#define Malloc(type,n) (type *)malloc((n)*sizeof(type))
academic code Owns

quiggy
Aug 7, 2010

[in Russian] Oof.


hey fun c++03 fact: if you have a std::vector<Object*> v, then v[i]+1 compiles fine and without warning!

:suicide:

quiggy
Aug 7, 2010

[in Russian] Oof.


VikingofRock posted:

Really? I get a -Wunused-value warning, which is part of -Wall. (Link to example)

Unless you mean you were using that value somewhere in a surprising way, which is an understandable complaint but which is pretty reasonable behavior given how pointer arithmetic works in C++. Image that you are actually storing arrays of Objects in your vector--you would want v[i]+1 to compile in that case so that you can index your array. Like this:

C++ code:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    string arr[3];
    arr[0] = "yos";
    arr[1] = "pos";
    arr[2] = "bithcoin";

    vector<string*> v;
    v.push_back(arr);
    cout << "*(v[0]+1): " << *(v[0] + 1) << endl; // prints the element at v[0][1], which is "pos";
}

unless im mistaken you're only getting unused value if you don't actually then read it. also the only reason that you get "pos" in your example is that you already put "yos" and "pos" in an array so they're guaranteed to be adjacent, if they're not already adjacent you'll segfault when you try to access v[0] + 1

quiggy
Aug 7, 2010

[in Russian] Oof.


Bloody posted:

I thought vector guaranteed adjacency

vector guarantees adjacency, but the vector type is Object*. the Objects themselves are in no way guaranteed to be adjacent since it entirely defends on how and where they were defined

as a really lovely example that you should never actually write:

C++ code:
int a = 3;
int* b = new int;
std::vector<int*> v;
v.push_back(&a);
v.push_back(b);
this should compile and run fine, even though v[0] is a pointer to an int on the stack and v[1] is a pointer to an int on the heap

quiggy
Aug 7, 2010

[in Russian] Oof.


fritz posted:

no stop that, jesus christ


get yourself up to at least c++11 and fill that with smart pointers instead

would if i could m8, not up to me

quiggy
Aug 7, 2010

[in Russian] Oof.


honest question: is html turing-complete

quiggy
Aug 7, 2010

[in Russian] Oof.


Bloody posted:

for(int i = 0; i < butt.Length; i++)
{
fart(butt[i]);
}

nah now it's

code:
for (std::Butt::iterator it = butt.begin(); it != butt.end(); ++it) {
    fart(*it);
}
(ok or you just use auto in c++11 and up)

quiggy
Aug 7, 2010

[in Russian] Oof.


Notorious b.s.d. posted:

and smarter pointers

not if it's c++03 or earlier :negative:

quiggy
Aug 7, 2010

[in Russian] Oof.


fritz posted:

can you at least use a boost

in theory yes, at this job no

quiggy
Aug 7, 2010

[in Russian] Oof.


weird posted:

code:
std::for_each(butt.begin(), butt.end(), fart);

yes this technically works but it assumes that the contents of the loop are one and only one function call

of course you could (a) write an external function that handles the inside of loop (:gonk:) or (b) write a lambda, but lambdas only exist in c++11 and up. and besides goddamn is that some ugly code either way if you aren't just trying to fart() each butt

oh also without lambdas you can't capture variables from outside the loop so have fun trying to get that to work with c++03 with any function that depends in some way on external state!

quiggy
Aug 7, 2010

[in Russian] Oof.


i pretty frequently have to iterate over stl::map objects, which is really "fun" in c++03. say i want to add one to each member of an int map keyed by strings

C++ code:
std::map<std::string, int> myMap;
...
for (std::map<std::string, int>::iterator it = myMap.begin(); it != myMap.end(); ++it) {
    ++myMap[it->first];
}
concise!

quiggy
Aug 7, 2010

[in Russian] Oof.


also be sure to note that it is not a pointer, it just overrides operator* and operator-> to make it look like one! this has the fun side effect that

&(*it) != it

quiggy
Aug 7, 2010

[in Russian] Oof.


more like dICK posted:

std::transform should do that?

same problem as before re: external functions or lambdas. im intentionally making simple examples here of loop structures, ofc there are easier ways to add 1

(also std::transform and std::for_each are in libraries separate from, say, <map> so you have the added joy of more #includes, hooray)

quiggy
Aug 7, 2010

[in Russian] Oof.


more like dICK posted:

I think that "operation I regularly apply to a map entry" is he perfect thing to encapsulate in a function but I'm in this thread so whatevs

depends on how often you actually apply that operation i guess. plus im generally of the opinion that fewer functions = better (within reason, of course)

quiggy
Aug 7, 2010

[in Russian] Oof.


VikingofRock posted:

Why wouldn't you just do ++(it->second)?

again because it's a simple example to demonstrate the general gist of what im talking about

christ almighty do i have to write unit tests for example code too

quiggy
Aug 7, 2010

[in Russian] Oof.


Fergus Mac Roich posted:

what is the purpose of reducing the number of functions?

i make functions that are only ever called once. i like the idea that i give a discrete bit of computation a name and an identity.

keeps anybody reading the code (yourself included) from having to jump around in a file (or multiple files!) to figure out what the code is doing. if you need code that does One Thing, write a function that does it. don't then separate One Thing into Nine Subthings and write nine functions

quiggy
Aug 7, 2010

[in Russian] Oof.


example from my current neural network code for job:

one function trainFromCsv that opens a csv file, reads data out of it, closes the csv file, and then trains itself based on that data i could do, in theory (pseudocode before someone jumps down my loving throat)
code:
function trainFromCsv(csv_file_path) {
    csv_file = fopen(csv_file_path);
    data = getdata(csv_file);
    fclose(csv_file);
    train(data);
}
but why should i when i can just do it all in one function? if i need to break it up later i can do that later, no reason to add complexity now

quiggy
Aug 7, 2010

[in Russian] Oof.


JimboMaloi posted:

uh the reason you do it like that is because its way easier to read. if youre working in a language with a functional ide the cost of jumping to a method implementation is trivial, and then each thing is actually readable without the noise of unrelated tasks surrounding it. its precisely the 'write a function that does one thing' notion that you just stated. reading a csv file and training a neural net are 2 things

i mean i run vim/ctags so it's literally as easy as :ta <name of function> or C-] on the function name itself. that still doesn't change the fact that it's an additional step other than "scrolling down"

quiggy
Aug 7, 2010

[in Russian] Oof.


Bloody posted:

verilog's most common form of flow control is a convoluted version of goto

*hits blunt*

all programs are just applications of subleq, maaaaaaan

quiggy
Aug 7, 2010

[in Russian] Oof.


Illusive gently caress Man posted:

The ideal is that you don't need to scroll down or look at the other function at all because it does exactly what the function name says

and trainFromCsv() trains the network from a .csv

your point?

quiggy
Aug 7, 2010

[in Russian] Oof.


Jabor posted:

i really love it when the fiddly implementation details of reading a csv (do you use a library for this, or is yet-another-bespoke-csv-like-format?) occupy the same space as my machine-learning neural net stuff. i can think of no reason you'd ever want to separate those two wildly distinct concepts. none at all.

it's straight up an stl-based csv reader and the main training loop is a function called propagate and a function called back propagate

it's v easy to extend to new formats

quiggy
Aug 7, 2010

[in Russian] Oof.


Bloody posted:

wish I could back propagate your posts

gently caress me im so owned

quiggy
Aug 7, 2010

[in Russian] Oof.


Wheany posted:

you have to use "butt" and "fart" as your variable names or us terrible yospos programmers will think you're posting production code.

what if i write enterprise code for the fartbutt industry

quiggy
Aug 7, 2010

[in Russian] Oof.


Bloody posted:

i have created a revolting clusterfuck

you're posts!!

quiggy
Aug 7, 2010

[in Russian] Oof.


Wheany posted:

are you hiring? i'm willing to relocate

we currently have job offerings on uranus

quiggy
Aug 7, 2010

[in Russian] Oof.


piratepilates posted:

the evil fartbutt industrial complex

hillary clinton takes donations from Big Butt

quiggy
Aug 7, 2010

[in Russian] Oof.




:suicide:

Adbot
ADBOT LOVES YOU

quiggy
Aug 7, 2010

[in Russian] Oof.


triple sulk posted:

lol if u think this is as bad as it can get

oh no i know it can get worse than this, but this is a chain of ifs with a single line that it actually executes embedded into a switch statement embedded in a for loop in a function

literally kill me

  • Locked thread