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
Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
As much as we love to rage about long-rear end type names, the unfortunate reality is that if we're using a language like Java for a project, we're stuck with them, since the chucklefucks at Sun refuse to actually improve the language in any meaningful way.

So I'd at least like it if we could get people behind the idea of bumping up the obsolete 80-character limitation to something a little more reasonable but still legible, like say 100. There's no reasons it should take me two lines to do a simple object allocation like:
code:
    BigAssTypeNameFactoryVisitor factory =
        new BigAssTypeNameFactoryVisitor(someArg, otherArg);

Adbot
ADBOT LOVES YOU

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Sure there's a reason, to get you to complain to Sun or Oracle or the Java Community Process or whoever to get some type inference up in this bitch






























Also as some salt against making AbstractFactoryVisitorBridgeMementoSingletons

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Otto Skorzeny posted:

to get you to complain to Sun or Oracle or the Java Community Process or whoever to get some type inference up in this bitch

I don't believe the action in the first part of that sentence has ever achieved the consequence in the second part. And even when Sun does add something people have been asking for, they manage to cock it up in the worst way possible to the point of making it only a fraction as useful as it could be (cf. generics). I think auto(un)boxing is the only thing they've added recently that I've actually been 100% grateful for.

Watching Microsoft continue to develop and grow C# in a ton of ways makes me wish someone would just fire the entire Java language team and get new people in there who listen to feedback and care about turning it into a real modern programming language.

Zombywuf
Mar 29, 2008

Flobbster posted:

Watching Microsoft continue to develop and grow C# in a ton of ways makes me wish someone would just fire the entire Java language team and get new people in there who listen to feedback and care about turning it into a real modern programming language.

What you need is Perl 6.

biznatchio
Mar 31, 2001


Buglord

Zombywuf posted:

What you need is Perl 6.

I used to follow Perl 6 development pretty closely. Back in 2001. When I checked in on it a few months ago, they still hadn't delivered a usable product.

I'll check in again on it in 2015. Hopefully it's done by then so I can install it on my copy of the HURD and use it to script entities in Duke Nukem Forever.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Flobbster posted:

generics

gently caress Java for not having generic arrays!

Zombywuf
Mar 29, 2008

biznatchio posted:

I used to follow Perl 6 development pretty closely. Back in 2001. When I checked in on it a few months ago, they still hadn't delivered a usable product.

I'll check in again on it in 2015. Hopefully it's done by then so I can install it on my copy of the HURD and use it to script entities in Duke Nukem Forever.

It may not be a usable product yet, but it's definitely growing due to user feedback, and the developers intend on turning it into a modern programming language.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Zombywuf posted:

What you need is Perl 6.

He asked for a real language. :smug:

biznatchio
Mar 31, 2001


Buglord

Zombywuf posted:

It may not be a usable product yet, but it's definitely growing due to user feedback, and the developers intend on turning it into a modern programming language.

So what advantages would I have for choosing Perl 6 for a new project being started today over, say, a language that exists?

Volguus
Mar 3, 2009

biznatchio posted:

So what advantages would I have for choosing Perl 6 for a new project being started today over, say, a language that exists?

As usual, the answer to that is: depends on your project.

