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
Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
It sure is. Arthur Whitney has a very distinctive coding style. His current project is an operating system.

I've been learning K for fun recently and it's a very nice little language, but the initial learning curve is pretty tough. Once you memorize the primitive operators it's much easier to read.

Adbot
ADBOT LOVES YOU

MrMoo
Sep 14, 2000

You should see the mess BoA implemented to workaround lack of materialized views in KDB, :lol: A client written in IronPython with a web browser address bar interface too, kinda neat and scary at the same time.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Snapchat A Titty posted:

Reminds me: There's a website I use where once your session times out, http://www.example.com/user/account.php will start returning a blank 404 page until you go to /user/login.php and log in again.

necrotic posted:

While that's a bit on the extreme side, its pretty common to return 404 instead of 403 to hide stuff from users who can't access it. I don't think I've ever seen it for an account management page, but maybe its just a generic handler they use for that crap?

Scaramouche posted:

The idea being that it's trivially easy to redirect to a login page on session expire instead of just failing to return the resource.

Almost any other return code would be better suited than 404. Forbidden, redirect, 200 with a login page, whatever

No idea what kinda backend they have, though. Indicia say it's bespoke.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Snapchat A Titty posted:

Almost any other return code would be better suited than 404. Forbidden, redirect, 200 with a login page, whatever

No idea what kinda backend they have, though. Indicia say it's bespoke.

Returning 404 certainly conforms to the standard:

RFC 7231 posted:

An origin server that wishes to "hide" the current existence of a forbidden target resource MAY instead respond with a status code of 404 (Not Found).
but I agree with you, it's not terribly helpful, as the existence of the resource is surely not a secret.

Deus Rex
Mar 5, 2005

pokeyman posted:

Returning 404 certainly conforms to the standard:

but I agree with you, it's not terribly helpful, as the existence of the resource is surely not a secret.

It very well might be a secret! I like how GitHub does it: private and non-existent repositories are both served the same 404 page, but if you're not logged in you get an inline login form right there.

https://github.com/foo/bar

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Huh, that is surprising! Gotta say that's a lovely thing to put in the standard. A horror, if you will.

Though I guess it does make sense if the url isn't literally the account homepage url, like if it's some asset that should only be available in very specific contexts. Better to just pretend it doesn't exist than let people know that there's something at this very specific address that they can try to grab at.

E; Yea like the emoji guy says :argh:

Chuu
Sep 11, 2004

Grimey Drawer

MrMoo posted:

You should see the mess BoA implemented to workaround lack of materialized views in KDB, :lol: A client written in IronPython with a web browser address bar interface too, kinda neat and scary at the same time.

Yeah, after working with KDB for a while I have really mixed fealings about the ecosystem as a whole. It's very good at what it does (storing and querying timeseries data) but I feel a lot of installations have various rude-goldberg like services built around its shortcomings (it's not a database, but people want to treat it like a database).

It wouldn't be so bad if the learning curve wasn't a cliff, and query optimization wasn't a black art (an example: using "within" with a dummy variable can be ten times faster than using the greater than/less than operators. Completely counter intuitive since one is a language primitive that translates directly to a hardware op, and one theoretically requires two bounds checks).

I will say though, I think the ridiculously-specked-server with an in memory database model that KDB is exemplary of is an evolutionary dead end*.

(*unless we see a true distributed memory fabric implementation at the OS level. I don't know any company that's working in this area that has any desire to open-source their code though. Apache Ignite is the closest thing, and I do find that project incredibly exciting.)

Chuu fucked around with this message at 09:07 on Dec 13, 2014

Chuu
Sep 11, 2004

Grimey Drawer

Internet Janitor posted:

It sure is. Arthur Whitney has a very distinctive coding style. His current project is an operating system.

I've been learning K for fun recently and it's a very nice little language, but the initial learning curve is pretty tough. Once you memorize the primitive operators it's much easier to read.

I love the last three lines of his coding style doc:

Arthur Whitney posted:

don't generalize.
don't optimize.
don't scroll.

I'll leave it up to the audience to decide if that's a coding horror or not. Really, my gut feeling when looking at anything Arthur has worked on is "this is so alien to me I can't even judge if this is an abomination or incredibly brilliant. It's probably both." It's the only coding style that I have that reaction to.

Chuu fucked around with this message at 09:05 on Dec 13, 2014

QuarkJets
Sep 8, 2008

