|
unnecessarily, dangerously clever code, according to rob pike:code:
|
# ? Oct 23, 2020 08:08 |
|
|
# ? May 30, 2024 01:26 |
|
redleader posted:unnecessarily, dangerously clever code, according to rob pike: According to the code block that's C#. I don't know C# well but this looks like valid Java too - if it was it would be a coding horror though. In Java, the String type has a capital S. This could would imply that someone made a custom string class starting with a lowercase which is all kinds of wrong and confusing.
|
# ? Oct 23, 2020 11:53 |
|
Carbon dioxide posted:According to the code block that's C#. I don't know C# well but this looks like valid Java too - if it was it would be a coding horror though.
|
# ? Oct 23, 2020 13:07 |
|
If it was Java they'd be instantiating an ArrayList instead of a List though.
|
# ? Oct 23, 2020 13:21 |
|
Is there type inference in java or c# or is using their equivalent of auto too advanced
|
# ? Oct 23, 2020 13:54 |
|
Both languages have the 'var' keyword, yes.
|
# ? Oct 23, 2020 13:59 |
|
Carbon dioxide posted:According to the code block that's C#. I don't know C# well but this looks like valid Java too - if it was it would be a coding horror though. Go actually supports built-in dynamic arrays called "slices" that behave kind of like C# Lists and Java ArrayLists (with a few additional tricks against backing arrays) and are used in the same kind of problems. But, more generally, Go hates constructors and wants to work with structs rather than objects. A new struct is given to you zeroed out - which wouldn't work for a like-for-like implementation of a Java ArrayList, because it has to instantiate the backing array and store a nonzero size. Instead, in Go, you need to make factory methods, and treat the "new" operator as an implementation detail in that factory method. Go takes a lot of ideas from object oriented languages, but it tries to sell itself as "post object oriented" - so, coming from Java, C#, or even C++, you end up with a lot of "what the hell, why won't it do that?" moments.
|
# ? Oct 23, 2020 15:53 |
|
Making it harder to enforce object invariants seems like something that belongs in this thread, yes.
|
# ? Oct 23, 2020 16:16 |
|
Carbon dioxide posted:According to the code block that's C#. I don't know C# well but this looks like valid Java too - if it was it would be a coding horror though. the joke is go hates generics
|
# ? Oct 23, 2020 21:42 |
|
more generally, the joke is go itself
|
# ? Oct 23, 2020 21:42 |
|
ironically, the more i have learned Rust and Haskell, the more i have moderated my scorn of Go; there's something to be said for obsessively prioritizing compilation speed at the cost of even obviously sensible language constructs.
|
# ? Oct 23, 2020 23:25 |
|
Doc Hawkins posted:ironically, the more i have learned Rust and Haskell, the more i have moderated my scorn of Go; there's something to be said for obsessively prioritizing compilation speed at the cost of even obviously sensible language constructs. I've often heard complaints about Rust's compilation speed, but I never really got them. Is there a particular type of code that compiles especially slowly or something? I've rarely had a project take more than 10-20 seconds to compile in Rust after it finishes downloading/and compiling the included stuff the first time. Normally if I'm iterating compilations for a project I am working on it hardly ever takes substantial time, and I've written like 10k+ line programs. (Admittedly my code is usually fairly simplistic math stuff)
|
# ? Oct 24, 2020 00:36 |
|
IIRC slowness tends to come from complicated types and macro usage. If you're doing mostly math it'll compile pretty quick. It's also definitely gotten better over time.
|
# ? Oct 24, 2020 00:44 |
|
necrotic posted:IIRC slowness tends to come from complicated types and macro usage. If you're doing mostly math it'll compile pretty quick. I only ever got as far as Data Structures in CS (all that my major called for), so I was never clear on this, what's the use case for macros vs other ways of achieving similar goals? The most common use case for macros I've seen in Rust is a variable number of arguments (eg for println! or format!), but if you really want such a thing I can imagine passing a vec of trait objects to a function that ensures everything has a .tostr() method. The other one that people often mention is generating actual code procedurally, which I've seen most commonly implemented for writing a scary version of generic code (for example generating typed functions that serve as wrappers for BLAS in order to hook up to a Fortran linked library). When I was looking at that library I was REALLY unclear on why they didn't go with a generic version of the code using some trait instead, since at compile time it should all boil down to the same thing. For me the platonic ideal of a situation where recursion leads to clean code that makes total sense is divide-and-conquer searching, and the platonic ideal of a situation where object-oriented code leads to clean code that makes total sense is linked lists (leaving aside the fact that linked lists are a bad idea 99% of the time) What's the platonic ideal of a situation where a macro leads to really clean code, but if you tried to do it with normal code you would get a giant mess? DearSirXNORMadam fucked around with this message at 01:43 on Oct 24, 2020 |
# ? Oct 24, 2020 01:14 |
|
Scala macros have been used to translate language constructs into typesafe representations of those constructs in other languages at compile time. One example is Slick, which turns Scala expressions into equivalent SQL code. There's also another for OpenCL that I can't remember off the top of my head which turns Scala expressions into shaders that can run on the GPU. Having SQL or GLSL embedded in with the rest of your codebase isn't that messy but it's nice to just have a plain old for loop that you pass to a special executor and poof it's running on your GPU without having to switch to glorified C.
|
# ? Oct 24, 2020 03:17 |
|
1337JiveTurkey posted:Scala macros have been used to translate language constructs into typesafe representations of those constructs in other languages at compile time. One example is Slick, which turns Scala expressions into equivalent SQL code. There's also another for OpenCL that I can't remember off the top of my head which turns Scala expressions into shaders that can run on the GPU. Having experience with Slick, it works but I find it a bit annoying to use. If you need more complicated queries you need to struggle quite a bit to get it to do what you want. And things can also get annoying once you want to make use of stuff that's not db engine agnostic.
|
# ? Oct 24, 2020 09:15 |
|
Soricidus posted:Ok, have fun going to the dentist who uses iron tongs and a sharp scraping stick, I’ll stick with professionals using modern sophisticated tools that might be dangerous in untrained hands but allow a skilled practitioner to do a better job. The dentist has gone thru a standardized training regimen and is licensed by the state.
|
# ? Oct 24, 2020 14:51 |
|
fritz posted:The dentist has gone thru a standardized training regimen and is licensed by the state. The more relevant difference, IMO, is that a dentist is very easy to hold accountable for any damage they cause. Lawyers are formally trained and licensed too, but they're quite capable of getting away with incompetence.
|
# ? Oct 24, 2020 18:08 |
|
fritz posted:The dentist has gone thru a standardized training regimen and is licensed by the state. Medical malpractice is a leading cause of death, not really a great example if you're trying to make credentialism sound like a good thing
|
# ? Oct 25, 2020 01:53 |
|
xtal posted:Medical malpractice is a leading cause of death, not really a great example if you're trying to make credentialism sound like a good thing Yeah, the death rate for hospital patients is also way higher than for the population in general. Stay home and write code instead!
|
# ? Oct 25, 2020 10:10 |
|
xtal posted:Medical malpractice is a leading cause of death, not really a great example if you're trying to make credentialism sound like a good thing Medical errors matter, but the studies that people cite for them being the third leading cause of death are pretty questionable.
|
# ? Oct 25, 2020 14:55 |
|
Coding malpractice: https://twitter.com/sandofsky/status/1321593104298725376
|
# ? Nov 1, 2020 07:30 |
|
tickets and coins
|
# ? Nov 1, 2020 08:25 |
|
Why would you want to let your currency work for both cosmetics AND cheating? Jeez.
|
# ? Nov 1, 2020 21:47 |
|
https://twitter.com/q3k/status/1322943395497680897
|
# ? Nov 2, 2020 01:31 |
|
OMG, this is a horror on so many levels
|
# ? Nov 2, 2020 09:11 |
|
wikipedia posted:Zhejiang Dahua Technology Co., Ltd. is a partially state-owned Chinese company which sells video surveillance products and services Wow. That's... terrifying.
|
# ? Nov 2, 2020 13:29 |
|
Working on updating a little web application that helps HR enter information when setting up a new employee. Nodding my head in approval at the hoops the code jumps through when it comes to things like SSN, where that column is encrypted in the web application's database; it's not re-populated in the form after the employee has been saved; and so on. The function that saves the form to the database dumps all the POSTed parameters into the application log, in plain text.
|
# ? Nov 2, 2020 19:28 |
|
Well how else would you debug it?
|
# ? Nov 2, 2020 23:45 |
|
code:
|
# ? Nov 5, 2020 22:53 |
|
ultrafilter posted:
this seems fine once i googled what rcpp was?
|
# ? Nov 5, 2020 22:58 |
|
C++ doesn't have named arguments. My code isn't the horror.
|
# ? Nov 5, 2020 23:03 |
|
gently caress, we use Dahua cameras.
|
# ? Nov 5, 2020 23:18 |
|
Database calculating accumulated of column - Quantities are euros User report the accumulated total is wrong in some report by 4 euros We check it 1) Column is float in the database (mysql)- Changing it to decimal(13 2) fix the 4 euros- but the total is still of by 21 cents- I guess float not good for money 2) The accumulated total is calculated with a session variable defined has @total:=0 ---- the fix is to change that to @total:=0.00 so it inherit a floating type instead of a integer?
|
# ? Nov 9, 2020 11:59 |
|
https://amp.theguardian.com/uk-news/2020/nov/06/companies-house-forces-business-name-change-to-prevent-security-riskquote:The company now legally known as “THAT COMPANY WHOSE NAME USED TO CONTAIN HTML SCRIPT TAGS LTD” was set up by a British software engineer, who says he did it purely because he thought it would be “a fun playful name” for his consulting business.
|
# ? Nov 9, 2020 17:04 |
|
Jeb Bush 2012 posted:https://amp.theguardian.com/uk-news/2020/nov/06/companies-house-forces-business-name-change-to-prevent-security-risk It's unclear if there was actually a vulnerability triggered, or if they were just being cautious.
|
# ? Nov 9, 2020 18:01 |
|
anything which can be destroyed by crafted input should be
|
# ? Nov 9, 2020 18:40 |
|
Doc Hawkins posted:anything which can be destroyed by crafted input should be mods, please change my username to '); DROP TABLE Goons; —
|
# ? Nov 9, 2020 18:49 |
i wonder how many countries you could evade taxes in if you were NULL, LLC
|
|
# ? Nov 9, 2020 19:33 |
|
|
# ? May 30, 2024 01:26 |
|
Jazerus posted:i wonder how many countries you could evade taxes in if you were NULL, LLC you'll just get all the extra taxes they couldn't figure out for other people
|
# ? Nov 9, 2020 19:39 |