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
Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that

Athas posted:

Actually, in APL, it is not valid to use Greek letters for variable or function names. It is valid for function parameter names, kind of, because the two parameters permitted for a function are always called ⍺ and ⍵. This means that APL can look kind of funny because everything that uses built-in operations is written very succintly using symbols, but user-defined functions and variables often have user-readable names. Here's an example written by a colleague of mine:

https://raw.githubusercontent.com/dybber/aplbench/master/benchmarks/rodinia-hotspot/tail/hotspot.apl

The weird a-like symbol denotes a line comment if you are curious. The curly braces denote lambdas, kind of.

Oh wow, so you can write reasonable looking code in APL. Whenever I've seen it, it's always been in condensed code-golf style.

Adbot
ADBOT LOVES YOU

Space Kablooey
May 6, 2009


kitten smoothie posted:

Oh, nice, an Android library to help you figure out your user's phone from their model number ("Moto X," not "XT1049.").

Oh, wait.

At least it was autogenerated.

Loezi
Dec 18, 2012

Never buy the cheap stuff

kitten smoothie posted:

Oh, nice, an Android library to help you figure out your user's phone from their model number ("Moto X," not "XT1049.").

Oh, wait.

code:
switch (c) {
            case 'A': //...
            case 'C': //...
            case 'B': //...
            case 'E': //...
            case 'D': //...
            case 'G': //...
            case 'F': //...
            case 'I': //...
:wtc: is going on with this "alphabetical ordering"?

Space Kablooey
May 6, 2009


kitten smoothie posted:

Oh, nice, an Android library to help you figure out your user's phone from their model number ("Moto X," not "XT1049.").

Oh, wait.

"When I'm using a Map, it feels like I'm doing something wrong" - Actual person that is also a Java Programmer.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
HashMap is slow, since it's an object. A switch statement is fast, since it's a goto.

Space Kablooey
May 6, 2009


Source your quotes, please.

Space Kablooey fucked around with this message at 19:05 on Aug 17, 2015

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Dr. Kris Schnauser & Pete Kweller - The Big Book of Java Jokes (ISBN 978-6-15-126602-0)

ExcessBLarg!
Sep 1, 2001
So you probably call getCurrentDeviceName once per app session at most right? Constructing the HashMap probably takes longer than it does to churn through that method once. It's not a terrible approach. I'd probably iterate over array literals though than the massive if/else if trees.

Bongo Bill
Jan 17, 2012

Don't switch statements get optimized into jump tables when compiling, or am I thinking of .NET?

kitten smoothie
Dec 29, 2001

ExcessBLarg! posted:

So you probably call getCurrentDeviceName once per app session at most right? Constructing the HashMap probably takes longer than it does to churn through that method once. It's not a terrible approach. I'd probably iterate over array literals though than the massive if/else if trees.

From a performance standpoint you have a point, but shipping the list as part of your package still means you're going to have to push regular app updates just to update this mapping. If you care that much about having the info, then you're probably willing to pay for a network call for it.

edit: also don't all those string literals count toward your dex limit? (edit 2: no)

kitten smoothie fucked around with this message at 19:49 on Aug 17, 2015

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Bongo Bill posted:

Don't switch statements get optimized into jump tables when compiling, or am I thinking of .NET?

Depends on their size, I think in both environments.

Having my app depend on some random github user keeping their server up seems worse than baking in a list of phone mappings. Besides, if I care about some new addition to the list, my code is going to have to change to handle it as well, so I'm looking at an update either way.

Vanadium
Jan 8, 2005

Bongo Bill posted:

Don't switch statements get optimized into jump tables when compiling, or am I thinking of .NET?

I don't think it's really straightforward to optimize a series of string comparisons to jump tables. Typically people use the jump table argument with C-like switches with a handful of sequential-integer cases or thereabouts.

JawnV6
Jul 4, 2004

So hot ...

Vanadium posted:

I don't think it's really straightforward to optimize a series of string comparisons to jump tables. Typically people use the jump table argument with C-like switches with a handful of sequential-integer cases or thereabouts.

That switch is being done on a char, not a string. It shouldn't be a string comparison. Guarded language because Java, but that ought to boil down to a jump table.

Linear Zoetrope
Nov 28, 2011

A hero must cook

Vanadium posted:

I don't think it's really straightforward to optimize a series of string comparisons to jump tables. Typically people use the jump table argument with C-like switches with a handful of sequential-integer cases or thereabouts.

Yeah, it depends on the exact construct. In order for there to be a jump table (in any language) you pretty much need a C-style switch, or something that could be reasonably interpreted by the compiler as an integer switch (e.g. simple match statements in Rust are basically just matching the tag of a tagged union, which is just an integer switch).

AFAIK, "jump tables" in Java are going to be at the actual post-JIT level, not the bytecode level, so it's dependent on who wrote your JVM. It very well could be a jump table on Windows and Android, but not on OS X, or any other such nonsense. (Like that one time I found out the JVM unrolled a certain loop I had written, but only on Windows, and only if your laptop was plugged into a wall socket and not running on battery...)

Linear Zoetrope fucked around with this message at 20:50 on Aug 17, 2015

ChickenWing
Jul 22, 2010

:v:

HardDisk posted:

"When I'm using a Map, it feels like I'm doing something wrong" - Actual person that is also a Java Programmer.

I'm relatively new to work-programming and I started to worry that I was overusing hashmaps.


Seriously am I crazy or are they the best option for approximately everything?

Linear Zoetrope
Nov 28, 2011

A hero must cook

ChickenWing posted:

I'm relatively new to work-programming and I started to worry that I was overusing hashmaps.


Seriously am I crazy or are they the best option for approximately everything?

They suck for cache locality, but you probably don't care about this unless you're writing a AAA game engine or something.

Hash collisions can also be a bitch, but hash maps are often a good first draft tool. They're the sort of thing that unless you know up front you're going to have trouble with them, they're better to remove later after profiling.

ExcessBLarg!
Sep 1, 2001

JawnV6 posted:

That switch is being done on a char, not a string. It shouldn't be a string comparison. Guarded language because Java, but that ought to boil down to a jump table.
Even if it's not converted to a jump table, doing sequential comparison of the first letter to find the correct first-letter-bucket is faster than iterating over the entire list of model names.

Although, it's a large enough list that a binary search is probably the fastest, and still doesn't require creation of fancy data structures at runtime.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

If you have a fixed list, generating a perfect hash for them isn't too hard. Lots of such tools exist.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

ChickenWing posted:

I'm relatively new to work-programming and I started to worry that I was overusing hashmaps.


Seriously am I crazy or are they the best option for approximately everything?

Hash maps are so good that in Clojure you just use them for everything vaguely object-like. The language provides tools to create actual objects that still act exactly like hashmaps so that you can improve performance on the "expected" fields without changing all of your code that you wrote back when your object was just a map.

Like was said above, use them until you have a reason not to.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
AndroidDeviceNames/lib/adn/androiddevicenames/src/main/java/tslamic/github/io/adn/DeviceNames.java

Why do java projects have directory structures that are like a dozen levels deep? It just seems unnecessary.

loinburger
Jul 10, 2004
Sweet Sauce Jones
In my experience, the first several directories are usually identical. For example, I'm working with a directory "src/main/java/com/companyname/async/actor", but EVERYTHING is in "src/main/java/com/companyname", so as far as the IDE is concerned the directory is just "/async/actor"

Zorro KingOfEngland
May 7, 2008

src/main/java is the standard layout for Maven projects

The rest of the directories after /src/main/java are the package structure (one directory per package). So in that example, DeviceNames is in the tslamic.github.io.adn package, which is where the tslamic/github/io/adn directory structure comes from.

As for why this is the case, I have no idea.

Zorro KingOfEngland fucked around with this message at 22:20 on Aug 17, 2015

Vanadium
Jan 8, 2005

How does the constant time in a hashmap lookup compare to the "constant time" of doing the constant amount of string comparisons that are hardcoded in that file?

Soricidus
Oct 21, 2010
freedom-hating statist shill

Jsor posted:

AFAIK, "jump tables" in Java are going to be at the actual post-JIT level, not the bytecode level,

depends what you mean. java bytecode uses the tableswitch and lookupswitch opcodes. this is android so it'll be dalvik byteode, but that has equivalent opcodes called packed-switch and sparse-switch.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Zorro KingOfEngland posted:

src/main/java is the standard layout for Maven projects

The rest of the directories after /src/main/java are the package structure (one directory per package). So in that example, DeviceNames is in the tslamic.github.io.adn package, which is where the tslamic/github/io/adn directory structure comes from.

As for why this is the case, I have no idea.

There are two directory names in that path that are the name of the project (surely one is enough), and then two more that are "adn", which is just an abbreviation of the name of the project. So that's at least 3 directories in the path that I can't see how they are not completely redundant. And why does "github" need to be in the package name? What relevance does it have to anything that the project is hosted on github? What, if you decided to host it somewhere else you'd change what it was called? And naming it after the maintainer seems similarly suspect, although I have no idea of Java culture or idioms and maybe it's just standard practice for some reason.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Hammerite posted:

There are two directory names in that path that are the name of the project (surely one is enough), and then two more that are "adn", which is just an abbreviation of the name of the project. So that's at least 3 directories in the path that I can't see how they are not completely redundant. And why does "github" need to be in the package name? What relevance does it have to anything that the project is hosted on github? What, if you decided to host it somewhere else you'd change what it was called? And naming it after the maintainer seems similarly suspect, although I have no idea of Java culture or idioms and maybe it's just standard practice for some reason.

Who cares, it's not like it's 1982 and directories are a precious resource

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Soricidus posted:

Who cares, it's not like it's 1982 and directories are a precious resource

I worked on a project recently where the directory depth on the build server hit some Windows limit and we had to rename a bunch of things. :negative:

qntm
Jun 17, 2009
Nested NPM modules can have that effect pretty routinely, last time I checked.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Soricidus posted:

Who cares, it's not like it's 1982 and directories are a precious resource

A developer's time is a resource, and any time you go looking for something in a directory structure how much time are you willing to spend unnecessarily sorting through gratuitous extra layers? Even if your tools mean you seldom have to do that, doesn't it just look ugly to you? I mean I know Java has a reputation for being verbose but drat.

No Safe Word
Feb 26, 2005

Subjunctive posted:

I worked on a project recently where the directory depth on the build server hit some Windows limit and we had to rename a bunch of things. :negative:

That this is still a thing in TYOOL 2015 (and it most definitely is) is loving ridiculous to me.

And drive letters still existing but that's just such a deeply embedded thing that I doubt that will ever go away in my lifetime.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Hammerite posted:

A developer's time is a resource, and any time you go looking for something in a directory structure how much time are you willing to spend unnecessarily sorting through gratuitous extra layers? Even if your tools mean you seldom have to do that, doesn't it just look ugly to you? I mean I know Java has a reputation for being verbose but drat.

It doesn't come up. If you're doing Java you're using an IDE, and your IDE hides the directories from you, you just have packages and classes and the tree will be flattened sensibly. If you're not in your IDE then you're probably looking at something like github or stash or what have you, which again knows how to flatten the tree and skip through empty directories. If you're on the command line then it's unlikely to hurt that the directory structure mirrors the package hierarchy and you can predict exactly which file a given class will be defined in without having to search for it.

The only situation I can think of where it's inconvenient is if you're using a graphical tool that doesn't know about source code, like Windows Explorer or whatever, and in that case you have only yourself to blame because it's a bad tool for working with source code in any language.

sarehu
Apr 20, 2007

(call/cc call/cc)

Subjunctive posted:

I worked on a project recently where the directory depth on the build server hit some Windows limit and we had to rename a bunch of things. :negative:

I had a file on my computer, when it ran Windows, whose filename was too long for me to rename or delete it.

loinburger
Jul 10, 2004
Sweet Sauce Jones

Soricidus posted:

The only situation I can think of where it's inconvenient is if you're using a graphical tool that doesn't know about source code, like Windows Explorer or whatever, and in that case you have only yourself to blame because it's a bad tool for working with source code in any language.

About once a month I'll get drunk (at least I hope that's my excuse) and browse through my source code using Finder and then I've got to hunt around for the script that will delete all of the stupid .ds_store files

