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
Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

Xarn posted:

C++ code:
for (int i = 0; i < carry.size(); i++)
    ps_rem.push_back(carry[i]),
    Cs_rem.push_back(1);

How does this even compile? Is this like the final boss trick for avoiding brackets on your for loops? (btw my biggest pet peeve is people not using brackets on their single statement for loops.

Joda fucked around with this message at 12:41 on Jul 16, 2019

Adbot
ADBOT LOVES YOU

Ola
Jul 19, 2004

Joda posted:

How does this even compile? Is this like the final boss trick for avoiding brackets on your for loops? (btw my biggest pet peeve is people not using brackets on their single statement for loops.

"The professor said we should try to write functional code and brackets are imperative."

Xarn
Jun 26, 2015
The comma operator is hell of a drug.

Also agreed, write the loving brackets on your single statement ifs/fors/whiles/etc.

e: found 4 more of these beauties, but at least the std_err bool is given as an argument this time (find usage tells me that it is always defaulted to false :shrug:)

e2:

:suicide:
C++ code:
void PBConstraint::printGeq(bool std_err) const
{

    ...

  if(stderr) cerr << " >= " << -leq << " ;" << endl;
  else cout << " >= " << -leq << " ;" << endl;
}

Xarn fucked around with this message at 13:26 on Jul 16, 2019

EssOEss
Oct 23, 2006
128-bit approved

CPColin posted:

A class to abstract away DateTime.Now! Because we can't just make now a function parameter or anything!

You'll change your mind once you need to work on your first piece of timing-dependent code. Abstracting "the current time" away is one of the best moves you can make toward testability of timing-dependent code! (Also "delay for X duration" and "how long has it been" are amazingly valuable abstractions). You can't do this by passing arguments, beyond trivial cases.

EssOEss fucked around with this message at 13:43 on Jul 16, 2019

Absurd Alhazred
Mar 27, 2010

by Athanatos

EssOEss posted:

You'll change your mind once you need to work on your first piece of timing-dependent code. Abstracting "the current time" away is one of the best moves you can make toward testability of timing-dependent code! (Also "delay for X duration" and "how long has it been" are amazingly valuable abstractions). You can't do this by passing arguments, beyond trivial cases.

Don't forget pausing!

CPColin
Sep 9, 2003

Big ol' smile.

EssOEss posted:

You'll change your mind once you need to work on your first piece of timing-dependent code.

I am at least a 3x developer; I will never change my mind about anything!

qsvui
Aug 23, 2003
some crazy thing

Ola posted:

"The professor said we should try to write functional code and brackets are imperative."

Is it really a thing nowadays that professors for intro to programming courses teach functional styles?

xtal
Jan 9, 2011

by Fluffdaddy

qsvui posted:

Is it really a thing nowadays that professors for intro to programming courses teach functional styles?

The thing you're quoting, while funny, is obviously not a thing. But Haskell and Scheme are common first languages in academia. Maybe this is because people just learned lambda calculus, but I'm pulling that out of my rear end.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I once helped an intern with his second semester course, which was based on agda. loving agda. As an undergrad programming course. Half of the course was taken up with setting up zsh.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Functional programming is much easier to learn if you don't have to unlearn imperative programming first. I think the transition from functional to imperative isn't as bad, but I'm not so sure about that.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
Tbh functional programming is better suited for the concepts required for a 4 year or graduate CS degree but the real horror is companies asking for a 4 year CS degree when they could hire a candidate with a 2 year or trade degree to do the tasks they require.

xtal
Jan 9, 2011

by Fluffdaddy

dougdrums posted:

I once helped an intern with his second semester course, which was based on agda. loving agda. As an undergrad programming course. Half of the course was taken up with setting up zsh.

You're supposed to run agda inside emacs :shh:

Volte
Oct 4, 2004

woosh woosh
How do you even type Agda code outside of emacs? Copying and pasting unicode characters from a big table?

iospace
Jan 19, 2038


ultrafilter posted:

Functional programming is much easier to learn if you don't have to unlearn imperative programming first. I think the transition from functional to imperative isn't as bad, but I'm not so sure about that.

Functional programming is fine to learn, even if you learned imperative, if you think of them like math functions as opposed to a traditional program function. You know math functions will always have the same output based on the a given input, and once you realize that functional programming is like that, it's much easier to take.

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

iospace posted:

Functional programming is fine to learn, even if you learned imperative, if you think of them like math functions as opposed to a traditional program function. You know math functions will always have the same output based on the a given input, and once you realize that functional programming is like that, it's much easier to take.

Excepting that quite a few folks who started imperative never learned the formal math, or have since forgotten it like so much else. The trouble with the imperative->functional transition isn't in a single word, it's in disassembling an understanding of the actual shape and flow of software. If anything, the thing that can help is also having really deconstructed imperative thinking first with some good old declarative stuff like lots of SQL work - where you (should) get your wrist slapped for trying to do explicit iteration over result sets.

Jewel
May 2, 2009

What mostly fucks me up personally is I've had such a deep history with all the internals of things, hovering from C++ down to bytecode, so when I try to wrap my head around functional programming I often hit a wall of finding it hard to parse how something works, since it's not structured in a similar way to how the actual cpu is operating. A good example of this is stuff like infinite lists or how most things prefer recursion.

Ruggan
Feb 20, 2007
WHAT THAT SMELL LIKE?!


Cuntpunch posted:

Excepting that quite a few folks who started imperative never learned the formal math, or have since forgotten it like so much else. The trouble with the imperative->functional transition isn't in a single word, it's in disassembling an understanding of the actual shape and flow of software. If anything, the thing that can help is also having really deconstructed imperative thinking first with some good old declarative stuff like lots of SQL work - where you (should) get your wrist slapped for trying to do explicit iteration over result sets.

I especially agree with your last sentence. I work with SQL daily, and one thing that it has really helped me with in moving into other languages is understanding the concept of set-based operations and their benefit over loops/cursors. Especially when it comes to performance and set based operations can run multithreaded as chunks whereas loops and cursors need to run sequentially.

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

Jewel posted:

What mostly fucks me up personally is I've had such a deep history with all the internals of things, hovering from C++ down to bytecode, so when I try to wrap my head around functional programming I often hit a wall of finding it hard to parse how something works, since it's not structured in a similar way to how the actual cpu is operating. A good example of this is stuff like infinite lists or how most things prefer recursion.

Yeah, for folks *super* comfortable in imperative land, there's definitely a nagging feeling of 'but...this MUST just be creating a loop under the hood. so what do I really get from this that I can't do in (my language of choice)?'

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
some people like that style of declarative programming where you express what you want instead of how to do it. i can't add print statements to it so i get angry

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

xtal posted:

You're supposed to run agda inside emacs :shh:
Yeah the setup for the course required using zsh inside of emacs. I can't remember why though. He was having issues with not having the fonts, terminal encoding, auto-completion, etc. But it looks like you can just install everything from the respective package managers now.

Volte posted:

How do you even type Agda code outside of emacs? Copying and pasting unicode characters from a big table?
You can use custom ime tables, like there's a latex one for fcitx available. Of course you'd still need emacs for the interactive stuff.

iospace
Jan 19, 2038


Cuntpunch posted:

Excepting that quite a few folks who started imperative never learned the formal math, or have since forgotten it like so much else. The trouble with the imperative->functional transition isn't in a single word, it's in disassembling an understanding of the actual shape and flow of software. If anything, the thing that can help is also having really deconstructed imperative thinking first with some good old declarative stuff like lots of SQL work - where you (should) get your wrist slapped for trying to do explicit iteration over result sets.

That's also true. When we had a class that taught us a bunch of languages and their quirks, I was probably one of the few that actually was able to wrap their head around F#. I had been exposed a little to Haskell prior, but functional really didn't click until that moment.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

Ruggan posted:

I especially agree with your last sentence. I work with SQL daily, and one thing that it has really helped me with in moving into other languages is understanding the concept of set-based operations and their benefit over loops/cursors. Especially when it comes to performance and set based operations can run multithreaded as chunks whereas loops and cursors need to run sequentially.

Well ultimately you can do these things with imperative programming as well by chunking your data, using hash maps to make lookups faster or whatever, and ultimately you can end up making execution faster than any abstraction would ever be able to, but the abstractions are still wildly useful. Interacting with a database in an abstract way based on set operations makes a whole lot more intuitive sense, and whoever makes the abstractions can make enough assumptions that 99.999% of the time the trade-off between performance, dev time and maintainability is so heavily in favour of using the abstraction, that no one should ever really consider doing their database interactions in imperative programming (except the business logic in my opinion, because business logic in SQL always ends up being uneradable.)

I imagine it's much the same with functional programming, but because it's less ubiquitous, a lot of people (including myself) are not familiar enough with it to know when to use it, and if we did it'd probably be a bad idea because such a small amount of people would be able to maintain it effectively.

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.

Suspicious Dish posted:

some people like that style of declarative programming where you express what you want instead of how to do it. i can't add print statements to it so i get angry

any kind of programming where you write a bunch of code to set up a pipeline and you'll know if it worked or not later when the poo poo actually runs sucks rear end to debug, and declarative programming does that in spades. i hate working with anything that i can't println debug.

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop
Do people still do print-based debugging because they don't know about logpoints, or because their IDE just doesn't have them? Modifying your code to do debugging sucks.

More in general, sometimes this thread gives me the impression that there senior developers are out there that just aren't fully using their integrated debugging features.

For me, finding a bug is usually a painless and pleasant process because of how much help I get from DevTools (or previously, Visual C++). It even usually involves only mouse interactions..... hovering the mouse over variable names or entire expressions while stopped at a breakpoint (at the earliest moment I can find that the program state went wrong) until you find something with a wrong value. Clicking a different call stack frame to bring it into focus. I revert to prints only when some entire process I made is so hosed up that I have to get the entire program to narrate itself to me, and even for that there's logpoints so there's no need to change the code or risk leaving debugging lines in.

Each IDE offers some more help in a way that's unique to them, too. Visual C++ (unlike XCode, last I checked) lets you move the instruction pointer around while the program is running so you can repeat the code that just crashed without having to wait for the crash state to happen. Chrome DevTools lets you put multiple breakpoints per line, for example to break during lambda expressions that are passed in as arguments.

\/\/\/ Would logpoints not help with that?

Happy Thread fucked around with this message at 18:46 on Jul 17, 2019

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Look at this guy who's never had to debug a race condition in the wild

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop
e: double post

Qwertycoatl
Dec 31, 2008

Look at this guy on a platform where a debugger exists

MrMoo
Sep 14, 2000

ECS is a thing, such utter balls to debug on. Log too much it crashes, and the CloudWatch UI is really bad to view like a 10 line fragment of log. You cannot download the full log, and it throws away log after a while too. Awesome.

Real-time × debugging is constantly amazeballs.

I’ve debugged via broadcast news TV too, so idk I’m a bit unconventional.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Dumb Lowtax posted:

Do people still do print-based debugging because they don't know about logpoints, or because their IDE just doesn't have them? Modifying your code to do debugging sucks.

logpoints are way too slow for me

iospace
Jan 19, 2038


I usually do print based depending on what I'm writing.

A prior job that's all we really had available unless we wanted to set up a JTAG system and that was generally A. too much effort, B. limited in quantities to use, and C. only used for the serious poo poo.

ryde
Sep 9, 2011

God I love young girls
I've met a few so-called 10x engineers. Turns out that they did 1x of the work that gets the visibility and shipped the other 9x out to "maintenance programmers."

Their stuff was buggy messes that were unmonitored, unmaintainable spaghetti code, and perpetually days away from critical failure.

OddObserver
Apr 3, 2009
I don't think "no need to modify code" is much of an advantage --- this is something people in our profession typically have plenty of experience with, and I feel I am reasonably efficient at it --- and version control makes it easy to back stuff out. Dealing with a whole bunch of UI stuff is actually likely to be much slower for me except for the simplest cases.

Thermopyle
Jul 1, 2003

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

I'm an extensive user of the browser dev tools, but sometimes it's nice to throw some console.log's in there to get a...log of the various sections of the code that got hit over time without having to sit and click continue 400 times.

Thermopyle
Jul 1, 2003

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

That's a really nice thing about React+Redux...redux's time-traveling devtools extension.

If you're not familiar, with React and Redux, your UI is a function of your state and you modify that state with actions to change your UI and do business logic.

Redux's devtools extension logs every action that gets fired and shows you a diff of the applications state caused by that action, and you can roll your whole application back and forth in time by selecting any action.

Athas
Aug 6, 2007

fuck that joker

dougdrums posted:

Tbh functional programming is better suited for the concepts required for a 4 year or graduate CS degree

I am agitating for the opposite at my department! We teach light functional and object-oriented programming to first year bachelors students (and the latter is really mostly procedural programming and abstract data types), and I think we should move even more of the heavyweight OO to the masters program. It really does not make sense for the relatively small programs they write early in their education (and they don't have the experience to appreciate a large system in the abstract), while the FP techniques still work well at small scale.

JawnV6
Jul 4, 2004

So hot ...

Dumb Lowtax posted:

Do people still do print-based debugging because they don't know about logpoints, or because their IDE just doesn't have them? Modifying your code to do debugging sucks.
ah right, i forgot there's One Tool that is applicable to every dev niche ever and the only alternative is Fools. language? got all of em. distributed or embedded? w/e it's probably covered

how could we be so foolish

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop

JawnV6 posted:

ah right, i forgot there's One Tool that is applicable to every dev niche ever and the only alternative is Fools. language? got all of em. distributed or embedded? w/e it's probably covered

how could we be so foolish

So "yes" then to the second possibility I offered in what you quoted, plus a side of being unnecessarily dickish

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.

Dumb Lowtax posted:

Do people still do print-based debugging because they don't know about logpoints, or because their IDE just doesn't have them? Modifying your code to do debugging sucks.

println debugging, setting breakpoints etc. is not possible in certain situations. There's a whole spectrum of "debuggable" that ranges from "can be interactively debugged, change values on the fly and see what happens" to "I can't loving step this poo poo, but println", all the way down to "can't step, can't println" I ran into "can't step, can't println" all the loving time as a beginner with tensorflow because it's a declarative framework so you can be in position where you tell it to do a bunch of stuff, oh god it doesn't work and I have no idea why (it's possible to log using the framework itself but println won't work for that.) This is one thing to keep in mind when evaluating a framework - I generally try to avoid loving with poo poo I can't effectively interactively debug (e.g. when evaluating clojure, I noped out because there were no breakpoints and it just had println debugging.) Generally if I run into a category of problem I can't step, it's going to take longer than an ordinary problem and it's not going to be fun.

Kazinsal
Dec 13, 2011
"can't step, can printf, except the bug is that the machine stops responding to interrupts after a random period of inactivity generally in excess of 12 hours on that interrupt line, so I can't tell when or why it happens" is the one I'm dealing with right now.

I want to know what IDE can help me debug that.

Adbot
ADBOT LOVES YOU

Ola
Jul 19, 2004

I wonder when someone will inject some "soft science" into CS and do computer language linguistic studies of all the different cultures and their weird belief systems. Here is my functional take:

Nice: Learn to keep state in one place, let everything else just do whatever its told. Fewer bugs! Maybe.

Not nice: Professors get super hard academic boners from functional programming, they dream of hanging out with Haskell (curried 1900, un-curried 1982 RIP) and Alan, smoking tweed in pipes, drawing lambdas on blackboards, receiving awards that have beards and dandruff on them and perhaps not even touching a computer all the while because implementation is not very interesting. (implementation also means you have to admit that state actually exists at some point)

But most of it is not that different from a functional take in an otherwise imperative language and of course it all relies on what the hell it compiles to. (Or does it? Don't touch computers) One way to look at it is that a super strict type system makes you behave in a controlled, predictable way which a compiler can act super safe and super fast on. Wonderful in theory. (no "but in practice" punchline, because this is where the professor puts a full stop, gently caress practice, it's stateful).

I had a professor lost to this, he's a super brilliant guy and but he gets so lost in these onanistic whirlpools of tweed logic, he takes 20 hours to explain really quite simple concepts, struggling so hard to make it as greek as possible. I don't know enough to say exactly what's bad and how to make it better, but clearly there is some dream about a world free of bugs through mathematically provable software. But software doesn't go wrong because the math is bad, does it? It's because tower of Babel, a sarcastic metaphor that's 3000 years old or more, not because we've uncurried some monads we shouldn't have or been particularly stateful. How many billions of IQ points are stuck in tweed, hopelessly currying and uncurrying pipes, but haven't read single page of the history of ideas of anything that would help them understand what job software does in modern society. Hint: it's not provable math.

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