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
comedyblissoption
Mar 15, 2006

AFAIK the memory "metadata" (its current size, the current array capacity, the pointer to the array, and any other bookkeeping) for the Vector is allocated statically. typically the actual data part of the Vector is going to be stored in an array that is dynamically allocated on the heap. the location and size of this dynamically allocated array on the heap can change as you add elements.

Adbot
ADBOT LOVES YOU

comedyblissoption
Mar 15, 2006

the vector as used above will not cause memory leaks. using a static vector doesn't cause memory leaks just because it is static. a static vector won't ever be "freed" AFAIK (maybe there's special rules on program exit? I have no clue)

if you're new to C++, you have to be aware of the memory unsafety pitfalls of using vectors. look up reference invalidation and iterator invalidation with vectors.

the golden rule of thumb is to not hold any reference to the data while doing any operation that could invalidate references. using an iterator is equivalent to holding a reference to the data.

operations that can invalidate references will include adding to the vector, compacting the vector, clearing the vector, removing elements from the vector, etc. basically anything that could invalidate a reference by marking that memory as freed. you could think of it as "mutating" the array.

an illustrative example of use after free of potentially terrible things happening:
https://monoinfinito.wordpress.com/2015/04/14/c-invalidating-references-to-elements-in-a-vector/
code:
void do_something(const int&);
#include <vector>
 
void foo() {
    std::vector<int> v = {1,2,3,4,5};
    const int &num = v.at(1);
    v.push_back(42);
    do_something(num);
}

comedyblissoption fucked around with this message at 15:12 on Mar 8, 2017

comedyblissoption
Mar 15, 2006

Bloody posted:

c++ is like the last row in that brain enlightenment meme
i hope rust is able to create a world where people no longer have to worry about all the ridiculous c++ minutiae and gotchas

comedyblissoption
Mar 15, 2006

St Evan Echoes posted:

never use the vs git client, it is so so bad

comedyblissoption
Mar 15, 2006

use sourcetree instead

comedyblissoption
Mar 15, 2006

MALE SHOEGAZE posted:

i wrote this scala function and it's so perfect and beautiful i wish i could share it.

it's the best function i've ever written. and then i wrote a test case for it that is the best unit test i've ever written.

sorry just wanted to share.
i envy you

in my world a function is considered not good. you must create and instantiate an object that wraps the function. then you have to use dynamic reflection to inject it into another instantiated object as a dependency. then you have to make sure the object implements an interface. then depending on the flavor of kool-aid you have to create a mock of any other functions wrapped in objects implementing interfaces your function might depend on. this is considered best practices. lol kill me and our industry

comedyblissoption
Mar 15, 2006

MALE SHOEGAZE posted:

i have been looking at and messing with this mongo data model for a few hours now and i just don't get it at all.
did you just assume the database's schema

comedyblissoption
Mar 15, 2006

any editor can do what any other editor can do in theory. it's more about what you emphasize.

emacs emphasizes text-based interfaces over gui widgets. you don't end up with text embedded in UI elements that you can't navigate or search or copy. you don't have to hunt for poo poo in nested gui menus. almost everything is just plain old text and you can manipulate this in universal ways.

emacs emphasizes ergonomic use of the computer. ergonomic in this case means using primarily a home row hand position and not constantly having to shift your hands to the arrow keys or mouse. this can enable very fast workflows for text editing. you can think of it like the difference between playing an RTS game using only the mouse and playing an RTS game while using all the hotkeys. if you don't care about this emacs is not for you. this approach has a disadvantage of a large up-front learning cost.

emacs emphasizes less visual clutter. you tend to have just the relevant information you want with everything else removed.

i think these basic principles give emacs a certain aesthetic and user experience that can't be matched by other editors that rely primarily on GUI-based and mouse based interactions. as an example, managing multiple files in emacs and recalling the ones you want is way more manageable than fiddling with unsearchable tabs in visual studio that overflow the top of the screen.

there are pros/cons with any approach. youre not gonna be an ubermensch by using emacs, but if its principles appeal to you youre gonna have a more pleasant time.

if another editor has much better code support than emacs for a particular language, you should still use that. I still use visual studio for C#.

comedyblissoption fucked around with this message at 11:01 on Mar 21, 2017

comedyblissoption
Mar 15, 2006

spacemacs is a good batteries included emacs. you can also use holy mode (like i do) if you don't like vi modal editing.

comedyblissoption fucked around with this message at 10:34 on Mar 21, 2017

comedyblissoption
Mar 15, 2006

gonadic io posted:

Thanks for summing up the problem with keyboard interfaces


All keyboard editing has a much higher cognitive load than mouse editing. I want to move to a location in text.

With a keyboard you need to pay attention to how many lines/words/chars are involved, with a mouse you do not.
constantly moving your hands between the mouse and keyboard is a cognitive load. having to sometimes use a pointing device to select text with character precision also has its own cognitive load. based on my own personal experience, keyboard navigation is faster in general and easier to be precise than having to constantly context switch to the mouse. i feel i get a lot of stress on my hands/wrists by constantly moving back and forth with a mouse and keyboard.

comedyblissoption
Mar 15, 2006

Bloody posted:

keyboard interfaces struggle from generally having terrible discovery. fun fact: all that poo poo you complain about being buried in an ide's menus somewhere is also accessible via keyboard commands
emacs is discoverable once you know a few of the discovery tools. it has a literal tutorial to jumpstart everything else. I can just hit m-x and just generally type what i want and it will find the function or configuration.

a gui editor could in theory allow itself to be discoverable and keyboard driven in the way emacs is, but the difference in philosophy puts their emphasis elsewhere. typically gui editors don't expose potential keybindings in the universal way emacs does for almost all its functionality. the amount of key bindings is generally incomplete. the keybindings for text navigation and editing is also typically really lovely, and the defaults often use arrow keys for text navigation which is terrible ergonomically.

the benefit you are getting here with non-gui discoverability is the screen looks aesthetically minimalist instead of having a giant amounts of bells and whistles and text that is irrelevant the vast majority of the time. this is mostly a preference thing though.

comedyblissoption
Mar 15, 2006

a trackpad is insanely worse than a good mouse

comedyblissoption
Mar 15, 2006

Bloody posted:

ya theres a mismatch between "workin in an editor" and "workin in an ide" but its mostly self-inflicted. i find vim to be superior for text manipulation than visual studio's text editor. i find the rest of visual studio dramatically better for software development than any imaginable combination of command-line tools and text editor plug-ins. i prefer to make the tradeoff towards the ide, as i personally do not find the text editing portion of software development to be the long pole in the tent. when there is no ide available, as is the case with fpga development, then i will use a good text editor with plug-ins as a next-best thing. the text editing part of the experience improves, but the experience on the whole is inferior due to the lack of tight semantic integration.

in my opinion, for larger code bases, the semantic integration becomes increasingly important: in a kloc-scale code base, it isnt too demanding to manually figure out (or text-only figure out) where every occurence of butt.fart is; in a 100k+loc scale code base (never mind 1M-10M+) it may become impossible to manually tease out components and text-only methods are more likely to fail as text-based symbols are more likely to collide.
in emacs some languages have pretty fleshed out facilities for semantic analysis of the code that show you errors as you iteratively develop similar to what you'd expect in a GUI IDE. the philosophy of emacs absolutely doesn't prevent having real-time visual semantic code analysis, editing, and navigation. emacs can work on a higher level than just textual symbols.

you have to remember that emacs is still GUI but with primarily text-based interfaces. it's not just a raw terminal editor. it can have squigglies under text showing errors and graphics in the margins and poo poo.

the main issue with emacs is it's typically volunteer driven and so it doesn't have the same resources for code-based tooling that companies backing GUI-based IDEs can throw at the problem.

comedyblissoption
Mar 15, 2006

anthonypants posted:

this sounds insanely bad from a usability perspective
the alternative for thousands of configuration options is trying to visually scan linearly for what you want in a shitload of nested menus (e.g. any configuration in Visual Studio). i prefer just typing to search for what i want since it's typically faster.

also it's good for functionality that isn't used often but I still use from time to time. as an example, i can just hit m-x occur and find what i want and it will let me regexp search my current text buffer and then spit it out to another window with all the matching lines. i don't need to remember a dedicated keybinding for that. the alternative typically provided in a gui based editor is context switching to the mouse and taking a few seconds to find where the functionality is.

comedyblissoption fucked around with this message at 00:15 on Mar 22, 2017

comedyblissoption
Mar 15, 2006

Bloody posted:

go is bad
this is the best article i've seen so far on why some people really dislike go
http://sitr.us/2017/02/21/changes-i-would-make-to-go.html

comedyblissoption
Mar 15, 2006

intellj sounds cool on accomodating keyboard-driven usage

comedyblissoption
Mar 15, 2006

Wheany posted:

are you describing "find?"
it does a regex search on your current file and spits it out into a separate buffer to look at

my main point is that i don't have to remember a hotkey for it or where it sits in some nested gui somewhere under "advanced". i can just type the functionality i want and execute it.

comedyblissoption
Mar 15, 2006

HoboMan posted:

here's something i never understand: in emacs all the commands get notated like "M-x" what does that mean? press m then x? press m and x at the same time? shift + m + x? shift + M then x? or is it one of the first two except M stands for coMmand or something dumb like that? something completely different?
pressing alt and the key x is M-x
pressing control and the key x is C-x
pressing shift and the key x is just notated as X
pressing control and alt and the key x is C-M-x

this notation is explained in the emacs tutorial and used in the documentation

some of the terminology is historical baggage because emacs is ancient. M stands for meta which used to be a key on certain ancient keyboards.

comedyblissoption
Mar 15, 2006

liking modal editing vs key chords is probably based on personal preference and how your hand is built. some people have a hard time using ctrl key combinations and rebind ctrl but for me it's very easy.

comedyblissoption
Mar 15, 2006

my coworkers are hopped up on creating .net microservices just because

can someone kill the cottage industry making up these buzzwords and fashion trends

comedyblissoption
Mar 15, 2006

Maluco Marinero posted:

it's concerning how much stock developers put into not understanding css. or at least, they want a framework to 'take the pain of css away', missing that most frameworks aren't nice clean abstractions of CSS and thus don't really obviate the need to actually understand CSS unless you follow their examples.

I guess what I'm saying is, it'd be real swell if people acknowledged that maybe having someone on staff who actually knew how CSS worked, how it's used to achieve standard design patterns, and could dictate best practices. maybe then CSS wouldn't be this inscrutable language of mystery it seems to be for most people.

I'm not saying CSS is a good language, far from it, but like if you had a MUMPS codebase, you don't suddenly turn around and get a developer who knows nothing about the lang to make fundamental implementation decisions.
the problem with css is it wasn't designed properly for common UI lay out concerns for graphical applications and you had to learn a bunch of hacks and "css tricks" for what should otherwise be straightforward concerns. of course people are going to get frustrated having only absurd hacks as their primitives for composing what they want.

a lot of the "css frameworks" like bootstrap are a blessing because they help get you some basic layouts without having to learn absurd hacks.

even flexbox alone isn't good enough for general purpose layout

afaik region based layouts are still experimental poo poo

comedyblissoption
Mar 15, 2006

what im saying is people would probably in general be more open to properly learning css if it wasn't historically such a steaming pile of poo poo. idk if it's actually gotten any better (i have low hopes)

comedyblissoption
Mar 15, 2006

if youre writing tests make sure the only things you ever mock are interfaces external to your program (e.g. file system, network calls). mocking too much and having a bunch of useless tests is a very common trap

someone told me that you shouldn't even mock at all and design your program so it's easy to test everything w/o even calling out to external systems. i dont have experience w/ this at all but maybe he's right.

comedyblissoption
Mar 15, 2006

fleshweasel posted:

this sometimes works. all you do is write a deterministic function that does your business logic, then write a wrapper function that does I/O or network poo poo and then runs your business logic on the stuff that come from disk or network. it falls short when you conditionally need to do a fetch based on the results of another fetch, etc. because you either have to just fetch everything upfront or do some kind of sequencing in your function that directly touches I/O that pretty much turns it into a business logic function.
im wondering if there's a generalized solution to this problem of falling short w/o mocking or polymorphism where you have a test version. maybe this is just inherent and essential complexity.

rust doesnt really have a mocking library afaik and i was wondering how people do tests in rust. i guess the best you can do is passing in a test version that mocks a trait and try to limit this to the outermost shell of your program.

comedyblissoption
Mar 15, 2006

it's okay to let things fall over to the next sprint for whatever reason. your velocity will self-adjust. someone who isn't sick can just pick up something else from the backlog and not have to close out that story.

of course i know people (e.g. business stakeholders) instead want to follow a process that doesn't align with reality at all and want everything committed to in a sprint to be finished in a sprint which causes all kinds of absurd issues.

but yah pushing to the remote at the end of day in a branch if you have anything is a good practice

comedyblissoption
Mar 15, 2006

Arcsech posted:

Had a meeting today to propose moving to a better branching model than "let's have 60 developers clusterfuck master"

Got shut right the gently caress down because WHAT IF MERGE PROBLEMS

aaaaaaaaagggggggggggggrrrrrhrhrhrhrhrh
If you use git or some other VC system w/ sane branching, this should be justifiably frustrating. If you are using SVN or an SVN-like, then you are right to get shut down b/c the branching in SVN is garbo.

Adbot
ADBOT LOVES YOU

comedyblissoption
Mar 15, 2006

Notorious b.s.d. posted:

how long is it gonna take y'all to learn emacs is the one true path
also if someone is interested in emacs i would heavily recommend spacemacs (emacs w/ sperges managing your config for you)

  • Locked thread