How does one even arrive at that kind of coding style. "Hmm this algorithm is slow as gently caress, welp no point in trying to optimize it"

fritz
Jul 26, 2003

Chuu posted:

I'll leave it up to the audience to decide if that's a coding horror or not.

How can it possibly not be?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
I've shown the kdb c header file to friends out of context and they've asked why I linked to the IOCCC.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

QuarkJets posted:

How does one even arrive at that kind of coding style. "Hmm this algorithm is slow as gently caress, welp no point in trying to optimize it"

Well don't pick a lovely algorithm and your poo poo won't be slow! Maybe your algorithm for putting a list of items in a drop-down menu doesn't need to run in factorial time.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Chuu posted:

Really, my gut feeling when looking at anything Arthur has worked on is "this is so alien to me I can't even judge if this is an abomination or incredibly brilliant. It's probably both." It's the only coding style that I have that reaction to.

I think there are many parallels between Whitney and Chuck Moore, the creator of Forth. Here's how Moore has been coding recently:

http://www.colorforth.com/cosd.htm

That's a semi-symbolic representation of machine code (the colors are semantically significant, not syntax highlighting) meant to run on one processing node of a 144-core machine he designed at the transistor level, using tools which ran on another machine he likewise made.

Whitney published a style guide for K which provides some reasoning behind the way he formats code, although his personal style seems to have become a more extreme version of some of the ideas in that manual.

Chuu
Sep 11, 2004

Grimey Drawer

fritz posted:

How can it possibly not be?

Because it comes from an alternate world where Scheme and APL won the mindshare wars in early computing history, and procedural languages and their decedents are academic curiosities. The rules in that world could be very different than ours, and his coding style could have been the standard in that timeline. I mean, all of Whitney's work would just be an intellectual curiosity if KDB wasn't the backbone of most investment banks. Because it's thrived in the wild makes it such an interesting study.

MrMoo
Sep 14, 2000

QuarkJets posted:

How does one even arrive at that kind of coding style. "Hmm this algorithm is slow as gently caress, welp no point in trying to optimize it"

He has severe savant induced aspergers? I unfortunately found someone else with similar traits and whilst the code running is impressive it is just too depressing to understand: hundreds of local variables with short names and what should be hundreds of functions all rolled up into visually short but very long logic single functions.

It is the pseudo-inlining that causes them to give up on optimization.

QuarkJets
Sep 8, 2008

Bruegels Fuckbooks posted:

Well don't pick a lovely algorithm and your poo poo won't be slow! Maybe your algorithm for putting a list of items in a drop-down menu doesn't need to run in factorial time.

And what if you're solving a problem that hasn't been solved before, perhaps something important that takes a month of supercomputing time in the optimal case? Then you just pick whatever first comes to mind and go with that?

QuarkJets fucked around with this message at 19:05 on Dec 13, 2014

Soricidus
Oct 21, 2010
freedom-hating statist shill

QuarkJets posted:

And what if you're solving a problem that hasn't been solved before?

If you think you fall into this category, you are probably mistaken.

Feel free to keep right on reinventing the wheel, though, rewriting things in increasingly inefficient ways has kept programmers employed for decades now and there's no reason to suppose you can't spin it out for the rest of a lucrative career!

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Soricidus posted:

If you think you fall into this category, you are probably mistaken.

Feel free to keep right on reinventing the wheel, though, rewriting things in increasingly inefficient ways has kept programmers employed for decades now and there's no reason to suppose you can't spin it out for the rest of a lucrative career!

No, it's actually the aggressive condescension.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

QuarkJets posted:

And what if you're solving a problem that hasn't been solved before, perhaps something important that takes a month of supercomputing time in the optimal case? Then you just pick whatever first comes to mind and go with that?

Unless you're working in academia or some company has hired you to solve the Travelling Salesman problem or somesuch*, you, with all likelihood, never have to invent any new algorithms. At most you'd have to refurbish, implement and combine algorithms others have already made.

*which they would probably hire a mathematician for, if private companies hired for that purpose at all.

E: Welp, looks like I was wrong. I guess I'm still young and naïve.

Joda fucked around with this message at 20:02 on Dec 13, 2014

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Arthur Whitney posted:

don't generalize.
don't optimize.
don't scroll.

QuarkJets posted:

"Hmm this algorithm is slow as gently caress, welp no point in trying to optimize it"

