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
sarehu
Apr 20, 2007

(call/cc call/cc)
Yeah but he has a point, or if even if he doesn't have it, there exists the point that if two interfaces happen to use the same names of things, you will have a type misused. The moral is that method names should have namespaces :colbert:. (Actually this is why sometimes for templated code calling a function, it's handy to make a namespace for the overloaded functions to reside in that implementers of this "concept" have to use.)

Adbot
ADBOT LOVES YOU

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
A few pages back, but I can't resist:

feedmegin posted:

Edit: on Windows, of course, it's not main() but WinMain(), because Microsoft gotta be different! :sun:

Starting from Win32 (est. 1993), WinMain and main are completely interchangeable and the difference is largely cosmetic. Only 16 bit Windows required WinMain, and had really poor support for UNIX-like C code (no pipes, no terminal emulation, no preemptive multitasking) so you didn't want to use main anyway: command line applications would work much better as DOS applications. UNIX-like C code, i.e. designed around I/O multiplexing, would work like total poo poo on Windows, because back then, Windows multitasking was based on the message queue, and I/O didn't (doesn't!) pump messages (I remember an obscure project to port the UNIX environment to Windows, using pipes based on messaging instead of I/O). In Windows, though, DOS applications ran in virtual machines, so the issue could be elegantly side-stepped (not that DOS had pipes because it was strictly single-task...)

feedmegin posted:

Nah. You're thinking of the MS-DOS stub at the start of PE/COFF files, which is completely separate and independent from the actual Windows program (and, of course, is running in 16-bit mode). You can't write one program which directly targets both environments or anything.

You totally can. Lots of DOS extenders implemented the Win32 API, some to an insane degree (graphics, sound, etc. one hobbyist extender even implemented part of DirectX), so yes, you could literally run the same identical executable under Windows and DOS. The DOS stub loads the Windows executable in memory, and fixes up its imports so that it calls the DOS implementation of Win32 APIs. On Windows, the stub is skipped and the real Win32 is used. It's not perfect, and last time I checked years ago, Windows had checks to ensure some ostensibly Win32 executables ran in DOS instead, due to buggy extenders that (I presume) took liberties in their Win32 implementations

comedyblissoption posted:

strong typing means stuff i like and weak typing means stuff i dont like

Strong typing means pressing your keyboard keys very hard

Xarn
Jun 26, 2015

hackbunny posted:

You totally can. Lots of DOS extenders implemented the Win32 API, some to an insane degree (graphics, sound, etc. one hobbyist extender even implemented part of DirectX), so yes, you could literally run the same identical executable under Windows and DOS. The DOS stub loads the Windows executable in memory, and fixes up its imports so that it calls the DOS implementation of Win32 APIs. On Windows, the stub is skipped and the real Win32 is used. It's not perfect, and last time I checked years ago, Windows had checks to ensure some ostensibly Win32 executables ran in DOS instead, due to buggy extenders that (I presume) took liberties in their Win32 implementations
Keep posting these forever please. :allears:


hackbunny posted:

Strong typing means pressing your keyboard keys very hard
Yup.

ModeSix
Mar 14, 2009

hackbunny posted:

Strong typing means pressing your keyboard keys very hard

Would you recommend using the forehead or the chin for super strong typing?

xzzy
Mar 5, 2009

ModeSix posted:

Would you recommend using the forehead or the chin for super strong typing?

Use your heels, get those glutes involved. I recommend using an IBM model M though, the steel backplate ensures it survives the extra load. It also makes everyone in the office aware how strongly you are typing.

One Eye Open
Sep 19, 2006
Am I awake?

hackbunny posted:


You totally can. Lots of DOS extenders implemented the Win32 API, some to an insane degree (graphics, sound, etc. one hobbyist extender even implemented part of DirectX), so yes, you could literally run the same identical executable under Windows and DOS. The DOS stub loads the Windows executable in memory, and fixes up its imports so that it calls the DOS implementation of Win32 APIs. On Windows, the stub is skipped and the real Win32 is used. It's not perfect, and last time I checked years ago, Windows had checks to ensure some ostensibly Win32 executables ran in DOS instead, due to buggy extenders that (I presume) took liberties in their Win32 implementations

That reminds me of one of the easier ways I used to make 32bit DOS applications when I only had Borland C++, was to build it as a Win32 executable and then graft on the DOS extender because I couldn't afford Watcom. You had to have different pathways for DOS SVGA and WinG (the predecessor of DirectX) which made debugging interesting, to say the least.

feedmegin
Jul 30, 2008

One Eye Open posted:

That reminds me of one of the easier ways I used to make 32bit DOS applications when I only had Borland C++, was to build it as a Win32 executable and then graft on the DOS extender because I couldn't afford Watcom. You had to have different pathways for DOS SVGA and WinG (the predecessor of DirectX) which made debugging interesting, to say the least.

I take it back I guess. This is some :black101: poo poo though.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

hackbunny posted:

Coding horrors: Strong typing means pressing your keyboard keys very hard

TZer0
Jun 22, 2013
I want to bash my head against a wall right now.

We have an API that does the following:

  • Receive a request for a resource over http.
  • Parse the URL and figure out what to do.
  • In a loop: generate new URLs and send them to another method method in the API which then parses it to figure out what resource to fetch.

.. this exists in several places. :wtc:

Who on earth thought this was a good idea? Why wasn't whatever that other method doing refactored into a separate method? Who thought this was maintainable?

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

toiletbrush posted:

When I first 'got' lambdas/LINQ etc I started writing all my code this way, but had this weird gut feeling that it was wrong. The only thing I've been able to come up with in the last few years is that it sucks to debug when you get an error later on in the chain and want to check an intermediate result.

If you're using VS you can evaluate enumerations using the 'watch' window. I've been copy and pasting the expressions, which is a little annoying. There's got to be a better way...

Otherwise you can use the 'dissassembly' window and step through it instruction by instruction.

I felt the same way, until a total stranger showed me some of their code that used that sort of heavily functional c# style. It was one of the few times I looked at someone elses code and could tell what they doing almost immediately.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

TZer0 posted:

I want to bash my head against a wall right now.

We have an API that does the following:

  • Receive a request for a resource over http.
  • Parse the URL and figure out what to do.
  • In a loop: generate new URLs and send them to another method method in the API which then parses it to figure out what resource to fetch.

.. this exists in several places. :wtc:

Who on earth thought this was a good idea? Why wasn't whatever that other method doing refactored into a separate method? Who thought this was maintainable?

Probably no one. It's the type of thing you get when you have several people who refuse to touch anything other people are working on.

Pollyanna
Mar 5, 2005

Milk's on them.


"Hey, the text in these elements can't be longer than 25 characters or it throws the rest of the page off, can you make it so that this weird overflow thing doesn't happen?"

"Kay."

JavaScript code:
if (!$('.help-button').is(':visible')) {
  var titles = $('.edit-event-button span');
  $.each(titles, function (index, value) {
    titles[index].innerHTML = trimEventTitle(value.innerHTML)
  });
  function trimEventTitle(string) {
    if (string.length > 25) return string.substring(0, 25) + '...';
    return string
  }
}
:downs:

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Pollyanna posted:

"Hey, the text in these elements can't be longer than 25 characters or it throws the rest of the page off, can you make it so that this weird overflow thing doesn't happen?"

"Kay."

JavaScript code:

if (!$('.help-button').is(':visible')) {
  var titles = $('.edit-event-button span');
  $.each(titles, function (index, value) {
    titles[index].innerHTML = trimEventTitle(value.innerHTML)
  });
  function trimEventTitle(string) {
    if (string.length > 25) return string.substring(0, 25) + '...';
    return string
  }
}

:downs:

Should be (0, 22) + '...'
:downs:

Pollyanna
Mar 5, 2005

Milk's on them.


leper khan posted:

Should be (0, 22) + '...'
:downs:

Oh, don't get me started. I gave him a little more credit than is due in that post, because he's actually the one that came up with the 25 character limit rather than it being specified in the requirements. Which means that he actually didn't do what he himself said was required, and even hosed that up. I asked him how he came to the 25-character conclusion and he just said that was kind of how it looked to him, and when I pointed out that he's actually returning 28 characters instead he was like "oh yeah uhhh it's supposed to be 28 characters I misspoke".

The if !$('.help-button').is(':visible') line is also supposedly meant to check if we are in a mobile view or not. The presence of the help button is completely irrelevant to the viewpoint/window size, and we already have a media query for our mobile view in our stylesheets. :doh:

There is also absolutely no need for this to be handled via Javascript, at all. I implemented what he was trying to do in four lines of CSS. That sure as poo poo is better than some Javascript that isn't even properly implemented.

I am absolutely piss-awful at front-end design and styling, and even I know more than this jackass does, and this is supposedly his expertise. :gonk:

xzzy
Mar 5, 2009

I'm pretty sure everyone doing web design is just cutting and pasting examples from google searches and randomly adjusting values until it looks right.

CSS is a cool idea but goddamn if it's not harder than building rockets.. at least a rocket is governed by known formulas.

Pollyanna
Mar 5, 2005

Milk's on them.


I hate CSS as much as you do, don't get me wrong. But this is a clear case of using the wrong/more inappropriate tool. I feel like this is much, much easier to accomplish via CSS, and there has to be a way to do it somehow. I don't want to prescribe a solution, not at all, but I just feel dirty manipulating HTML instead of adding some kinda style.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
well yeah you almost certainly just want to set a max width and text-overflow:ellipsis

Pollyanna
Mar 5, 2005

Milk's on them.


Jabor posted:

well yeah you almost certainly just want to set a max width and text-overflow:ellipsis

Pretty much, the one thing we're stuck on is how to calculate max-width since it's dependent on some weird poo poo.

The person in question was pretty miffed when I questioned their approach and was utterly mystified why I wasn't satisfied with it when it "worked on my machine". :shepicide:

Klades
Sep 8, 2011

Obviously the solution is to render the Web page in pdf format with latex so you can use its robust formatting system.

OddObserver
Apr 3, 2009

Klades posted:

Obviously the solution is to render the Web page in pdf format with latex so you can use its robust formatting system.

Or at least it would compute the badness for the overfull hboxes...

qntm
Jun 17, 2009

Pollyanna posted:

There is also absolutely no need for this to be handled via Javascript, at all.

Today I had to open a defect entitled "Don't modify CSS stylesheet contents dynamically at run time".

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

OddObserver posted:

Or at least it would compute the badness for the overfull hboxes...

The concept of "badness" gives me a chuckle every time I compile a LaTeX document.

canis minor
May 4, 2011

Pollyanna posted:

I hate CSS as much as you do, don't get me wrong. But this is a clear case of using the wrong/more inappropriate tool. I feel like this is much, much easier to accomplish via CSS, and there has to be a way to do it somehow. I don't want to prescribe a solution, not at all, but I just feel dirty manipulating HTML instead of adding some kinda style.

Text-overflow: ellipsis.

What drives me insane is the circlejerk about not using tables, but then using divs and separate js library for the divs to have the same height. This coming from our css guys, when: 1) it's doable by using css alone, 2) the js that they are using is so botched together that it extended the rendering of page by 4s.

