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."
NotShadowStar: it's not fair to blame Java for RIM's bullshit platform. Once you blatantly violate the JLS in your implementation, it isn't really Java anymore. Imagine the new levels of hell that might be unleashed if RIM tried to develop their own version of PHP.

Adbot
ADBOT LOVES YOU

NotShadowStar
Sep 20, 2000
You know the Godwin Law of Hitler, where Hitler is the singularity of everything terrible in the 20th century.

Java is like that, it's the singular point of everything terrible in technology.

Yes, Java is Hitler. :godwin: :goonsay:

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Does that make PHP Stalin?

Zombywuf
Mar 29, 2008

w00tz0r posted:

You're right, I'm totally off the mark with this one. My original plan was to use a vector, since it has contiguous memory allocation, rather than a linked list; LinkedHashMap was a terrible example, I was thinking of complexity, not efficiency.

I forgot we were storing pointers to the objects, not the object themselves; so even if we used a contiguous block of memory to store them, we'd still get cache misses when we went to dereference the pointers.

Haha, fair enough. With that extra information it is most certainly a horror.

Also yeah, I'd use a vector along the lines of:
code:
template<class X>
class IterableHashMapImpl {
  std::vector<X> m_vector;
  std::hash_map<typename std::vector<X>::iterator> m_hash_index;
...
edit: oh wait, do you mean he overloaded new on the objects being stored, in which case it's possibly a non-horrific way of working around other horrors in the codebase.

Zombywuf fucked around with this message at 11:58 on Sep 30, 2010

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

NotShadowStar posted:

Yes, Java is Hitler. :godwin: :goonsay:

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



NotShadowStar posted:

I wonder how RIM isn't sued to hell from Oracle like they're doing with Google.

Maybe the secret to not getting sued is to make really terrible copies.

I do wish Google had chosen something other (less verbose) than Java, though.

Munkeymon fucked around with this message at 15:08 on Sep 30, 2010

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Munkeymon posted:

Maybe the secret to not getting sued is to make really terrible copies.

I do wish Google had chosen something other (less verbose) than Java, though.

They have Guido Van Rossum on their team!! loving google :argh:

NotShadowStar
Sep 20, 2000

Munkeymon posted:

Maybe the secret to not getting sued is to make really terrible copies.

I do wish Google had chosen something other (less verbose) than Java, though.

It looks like Scala and JRuby run on Dalvik, so there's that.

You could also drop down to C++ :suicide:

w00tz0r
Aug 10, 2006

I'm just so god damn happy.

Zombywuf posted:

Haha, fair enough. With that extra information it is most certainly a horror.

Also yeah, I'd use a vector along the lines of:
code:
template<class X>
class IterableHashMapImpl {
  std::vector<X> m_vector;
  std::hash_map<typename std::vector<X>::iterator> m_hash_index;
...
edit: oh wait, do you mean he overloaded new on the objects being stored, in which case it's possibly a non-horrific way of working around other horrors in the codebase.

In hindsight, it's not the fact that he's using a custom memory pool that's a horror - cache misses are an issue, and this resolves them - it's just his implementation and lack of documentation. As is usual with this codebase, I get told to do a simple task like "parse this file into this data structure", and then when I start to look at how, it requires 14 classes and a custom memory pool.

qntm
Jun 17, 2009
In Python, to quote the Python thread, a folder is a package.

In Perl, this is not true. When you use the "use" function, all the terms are directories except the last one which is the file. And the double colon :: is the delimiter between each term. ...But the file can contain a package or packages plural which are named completely differently. You have absolutely no idea what semantics you just imported. Plus, when you do start to make use of stuff in that package, suddenly all the terms are levels in the package heirarchy except the last term which is a function or variable inside the file, and the double colon is now magically the package heirarchy delimiter. Only now have I realised that any agreement between the package heirarchy and the filesystem heirarchy is basically just a huge coincidence, and even now I probably still have most of this wrong. Why would a programming language even allow you to do such confusing things?

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
We have some code that generates SQL queries based on limited regexes that a user can enter. For some of these, we have to query a secondary table to determine which rows we can pull from the primary table, via regex.

Here's a small portion of one of the queries generated today:

select id, field1, field2, field3, field4 from TABLE where id> 0 and (id regexp '^3$' or id regexp '^4$' or id regexp '^5$' or id regexp '^6$' or id regexp '^7$' or id regexp '^8$' or id regexp '^9$' or id regexp '^10$' or id regexp '^11$' or id regexp '^12$' or id regexp '^13$' or id regexp '^14$' or id regexp '^15$' or id regexp '^16$' or id regexp '^17$' or id regexp '^18$' or id regexp '^19$' or id regexp '^20$' or id regexp '^21$' or id regexp '^22$' or id regexp '^23$' or id regexp '^24$' or id regexp '^25$' or id regexp '^26$' or id regexp '^27$' or id regexp '^28$' or id regexp '^29$' or id regexp '^30$' or id regexp '^31$' or id regexp '^32$' or id regexp '^33$' or id regexp '^34$' or id regexp '^35$' or id regexp '^36$' or id regexp '^37$' or id regexp '^38$' or id regexp '^39$' or id regexp '^40$' or id regexp '^41$' or id regexp '^42$' or id regexp '^43$' or id regexp '^44$' or id regexp '^45$' or id regexp '^46$' or id regexp '^47$' or id regexp '^48$' or id regexp '^49$' or id regexp '^50$' or id regexp '^51$' or id regexp '^52$' or id regexp '^53$' or id regexp '^54$' or id regexp '^55$' or id regexp '^56$' or id regexp '^57$' or id regexp '^58$' or id regexp '^59$' or id regexp '^60$' or id regexp '^61$' or id regexp '^62$' or id regexp '^63$' or id regexp '^64$' or id regexp '^65$' or id regexp '^66$' or id regexp '^67$' or id regexp '^68$' or id regexp '^69$' or id regexp '^70$' or id regexp '^71$' or id regexp '^72$' or id regexp '^73$' or id regexp '^74$' or id regexp '^75$' or id regexp '^76$' or id regexp '^77$' or id regexp '^78$' or id regexp '^79$' or id regexp '^80$' or id regexp '^81$' or id regexp '^82$' or id regexp '^83$' or id regexp '^84$' or id regexp '^85$' or id regexp '^86$' or id regexp '^87$' or id regexp '^88$' or id regexp '^89$' or id regexp '^90$' or id regexp '^91$' or id regexp '^92$' or id regexp '^93$' or id regexp '^94$' or id regexp '^95$' or id regexp '^96$' or id regexp '^97$' or id regexp '^98$' or id regexp '^99$' or id regexp '^100$' or id regexp '^101$' or id regexp '^300$' or id regexp '^301$' or id regexp '^302$' or id regexp '^303$' or id regexp '^304$' or id regexp '^305$' or id regexp '^306$' or id regexp '^307$' or id regexp '^308$' or id regexp '^309$' or id regexp '^310$' or id regexp '^311$' or id regexp '^312$' or id regexp '^313$' or id regexp '^314$' or id regexp '^315$' or id regexp '^1018$' or id regexp '^1019$' or id regexp '^1020$' or id regexp '^1021$' or id regexp '^1022$' or id regexp '^1023$' or id regexp '^1024$' or id regexp '^1025$' or id regexp '^1026$' or id regexp '^1027$' or id regexp '^1028$' or id regexp '^1029$' or id regexp '^1030$' or id regexp '^1031$' or id regexp '^1032$' or id regexp '^1033$' or id regexp '^1034$' or id regexp '^1035$' or id regexp '^1036$' or id regexp '^1037$' or id regexp '^1038$' or id regexp '^1039$' or id regexp '^1040$' or id regexp '^1041$' or id regexp '^1042$' or id regexp '^1043$' or id regexp '^1044$' or id regexp '^1045$' or id regexp '^1046$' or id regexp '^1047$' or id regexp '^1048$' or id regexp '^1049$' or id regexp '^1050$' or id regexp '^1051$' or id regexp '^1052$' or id regexp '^1053$' or id regexp '^1054$' or id regexp '^1055$' or ...

:cry:

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

qntm posted:

In Python, to quote the Python thread, a folder is a package.

In Perl, this is not true. When you use the "use" function, all the terms are directories except the last one which is the file. And the double colon :: is the delimiter between each term. ...But the file can contain a package or packages plural which are named completely differently. You have absolutely no idea what semantics you just imported. Plus, when you do start to make use of stuff in that package, suddenly all the terms are levels in the package heirarchy except the last term which is a function or variable inside the file, and the double colon is now magically the package heirarchy delimiter. Only now have I realised that any agreement between the package heirarchy and the filesystem heirarchy is basically just a huge coincidence, and even now I probably still have most of this wrong. Why would a programming language even allow you to do such confusing things?


You seem to have thoroughly confused the default place perl looks for a Perl package based on its namespace with some sort of deep meaning, and also forgotten that you have very, very fine grained control of what semantics you import.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



NotShadowStar posted:

It looks like Scala and JRuby run on Dalvik, so there's that.

They seem to have abandoned the Python compiler in favor of ASE, though :\

quote:

You could also drop down to C++ :suicide:

Yeah, I saw that and my first thought was "Let's fracture the platform as hard as we loving can!" but maybe I'm overreacting

Combat Pretzel
Jun 23, 2004

No, seriously... what kurds?!
I just wrote a short three number wide median algorithm using ?: notation. After I removed the helping parentheses, I got this construct out of it:

code:
m = y < z ? x < y ? y : x < z ? x : z : y < x ? y : x < z ? z : x;
Gotta hate certain C based syntax elements. :suicide:

1337JiveTurkey
Feb 17, 2005

Plorkyeran posted:

Does that make PHP Stalin?

No, .NET is Stalin and Mono is the People's Republic of Tannu Tuva. PHP is probably Imperial Japan or something.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

1337JiveTurkey posted:

No, .NET is Stalin and Mono is the People's Republic of Tannu Tuva. PHP is probably Imperial Japan or something.

PHP just doesn't have an Imperial Japan feel to me. PHP is more like a tribe that is into some weird freaky poo poo they do out in the middle of the jungle, oblivious to the modern civilizations being built around them.

Haystack
Jan 23, 2005





PHP is Pol Pot

qntm
Jun 17, 2009

Otto Skorzeny posted:

You seem to have thoroughly confused the default place perl looks for a Perl package based on its namespace with some sort of deep meaning, and also forgotten that you have very, very fine grained control of what semantics you import.

Well, by all means explain it. As I understand it, "use Foo::Bar;" will make Perl look through all of the directories in @INC for a file named "Foo/Bar.pm", NOT for a file containing "package Foo::Bar;". That is, it is a command to import a specific file, and "::" is being made into a directory separator. Meanwhile, Foo/Bar.pm could start off with "package Something::Else;", so that when, later in the script, you start calling Something::Else::function(), (1) the "::" suddenly has a completely different meaning and (2) the reader has no idea where this function has mysteriously appeared from.

POKEMAN SAM
Jul 8, 2004

Combat Pretzel posted:

I just wrote a short three number wide median algorithm using ?: notation. After I removed the helping parentheses, I got this construct out of it:

code:
m = y < z ? x < y ? y : x < z ? x : z : y < x ? y : x < z ? z : x;
Gotta hate certain C based syntax elements. :suicide:

this is awesome don't let anyone else tell you otherwise

McGlockenshire
Dec 16, 2005

GOLLOCKS!
php-internals is Kim Jung-il. PHP is North Korea.

e: also,

qntm posted:

Well, by all means explain it. As I understand it, "use Foo::Bar;" will make Perl look through all of the directories in @INC for a file named "Foo/Bar.pm", NOT for a file containing "package Foo::Bar;". That is, it is a command to import a specific file, and "::" is being made into a directory separator. Meanwhile, Foo/Bar.pm could start off with "package Something::Else;", so that when, later in the script, you start calling Something::Else::function(), (1) the "::" suddenly has a completely different meaning and (2) the reader has no idea where this function has mysteriously appeared from.

Any Perl developer that places two unrelated packages in a single .pm file deserves to get shot in the face, and then only under extremely extreme circumstances. If you see this on CPAN, name and shame. I'll bring the pitchforks.

McGlockenshire fucked around with this message at 00:49 on Oct 1, 2010

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal
PHP is fascist Italy. All of their poo poo is shoddily built and is barely fit to subjugate Ethiopia/be used as a scripting language. Their general staff ranks from useless to incompetent to insane, and any competent engineer/scientist/technician has long since fled to better places. Unfortunately, they happen to be positioned in such a way that no matter what side you're on you'll have to deal with them at some point.

Flobbster
Feb 17, 2005

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

Combat Pretzel posted:

I just wrote a short three number wide median algorithm using ?: notation. After I removed the helping parentheses, I got this construct out of it:

code:
m = y < z ? x < y ? y : x < z ? x : z : y < x ? y : x < z ? z : x;
Gotta hate certain C based syntax elements. :suicide:

That's nothin' compared to the elevenary operator.

Oddly enough, your median algorithm doesn't disturb me as much as Stepanov's order-selection algorithms in Elements of Programming (well, maybe if you added the parens back at least). Although after some aggressive template-based inlining, I bet they end up being nearly the exact same assembly code.

A very bad man
Mar 31, 2010

Zombywuf posted:

That has nothing to do with Perl, I used to have to maintain a 60,000 line XSLT file.

What has what to do with what? I have seen regex's that have destroyed worlds, and bad Perl code is the worst kind of code.

Plorkyeran
Mar 22, 2007

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

Flobbster posted:

Oddly enough, your median algorithm doesn't disturb me as much as Stepanov's order-selection algorithms in Elements of Programming (well, maybe if you added the parens back at least). Although after some aggressive template-based inlining, I bet they end up being nearly the exact same assembly code.
Assuming the compiler doesn't explode in the process.

Actually using Stepanov's order-selection algorithm over just sorting and grabbing the middle element would nearly always be a bit of a horror, but I guess if you need its performance it's better than trying to write the same thing without the ridiculous template metaprogramming.

Zombywuf
Mar 29, 2008

A very bad man posted:

What has what to do with what? I have seen regex's that have destroyed worlds, and bad Perl code is the worst kind of code.

No, it really really isn't, I'd paste some of this xslt, but business concerns were buried so deep into the madness of this web scraping tool it's impossible. Perl does not make code any worse. Hell, good Haskell code is twice as unreadable as bad Perl.

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"

Zombywuf posted:

Hell, good Haskell code is twice as unreadable as bad Perl.
This isn't true at all, FYI -- good Haskell is roughly comparable to Ruby, better than Python, and much better than Perl.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Janin posted:

This isn't true at all, FYI -- good Haskell is roughly comparable to Ruby, better than Python, and much better than Perl.

You seriously consider Ruby more readable than Python? Every Ruby example I see reminds me of Perl golf*.

*I have not made a serious effort to learn Ruby, but I have looked at code samples out of curiosity

mr_jim
Oct 30, 2006

OUT OF THE DARK

Munkeymon posted:

You seriously consider Ruby more readable than Python? Every Ruby example I see reminds me of Perl golf*.

*I have not made a serious effort to learn Ruby, but I have looked at code samples out of curiosity

There's a lot of bad Ruby out there.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Munkeymon posted:

Every Ruby example I see reminds me of Perl golf*.

*I have not made a serious effort to learn Ruby, but I have looked at code samples out of curiosity

Seconding this. I made it about as far as the difference between the .. and ... operators. Ruby may be concise, but you're kidding yourself if you call it intuitive.

POKEMAN SAM
Jul 8, 2004

Janin posted:

This isn't true at all, FYI -- good Haskell is roughly comparable to Ruby, better than Python, and much better than Perl.

Better than Python? Reading Python is just reading pseudocode that can be interpreted by a computer, too.

tef
May 30, 2004

-> some l-system crap ->
I think he's talking about how haskell's type signatures add to the readability:

code:

import Control.Morphism.Zygo
import Control.Morphism.Prepro
import Control.Morphism.Histo
import Control.Functor.Algebra
import Control.Functor.Extras

zygohistomorphic_prepromorphism :: Functor f => Algebra f b -> GAlgebra f (Cofree f) a -> (f :~> f) -> FixF f -> a
zygohistomorphic_prepromorphism f = g_prepro (distZygoT (liftAlgebra f) (distHisto id))
-- unless you want a generalized zygomorphism.

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

Ugg boots posted:

Better than Python? Reading Python is just reading pseudocode that can be interpreted by a computer, too.

My pseudocode isn't full of __________gratuitous_underscores__________

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Otto Skorzeny posted:

My pseudocode isn't full of __________gratuitous_underscores__________

Maybe that's why your computer refuses to interpret it

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"

Ugg boots posted:

Better than Python? Reading Python is just reading pseudocode that can be interpreted by a computer, too.
Haskell is the same, except more so. There's no(extra(parentheses()()), or, commas()) cluttering it up, and monads make workarounds like explicit "self" unnecessary.

tef posted:

zygohistomorphic_prepromorphism
You're aware that this is a joke, right? That entire page is parody.

tef
May 30, 2004

-> some l-system crap ->
Yes


My point was that haskell is as readable as the types it is using. A lot of haskell is readable but I feel like i need a PHD in category theory for some of the more crazy stuff.

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"
I'm not denying that it's *possible* to write unreadable code in Haskell. Rather, I'm simply stating that properly written Haskell is more readable than properly written Python.

Type signatures, types, and especially category theory have nothing to do with it. In fact, category theory is irrelevant to 99% of Haskell programmers.

NotShadowStar
Sep 20, 2000

Internet Janitor posted:

Seconding this. I made it about as far as the difference between the .. and ... operators. Ruby may be concise, but you're kidding yourself if you call it intuitive.

Que.

Actually I've been doing Ruby for like 6 years and I have never seen this triple dot. I had to look it up, and it looks straightforward.

Old Ruby code can be really bad because it's either 'oh hai metaprogramming and syntax shortcuts' and a huge mess (I maintain the old Ruby-LDAP library and it's like this, we're slowly fixing it) or it's Java refugees making a gigantic mess out of poo poo (MOAR CLASSES).

People who actually get it, it's loving awesome. You can write crazy DSLs without anyone having to understand why the DSL works. Like this RSpec test I converted:

code:
  context "when reading an invalid string" do
    subject { "xxx" }
    its(:read_ber!) { should be nil }
    it { should eq "xxx "}
  end
If you don't understand that then...

Or check out the new upcoming superstar Homebrew which is a no-bullshit package manager for OSX. It's written in Ruby, and package specifications are written as 'formulae', but you don't need to know anything about Ruby because Homebrew is great and built a fantastic DSL:

code:
require 'formula'

class Io <Formula
  head 'git://github.com/stevedekorte/io.git'
  homepage 'http://iolanguage.com/'

  depends_on 'cmake'
  depends_on 'libsgml'

  def install
    ENV.j1
    mkdir 'io-build'

    Dir.chdir 'io-build' do
      system "cmake .. #{std_cmake_parameters}"
      system "make install"
    end

    rm_f Dir['docs/*.pdf']
    doc.install Dir['docs/*']

    prefix.install 'license/bsd_license.txt' => 'LICENSE'
  end
end
Actually old Rails before 3 was nothing but a gigantic metaprogramming machine, but Rails 3 kicked all that poo poo out and made it sane.

wwb
Aug 17, 2004

Small horrors are the best.

Requirement: Validator should ensure that object has no child objects and no related objects.

Thank ye gods I was walking through the junior developer's office as we don't have much in the way of formal code reviews. Mainly because I think my people can handle poo poo like this. But apparently this guy missed the day on operators. He wrote this:

code:
if (entity.Children.Count > 1) { // invalidate for save }
if (entity.Relations.Count > 1) { // invalidate for save }
Now, I've miskeyed stuff. Lots of stuff. And I'll even try and believe you might have been using the keypad to type numbers so you even missed. But you went and did it twice. Then you argued with me that it was correct.

Good help is hard to find.

tef
May 30, 2004

-> some l-system crap ->

NotShadowStar posted:

You can write crazy DSLs without anyone having to understand why the DSL works.

People who actually get it, it's loving awesome. You can write crazy DSLs without anyone having to understand why the DSL works.

These embedded languages aren't really 'domain-specific' by virtue of being a superset of ruby. Unless of course you think ruby itself isn't a general programming language. That and you'd expect the errors from a domain specific language would be about the language itself.

:spergin:

It isn't a DSL unless you get errors about the language itself when things break. Abstractions are double edged - people shouldn't have to understand how the internals work *or* fails. You might as well call any set of C preprocessor macros a DSL

Adbot
ADBOT LOVES YOU

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"

tef posted:

These embedded languages aren't really 'domain-specific' by virtue of being a superset of ruby. Unless of course you think ruby itself isn't a general programming language. That and you'd expect the errors from a domain specific language would be about the language itself.

:spergin:

It isn't a DSL unless you get errors about the language itself when things break. Abstractions are double edged - people shouldn't have to understand how the internals work *or* fails. You might as well call any set of C preprocessor macros a DSL
"DSL" is what Ruby people call libraries

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