Xarn 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. Joda fucked around with this message at 12:41 on Jul 16, 2019 |
|
# ? Jul 16, 2019 12:39 |
|
|
# ? Jun 1, 2024 17:24 |
|
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."
|
# ? Jul 16, 2019 12:46 |
|
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 ) e2: C++ code:
Xarn fucked around with this message at 13:26 on Jul 16, 2019 |
# ? Jul 16, 2019 13:14 |
|
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 |
# ? Jul 16, 2019 13:38 |
|
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!
|
# ? Jul 16, 2019 14:14 |
|
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!
|
# ? Jul 16, 2019 15:36 |
|
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?
|
# ? Jul 17, 2019 03:26 |
|
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.
|
# ? Jul 17, 2019 03:32 |
|
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.
|
# ? Jul 17, 2019 04:17 |
|
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.
|
# ? Jul 17, 2019 04:19 |
|
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.
|
# ? Jul 17, 2019 04:34 |
|
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:
|
# ? Jul 17, 2019 11:59 |
|
How do you even type Agda code outside of emacs? Copying and pasting unicode characters from a big table?
|
# ? Jul 17, 2019 13:46 |
|
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.
|
# ? Jul 17, 2019 14:02 |
|
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.
|
# ? Jul 17, 2019 15:07 |
|
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.
|
# ? Jul 17, 2019 15:17 |
|
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.
|
# ? Jul 17, 2019 15:41 |
|
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)?'
|
# ? Jul 17, 2019 15:55 |
|
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
|
# ? Jul 17, 2019 17:04 |
|
xtal posted:You're supposed to run agda inside emacs :shh: Volte posted:How do you even type Agda code outside of emacs? Copying and pasting unicode characters from a big table?
|
# ? Jul 17, 2019 17:37 |
|
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.
|
# ? Jul 17, 2019 17:40 |
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.
|
|
# ? Jul 17, 2019 17:57 |
|
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.
|
# ? Jul 17, 2019 18:05 |
|
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 |
# ? Jul 17, 2019 18:38 |
|
Look at this guy who's never had to debug a race condition in the wild
|
# ? Jul 17, 2019 18:43 |
|
e: double post
|
# ? Jul 17, 2019 18:43 |
|
Look at this guy on a platform where a debugger exists
|
# ? Jul 17, 2019 18:44 |
|
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.
|
# ? Jul 17, 2019 18:56 |
|
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
|
# ? Jul 17, 2019 19:02 |
|
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.
|
# ? Jul 17, 2019 19:07 |
|
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.
|
# ? Jul 17, 2019 19:11 |
|
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.
|
# ? Jul 17, 2019 19:52 |
|
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.
|
# ? Jul 17, 2019 20:37 |
|
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.
|
# ? Jul 17, 2019 20:39 |
|
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.
|
# ? Jul 17, 2019 21:47 |
|
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. how could we be so foolish
|
# ? Jul 17, 2019 22:01 |
|
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 So "yes" then to the second possibility I offered in what you quoted, plus a side of being unnecessarily dickish
|
# ? Jul 17, 2019 22:25 |
|
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.
|
# ? Jul 18, 2019 01:24 |
|
"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.
|
# ? Jul 18, 2019 01:37 |
|
|
# ? Jun 1, 2024 17:24 |
|
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.
|
# ? Jul 18, 2019 01:41 |