canis minor fucked around with this message at 17:26 on Jul 20, 2016

fritz
Jul 26, 2003

xzzy posted:

I'm pretty sure everyone doing web design is just cutting and pasting examples from google searches and randomly adjusting values until it looks right.

In a previous job I was doing web scraping and : I would totally believe it.

Pollyanna
Mar 5, 2005

Milk's on them.


canis minor posted:

Text-overflow: ellipsis.

What drives me insane is the circlejerk about not using tables, but then using divs and separate js library for the divs to have the same height. This coming from our css guys, when: 1) it's doable by using css alone, 2) the js that they are using is so botched together that it extended the rendering of page by 4s.

That's what I suggested. He seems to disagree and instead wanted to just put span { word-break: break-all; }. This doesn't work if you have text without spaces like "aaaaaaaaaaaaaaaaaaaaaaaaa", so it's technically incorrect, but arguing that point with him is like the last thing I want to do right now so whatever.

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

xzzy posted:

CSS is a cool idea but goddamn if it's not harder than building rockets.. at least a rocket is governed by known formulas.

There's also the advantage that a rocket that works on one launchpad is typically also going to work on a different launchpad that (supposedly) provides the same facilities, and not explode in a giant fireball the moment the countdown starts.

This is not quite so with CSS and different browsers last I checked.

