|
Sockser posted:Hey thread, I got a lovely bachelor's in computer science and at work I develop internal tools where nobody else will ever look at my code until I leave the company so I never really get feedback other than "it does/n't work" What exactly do you do? Java? Ruby? MUMPS? Do you have other co-workers to do code reviews with even if they are on another team? I also suggest reading a few good books. The first book I read on software as a craft was The Pragmatic Programmer. It's fairly language agnostic (I think there's some C++) but it talks about writing good clean code. Some other books I've read and enjoyed are Code Complete and Head First Design Patterns. I'm also reading Art of Unit Testing and it's written for .NET developers I think there is enough wisdom that would apply to at least Java. Also, try to get involved with your local user groups. EDIT: Added Art of Unit Testing
|
# ? Dec 17, 2013 20:15 |
|
|
# ? Jun 1, 2024 05:09 |
|
Suspicious Dish posted:In the same vein, I've seen a bug that manifested with (a && b) * 100. Don't write clever code. Let me guess - it was a single-boolean test with a macro like "IS_FOO * 100" and IS_FOO got redefined to a && b without parens, which left it as a && b * 100. Close?
|
# ? Dec 17, 2013 20:21 |
|
PleasingFungus posted:This is all really terrible code, though, and more languages should discourage you from writing it! Surely it's okay in some contexts? Is it really so bad to, e.g., take the mean of a list of bools in order to get a percentage? \/ \/ \/ Thank you. SurgicalOntologist fucked around with this message at 20:59 on Dec 17, 2013 |
# ? Dec 17, 2013 20:24 |
|
Multiplying by booleans is perfectly concise and natural, e.g. http://en.m.wikipedia.org/wiki/Kronecker_delta and if you think it's terrible code you need to get out
|
# ? Dec 17, 2013 20:33 |
|
Sockser posted:How do I learn to be a better programmer and avoid doing dumb poo poo that crops up in this thread? Do the dumb poo poo, have things break horifically, learn why it's dumb. Reading this thread/books/Pollyanna's posting will only get you so far, there's no real trick to programming. Practice.
|
# ? Dec 17, 2013 20:36 |
|
Sockser posted:Hey thread, I got a lovely bachelor's in computer science and at work I develop internal tools where nobody else will ever look at my code until I leave the company so I never really get feedback other than "it does/n't work" Quit and find a better job. Seriously. If you're always the smartest person in the room and you're not Dennis Ritchie or something, or you're in an area where there's no one you can really collaborate with, and you don't feel that you can really push yourself to improve on a continuous basis without any sort of outside forces, then you should move somewhere where there are outside forces. You should always be wary about picking up bad habits from crappy developers who advocate using println instead of the debugger because "it's too hard", etc. If, for whatever reason, you can't quit, you should do what others suggest and work on public projects, get involved in your programming community, have peers/mentors discuss what you do, etc.
|
# ? Dec 17, 2013 20:53 |
|
seiken posted:Multiplying by booleans is perfectly concise and natural, e.g. http://en.m.wikipedia.org/wiki/Kronecker_delta and if you think it's terrible code you need to get out See, this kind of poo poo is why mathematicians write the worst code. From work, found this piece of brilliant code yesterday. Before you read the below, think: how, using Python's tempfile library, would you create a temporary file to upload to Amazon S3? Would you perhaps write this? Python code:
Nah, too simple. This is what I found: Python code:
|
# ? Dec 17, 2013 21:16 |
|
Suspicious Dish posted:It's quite rare that you ever see zero voltage across a wire, even if it's treated as a logical zero. Real-world physics is dope, yo. So you are saying that bools should coerce to floats and we have functions that compare them with an epsilon like nearlyTrue and nearlyFalse?
|
# ? Dec 17, 2013 21:17 |
|
I've found being too comfortable is a good way to get extremely complacent. It's only when you're exposed to new things or have to adhere to a new standard that you can grow. I had no loving clue how OOP and classes and dependency injection could help you out in a complex or big project until I got on a big, complex project. I didn't have a clue why you'd want layers of classes passing poo poo around, or why you'd want to inject one into the other. IoC was also a loving mystery. Now I wonder why the hell you wouldn't do it for anything in production or for testing, since there's free poo poo you can download that does a lot of it for you. I think the problems are lack of education on the subject as much as the names not being very descriptive.
|
# ? Dec 17, 2013 21:18 |
|
seiken posted:Multiplying by booleans is perfectly concise and natural, e.g. http://en.m.wikipedia.org/wiki/Kronecker_delta and if you think it's terrible code you need to get out But you don't write (i = j) * 2, you write \delta_{ij} * 2. The analogy would be if you wrote boolToInt(i == j) * 2, which isn't unreasonable. Also don't take style advice from math unless you use single letter variable names and have a roughly 4:1 comment:LOC ratio.
|
# ? Dec 17, 2013 21:29 |
|
Hughlander posted:So you are saying that bools should coerce to floats and we have functions that compare them with an epsilon like nearlyTrue and nearlyFalse? It's a trick question since you're likely to only get 10bit ADC across 5V so anything under 5mV wouldn't even show up on that.
|
# ? Dec 17, 2013 21:33 |
|
Hughlander posted:So you are saying that bools should coerce to floats and we have functions that compare them with an epsilon like nearlyTrue and nearlyFalse? Or, alternately, he might be saying that there isn't any real 'fundamental connection' between 1/0 and true/false, even in the context of EE. Your way is funnier, though.
|
# ? Dec 17, 2013 21:44 |
|
gariig posted:What exactly do you do? Java? Ruby? MUMPS? Do you have other co-workers to do code reviews with even if they are on another team? I also suggest reading a few good books. The first book I read on software as a craft was The Pragmatic Programmer. It's fairly language agnostic (I think there's some C++) but it talks about writing good clean code. Some other books I've read and enjoyed are Code Complete and Head First Design Patterns. I'm also reading Art of Unit Testing and it's written for .NET developers I think there is enough wisdom that would apply to at least Java. Also, try to get involved with your local user groups. Volmarias posted:Quit and find a better job. Because I develop internal tools, I get to write whatever the hell I want. A lot of what I do is C# simply because I inherited a lot of C# code. And I've worked to improve a lot of that, which recently went from scrapping one huge project (~45000 lines of code) and rewriting it (down to a nice, maintainable, ~1200 including unit tests) so it's not like I'm not actively engaging myself in writing good code or anything like that, I loving hate the majority of code that gets written here even in our release stuff (I'm one of maybe a dozen people in the company with a CS degree and not an engineering degree if that says anything) I'm just looking for ways to expose myself to like, I dunno, higher concepts of CS and poo poo? Like that big discussion of strong vs weak typing that came up the last couple pages. My degree didn't cover that and I could almost guarantee I'd never come across that at work but I want to learn more about uh.... something? I'm finding it hard to eloquently state what I mean here.
|
# ? Dec 17, 2013 21:45 |
|
Work on other open source projects.
|
# ? Dec 17, 2013 21:47 |
|
Hughlander posted:So you are saying that bools should coerce to floats and we have functions that compare them with an epsilon like nearlyTrue and nearlyFalse? We're seeing the birth of the weak/dynamic truth concept that brings us closer to quantum computing. Sockser posted:Because I develop internal tools, I get to write whatever the hell I want. Personally I write something and think "all right, it works, I'm brilliant!!" and then come back to it about two weeks of reading this thread later and go "holy poo poo, I'm awful!!" and refactor it until it fits what I've learned. Then I rinse and repeat until it stops happening. Obviously I exclusively code in bash with occasional GNU coreutils usage. Tesseraction fucked around with this message at 23:07 on Dec 17, 2013 |
# ? Dec 17, 2013 23:04 |
|
Zombywuf posted:Any language where you can't do: I'm not sure exactly who or what you're replying to, but this compiles just fine in C++ and as C (with appropriate typedefs added to the structs).
|
# ? Dec 18, 2013 02:40 |
|
PleasingFungus posted:See, this kind of poo poo is why mathematicians write the worst code. If knowing how to use a Kronecker delta means that you write the worst code then I guess all scientists and engineers write the worst code (I'm not disagreeing) Deus Rex posted:I'm not sure exactly who or what you're replying to, but this compiles just fine in C++ and as C (with appropriate typedefs added to the structs). He's replying to the weak vs strong typing discussion by providing a great example of weak typing and suggesting that any language that can't do the same is not weakly typed. He's not saying that it's bad code or that it won't compile
|
# ? Dec 18, 2013 06:48 |
|
This is not a Coding Horror. I just want to put this out there for the people who care about women in tech. Open Source Interns Outperform Industry Heavyweights In Linux Kernel Contributions I've never been prouder of my coworkers in my life.
|
# ? Dec 18, 2013 07:55 |
|
Multiplying single booleans is a little weird, but say elementwise multiplication of an array of booleans by an array of something else doesn't seem that weird.
|
# ? Dec 18, 2013 09:17 |
|
Surprised nobody posted this: http://www.secalert.net/2013/12/13/ebay-remote-code-execution/ and a followup: http://gynvael.coldwind.pl/n/ebay_rce_analysis_wrong_question_mark Basically eBay uses eval(). (The guy seems to be wrong about how PHP strings work though, the real horror is eBay)
|
# ? Dec 18, 2013 10:51 |
|
QuarkJets posted:I think that having False and True be represented by integers has become so ingrained in so many languages in different ways too quote:In VB 6, True has a numeric value of -1. False has a numeric value of 0.
|
# ? Dec 18, 2013 11:04 |
|
So I finally found something worth posting:code:
|
# ? Dec 18, 2013 11:15 |
|
tef posted:in different ways too Oh no what have I done I like them being represented as integers but this... Also how is "True = Not False" equivalent to "-1 = Not 0". 1 is "Not 0" in boolean logic in the most basic of circuitry and even if you went with their wacky logic wouldn't "-1 = Not 1". I have no idea to the reasoning behind that part (the reasoning between true being 11111111 and false being 00000000 is a whole 'nother set of garbage imo) Edit: vvv I'm a moron Jewel fucked around with this message at 11:28 on Dec 18, 2013 |
# ? Dec 18, 2013 11:16 |
|
Um yeah, the fact that it's bitwise not is the reason.
|
# ? Dec 18, 2013 11:20 |
|
Jewel posted:I have no idea to the reasoning behind that part http://en.wikipedia.org/wiki/Two%27s_complement
|
# ? Dec 18, 2013 11:52 |
|
Opinion Haver posted:But you don't write (i = j) * 2, you write \delta_{ij} * 2. The analogy would be if you wrote boolToInt(i == j) * 2, which isn't unreasonable. This kind of failure to be comfortable with the most basic rules of your language is why we end up with poo poo like if (bool_value == true) ....
|
# ? Dec 18, 2013 11:54 |
|
Ornedan posted:I'm not sure that Haskell should be called weakly typed, though. If the shoe fits :-) QuarkJets posted:He's replying to the weak vs strong typing discussion by providing a great example of weak typing and suggesting that any language that can't do the same is not weakly typed. He's not saying that it's bad code or that it won't compile Yeah that.
|
# ? Dec 18, 2013 12:26 |
|
Weak typed is just an ill-defined term. Maybe it means "has tons of idiotic implicit conversions". How many? Who knows.
|
# ? Dec 18, 2013 12:27 |
|
Sockser posted:I'm just looking for ways to expose myself to like, I dunno, higher concepts of CS and poo poo? Like that big discussion of strong vs weak typing that came up the last couple pages. My degree didn't cover that and I could almost guarantee I'd never come across that at work but I want to learn more about uh.... something? The joke is that strong typing and weak typing are not well defined terms. Everyone has their own idea of what they mean, so don't feel bad if you don't get it; just make up your own definitions and play along. Otherwise, just read stuff. Sadly it's hard to find places on the Internet where people discuss programming in any kind of depth any more, caring about programming has become incredibly passe. This thread is actually one of the more knowledgeable parts of the web.
|
# ? Dec 18, 2013 12:31 |
|
Zombywuf posted:The joke is that strong typing and weak typing are not well defined terms. Everyone has their own idea of what they mean, so don't feel bad if you don't get it; just make up your own definitions and play along. Just get a job on the C# or Java language development teams, and you can spend all of your time discussing this and other exciting issues! may or may not be accurate
|
# ? Dec 18, 2013 12:43 |
|
tef posted:in different ways too Visual Basic .NET code:
code:
|
# ? Dec 18, 2013 13:23 |
|
The "0 false, -1 true" convention has been used by Forth for a very long time. Words which consume a boolean value typically accept 0 as false and anything nonzero as true, while operators such as < produce 0/-1 "flags". Part of the justification for the feature is that by doing bitwise operations on flags you can remove some branches, as in the following idiom:code:
|
# ? Dec 18, 2013 15:37 |
|
There's pretty much nothing worse than maintaining a codebase where someone decided to play code golf the entire time they were working on it. That's all I see when I look at those sorts of statements.
|
# ? Dec 18, 2013 15:40 |
|
ninjeff posted:A weird result of this in VB, even today:
|
# ? Dec 18, 2013 17:17 |
|
shrughes posted:Weak typed is just an ill-defined term. Maybe it means "has tons of idiotic implicit conversions". How many? Who knows. Perhaps it's because English is weak-typed.
|
# ? Dec 18, 2013 17:45 |
|
Amarkov posted:Just get a job on the C# or Java language development teams, and you can spend all of your time discussing this and other exciting issues! My fourth stint as a co-op at my current employer was as a developer intern, and our weekly meetings usually consisted of such, and I just kinda sat there with no idea what was going on. And now I sit next to those same dudes and hear it every day and have no idea what the gently caress they're ever talking about.
|
# ? Dec 18, 2013 17:57 |
|
Sockser posted:And now I sit next to those same dudes and hear it every day and have no idea what the gently caress they're ever talking about. Your mistake may be assuming that they do tbh though, a dev meeting is almost certainly tied entirely to the codebase people are working on - the only way to understand the conversations would be to dive into the codebase and ask questions.
|
# ? Dec 18, 2013 18:13 |
|
I found an use for everybody's favorite Unicode characterObjective-C code:
E: Suspicious Dish posted:In the same vein, I've seen a bug that manifested with (a && b) * 100. Don't write clever code. !!(a && b) * 100 E2: shrughes posted:Um yeah, the fact that it's bitwise not is the reason. In fact all operators in (Visual)Basic were bitwise. This is why And/Or don't short-circuit, hence the new logical operators AndAlso/OrElse introduced in VisualBasic.NET hackbunny fucked around with this message at 20:24 on Dec 18, 2013 |
# ? Dec 18, 2013 20:14 |
|
People get all emotional when you start calling their language "weak", and smug when their language is "dynamic".
|
# ? Dec 18, 2013 20:54 |
|
|
# ? Jun 1, 2024 05:09 |
|
Hughlander posted:So you are saying that bools should coerce to floats and we have functions that compare them with an epsilon like nearlyTrue and nearlyFalse? https://www.youtube.com/watch?v=yzitqjUI6ok
|
# ? Dec 18, 2013 22:13 |