I think it's pretty obvious that Whitney is rephrasing another older piece of advice:

Donald Knuth posted:

Premature optimization is the root of all evil.

Don't let me interrupt your derail though.

vOv
Feb 8, 2014

Actually it's "Love of premature optimization is the root of all evil." :colbert:

Evil_Greven
Feb 20, 2007

Whadda I got to,
whadda I got to do
to wake ya up?

To shake ya up,
to break the structure up!?
You guys realize QuarkJets works at/for motherfucking CERN, right?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

People invent, combine, and refine algorithms for their purposes all the time in industry. Not everyone is pushing together Lego bricks according to the instructions that came in the box. You can find lots of papers published by non-academic practitioners. Even if you're not doing publishable work, you may well be attacking a problem that hasn't been attacked in the relevant configuration before, or for which a general solution doesn't exist in literature.

Well, I guess not so much you you, given this thread, but software developers.

Steve French
Sep 8, 2003

Choosing a better/faster/more suitable algorithm is a form of optimization.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Usually a form of amelioration, since it rarely ends up actually optimal. :spergin: But doing anything prematurely is bad, or it would be timely rather than premature.

What are we talking about here again? That people never have to optimize, or that its always premature, or that nobody does algorithm design? I've lost my sense of direction.

QuarkJets
Sep 8, 2008

Subjunctive posted:

Usually a form of amelioration, since it rarely ends up actually optimal. :spergin: But doing anything prematurely is bad, or it would be timely rather than premature.

What are we talking about here again? That people never have to optimize, or that its always premature, or that nobody does algorithm design? I've lost my sense of direction.

I'm not really sure anymore, everyone seemed to take their own interpretation of the topic. I thought that we were talking about some guy who believes that all attempts at optimization are bad, which would imply that all worthwhile optimizations have already occurred or something. Or maybe he's just misquoting the idea that premature optimization is bad, an idea with which I think we all agree (for many reasons)

The idea that real efficiency gains to very important computational problems can't be made because they've already been made just kind of irked me, since there are tons of unsolved or poorly solved problems out there. It'd be like taking Numerical Recipes in C and then assuming that those are a complete set of the best algorithms for all problems and for all time. It's kind of a coding horror in and of itself, like if someone saw a sorting function that uses bubble sort and then said "well this function is already perfect, no point in trying to improve it." But at the same time, yeah, there's no point in you trying to roll your own heapsort or something like that. We can agree that there's a middle ground where there are lots of nice and commonly used algorithms for many problems while also agreeing that these existing tools don't necessarily solve all problems. Or "for every complex problem, there is a solution that is simple, neat, and wrong."

QuarkJets fucked around with this message at 21:39 on Dec 13, 2014

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

QuarkJets posted:

But at the same time, yeah, there's no point in you trying to roll your own heapsort or something like that.

And yet it wasn't that long ago that we got timsort, so maybe that well's not totally dry.

Understanding what is unusual about your problem, what's not, and the importance of the unusualness is pretty core to systems design in all fields, I would expect.

QuarkJets
Sep 8, 2008

Good points

Honest Thief
Jan 11, 2009
I'm currently on the bench, because my previous client hosed me without me knowing and so now I'm marked for death, so to speak. Anyways, the in-house project I'm one is a project with a specific management sytle. Basically, someone can work on it for 1 month or two at most and then leaves, so you can imagine the quality of the code. Here's a quick example:

public InitializeViewBagItems(ClassModel model, bool isCreate = false){
*cringe worthy stuff here*
}

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Honest Thief posted:

I'm currently on the bench, because my previous client hosed me without me knowing and so now I'm marked for death, so to speak. Anyways, the in-house project I'm one is a project with a specific management sytle. Basically, someone can work on it for 1 month or two at most and then leaves, so you can imagine the quality of the code. Here's a quick example:

public InitializeViewBagItems(ClassModel model, bool isCreate = false){
*cringe worthy stuff here*
}

Maybe you should post some of the cringe-worthy stuff. The method signature means nothing.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Ithaqua posted:

Maybe you should post some of the cringe-worthy stuff. The method signature means nothing.

That method signature sounds like someone cut up the Microsoft Marketing handbook and taped together seven random pieces. But yes, I'm also excited to see its contents!

Pollyanna
Mar 5, 2005

Milk's on them.


Okay, you know how XORing a byte by 0b0000 0000 (0x00) will flip the bits, right? e.g. 0b1010 1010 (0xAA) ^ 0b0000 0000 (0x00) -> 0b0101 0101 (0x55). You'd expect the same behavior in Javascript, since it's basic computer science and logic, right?

WRONG

code:
> 0xFF ^ 0x00
=> 255
What the gently caress? Why is this not flipping? What could possibly be loving this all up-

" MDN posted:

Bitwise XORing any number x with 0 yields x. Bitwise XORing any number x with -1 yields ~x.

:psyduck:

You have got to be kidding me.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
XORing a byte by 0xFF will flip the bits. XORing a byte by 0x00 will change nothing. This is how XOR ordinarily works.

Edit: and to clarify, -1 as a signed two's complement byte is 0xFF.

apseudonym
Feb 25, 2011

Pollyanna posted:

Okay, you know how XORing a byte by 0b0000 0000 (0x00) will flip the bits, right? e.g. 0b1010 1010 (0xAA) ^ 0b0000 0000 (0x00) -> 0b0101 0101 (0x55). You'd expect the same behavior in Javascript, since it's basic computer science and logic, right?

WRONG

code:
> 0xFF ^ 0x00
=> 255
What the gently caress? Why is this not flipping? What could possibly be loving this all up-


:psyduck:

You have got to be kidding me.

:psyduck: what are you talking about that's not how xor works.

Pollyanna
Mar 5, 2005

Milk's on them.


Internet Janitor posted:

XORing a byte by 0xFF will flip the bits. XORing a byte by 0x00 will change nothing. This is how XOR ordinarily works.

mother gently caress me

I'm gonna go hide my shame in the corner.

nuvan
Mar 29, 2008

And the gentle call of the feral 3am "Everything is going so well you can't help but panic."

Pollyanna posted:

Okay, you know how XORing a byte by 0b0000 0000 (0x00) will flip the bits, right? e.g. 0b1010 1010 (0xAA) ^ 0b0000 0000 (0x00) -> 0b0101 0101 (0x55). You'd expect the same behavior in Javascript, since it's basic computer science and logic, right?

WRONG

code:
> 0xFF ^ 0x00
=> 255
What the gently caress? Why is this not flipping? What could possibly be loving this all up-


:psyduck:

You have got to be kidding me.

That isn't XOR. This is XOR.

code:
 ^ | 0 | 1 |
------------
 0 | 0 | 1 |
 1 | 1 | 0 |
When the compared bits are different, the result is 1. When they are the same, the result is 0.
In other words, one OR the other, but NOT both. Hence, eXclusive OR, or XOR for short.

This is also why 0x(something) ^ 0x00 will remain the same, because 0x0 ^ 0x0 == 0x0 and 0x1 ^ 0x0 == 0x1

e:f;b

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
If you want an operator which bitwise flips one operand when the second operand is 0 you could use NOR (joint denial), biconditional or converse implication, but most languages don't include those as primitives. :)

Honest Thief
Jan 11, 2009

Ithaqua posted:

Maybe you should post some of the cringe-worthy stuff. The method signature means nothing.
Maybe cringe worthy was selling it too much, it's a simple if check that forks the old and newer logics for filling in the viewbag. Why the heck they didnt just commented, erased, anything but set the flag to false on the signature, I have no idea. I'm also not sure its working as it is.
btw I say its a new logic because it explicitly says so on the comment, because otherwise I got no freakin idea

if (isCreate)
{
var clist = ClientsService.FindAll(new FindAllClientsRequest { UserId = User.UserId }).Clients.ToList();
var emptyOption = new ClientModel { ClientId = Guid.Empty, Name = ViewRes.Appointment.Select };
if (clist == null)
{
clist = new List<ClientModel>();
}
clist.Insert(0, emptyOption);
ViewBag.ClientList = clist;
}
else
{
ViewBag.ClientList = GetClientsByUserId(User.UserId); // NEW LOGIC!
}

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I don't see the problem with that code.

Adbot
ADBOT LOVES YOU

Honest Thief
Jan 11, 2009
The problem is they have a method signature setting, I guess, the flag to false to force the new logic, and yet kept the method signature as it is and the whole code. Because, I dunno. The only other place its used the flag is always true, so I dunno, either it's leftover code from whenever or..

the whole project is stuff like this, I've found classes commented whole and kept around for what I guess passes as stashing.

Honest Thief fucked around with this message at 19:13 on Dec 15, 2014

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