ToxicSlurpee
Nov 5, 2003

-=SEND HELP=-


Pillbug

xzzy posted:

I'm pretty sure everyone doing web design is just cutting and pasting examples from google searches and randomly adjusting values until it looks right.

CSS is a cool idea but goddamn if it's not harder than building rockets.. at least a rocket is governed by known formulas.

CSS is basically black magic.

It's incredibly powerful but at the same time might summon a demon that burns the city down.

Absurd Alhazred
Mar 27, 2010

by Athanatos
Visual Studio is dark and full of horrors. As if the Windows API wasn't terrible enough to work with (yeah, in the year 2016, let's keep identifying every single system object as structureless recast void pointers :downs:), I somehow managed to get Intellisense to stop working. :smith:

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.

ToxicSlurpee posted:

CSS is basically black magic.

It's incredibly powerful but at the same time might summon a demon that burns the city down.

You can just type whatever the gently caress style you want into a web browser's F12 debugger and it'lll show up live, realtime. There's no excuse for being poo poo at CSS.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Bruegels Fuckbooks posted:

You can just type whatever the gently caress style you want into a web browser's F12 debugger and it'lll show up live, realtime. There's no excuse for being poo poo at CSS.

I've never had to look at CSS, so I imagine I'm poo poo at it.

xzzy
Mar 5, 2009

