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.
 
  • Post
  • Reply
john donne
Apr 10, 2016

All suitors of all sorts themselves enthral;

So on his back lies this whale wantoning,

And in his gulf-like throat, sucks everything

That passeth near.
Arrow notation is the opposite of a coding horror.

Adbot
ADBOT LOVES YOU

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

chutwig posted:

What are you people doing with Git that makes you feel like you need an army of shell scripts to manage it? Nearly all of my Git usage can be distilled down to 10 commands:
  • git pull
    ...
Methinks you forgot `git clone`. :laugh:

I work on some projects in CVS; I'd have to ask what people _think_ they are doing in git that's so much more impossibly difficultingly world-ending in CVS. I just watched an intern get all excited about branching in git, until two weeks later when it took him three hours to figure out how to patch and code review his branches for release, because half the stuff was strewn on that side, and half on the other. I've seen a lot of production teams convince themselves "there should only be mainline with continuous deployment and continuous integration testing", at which point a project wouldn't even need functionality beyond that afforded by the most basic CVS commands. All the git reflog history rewriting carap, yeah I've only ever worked where git repositories permit no rewriting of history; once you push, it's recorded for all to see.

So here it is, basically all I ever use to manage tasks in the CVS projects, and how they line up against git. I'll say this, I have to look up the syntax every single time I try to branch in git (I mean a real branch, in the repository). I was going to leave off the tool name so you'd be unbiased, but if you know one or the other you'll recognize the commands anyway. Note the clever flags on both sides, and the not-so-clever flags on both sides. I guess git didn't learn.

code:
...                                                    ...                                                    create a locally-hosted repository tree (both suck)
cvs checkout MODULE                                    git clone URL/MODULE                                   create repository copy, using configured repository
cvs -d URL checkout MODULE                             git clone URL/MODULE                                   create repository copy, default directory
cvs -d URL checkout -d TGT MODULE                      git clone URL/MODULE TGT                               create repository copy, named directory
cvs add FILE ; cvs commit -m MSG                       git add FILE ; git commit -m MSG ; git push            add new file to repository
cvs diff                                               git diff                                               show diff of files changed since last commit
cvs commit -m MSG FILE                                 git add FILE ; git commit -m MSG ; git push            commit changes to one file
cvs commit -m MSG                                      git commit -a -m MSG ; git push                        commit changes to all changed files
cvs update                                             git pull                                               merge remote changes into local repository
cvs tag -b BRANCH                                      git checkout -b BRANCH ; git push -u origin BRANCH     create a branch (slightly different side effects)
cvs update -r BRANCH                                   git checkout BRANCH                                    switch to existing branch
cvs update -C -r REV                                   git reset --hard ID                                    reset files to revision / commit id
cvs tag TAG                                            git tag TAG                                            create a tag
cvs diff -C3 -r REVA -r REVB                           git difftool -y -x 'diff -C3' IDA IDB                  "code review" between two revisions / ids
cvs diff -C3 -D DATEA -D DATEB                         ?? git diff '@{DATEA}..@{DATEB}'                       "code review" between two dates
cvs status                                             git status
cvs status FILE 
cvs log                                                git log
cvs log FILE                                           git log -p FILE
cvs history FILE  

FlapYoJacks
Feb 12, 2009
Python's "self" operator is the real coding horror.

JawnV6
Jul 4, 2004

So hot ...
Remind me how you break a lock with git?

vOv
Feb 8, 2014

ratbert90 posted:

Python's "self" operator is the real coding horror.

It doesn't have an operator, it just explicitly passes the object as the first parameter in method calls and by (almost universal) convention that's called self.

Coffee Mugshot
Jun 26, 2010

by Lowtax

I'm really having a hard time understanding why they decided to use this awkward looking thunk or even suggest it rather than just provide a fake implementation. What am I missing here? It surely must be easier to test middleware in JavaScript.

FlapYoJacks
Feb 12, 2009

vOv posted:

It doesn't have an operator, it just explicitly passes the object as the first parameter in method calls and by (almost universal) convention that's called self.

Fine, but it's still stupid and bad.

Eela6
May 25, 2007
Shredded Hen

ratbert90 posted:

Python's "self" operator is the real coding horror.

I agree, but only because it's not a real keyword that's enforced by the interpreter. They should go all the way or not at all.

QuarkJets
Sep 8, 2008

ratbert90 posted:

Fine, but it's still stupid and bad.

How do you feel about "this" in languages like Java?

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

ratbert90 posted:

Fine, but it's still stupid and bad.

I like it; it helps reinforce how object methods work. Python in general gives you a lot of access to the underlying constructs of the language. Of course, you shouldn't actually use that access in the vast majority of circumstances, but e.g. being able to monkey-patch in a stub so your unit tests can have a limited scope is pretty handy.

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!
self is preferential to an implicit this, but it is obnoxious how it makes the method's definition signature look different than how you use the method in 99% of cases.

VikingofRock
Aug 24, 2008




chutwig posted:

What are you people doing with Git that makes you feel like you need an army of shell scripts to manage it? Nearly all of my Git usage can be distilled down to 10 commands:
  • git pull
  • git push
  • git log
  • git diff
  • git commit -a
  • git checkout -b feature/some-branch
  • git rebase -i some/other/branch
  • git push -u origin feature/some-branch
  • git branch -d feature/some-branch
  • git reset --hard some-branch-pointer

Am I missing something in this discussion? The Mercurial CLI suite isn't any friendlier for the commands I just listed, and the second you start using Mercurial for actual things you run into the buzzsaw of annoying error messages like abort: cannot rebase immutable changeset because Mercurial knows best about history rewriting and abort: abandoned transaction found - run hg recover! because Mercurial is a fragile flower when it comes to repo integrity. It lost versus Git for a reason, and it's not just because it's like an order of magnitude slower.

I used my first git shell script today! It was this github-provided one which changes author info throughout a project's history.

Bongo Bill
Jan 17, 2012

Asymmetrikon posted:

self is preferential to an implicit this, but it is obnoxious how it makes the method's definition signature look different than how you use the method in 99% of cases.

I like the way it's done in Lua, where a method call is syntactic sugar for a function call with the owning table given as the first parameter.

Absurd Alhazred
Mar 27, 2010

by Athanatos
This discussion reminds me of a coding horror perpetrated by inexperienced C API writers: forgetting to add a void* pData parameter to the signature of a function setting a callback.

I did this once or twice, but fortunately not for libraries that ever had to be used out of house

TheresaJayne
Jul 1, 2011

TooMuchAbstraction posted:

Look, you're not supposed to prematurely optimize. That means you don't have to care about runtime whatsoever until it becomes a problem, right?

This is with 5 users and its supposed to run with 1000s using the system,

The issue is that they have central microservices that have single threads and single queue, meaning that there is a bottleneck with the queue,

We ran up 5 microservices (their suggested amount) and the processor was running at 2% cpu and in my first post I got the figures wrong, it was 15 minutes not seconds for the response.

When we ran up the extra services it then increased the speed and CPU usage jumped to 20% and the page response decreased to about 5 minutes.

The issue here is that the old system has delays on some of the large pages of say 30 seconds to 1 minute and the new "faster" one is about 10 times slower.

raminasi
Jan 25, 2005

a last drink with no ice

PhantomOfTheCopier posted:

I work on some projects in CVS; I'd have to ask what people _think_ they are doing in git that's so much more impossibly difficultingly world-ending in CVS.

Here's why you don't think they're different:

PhantomOfTheCopier posted:

All the git reflog history rewriting carap, yeah I've only ever worked where git repositories permit no rewriting of history; once you push, it's recorded for all to see.

PhantomOfTheCopier posted:

I mean a real branch, in the repository

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.
:) "I'm surprised you can use your mac for development and use git on it."
:eng101: "Of course I can, it runs natively in my environment. Git was created by Linus Torvalds to manage the Linux kernel, ..."
:) "How did you learn all this?"
:eng99:

Something seems wrong with the hiring practices at my current job.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

TheresaJayne posted:

This is with 5 users and its supposed to run with 1000s using the system,

