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
Sapozhnik
Jan 2, 2005

Nap Ghost
Awful_Case is objectively the worst casing style, bikeshed all you want about c_case and C_CONSTANT_CASE vs javaCase and PascalCase though.

Adbot
ADBOT LOVES YOU

Sapozhnik
Jan 2, 2005

Nap Ghost
There should be a Java compiler plugin that automatically inserts null checks for every parameter not annotated @Nullable

Sapozhnik
Jan 2, 2005

Nap Ghost
linear algebra owns

Sapozhnik
Jan 2, 2005

Nap Ghost
linear algebra suffuses and perfuses DOOM's program code. or just any sort of real time computer graphics application in general really

who says math can't be metal as hell

Sapozhnik
Jan 2, 2005

Nap Ghost

LeftistMuslimObama posted:

is there a better place to read about it than wikipedia? the wiki article just starts talking about fields and poo poo half way through without really defining them and never really ties the theory to anything concrete so i get really lost

what concrete application are you interested in

If you're doing computer graphics then you're going to be dealing with position vectors for points in space of the form (x,y,z) a lot. You are also going to be dealing with linear functions of vectors a lot: for example, scaling and rotation are linear functions of vectors. A linear function is any function f(v) such that

f(Av) = A f(v), for any scalar (i.e. number) A

and

f(u + v) = f(u) + f(v).

In this particular case u and v are 3d vectors but you can have linear functions of other kinds of things. But, if we're considering 3d vectors, then as long as a function that maps from one vector (x, y, z) to another vector (x', y', z') is linear then it can always be written in the form

x' = AA x + AB y + AC z
y' = BA x + BB y + BC z
z' = CA x + CB y + CC z

where AA, AB, AC etc are to be read as names of constants, not products.

That's very long-winded, though, so instead we just write the AA AB AC BA BB ... bits as a grid surrounded by brackets and leave all the other stuff out. And then we can do linear algebra on these functions directly instead of doing a bunch of tedious and long-winded substituting and reducing on the functions that these matrices actually represent.

To multiply a matrix by a vector (on the right, order matters) is to apply that function to that vector.
To multiply two matrices together is to compose the two functions: the composition of two linear functions is also a linear function.
For two matrices M and N, the matrix product M N is not necessarily the same as N M, because the order in which you compose the functions might matter.
You can also invert some (but not all!) matrices. The inverse M^ of a matrix M is the matrix such that M^ M v = v, for all v (i.e. the matrix M^ that "undoes" whatever M does).

To see why you can't invert every matrix, consider the matrix

1 0 0
0 1 0
0 0 0

i.e.

x' = x,
y' = y,
z' = 0

that just crushes every point in space onto the plane z=0. This destroys information that can't be recovered, so this matrix is non-invertible. And this is where you get into determinants and stuff.

Sapozhnik fucked around with this message at 17:21 on Jul 21, 2016

Sapozhnik
Jan 2, 2005

Nap Ghost

LeftistMuslimObama posted:

got it. i need a matrix for each "thing" that is happening each frame that changes how the line should be displayed, and since camera movement, movement of the object the line is part of, movement of the scene the line is contained in, etc are all different transformations of the line relative to its screen position they are all separate functions that need to be multiplied together (composed?).

Don't worry so much about lines, we're just talking about points here. Rotate all the vertices in an object and you'll rotate the object.

A vector tells you the position of a point. Transforming that vector tells you the new position of that point.

The reason matrices are useful in this situation is that you don't have to, say, scale everything and then rotate everything. You can combine the scaling and the rotation into one matrix ahead of time, and then you only need to apply that one matrix to do both things simultaneously, which is more efficient. The whole discussion actually bottoms out fairly quickly if you're just talking about 3D space because about the only things you can do with 3x3 matrices is rotation, scaling, reflection, and I guess shearing. Beyond that they're not very useful, again, if you just stick to strictly 3D space and ignore the final paragraph of this post.

You can't move things using a matrix, because a matrix can only represent a linear function f(v), and remember how f(Av) = A f(v) must hold for all vectors v and numbers A for that function to be linear? Well, set A = 0. Then f(0 * v) = 0 * f(v), so f(0) = 0 must always always hold. If f(0) gives you something other than 0, then f isn't a linear function and you can't represent it as a matrix. Well, that means you can't move things around with a matrix, you'd have to move from 0 to some place other than 0. Matrices aren't useful here.