leper khan posted:

I've never had to look at CSS, so I imagine I'm poo poo at it.

CSS is fine.. you're just setting properties on objects to control how they look. Any idiot can grok that.

The horrible part comes from all the block/inline relative/absolute positioning interactions. And then throw in browser incompatibilities and clients who insist on a specific layout that isn't technically supported and you'll start considering shooting yourself to ease the pain.

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

xzzy posted:

CSS is fine.. you're just setting properties on objects to control how they look. Any idiot can grok that.

The horrible part comes from all the block/inline relative/absolute positioning interactions. And then throw in browser incompatibilities and clients who insist on a specific layout that isn't technically supported and you'll start considering shooting yourself to ease the pain.

I'm almost certain you just said, "CSS is poo poo." You might as well say, "Communism is awesome, it's just the implementations that are bad."

Volte
Oct 4, 2004

woosh woosh
CSS is fine if you can use flexbox

Soricidus
Oct 21, 2010
freedom-hating statist shill

Centripetal Horse posted:

You might as well say, "Communism is awesome, it's just the implementations that are bad."
So ... post in D&D then?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
CSS for style is relatively sane. "I want to make this thing have a larger font and this background color".

CSS layout is where insanity begins. Layout is about the relationships between objects, and CSS's "select one object" approach does not tend to fare well to that.

canis minor
May 4, 2011

Suspicious Dish posted:

CSS for style is relatively sane. "I want to make this thing have a larger font and this background color".

CSS layout is where insanity begins. Layout is about the relationships between objects, and CSS's "select one object" approach does not tend to fare well to that.

You can do BEM, but unfortunately around here we end up with rules like: .button-green or .section > .section_superheader > .section_superheader_title

Neco
Mar 13, 2005

listen

TZer0 posted:

I want to bash my head against a wall right now.

We have an API that does the following:

  • Receive a request for a resource over http.
  • Parse the URL and figure out what to do.
  • In a loop: generate new URLs and send them to another method method in the API which then parses it to figure out what resource to fetch.

.. this exists in several places. :wtc:


That's a monolithic microservice architecture if you ask me. :mmmhmm:

ATM Machine
Aug 20, 2007

I paid $5 for this

Absurd Alhazred posted:

Visual Studio is dark and full of horrors. As if the Windows API wasn't terrible enough to work with (yeah, in the year 2016, let's keep identifying every single system object as structureless recast void pointers :downs:), I somehow managed to get Intellisense to stop working. :smith:

This is totally normal, and happens with great frequency when you're constantly compiling and editing. Eventually intellisense just crashes silently while trying to constantly to get definitions until you restart VS. Super fun.

Spatial
Nov 15, 2007

Suspicious Dish posted:

CSS for style is relatively sane. "I want to make this thing have a larger font and this background color".

CSS layout is where insanity begins. Layout is about the relationships between objects, and CSS's "select one object" approach does not tend to fare well to that.
CSS is a design language conceived by programmers so it's no surprise it's pure poo poo. It's been a couple of years since I used it, but AFAIK it doesn't even have the fundamental layout structure of a grid with column spanning. Or the ability to define colour constants. No biggie, designers don't use colour palettes or column-based layouts right? Haha.

Another fun design-by-programmer horror is the collection of built-in layout managers in Java's Swing library. I remember a friend of mine trying to make a fairly simple resizable GUI using GridBagLayout and he just gave up in despair after two solid days of fighting it. You'd honestly have a tough time purposefully making something worse. Thankfully he discovered MigLayout, which has the grid model combined with CSS-a-like styling - one of those rare miracles where programmers with design skills actually released something that wasn't a videogame.

Adbot
ADBOT LOVES YOU

Spatial
Nov 15, 2007

Found an amazing horror at work a few weeks back.

IAR embedded workbench for ARM, a compiler and IDE package which is the stinking living embodiment of pure poo poo, doesn't warn you when a declared function signature doesn't match its actual usage at the point of call. This means incorrect code generation, overwritten/undefined parameters and all around serious business.

And it just so happened that it affected the core state machine dispatch function which is burned into ROM and cannot be patched.

By pure luck it works, because by chance one of the missing parameters is placed in the same CPU register after another function is done and nothing overwrites at an inopportune time. There's no guarantee that some ill-timed interrupt won't break it though. You never know.

Thank god it wasn't life critical.

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