Perl is a language suited for certain tasks (and here i'm looking at its legendary strong point: regular expressions), and probably not so suited for others.

Can you build a GUI app with it? Of course. Should you? I doubt it.
Especially since PERL-compatible regex libraries have been created for other languages as well (java, c/c++, python i think)

So, at the end of the day, the questions to be asked are:
- Does my project require certain features that PERL would be a perfect solution?
- Who will code it? Do those people know PERL?Do they wanna know PERL?
- Who will maintain it? Does that team know PERL ?Do they wanna know PERL?

tef
May 30, 2004

-> some l-system crap ->

rhag posted:

As usual, the answer to that is: depends on your project.

I.e. if it's vapourware then running on perl6 is a good idea.

Zombywuf
Mar 29, 2008

biznatchio posted:

So what advantages would I have for choosing Perl 6 for a new project being started today over, say, a language that exists?

That would depend on whether or not your project is a Perl 6 implementation.

tef
May 30, 2004

-> some l-system crap ->
Then you should use haskell

Zombywuf
Mar 29, 2008

tef posted:

Then you should use haskell

ITYM: every language under the sun

Brain Candy
May 18, 2006

MEAT TREAT posted:

gently caress Java for not having generic arrays!

gently caress Java for type erasure!

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
I don't buy type erasure as the excuse for not being able to say new T[n]. That expression doesn't even need any type information since the elements are all initialized to null and no other "T" methods are used.

It's just another reason to not use Java arrays for anything but varargs.

Vanadium
Jan 8, 2005

Mustach posted:

I don't buy type erasure as the excuse for not being able to say new T[n]. That expression doesn't even need any type information since the elements are all initialized to null and no other "T" methods are used.

It's just another reason to not use Java arrays for anything but varargs.

It needs to plug the type T into the array type at some point so RTTI can proceed to ask for the array's type. Which does not work if T gets erased.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Ah, I should've thought of that since I enjoy bitching about array covariance and the runtime checks associated with it.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

Vanadium posted:

It needs to plug the type T into the array type at some point so RTTI can proceed to ask for the array's type. Which does not work if T gets erased.
It puts the type into the array or it gets the erasure again.

floWenoL
Oct 23, 2002

rhag posted:

As usual, the answer to that is: depends on your project.

Perl is a language suited for certain tasks (and here i'm looking at its legendary strong point: regular expressions), and probably not so suited for others.

Can you build a GUI app with it? Of course. Should you? I doubt it.
Especially since PERL-compatible regex libraries have been created for other languages as well (java, c/c++, python i think)

So, at the end of the day, the questions to be asked are:
- Does my project require certain features that PERL would be a perfect solution?
- Who will code it? Do those people know PERL?Do they wanna know PERL?
- Who will maintain it? Does that team know PERL ?Do they wanna know PERL?

Do you know the difference between Perl 5.x and Perl 6? Or, for that matter, Perl and PERL?

biznatchio
Mar 31, 2001


Buglord

floWenoL posted:

Do you know the difference between Perl 5.x and Perl 6? Or, for that matter, Perl and PERL?

That was actually the posting equivalent of a design pattern. Posting it probably made the author feel smarter and like he actually contributed to what was going on, whether it actually fit into the discussion or not.

vanjalolz
Oct 31, 2006

Ha Ha Ha HaHa Ha
I had to write some stupid program in ActionScript (the ECMAScript used in flash files). Adobe has helper methods in the Microphone and Camera classes to get the devices and use them.

The prototypes look like this:
Microphone.Get(Integer)
Camera.Get(String)

:sciencefail: You'd think that since it accepts a string, the Camera.Get() needs the name of the camera to get. Not so. It still wants the id number... in a string instead of an integer. Its like they don't want code completion to be useful.

Intel Penguin
Sep 14, 2007
hooray

vanjalolz posted:

I had to write some stupid program in ActionScript (the ECMAScript used in flash files). Adobe has helper methods in the Microphone and Camera classes to get the devices and use them.

The prototypes look like this:
Microphone.Get(Integer)
Camera.Get(String)

:sciencefail: You'd think that since it accepts a string, the Camera.Get() needs the name of the camera to get. Not so. It still wants the id number... in a string instead of an integer. Its like they don't want code completion to be useful.

maybe the id can contain characters other than letters while microphones are always referred to by an integer since that's how windows managers audio input devices.

Not UNIX
Mar 29, 2005
It was stupid speculation when the WSJ reported it, and it's stupid speculation now. It's never going to happen.

vanjalolz posted:

I had to write some stupid program in ActionScript (the ECMAScript used in flash files). Adobe has helper methods in the Microphone and Camera classes to get the devices and use them.

The prototypes look like this:
Microphone.Get(Integer)
Camera.Get(String)

:sciencefail: You'd think that since it accepts a string, the Camera.Get() needs the name of the camera to get. Not so. It still wants the id number... in a string instead of an integer. Its like they don't want code completion to be useful.
Are you using AS2 or AS3? The definition in AS2 is public static get([index:Number]) : Camera, and in AS3, it's getCamera(name:String = null):Camera.

Presto
Nov 22, 2002

Keep calm and Harry on.

Not UNIX posted:

Are you using AS2 or AS3? The definition in AS2 is public static get([index:Number]) : Camera, and in AS3, it's getCamera(name:String = null):Camera.
Yes, but:

Adobe posted:

name:String (default = null) — Specifies which camera to get, as determined from the array returned by the names property. For most applications, get the default camera by omitting this parameter. To specify a value for this parameter, use the string representation of the zero-based index position within the Camera.names array. For example, to specify the third camera in the array, use Camera.getCamera("2").

Tad Naff
Jul 8, 2004

I told you you'd be sorry buying an emoticon, but no, you were hung over. Well look at you now. It's not catching on at all!
:backtowork:
From my own beautiful mind:

php:
<?
                if($url{0}=='/'){
                        if($path){
                                $url=$server.$url;
                        }else{
                                $url=$server.$path.$url;
                        }
                }else{
                        $url=$server.$path.'/'.$url;
                }
?>

Axel Rhodes Scholar
May 12, 2001

Courage Reactor

A piece of code I recently had the pleasure of looking over (provenance unspecified):

code:
int main(int argc, char** argv){
  [...]
  char szFile[30];
  [...]
  getopt("ab:cd")
  [...]
  strcpy(szFile, optargs);
  [...]
}
I forget the exact getopt string. Anyway, this program needed to be run suid root. The person responsible works at a security company.

And later, in the same codebase, about 3000 lines of code copy + pasted from IDA pro, with variable declarations for DWORD esi,eax,edx, etc, as well as an array for a fake stack and ~300 temporary values at the top to make it compile. My favourite part is that someone has seen fit to add the comment "// points to a DWORD" to every line that contains the string DWORD*.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
What is it about REST that gets people so confused? It doesn't seem like a difficult concept, but then I see "RESTful" APIs designed like this:

quote:

User online. This service returns whether the user is online or not. This is how i remembered how to write servlets.
code:
GET http://server/rest/user/online/zaryn%20zoryn
Kick user. Kicks a single user.
code:
POST http://server/rest/user/kick/zaryn%20zoryn
Kick a buncha users. the body should be a newline delimited list.
code:
POST http://server/rest/user/kick

Is it too much to ask that a user of some architecture actually *read* the paper in which that architecture was defined?

Mill Town
Apr 17, 2006

Janin posted:

What is it about REST that gets people so confused? It doesn't seem like a difficult concept, but then I see "RESTful" APIs designed like this:


Is it too much to ask that a user of some architecture actually *read* the paper in which that architecture was defined?

Most people interpret REST as "send whatever the hell I want over HTTP." I inherited a "REST" API where the command was solely determined by the URL, parameters could be passed by GET or POST, and the server always returned 200 OK as a response.

I cleaned it up to some degree but it still needed a lot of work when I left.

Ninja edit: And the person who wrote it rolled his own HTTP server because the default one was "slow." I never saw the benchmarks.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Janin posted:

What is it about REST that gets people so confused? It doesn't seem like a difficult concept, but then I see "RESTful" APIs designed like this:


Is it too much to ask that a user of some architecture actually *read* the paper in which that architecture was defined?

Could you repost those examples on how it should be done? I'm curious and I don't quite understand REST.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Triple Tech posted:

Could you repost those examples on how it should be done? I'm curious and I don't quite understand REST.
Read REST APIs must be hypertext-driven and It is okay to use POST. Summary: A REST API is distinguished from an RPC API by being a design and specification of the *responses*, rather than the *requests*. The only specified requests are the entry points, where initial information about the system may be obtained.

For example, assuming JSON-based resources, here's how that API could have been designed using REST:

code:
GET http://server/rest/users/

# Returns:
{
  "mass-kick-uri": "http://server/rest/user/kick",
  "user-list": [
    {"name": "zaryn zoryn",
     "uri": "http://server/rest/user/zaryn%20zoryn"}
  ]
}

# Retrieve per-user URI from user list resource
GET <user-uri>

# Returns:
{
  "name": "zaryn zoryn",
  "online": true,
  "kick-uri": "http://server/rest/user/kick/zaryn%20zoryn"
}

# To kick a user:
POST <kick-uri>

# To kick a bunch of users; uses mass-kick-uri from the main user list resource
POST <mass-kick-uri>
{"user-list": ["zaryn zoryn"]}
Note that aside from the entry point, I did not mention specific URIs anywhere in the API specification. How the client interacts with the server is defined by the values contained in returned resources. If/When the server is modified to use different URIs, or HTTPS, or load sharing, etc, the only piece of the client that's actually coupled to the server (the entry point) will have to change.

snowbee
Oct 1, 2003

line 67 :toot:
edit: it works only because in another function there's "if( name==null) return "null";"

snowbee fucked around with this message at 18:45 on Jun 1, 2009

OddObserver
Apr 3, 2009

Crackbunny posted:

line 67 :toot:
edit: it works only because in another function there's "if( name==null) return "null";"

So relying on the implementation hashcons'ing the string literal constants? (I don't remember, is that a MUST or a MAY, anyway?). They also can't seem to get method naming/capitalization consistent...

Pooball
Sep 21, 2005
Warm and squishy.

OddObserver posted:

So relying on the implementation hashcons'ing the string literal constants? (I don't remember, is that a MUST or a MAY, anyway?). They also can't seem to get method naming/capitalization consistent...