... well, sort of. Except you can do a hack where you model everything in four dimensions, and then you can cook up a 4x4 matrix that moves the camera, rotates the camera, and then does a perspective transformation of everything from 3D onto the 2D plane of your screen. Which is much faster than doing all these things separately and keeping track of them all separately. But that's getting a little bit ahead of things, and that's taking a very applied-computer-graphics-programming-oriented view of things as opposed to a pure mathematical view of what's actually going on.

Perspective transformation involves dividing both X and Y by Z which is an extremely non-linear operation but the trick there is that the actual division doesn't happen until you re-interpret your 4D space back into 3D... well, 2D at this point... by dividing X Y and Z by the fourth dimension co-ordinate. It all seems very simple to me after having read up a bit on it but I can see how this would seem incredibly confusing if you're diving straight in and trying to understand the entire stack of concepts all at once

Sapozhnik fucked around with this message at 04:19 on Jul 22, 2016

Sapozhnik
Jan 2, 2005

Nap Ghost
I guess maybe try doing a 3D rasterizer without using matrices at all and then it'll become a little bit more clear why they're useful. In programming terms they're an abstraction that takes a bunch of seemingly-different tasks and turns them into different instances of the same task, allowing you to use the same code and techniques for all of them.

Sapozhnik
Jan 2, 2005

Nap Ghost
that feel when you gently caress up so badly that you not only crash your process but you take Valgrind with it

Sapozhnik
Jan 2, 2005

Nap Ghost

who the gently caress comes up with these names

Sapozhnik
Jan 2, 2005

Nap Ghost
ruby: so bad that even javascript is better

ruby: at least we're not php!

Sapozhnik
Jan 2, 2005

Nap Ghost

LordSaturn posted:

we need to stop expanding C++, it's 2016 and you can just use a good language if you loving want to

People use C and then they're like "ugh I hate doing vtables by hand, maybe I'll just use a little bit of C++ but program it as if it were C"

"I'll just do a little meth, I'm a strong-willed person with lots of self control, it can't be that much of a slippery slope, can it?"

Sapozhnik
Jan 2, 2005

Nap Ghost
I mean I guess you could very carefully extend the bare minimum from the baseline of C in order to get the job done. Just templates and RAII and virtual methods, no exceptions and absolutely no loving operator overloading. Well, except you'll probably want a custom smart pointer class in order to do the RAII thing, so ok, maybe a tiny little bit of operator overloading.

No constructors, just assume that every new'ed object gets memset to 0 and make sure your destructors can handle that if your _init() methods fail, which is basically what you'd do in sensible C anyway. Well, except in C something is either uninitialized memory or a valid "object"; if your _init() function fails then it is the _init() function itself that is responsible for calling _fini() to undo the mess and return the object to being a mass of uninitialized junk that is no longer holding any resources. In this minimal C++ situation you'd instead have a pile of abortion waste on your stack that you have to be careful not to do anything with until it goes out of scope. eh.

constructors can't return an error code in c++ because that would break so much of the language, you have to throw an exception instead, and then, well you have to deal with all the myriad problems of exceptions in a non-garbage-collected language. this one aspect of c++ is a fount of aggravation and misery.

GCC has a nonstandard C extension instead that arranges for a cleanup method to be called whenever a stack variable (and only a stack variable) goes out of scope and it's a much nicer solution to this problem. the systemd guys use it extensively and it actually makes for rather nice code.

but there's still no nice way to do vtables in C. and you can't do just vtables in c++ without constructors and virtual destructors, and as described above you can't do those without exceptions.

c++. not even once.

Sapozhnik
Jan 2, 2005

Nap Ghost
http://250bpm.com/blog:4

Sapozhnik
Jan 2, 2005

Nap Ghost
the last time i had to professionally care about c++ was 2011 and i am very thankful for that

Sapozhnik
Jan 2, 2005

Nap Ghost
java 8 streams are an acceptable substitute for linq

never want to go back to earlier versions of java

Sapozhnik
Jan 2, 2005

Nap Ghost

Notorious b.s.d. posted:

java 8 adds proper collections libraries

java 9 is adding a repl

now all we need is for java 10 to get rid of the checked exceptions and java will finally be pleasant to work with

what Java needs now is async/await

unfortunately it is hamstrung by the java.util.concurrent.Future which is godfuckingawful

i'm pretty sure you couldn't design a worse interface if you tried

Sapozhnik
Jan 2, 2005

Nap Ghost

fritz posted:

thats when it got "good" tho

you mean that's when they piled even more poo poo on top of the existing poo poo in the hopes of making it less of a fuckshow

i am extremely loving done with c++ tyvm. rust seems interesting though, might check that out at some point.