Soricidus
Oct 21, 2010
freedom-hating statist shill

loinburger posted:

About once a month I'll get drunk (at least I hope that's my excuse) and browse through my source code using Finder and then I've got to hunt around for the script that will delete all of the stupid .ds_store files

my favourite thing is when I clone somebody's github repo and it turns out to have a bunch of .ds_stores that they've committed

No Safe Word posted:

That this is still a thing in TYOOL 2015 (and it most definitely is) is loving ridiculous to me.

backwards compatibility. you can't change it without breaking practically every c or c++ program ever that does path manipulation in a fixed-length buffer sized based on the longest possible path, and for some reason nobody's eager to take that step just yet.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Soricidus posted:

If you're on the command line then it's unlikely to hurt that the directory structure mirrors the package hierarchy and you can predict exactly which file a given class will be defined in without having to search for it.

actually it's really loving annoying having to hit tab an extra ten times for every path

loinburger posted:

About once a month I'll get drunk (at least I hope that's my excuse) and browse through my source code using Finder and then I've got to hunt around for the script that will delete all of the stupid .ds_store files

find . -name .ds_store -delete is all you need

Soricidus
Oct 21, 2010
freedom-hating statist shill

Plorkyeran posted:

actually it's really loving annoying having to hit tab an extra ten times for every path