To be clear: I was being sarcastic. A common bit of conventional wisdom is that you never prematurely optimize, because you may spend a lot of effort on something that ends up not mattering significantly (e.g. improving disk I/O on something that's CPU-bound). It'd be easy to interpret that as saying "you shouldn't worry about performance whatsoever until you discover that you can't scale". But there's a difference between not optimizing your code, and not giving any thought to its performance. Good designs take scaling requirements into account .

CPColin
Sep 9, 2003

Big ol' smile.

CPColin posted:

Something like 2.5 weeks into my new job, I got my first look at a small bit of the code. It's a utility class that's 2,077 lines long and has an 818-line method in it that's one giant switch statement. There's also a bunch of stuff that was clearly copied and pasted. Good target for refactoring, right? Well, too bad, because there's no test coverage, as far as I can tell!

Imagine ten functions like this, where the only differences are the type of Thing and sometimes the date format includes the time:

code:
        public static void PersistThing(Thing thing, string action, int id, string server)
        {
            //Note: only a PUT will have an id > 0
            string jsonToSend = string.Empty;
            jsonToSend = JsonConvert.SerializeObject(thing, new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd" });
            //Insert new record to the worklist
            string urlPart = "/rest/path/whatever/entities/Thing/";
            if (action == "PUT")
            {
                urlPart += id.ToString();
            }
            JsonPostPut(server + urlPart, action, jsonToSend, false);
        }
Note that all the types of objects being passed have an ID property, but the ID is passed to the above function separately.

That JsonPostPut function does the following:
  • Takes a string for the method to use and throws an exception if, when converted to uppercase, it's not "POST" or "PUT".
  • In the switch statement that's checking the desired method, properly uses the WebRequestMethods.Http enum.
  • Always sets the content type of the request to "application/json", then does it again if it's a POST.
  • Takes that last boolean parameter and pauses for two seconds if it's true. It's never true.
  • When making the request, correctly uses a StreamWriter in a using block, then uses the response and its stream without using blocks.
  • Is too long. Could be shorter, if the login credential lookup code were extracted into a separate function (and shared among the three functions that need it).
  • Manually filters both ,"id":0 and "id":0, strings out of the serialized JSON, but makes sure to check if they're present first. Always checks for both strings.
I just wish there were a tiny bit of test coverage, so I could clean this stuff up.

CPColin
Sep 9, 2003

Big ol' smile.
code:
            if (responseJSON == null)
            {
                return null;
            }
            else
            {
                return responseJSON;
            }
AAAAAA

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

CPColin posted:

code:
            if (responseJSON == null)
            {
                return null;
            }
            else
            {
                return responseJSON;
            }
AAAAAA

I mean, that's basically the classic "return (a == b) ? true : false" in a slightly different form.

ChubbyThePhat
Dec 22, 2006

Who nico nico needs anyone else

CPColin posted:

code:
            if (responseJSON == null)
            {
                return null;
            }
            else
            {
                return responseJSON;
            }
AAAAAA

What the hell is this lol. Please tell me there is context that at least lets you get on the train of thought applied here.

Ranzear
Jul 25, 2013

There was probably some debug logging stuffed in there at one point.

CPColin
Sep 9, 2003

Big ol' smile.

TooMuchAbstraction posted:

I mean, that's basically the classic "return (a == b) ? true : false" in a slightly different form.

Oh, that's in here, too:

code:
                if (string.Compare(type, "DEF", true) == 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }

ChubbyThePhat posted:

What the hell is this lol. Please tell me there is context that at least lets you get on the train of thought applied here.

Other functions pass the non-null JSON value to some other function for further processing, before returning it, so I'm guessing somebody did a copy-paste of one of the more complicated functions, realized they didn't want that call, stripped it out, and left the rest of the code where it was.

ChubbyThePhat
Dec 22, 2006

Who nico nico needs anyone else

Ranzear posted:

There was probably some debug logging stuffed in there at one point.

I hadn't thought of this. This would make a lot of sense.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

raminasi posted:

Here's why you don't think they're different:
Have you stopped beating your wife yet? :) What I said was that there's nothing in practical git that works out to be more complicated in cvs.

"Branch" is overloaded in git. A "local set of commits" is, obviously, not in the repository and prone to data loss; create and push a branch. I've seen junior engineers tear out their hair because they think they'll be cute and create local "branches", then they find out that git blocks them when they have unstaged changes that they don't want to commit anyway, or untracked files that they don't want to commit but don't follow their local branch, or... more likely, that they can't actually run tests because a branch switch introduces different build dependencies. In the end, they realize that `rm -rf` and `git clone repo dirname` are common in git workflows, and they end up with multiple local directories for their local work. Indistinguishable from CVS.

Coding horror: People that drink the git koolaid then spend three hours drawing pictures of branches and local stashes trying to figure out how to cherry pick their upstream remote rebased merge conflicted mess.

Also, if you're rewriting history in a shared and/or production repository :psyduck: you are bad and you should feel bad.




Fake edit: I'll find some horror that looks more like actual code. It's hard to find in CVS since it's so beautiful. :buddy:

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
You sound like someone who has never actually used (or even made an effort to use) git beyond "what git commands are equivalent to these CVS commands I already know". And no poo poo, if that's all you know about git then you're not going to understand how it's different from CVS.

Suffice to say that no, cloning the same remote into multiple different local repositories is not common git practice at all.

Coffee Mugshot
Jun 26, 2010

by Lowtax

PhantomOfTheCopier posted:

Also, if you're rewriting history in a shared and/or production repository :psyduck: you are bad and you should feel bad.

CVS model is fine, but I don't understand how this is possibly true. What is wrong with rewriting history with the history writing tool, git?

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Jabor posted:

Suffice to say that no, cloning the same remote into multiple different local repositories is not common git practice at all.

It is if you're working on multiple branches, and switching branches entails a 2+ hour recompile... :eng99:

Linear Zoetrope
Nov 28, 2011

A hero must cook

Zopotantor posted:

It is if you're working on multiple branches, and switching branches entails a 2+ hour recompile... :eng99:

I assume the branch switch changes some fundamental files everything else references so it can't reuse object/intermediate files from the other branch?

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Linear Zoetrope posted:

I assume the branch switch changes some fundamental files everything else references so it can't reuse object/intermediate files from the other branch?

Interface definitions & headers, yeah. We have gotten better lately, there are actually people working on improving build times now.

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

Zopotantor posted:

It is if you're working on multiple branches, and switching branches entails a 2+ hour recompile... :eng99:

https://git-scm.com/docs/git-worktree may be of interest.
Saves on duplicated objects in a way that's less fragile than cloning with --shared and on the manual effort of keeping multiple local repositories synchronised, since fetching in one workspace updates branches in all the workspaces.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

Coffee Mugshot posted:

What is wrong with rewriting history
Rewrite history in production repository, build, deploy. Repeat ad naseum. Production outage appears from low-occurrence scenario based on some change that was put in place several weeks ago. You try to isolate the change only to realize that you have to rollback the world for the last month because people have been rewriting history, and you have no idea how to correlate issue timestamps to code deployments because there are no timestamp-matched commits in the repository anymore. You drop multiple $100k in annual revenue because you can't isolate a rollforward/rollback. In other words, You're hosed.

Jabor posted:

You sound like someone...
Respond with content. If git is so damned awesome, tell us how.

I have used git, from the ground up, in many gity ways, learning from the "git source material", not from "A CVS user's guide to git" or anything, and watched people repeat all sorts of terrible patterns with it. The same basic mistakes, pointing out the fundamental flaws in the system, are made by most junior engineers. I posted a comparison to state "This is why CVS is easy", not "These are the only git commands I use". Learn to read. I've pointed out a few bad patterns in git. If you want to know what I really dislike about git, I can certainly give a complete list, but I don't know if this is the right forum. I didn't say all of git sucked. If you don't like CVS, don't use it, but be aware that it's not scary; it's easy and straightforward. Most of my CVS experience has happened after my production git experience.

I've demonstrated the ease of CVS by comparison. Proof by popular opinion of a different system is not a viable counter-example. Anyway I'm relatively new in this thread and feel this is enough of this pseudo-on/off-topic topic, so moving forward...



I wish I could find the Chef script that team wrote to randomize the crontab entry for a hardware info collection script. They were all checking in at midnight and it was blowing over the receiver, so someone had the nice idea to randomize the times. So they used Chef to "echo RANDOMTIME hardware-information.sh >> /etc/crontab". To ensure consistent system config, Chef ran every 30min on all servers in the fleet. Two weeks later, the receiver toppled because every host was checking in 10k times per day because the Chef script wasn't idempotent; of course they couldn't clean it up with their all-poweful automated Chef; they had to pull in someone who knew proper scripting to SSH to every server in the fleet.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Okay sure, here's my workflow and you tell me how it's just so simple in CVS.

- I do a bunch of work
- I send that work to a coworker for code review
- I continue working on the next bit (which depends on the changes I just sent for review) while waiting for my coworker to get around to reviewing the code
- My coworker makes some comments that necessitate some changes
- I go back and make changes in light of those comments, then send it back. It could go back and forth like this a fair bit.
- Concurrently, I'm working on the next bits that depend on the code being reviewed. Sometimes I want to pull the latest iteration of changes forward immediately, other times I want to wait and keep working against the previous version until I'm ready to merge things forwards.

In git this is dead easy. I have no idea how you'd do it in CVS, though I'm sure a master like you can point to the commands that I'm missing.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Jabor posted:

Okay sure, here's my workflow and you tell me how it's just so simple in CVS.

- I do a bunch of work
- I send that work to a coworker for code review
- I continue working on the next bit (which depends on the changes I just sent for review) while waiting for my coworker to get around to reviewing the code
- My coworker makes some comments that necessitate some changes
- I go back and make changes in light of those comments, then send it back. It could go back and forth like this a fair bit.
- Concurrently, I'm working on the next bits that depend on the code being reviewed. Sometimes I want to pull the latest iteration of changes forward immediately, other times I want to wait and keep working against the previous version until I'm ready to merge things forwards.

In git this is dead easy. I have no idea how you'd do it in CVS, though I'm sure a master like you can point to the commands that I'm missing.

Oh I know this one

'cvs co butts' in some other directory and then manually manage and track multiple copies of the repository. After you've done the back and forth, diff/patch your intermediary repo back to the real one.

Lol cvs is trash

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
code:
 def reportRepeat(intlist):
     setappearing = {}
     occurrences = []
     for index in intlist.length:
         occurences[index] = True
         for search in xrange(0, index):
             if intlist[search] == intlist[index]:
                 setappearing += intlist[index]
                 occurences[search] = !occurences[search]
:golfclap:

Soricidus
Oct 21, 2010
freedom-hating statist shill
fun fact: it's called cvs because you're gonna need lots of pills to make the pain go away

Khorne
May 1, 2002

GenJoe posted:

You are a 2-3 person development shop, and you need to build out a relatively complex web application. Node.js is appealing because:

• It is extremely simple to deploy. Your web application is the web server, and you don't have to proxy it behind Apache or nginx. This can and will save you a ton of time unless your deployment needs are exceedingly complex for whatever reason, in which case it's probably similar in effort to setting up a traditional web server.

• The community frameworks that actually matter are all maintained by smart people, so you can drop something like Express in and have middleware/cookies/sessions handled for you without having to worry too much about anything.

• Javascript as a language is actually relatively good now. ES7 is adding async/await (and the Promise support that's already there is very good), JSON literals and native parsing take away some of the cumbersomeness that you get with other languages' JSON libraries, and the dynamic type system makes new code quick to write. The lack of good OO is actually a blessing imo because it discourages bad and unnecessary object hierarchies that probably shouldn't have any place in a web application. Same with the lack of threads. Your application code does not need threads. Node.js under the hood is heavily multi-threaded, but that's so it can handle I/O and task scheduling -- your application code is fine without threads and you will complicate the poo poo out of your program if you try to introduce them.
This describes every worthwhile web language under the drat sun and even some questionable web languages. Golang and Python in particular are wildly popular and can both do this. Even dang PERL, a dead web language, has Mojolicious which will do all of this trivially.

I love Javascript for what it's good at. I've used Node a decent amount. Just, most of the time you should probably consider other options unless it's a small project or really time constrained. Javascript feels like you're perpetually prototyping.

Khorne fucked around with this message at 16:04 on Sep 2, 2017

Coffee Mugshot
Jun 26, 2010

by Lowtax

PhantomOfTheCopier posted:

Rewrite history in production repository, build, deploy. Repeat ad naseum. Production outage appears from low-occurrence scenario based on some change that was put in place several weeks ago. You try to isolate the change only to realize that you have to rollback the world for the last month because people have been rewriting history, and you have no idea how to correlate issue timestamps to code deployments because there are no timestamp-matched commits in the repository anymore. You drop multiple $100k in annual revenue because you can't isolate a rollforward/rollback. In other words, You're hosed.

It's getting hard to engage you on weird strawmen like this. Yes, it is possible for this to happen with git. It doesn't though, because just because you have a history rewriting time machine doesn't mean you let everyone have the keys. People are responsible for their rollbacks and rewriting history is a part of that process of fixing up a branch. This is not a git problem, the solution isn't a cvs solution, though. No one loses $100k annual revenue because of the tool.

Adbot
ADBOT LOVES YOU

Coffee Mugshot
Jun 26, 2010

by Lowtax

Linear Zoetrope posted:

I assume the branch switch changes some fundamental files everything else references so it can't reuse object/intermediate files from the other branch?

I do something similar with the code in https://github.com/gcc-mirror/gcc; a checked out repo for each branch. A different branch implies re-running your configure script, most likely, and as such, you probably want to rebuild any artifacts that might existed (might be missing linker flags or other extra environment set in the configuration). Depending on how you are building gcc (quick build, no opts vs stage3 comparison for testing), it can take 40min - couple of hours on 12 cores (make -kj12). This is just a compiler problem, though.

Coffee Mugshot fucked around with this message at 16:25 on Sep 2, 2017

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply