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
qntm
Jun 17, 2009

BigRedDot posted:

Python doesn't have matrices. The third party library NumPy has arrays, which are different things than matrices (obviously), for the reason that they are incredibly useful. (i.e., the person that wrote NumPy made a thing that solved the problem they had in front of them, instead of some different problem, go figure.)

Python has a dedicated operator for matrix multiplication but it doesn't have matrices?

Adbot
ADBOT LOVES YOU

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

qntm posted:

Python has a dedicated operator for matrix multiplication but it doesn't have matrices?

It has a dedicated operator that you can override in your own implementation of matrices, but it doesn't have a standard implementation.

They only added it recently, I guess because people who wanted to do matrix maths in Python asked them to.

sunaurus
Feb 13, 2012

Oh great, another bookah.
What's the difference between a matrix and a list of lists?

qntm
Jun 17, 2009

Illegal Move posted:

What's the difference between a matrix and a list of lists?

Well, among other things, in a matrix each list in the list must have the same length.

Linear Zoetrope
Nov 28, 2011

A hero must cook

qntm posted:

Well, among other things, in a matrix each list in the list must have the same length.

Also, the types of operations you do on matrices benefit tremendously from adhering to certain implementation details regarding contiguous memory storage, unlike lists of lists which are can be strewn about. There are also considerations for strides, views, and other fiddly bits you don't get out of simple [[1,2,3],[4,5,6],[7,8,9]]. (You could implement those operations on top of them, but at that point you may as well just go whole hog).

(Also, in practice you can also implement sparse matrices where you use the fact that it has known dimensions to not have to explicitly mention zero values).

Soricidus
Oct 21, 2010
freedom-hating statist shill

Hammerite posted:

This is why I've never been particularly wooed by those ultra-nerdy text editors Linux people use, vim and emacs and what have you. Advocates go on and on about how quickly they can move around a file and edit but I never feel like how quickly I can edit the file is a bottleneck, it's how quickly I decide on the right thing to do.

It's not about editing faster for the sake of it. An efficient editor lets you get right to the next bit of thinking without breaking your chain of thought.

feedmegin
Jul 30, 2008


They've all got C in the name, must be the same language! And the author's an MBA so he must be good at programming!

Linear Zoetrope
Nov 28, 2011

A hero must cook
C/C++/C#/Cobol

Meat Beat Agent
Aug 5, 2007

felonious assault with a sproinging boner

Jsor posted:

C/C++/C#/CSS

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED

This would be a cool book if it showed a language feature of C, how they tried to improve it in C++, and how they succeeded in improving it in C#.

FlapYoJacks
Feb 12, 2009
Is it a bad thing that every one in a while I do this: git commit -m "$(curl -s whatthecommit.com/index.txt)"
?

xzzy
Mar 5, 2009

Go all in, include the -a.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

feedmegin posted:

They've all got C in the name, must be the same language! And the author's an MBA so he must be good at programming!

I'm eagerly awaiting his Java/JavaScript followup.

duck monster
Dec 15, 2004

Soricidus posted:

It's not about editing faster for the sake of it. An efficient editor lets you get right to the next bit of thinking without breaking your chain of thought.

I've recently started using Emacs again (It was my first editor when I was learning unix, like, 20 years ago) and set up with a whole bunch of useful add ons (including the nav sidebar. Why thats not standard I'll never know) and with my chord memory starting to return, Its a loving lightning bolt to use. I mean sublime text is cool and all, but emacs really is a tight piece of software. And in 2015 "Omg it uses 8mb of ram" isn't exactly the memory hog it was in the 90s.

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
Yeah, I use vim not because I think it's stylish to use an incomprehensible text editor, but because it lets me edit text without having to think about it and without having to use my mouse. You know how when you're playing videogames you don't think "okay, jump, that means I need to press the jump button", you just think "jump" and your body does the appropriate action? The controller "disappears" and your thoughts lead directly to action. The really good text editors let you do that with composition and editing as well.

More WYSIWYG editors have a (much) shallower learning curve, but because they rely on the mouse to do anything especially complicated, you're never going to get the same level of flow out of them that you can out of the oldschool editors with their massive libraries of control commands.

SurgicalOntologist
Jun 17, 2004

As Heidegger would say, your text editor should be ready-to-hand.

sunaurus
Feb 13, 2012

Oh great, another bookah.
Oh a vim vs emacs vs everything else discussion.
I would love to be a vim or emacs pro, but every time I've tried them, I've always struggled with projects larger than a few files. Refactoring variable names or moving classes around are a few activities which are extremely simple in the JetBrains IDEs I use, but I've never found a way of doing anything like it in vim. Also, just configuring vim and installing plugins seems to take at least 10x longer compared to IntelliJ or even Atom. For example, I know that if I want to write haskell in Atom, all I need to do is open settings and search the packages for haskell and install anything that looks useful, but for vim I expect my first step would be to open a browser and start googling for what I need, which just seems way less efficient.

I feel like the gains I would get from faster text editing in vim are completely negated by how much slower it is to actually get to the editing.

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

Illegal Move posted:

Oh a vim vs emacs vs everything else discussion.
I would love to be a vim or emacs pro, but every time I've tried them, I've always struggled with projects larger than a few files. Refactoring variable names or moving classes around are a few activities which are extremely simple in the JetBrains IDEs I use, but I've never found a way of doing anything like it in vim.

Okay yeah, vim is not an IDE. If you want good text editing in an IDE, you install the vim or emacs editing tools into the IDE, rather than try to transform the text editor into an IDE.

EDIT: replacing variable names in vim: Switch to command mode and do "%s/\<oldVariableName\>/newVariableName/g" (without the quotes) to do a search-and-replace. Add a "c" at the end to ask for confirmation with each replacement. The \< and \> ensure that you only get the complete "word" of the old variable name, so e.g. if you have a variable "size" that you want to replace, you won't accidentally mangle the variable "sizes" that's in the same file.

TooMuchAbstraction fucked around with this message at 18:49 on Jan 22, 2016

xzzy
Mar 5, 2009

I would argue that if renaming variables or shuffling classes around is a significant part of your job, the problem isn't your editor. :v:

As for the plugin problem, I don't even know what that means. After you get syntax highlighting (and vim ships with rules for just about every language), what else is there?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

SurgicalOntologist posted:

As Heidegger would say, your text editor should be ready-to-hand.

That is a great framing.

xzzy posted:

I would argue that if renaming variables or shuffling classes around is a significant part of your job, the problem isn't your editor. :v:

I rename and reshuffle all the time, as the use of something shifts slightly, or the center of logic-mass shifts within a class hierarchy. It works out better than letting the maintenance chores pile up and turn into a renovation.

csammis
Aug 26, 2003

Mental Institution

xzzy posted:

As for the plugin problem, I don't even know what that means. After you get syntax highlighting (and vim ships with rules for just about every language), what else is there?

Tons of stuff. I have a very lightweight vim configuration and still have plugins for autocompletion and showing the git diff in the line number gutter. I guess whether you find plugins useful depends on where you want to draw the line between portability (since not all vim installs will have your special snowflake setup) and creating a personalized IDEish experience for yourself.

JawnV6
Jul 4, 2004

So hot ...

xzzy posted:

I would argue that if renaming variables or shuffling classes around is a significant part of your job, the problem isn't your editor. :v:
If you're at all scared of renaming or consider it some major burden or effort, the problem is your editor.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

TooMuchAbstraction posted:

EDIT: replacing variable names in vim: Switch to command mode and do "%s/\<oldVariableName\>/newVariableName/g" (without the quotes) to do a search-and-replace. Add a "c" at the end to ask for confirmation with each replacement. The \< and \> ensure that you only get the complete "word" of the old variable name, so e.g. if you have a variable "size" that you want to replace, you won't accidentally mangle the variable "sizes" that's in the same file.

This just sounds like a dreadful idea. Why would I want to do that when I can just go to where the symbol is defined, retype it, and then accept my IDE's offer to replace the old name with the new one everywhere that's appropriate? It's simpler and the IDE is contextually aware so it won't (for example) change the word "size" in a string literal, or a variable "size" in a different namespace.

And echoing the sentiment that if you don't rename and restructure things as you work on them then either you are spookily good at working out up front exactly how your programs should be structured, or you're not taking a step back and second-guessing yourself enough.

sarehu
Apr 20, 2007

(call/cc call/cc)
I'm not an IDE user. Can IDE's search and replace expression patterns with replacements?

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

Hammerite posted:

This just sounds like a dreadful idea. Why would I want to do that when I can just go to where the symbol is defined, retype it, and then accept my IDE's offer to replace the old name with the new one everywhere that's appropriate? It's simpler and the IDE is contextually aware so it won't (for example) change the word "size" in a string literal, or a variable "size" in a different namespace.

If you're in an IDE, use the IDE's tools, of course. That note was for more general "how do I X" vim usage.

That said, I doubt that an IDE is going to be able to fully replace a pattern-based search-and-replace. I've done some ridiculous things with vim.

sarehu
Apr 20, 2007

(call/cc call/cc)
Well, like, most automatable refactorings seem to be of that nature. For example if I want to replace foo(x, y, z) with foo(blah(x.t), y, z), because foo takes a different type and the conversion with blah is correct (it used to be inside foo) -- can one not do this in an IDE?

FamDav
Mar 29, 2008
is there a widely held belief that ides don't have regex replacement

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

sarehu posted:

I'm not an IDE user. Can IDE's search and replace expression patterns with replacements?

Yes.

I would have a hard time believing that vim or whatever can do anything that a decent IDE can do when it comes to functionality. I mean you might have preferences about keyboard shortcuts or whatever, but as far as what it can do to your code...

vOv
Feb 8, 2014

I like using emacs because I work with a bunch of different languages and it means I don't have to have three different editors open at once, plus I get basically the same interface when I work remotely.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
IDE regex replacement is usually not nearly as powerful or easy to use as vim/emacs', though.

And personally I like emacs because it's sort of like an OS-agnostic shell. I can get terminals in there, a bunch of apps that work great in text-mode are in there, and since my config is synced across all my machines I get the same experience on any machine after a couple of git clones.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

sarehu posted:

Well, like, most automatable refactorings seem to be of that nature. For example if I want to replace foo(x, y, z) with foo(blah(x.t), y, z), because foo takes a different type and the conversion with blah is correct (it used to be inside foo) -- can one not do this in an IDE?

Usually stuff like resharper is better about refactoring than just doing regex replacement. Regex can blow up if say two classes have the same method names, and you only want to change the name of one of the methods, or you do something like change a method to a property - resharper will only rename the method of the class rather than all strings with that method name.

sarehu
Apr 20, 2007

(call/cc call/cc)
I'm not talking about regex at all. I'm talking about AST patterns, replacing foo(X,Y,Z) with foo(blah(X.t),Y,Z) where the only replacements happen are the ones that resolve to a specific function foo. Or I guess those that did resolve but are now broken, if you changed foo first...

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

I don't know of any that even let you search on AST expressions, let alone replace them.

FamDav
Mar 29, 2008

Subjunctive posted:

I don't know of any that even let you search on AST expressions, let alone replace them.

i'd qualify that with granular control over the search/replace. when i search for a method named fartz in intellij, rename it to buttz, and have it drop the second parameter from all call sites (and clean up any unused variables that have resulted) then i am most certainly searching over the backing AST that intellij has built up.

brap
Aug 23, 2004

Grimey Drawer
I just haven't witnessed this productivity boon from command line text editors. I haven't had the opportunity. I see a lot of people jumping on the command line text editor train, then having to google whenever they need to do something they forgot the key combo for because the tool they're using is basically user-hostile and has zero discoverability.

I am sure someone out there has all the key combos in their head like a goddamn Mozart of code and manipulates text very quickly. I'm still skeptical that it's that big of a benefit when we all would likely benefit from writing less code and thinking more in our industry anyway. That is to say, how fast you can type is probably not your limiting factor as a programmer.

IDEs and GUI text editors have keyboard shortcuts. Lots of them have pretty powerful keyboard based text manipulation. Visual debugging is a tremendous quality of life improvement over command line debugging as well.

brap fucked around with this message at 01:18 on Jan 23, 2016

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

FamDav posted:

i'd qualify that with granular control over the search/replace. when i search for a method named fartz in intellij, rename it to buttz, and have it drop the second parameter from all call sites (and clean up any unused variables that have resulted) then i am most certainly searching over the backing AST that intellij has built up.

Sure, I just mean that you can't really give it an AST expression like the one described above, meaning something like "calling B with a parameter of the member X of type Y". It will search for certain kinds of symbols, but not syntax patterns AFAICT. I haven't looked at the intellij source to see what it uses to back that operation up, but I'd naively have guessed that it was just a set of indexes rather than an AST. That's interesting.

(I don't know what "granular control" actually means.)

E:

fleshweasel posted:

I just haven't witnessed this productivity boon from command line text editors.

You mean like sed? Nobody edits at the command line, they just use editors that are rendered with different UI symbols. Emacs doesn't change capabilities when you pop it out into a Quartz window (and you can have a menu bar and mouse support even with it inside a terminal window).

fritz
Jul 26, 2003

fleshweasel posted:

I just haven't witnessed this productivity boon from command line text editors. I haven't had the opportunity. I see a lot of people jumping on the command line text editor train, then having to google whenever they need to do something they forgot the key combo for because the tool they're using is basically user-hostile and has zero discoverability.

I used emacs/xemacs pretty much exclusively for 20+ years, and it's my go-to text editor for everything except c, c++, and java, but wow is it not a ton of fun for editing multiple files at once.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

fleshweasel posted:

I just haven't witnessed this productivity boon from command line text editors. I haven't had the opportunity. I see a lot of people jumping on the command line text editor train, then having to google whenever they need to do something they forgot the key combo for because the tool they're using is basically user-hostile and has zero discoverability.

This is basically how you learn to use the tool in the first place. After you know the fundamentals, learning consists of identifying something that's slow/annoying to do the manual way, and then determining a faster way to do it. If it's something you do often, you usually don't have to look it up again.

Expecting people to be immediately more productive without first learning how to use the thing in the first place is kinda dumb. It'd be like having an experienced programmer switch from C to Java and then wondering why they're not suddenly more productive and are instead spending half their time looking up APIs.

quote:

I am sure someone out there has all the key combos in their head like a goddamn Mozart of code and manipulates text very quickly. I'm still skeptical that it's that big of a benefit when we all would likely benefit from writing less code and thinking more in our industry anyway. That is to say, how fast you can type is probably not your limiting factor as a programmer.

My programming time typically alternates between thinking of the best way to achieve something, and then mechanically turning that headspace design into actual code. The faster I can do the latter, the more time I can spend on the former. If you're a multitasking savant that can focus on both the thinking and the typing at the same time then more power to you, I guess.

quote:

IDEs and GUI text editors have keyboard shortcuts. Lots of them have pretty powerful keyboard based text manipulation. Visual debugging is a tremendous quality of life improvement over command line debugging as well.

If you think that using vim or emacs means you have to use command-line gdb instead of a graphical debugger, you're completely wrong.

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that
Vim to me is just a set of keybindings. Which is great because everything under the sun seems to have some version that ports in those keybindings. Even things unrelated to programming.

Adbot
ADBOT LOVES YOU

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I don't know if you've ever used emacs because to say that it has "zero discoverability" suggests that you've never touched it.

Yes, emacs has some crazy keyboard shortcuts for you and you can of course assign your own to things you do a lot. But it also has, essentially, a command line (M-x) which lets you type some words which you think might describe the task you want to do, and it helpfully shows you the keyboard combo for those commands (if one exists). I have a lot of things in my emacs that I only access through that interface.

Imagine if, instead of hunting through menus to find the option for "open debugger window" (was that in View, or Window, or Debug? Which submenu of those menus might it be in?) you just typed "debug window" and every command that contained those words showed up.

Wondering what a certain variable in the editor does, or a function, or whatever? There's a help page for it. It's trivial to document any of the extensions, which is why it calls itself a "self-documenting text editor".

Yes there's a learning curve. every editor has one. I just decided to invest that time and energy into an editor which so far has stood the test of time and will probably still be around and still have a working version for whatever OSes we're using in 20 years. Assuming we're still editing text then, I guess.

I still use Visual Studio for C# and I still use Xcode for Swift because yes those are much better integrated with the development workflows for their languages, but those aren't the only text files I ever have to manipulate. Emacs works with Clojure like a dream. And occasionally I need to edit a configuration file, in XML or some other format. I'm sure as hell not doing that in visual studio.

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