if you're doing this enough to matter then you can just create symlinks or whatever

hmm, or you could probably hack your completion settings to skip empty subdirectories

omeg
Sep 3, 2012

Subjunctive posted:

I worked on a project recently where the directory depth on the build server hit some Windows limit and we had to rename a bunch of things. :negative:

NTFS doesn't have arbitrary directory nesting limit AFAIR, just a single directory entry must have name shorter than 256 characters (and a path, 32k).

sarehu posted:

I had a file on my computer, when it ran Windows, whose filename was too long for me to rename or delete it.

Try prepending "\\?\" at the beginning of the path in the future.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Sometimes you need to deal with source code as file artifacts, in which case deep hierarchies can be annoying and add a lot of visual noise. src/java/main annoys me because in every case I've seen main could just be at the top of that level with no loss of clarity or structure.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

omeg posted:

NTFS doesn't have arbitrary directory nesting limit AFAIR, just a single directory entry must have name shorter than 256 characters (and a path, 32k).

It wasn't an NTFS limit as much as a Windows API limit which IIRC is 260 characters in the full path and 245 in the directory portion. Visual Studio choking on long paths is a well-known problem, I think.

Adbot
ADBOT LOVES YOU

No Safe Word
Feb 26, 2005

Subjunctive posted:

It wasn't an NTFS limit as much as a Windows API limit which IIRC is 260 characters in the full path and 245 in the directory portion. Visual Studio choking on long paths is a well-known problem, I think.

Uh... yup.

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2156195-fix-260-character-file-name-length-limitation


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