Sapozhnik
Jan 2, 2005

Nap Ghost

Finster Dexter posted:

haha I about snorted energy drink all over my keyboard thanks. I needed a good laugh. This week is one of those weeks that makes me question my career choices.

same, except every week, and instead of career choices decision to pursue a green card

maybe i should go back to the uk.... *brexit* oh.

Sapozhnik
Jan 2, 2005

Nap Ghost
i spun up a t2.nano and put a regular bare git repo on there that's accessed over ssh. i have one coworker and i make about 80% of the commits.

an issue tracker would be nice but eh, this works in the meantime.

i'm gonna try gogs on something that doesn't matter as much and if that doesn't turn into a ball of flames then i might install that at work.

(speaking of matter and much, mattermost is a cool self hosted slack clone and yall should check it out)

Sapozhnik
Jan 2, 2005

Nap Ghost

~Coxy posted:

b-b-but everyone told me that branching and merging in git was fine!

It is. If you never rebase then you'll never screw up master by simply branching and merging.

However, you'll have a knotty history polluted with lots of useless bullshit.

If you've got a really long running feature branch then branching and merging master might make sense because then you've genuinely got two long-running concurrent streams of development and you should probably make the history reflect that. Also manually fixing up a rebase on top of a conflicting change is far more difficult and risky (in the sense that you might lose a shitton of work and not even realize) than just thrashing everything out in a merge commit at the end of it all.

Sapozhnik
Jan 2, 2005

Nap Ghost

