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
Soricidus
Oct 21, 2010
freedom-hating statist shill

Tei posted:

I like JSON because "use UTF-8 or else gently caress you" is a good call.

respect_for_python --;

seems a feature that should not exist.

if somebody really wanted or needed to read binary has input data, then have a mechanism where python receive the path of a file, and read from that file.

You misunderstand. This is for file paths, not data. It exists because otherwise it would be impossible to represent arbitrary POSIX paths as Python strings.

Adbot
ADBOT LOVES YOU

Soricidus
Oct 21, 2010
freedom-hating statist shill
You can still put control sequences in filenames, but common things like ls will escape them, and most modern terminal emulators refuse to implement control sequences they consider security risks, or at least disable them by default

Soricidus
Oct 21, 2010
freedom-hating statist shill

chglcu posted:

Just write your free immediately after you write your malloc, you lazy poo poo. Only being semi-ironic here. Memory management just really isn’t that hard.

The NSA thanks you for your commitment to their future

Soricidus
Oct 21, 2010
freedom-hating statist shill

raminasi posted:

200 for everything is definitely an extant pattern. Honestly I think it's fine if it's documented and consistent and the responses are machine-readable (i.e. you don't need to parse error strings).

If

Soricidus
Oct 21, 2010
freedom-hating statist shill
That’s not quite enough, because people want to add methods that extend existing data types. Like, extending methods. Extendy methods. Something like that.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Jigsaw posted:

otherwise I don’t see why it should fail to parse and run

I guess the question is “why does for…in take an arbitrary lvalue”. What use cases are there for binding anything other than an identifier or a tuple of identifiers, like we all probably assumed it did until we read that post?

Soricidus
Oct 21, 2010
freedom-hating statist shill

Hammerite posted:

love to see a library in which every property accessor has a documentation string that says either "gets the value of the Foo property" or "sets the value of the Foo property" as though that were helpful to anyone, clearly solely because there is some policy saying that every method and property accessor is required to have a documentation string so they can claim they reach some documentation target

and nothing anywhere in any documentation or comment that explains what Foo means

Soricidus
Oct 21, 2010
freedom-hating statist shill
They should just have rewritten the whole thing in algol

Soricidus
Oct 21, 2010
freedom-hating statist shill

brap posted:

fwiw the compiler actually eliminates the unnecessary comparisons in this case.

Does it?

Like, it could in this case, but I’d be kind of surprised if they bothered to implement that, given that it’s only possible in certain specific situations and the benefit is likely to be insignificant unless there are vast numbers of cases.

Soricidus
Oct 21, 2010
freedom-hating statist shill

rjmccall posted:

It falls out of any basic CSE / GVN optimization to the point that it would be weird not to do it. And eliminating redundant branches is a very worthwhile optimization in general; people tend to write a lot of redundant range checks, and reducing branch density is very good on modern processors.

That’s happening at a lower level surely? I was talking about specifically the difference between the switch vs if/else chain, where I’d be surprised if the compiler emitted significantly different code for each.

Soricidus
Oct 21, 2010
freedom-hating statist shill
Petition to rename groovy to groverlang

Soricidus
Oct 21, 2010
freedom-hating statist shill

OddObserver posted:

PowerShell looks like they really wanted to show off finally having good tab completion.

Powershell is awful for completion tho because they went with verb-noun, which is generally bad because it’s easier to guess the noun than the verb and you’re more likely to want to ask “what can I do to a Folder” than “what kinds of thing can I Get”

AWS cli is terrible for exactly the same reason

Soricidus
Oct 21, 2010
freedom-hating statist shill

QuarkJets posted:

AWS CLI sucks poo poo for sure, and boto is just a big pile of garbage made by idiots. It's seriously bad

Boto haram

Soricidus
Oct 21, 2010
freedom-hating statist shill

FlapYoJacks posted:

Yes, most of them are pretty intuitive. Unlike powershell commands, -h is drat near always help as well.
code:
$ find -h
find: illegal option -- -h

$ cd -h
cd: no such file or directory: -h

$ cc -h
clang: error: unknown argument: ‘-h’

$ ls -h
*exactly the same output as ls by itself*
and so on and so on

Soricidus
Oct 21, 2010
freedom-hating statist shill

FlapYoJacks posted:

Imagine defending Powershell syntax lmfao.

Imagine defending unix cli syntax lomarf

grep -h is another fun one, although without any other arguments it just does the same as plain grep so you do get a usage summary

Soricidus
Oct 21, 2010
freedom-hating statist shill

CPColin posted:

code:
#!/usr/bin/env java
:smuggo:

ftfy

(I have genuinely used this)

Soricidus
Oct 21, 2010
freedom-hating statist shill

Xarn posted:

I don't think you can typedef enable-ifs

#define doesn’t care about your templates

Soricidus
Oct 21, 2010
freedom-hating statist shill

Beef posted:

Another cargo cult Java dev brain damage story:

I was told once that I should put each of my python functions in a separate file, because that's more modular.

that’s not even a thing in java!

Soricidus
Oct 21, 2010
freedom-hating statist shill

Falcon2001 posted:

I mean the one class per file is a Java thing though right? And in Java you can't have just a function hanging out by itself, it has to be contained within a class, so probably that's where that particular brainworm comes from.

One public top-level class per file. You can have any number of nested classes, and any number of non-public top-level classes.

In a year or so you’ll also be able to define the main() function without needing a class at all, thanks to the magic of JEP 445! There’s amazing innovation going on in the Java community, idk why people think it’s oldfashioned

Soricidus
Oct 21, 2010
freedom-hating statist shill

Surprise T Rex posted:

Are Java enums sort of like Union types? From a C# perspective they’re confusing since in C# it’s just a strongly typed list of name-to-Integer mappings.

They’re sugar for collections of singletons with special compiler support to let you use them in switch statements, and special support classes like EnumSet and EnumMap that take advantage of the compiler-generated ordinal() method to use them as efficiently as integers in other common situations.

Soricidus
Oct 21, 2010
freedom-hating statist shill

RPATDO_LAMD posted:

Also how would you teach stuff like trees and linked lists in a 'friendly' language without pointers like java or python?

Possibly java.util.LinkedList and java.util.TreeMap might contain some hints

Soricidus
Oct 21, 2010
freedom-hating statist shill

nielsm posted:

It's called being omakase.

Nah, omakase means you trust the chef to deliver a good meal with minimal specifications. Golang is all about you having to write out every single step by hand because abstraction is scary, it’s literally the opposite

Soricidus
Oct 21, 2010
freedom-hating statist shill

LOOK I AM A TURTLE posted:

drat near any language? You definitely can't use the pattern in C-family languages like C, C++, Java or C#, as they all require the case expressions to be made up of only constant values.

Amusingly, Java doesn't even allow something like switch (true) { case true: ... } because "boolean cannot be converted to int".

Don’t worry, JEP 455 will fix this in a year or two!!!

Soricidus
Oct 21, 2010
freedom-hating statist shill

more falafel please posted:

In college I interviewed for an internship at Microsoft (they'd bring a bunch of recruiters and engineers on campus once a year and interview basically every 3rd/4th year CS student) and I was definitely in my smarmy-Unix-kid phase, which intersected heavily with my any-program-worth-writing-can-be-a-Perl-oneliner phase

My interview was being done by a recruiter, not an engineer, but they still asked technical questions. One was "write a function to reverse the order of words in a string". I had done plenty of that type of exercise in school, and I was well-versed in C and to a lesser extent C++, so I could have done a straightforward recursive or iterative algorithm, but the interviewer said I could use whatever language I wanted, and I wanted to show everyone just how fuckin' clever I was so I just wrote "join reverse split;" on the whiteboard and then refused to elaborate.

I didn't get the internship.

Well obviously not, you forgot the separator argument for join

Soricidus
Oct 21, 2010
freedom-hating statist shill

more falafel please posted:

goddamnit larry how does it not default to $_ (probably because it's in list context and all the args get collapsed, once again goddamnit larry)

I think technically your code uses the result of “reverse split” in scalar context (i.e. the number of words), to join an empty list. So the result is always an empty string.

Perl is fun!

Soricidus
Oct 21, 2010
freedom-hating statist shill

Bruegels Fuckbooks posted:

Why I am I getting blamed for this third party AI company's gsps not storing in dicom server?

5 minutes later...

Oh no these assholes used group 1337 for their dicom private tag group, this is going to go great.

5 minutes later...

Oh jesus christ not only are a million type 1 tags missing, they're not validating the lengths for any of their VRs etc etc.

Count yourself lucky it was 1337 not 1488

Soricidus
Oct 21, 2010
freedom-hating statist shill
code:
const iseven = 7

Soricidus
Oct 21, 2010
freedom-hating statist shill

Jen heir rick posted:

You should use Count instead of Contains. That way it'll iterate over all the numbers and you won't miss anything.

This will also ensure the runtime is constant, which is an important security property as it will stop hackers using timing attacks to work out what number you are testing for evenness.

Soricidus
Oct 21, 2010
freedom-hating statist shill

QuarkJets posted:

Native Python sure, TKinter sucks, but Python also has extremely good support for Qt and Qt is still a gold standard in desktop gui design, so that'd be a reasonably good choice.

I can't think of a good reason to use Java for any kind of frontend at all

Put it this way … if you’re writing python today, most likely you’re writing it either in vscode (electron) or pycharm (java).

I think the desktop apps I use regularly (ignoring the browser itself and stuff built into the os) are a pretty even split between electron, java, and native qt. I don’t think any of them are written in python.

Soricidus
Oct 21, 2010
freedom-hating statist shill
The problem with it is that having a case statement in the middle of a loop is the kind of thing that might plausibly be undefined behavior or a compiler-specific extension. It’s obvious what the code intends to do, but it’s not a common idiom, so unless you’re familiar with the trick, it’s not obvious whether it will actually do that reliably, even if you run it and it seems to work on your machine.

That’s why it’s bad code.

Adbot
ADBOT LOVES YOU

Soricidus
Oct 21, 2010
freedom-hating statist shill

leper khan posted:

what.

duff's device is a little silly, but it's not against the spec

I didn’t say it was against the spec. I know it’s not against the spec. I said it was the kind of thing that looks like it might be against the spec, and is bad code for that reason.

leper khan posted:

case statements in a loop have no issues

Coding Horrors: case statements in a loop have no issues

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