A must. From http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#101083:

quote:

String literals-or, more generally, strings that are the values of constant expressions (§15.28)-are "interned" so as to share unique instances, using the method String.intern

mr_jim
Oct 30, 2006

OUT OF THE DARK

This is paraphrased from a bit-array library that I'm working on.

code:
#define array_size(bits) (((bits) - 1) / (sizeof(unsigned int) * 8) + 1)
Any guesses for what array_size(0) returns?

Pooball
Sep 21, 2005
Warm and squishy.
edit: d'oh

mr_jim
Oct 30, 2006

OUT OF THE DARK

Nope. Here's a hint: it involves the C standard's arithmetic conversion rules.

Pooball
Sep 21, 2005
Warm and squishy.
Yeah, I wouldn't have guessed that. C is pretty weird.

Mill Town
Apr 17, 2006

mr_jim posted:

Nope. Here's a hint: it involves the C standard's arithmetic conversion rules.

I was guessing 0 due to integer division roundoff. Boy was I wrong!

Adbot
ADBOT LOVES YOU

mr_jim
Oct 30, 2006

OUT OF THE DARK

Mill Town posted:

I was guessing 0 due to integer division roundoff. Boy was I wrong!

gcc always truncates towards 0, but the C89 standard doesn't mandate that (C99 apparently does). That would make the expected result 1. That's not really what I wanted, but it's not as bad as what actually happens.

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