Making and reconciling development histories is the entire purpose of Git and tools like it. It stands to reason that you want this history to be constructed in a manner that maximizes its utility for merging or retrospection, and like any tool that depends on your competence using it (as well as how well the tool's design lends itself to being used competently, which is admittedly an area where Git leaves something to be desired).

Sapozhnik
Jan 2, 2005

Nap Ghost
post teh codes

javascript is bad for a whole bunch of reasons but xhrs aren't really one of them. if it's really proving to be a pain in the dick then use a polyfill for the new Request API.

Sapozhnik
Jan 2, 2005

Nap Ghost
your compiler has died of dysentery

Sapozhnik
Jan 2, 2005

Nap Ghost

Shaggar posted:

ORMs are bad

here's what i've learned in the last few years:

orms are bad

the alternatives are worse

Sapozhnik
Jan 2, 2005

Nap Ghost
EclipseLink and JPA2 are quite nice, and the metamodel generator is surprisingly easy to integrate into a Maven build and Java IDE as well.

Most of the time I don't actually model the relationships in the entity classes, I just map the ID fields as IDs. Then I do various criteria query joins in my data service layers. So I guess that means I kinda abuse it as a statement mapper. Attempting to model joins behind the scenes is I think where ORMs start to become a net source of problems.

The criteria API is a bit on the wordy side, but it's also type-safe ...ish. You kinda build an SQL syntax tree by calling a bunch of functions instead of bashing strings together.

If all else fails (read: you need to do a window query) then you can escape to raw SQL too.

Sapozhnik
Jan 2, 2005

Nap Ghost
oh i thought the ... -> ... -> ... notation was some dumb haskell currying thing

Sapozhnik
Jan 2, 2005

Nap Ghost
It's also obsolete these days because there are INVSQRT instructions now.

Still cool though!

Sapozhnik
Jan 2, 2005

Nap Ghost

MALE SHOEGAZE posted:

Apache uses the totally obvious convention of loading conf.d/* in order of file name and this will change the behavior of your server

This is also exactly what the nginx found in EPEL does by default on CentOS

Your conf files are each supposed to contain one vhost. If reordering these files changes the behaviour of your server you dun hosed up

Also dropfiles are a very common pattern.

Sapozhnik
Jan 2, 2005

Nap Ghost

GameCube posted:

ugh sourcetree got even worse with the latest update somehow. did you terrible fuckin programmers ever come to a consensus re: what's the best gui git client??

tig

used in conjunction with bash

Sapozhnik
Jan 2, 2005

Nap Ghost
java the language is alright. not fantastic, but for a lot of tasks it gets the job done pretty well.

java the standard library is a mixed bag. the very earliest stuff is awful, but soracle have done a good job of filing off the rougher edges. lol at java.util.concurrent.Future though.

java the ecosystem was rather touched in the head in the early 2000s but is considerably better in the 2010s. it is underpinned by maven which is extremely ftw even if the project files are written in xml. this is literally the least interesting thing about maven even though people obsess over it constantly (wadler's law lol)

spring is lol

Sapozhnik
Jan 2, 2005

Nap Ghost
Guice is pretty ftw

but it doesn't really come with any sort of web framework as such

also it's kinda hosed up in a c++ sort of way in that you can get easily high on your own farts doing all sorts of weird poo poo that doesn't actually solve any concrete problem

Sapozhnik
Jan 2, 2005

Nap Ghost
good langs for pedagogical purposes:

python 3
c (99? at that level it doesn't really matter)
risc-v asm (basically just mips without the branch delay slots, and about as likely to be used in practice in tyool 2016 as mips)

bad langs for pedagogical purposes:

java
ruby

horrible langs for pedagogical purposes:

c++
php

Sapozhnik
Jan 2, 2005

Nap Ghost

Captain Foo posted:

templated in the butt by my own templating error

Sapozhnik
Jan 2, 2005

Nap Ghost

LeftistMuslimObama posted:

it doesnt matter that irl a binary tree is usually implemented as an array

uh

...?

that makes about as much sense as implementing a linked list as an array

Sapozhnik
Jan 2, 2005

Nap Ghost
*puts on fishmech hat*

yeah a heap (data structure) is definitely best implemented as an array, because it will always be dense. a sparser tree like a rb tree is generally implemented as heap dynamically allocated nodes though.

i'm having trouble thinking of a situation where you'd want to put an rb tree into an array. like, ok if your keys and your values are fixed-length, and you really want to mmap() the poo poo so that it's stored in a backing file, but then because it's red-black that means you're going to be mutating it (otherwise you'd just make it into an array that's sorted ahead of time because at that point an array that you binary search is exactly equivalent to a linearized dense binary search tree) but then that means you have to be transactionally consistent with your updates and that's um really loving hard so you're going to have a write-ahead log as well and anyway at that point what you have is basically a database table so really you want a b+ tree and that's just a whole different animal altogether and...

if it's not being persisted to disk (and therefore doesn't need to store links as offsets within the arena as opposed to just using pointers like a normal person) then cramming a bunch of tree nodes into a gigantic contiguously-allocated dynamic array is a pessimization in every sense that matters.





.... did i pass the algorithms and data structures phase of the interview yet lol

Sapozhnik fucked around with this message at 23:13 on Aug 3, 2016

Sapozhnik
Jan 2, 2005

Nap Ghost

comedyblissoption posted:

implementing a linked list as an array would probably be faster the vast, vast majority of the time

linked lists that are implemented as dynamically allocated non-contiguous memory should be considered incredibly niche

optimizing for the computer's cache is one of the most important things in a data structure and linked lists poo poo all over that

This also doesn't make much sense to me, I'm afraid.

The whole point of using a linked list is to be able to insert and remove things from the middle of the list quickly. Backing your linked list with a slab allocator will speed up rapid allocations and deallocations but it won't do anything to help your cache usage, because the order in which your nodes gets traversed will get jumbled very quickly on account of all those insertions and removals in the middle. Having all the nodes be located in vaguely the same area of memory doesn't change that.

If you only need to insert and remove things at the start and end, and you also need to optimize for traversal performance, then the data structure you're looking for is a ring buffer, not a linked list.

Sapozhnik fucked around with this message at 15:26 on Aug 4, 2016

Sapozhnik
Jan 2, 2005

Nap Ghost
I mean when I'm writing C I use intrusive linked lists and the containerof() macro as my default collection data structure because it's quick and easy to implement, and most code isn't performance critical so who cares if it's not the absolute fastest thing in the world.

Though on further reflection I'm not entirely sure why. It wouldn't be any harder to bang out yet another dynamic array implementation instead.

Sapozhnik
Jan 2, 2005

Nap Ghost

Bloody posted:

go's idea of types is a bunch of poo poo you throw away with an interface{}

i look forward to the inevitable clusterfuck that was c# 1 to c# 2 or java 1.4 to java 5 happening to go

generics will happen, and they will gently caress up absolutely everything for the next five years by which time go will be replaced with some other fad lang

Sapozhnik
Jan 2, 2005

Nap Ghost
python 3 is ok. probably.

idk people make the whole dynamic typing thing work but it's not for me really. i'm sure with type annotations and slightly better ides it is at least serviceable.

Adbot
ADBOT LOVES YOU

Sapozhnik
Jan 2, 2005

Nap Ghost

HoboMan posted:

is oop actually bad? i personally hate it but i'm a terrible programmer

"Object oriented programming is a term that encompasses many ideas. Half of them are obvious. The other half are mistakes."

I think that was from Alan Kay?

  • Locked thread