Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Allegro's relevance makes me happy

This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
Allegro's relevance makes me happy
Thomas Fjellstrom
Member #476
June 2000
avatar

Call me when I don't have to hack the runtime just to get it to work properly ;)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Bruce Perry
Member #270
April 2000

In fairness, this is a very obscure bug I'm fixing. DLLs crash during unload if the thread that loaded them has terminated. :)

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

Fishcake
Member #8,704
June 2007
avatar

I hate you.

;D

Thomas Fjellstrom said:

It's a horrible idea. It papers over fatal errors as if they don't exist, and its hard to track down what went wrong.

NULL/nil values should crash when you try to dereference them. period. It is the only sane option.

It's true that this behavior can be the source of hard-to-track bugs. But I've trained myself to always assert the preconditions of my functions (i.e. programming by contract), so I guess I'm safe (for now). :P

amarillion
Member #940
January 2001
avatar

Call me when I don't have to hack the runtime just to get it to work properly

With D, you'll never get accused of re-inventing the wheel. The wheel doesn't exist yet, so invent away! I'm going to write my own XML library, and after that, my own GUI.

--
Martijn van Iersel | My Blog | Sin & Cos | Tegel tilemap editor | TINS 2017

Thomas Fjellstrom
Member #476
June 2000
avatar

Fishcake said:

It's true that this behavior can be the source of hard-to-track bugs. But I've trained myself to always assert the preconditions of my functions (i.e. programming by contract), so I guess I'm safe (for now).

So you're checking for nil anyway? As you'd do without the nil feature?

So what's the point? :P

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Fishcake
Member #8,704
June 2007
avatar

So you're checking for nil anyway? As you'd do without the nil feature?

So what's the point?

It's a practice that I carry over across programming languages (C++, C, Objective-C, C#). I was told (from a video lecture) that it's a bad practice to rely on the implementation of a language (might be wrong, because I'm not sure how to word what he said). If one day, Apple decided to change the runtime and make sending message to a nil object crash, I will still keep my assert statements. :)

To be honest, the very reason I like having nil eat my messages is because I use the delegation pattern a lot, and it's more pleasant to write this:

[delegate doStuff];

than this:

if (delegate) {
   [delegate doStuff];
}

Other than the usage above, I agree that the nil behavior results in hard-to-track bugs without proper coding discipline. :)

Thomas Fjellstrom
Member #476
June 2000
avatar

I've actually had errors happen when I didn't check for the delegate, so I always do now. What can you do ;D

Fishcake said:

Other than the usage above, I agree that the nil behavior results in hard-to-track bugs without proper coding discipline.

IMO that makes it pointless in my eyes. Mistakes happen. And I want to be notified as soon as possible that I've made a mistake, rather than having to hunt down a hard to find condition some place that nils out a value on me.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Matthew Leverton
Supreme Loser
January 1999
avatar

Fishcake said:

To be honest, the very reason I like having nil eat my messages is because I use the delegation pattern a lot, and it's more pleasant to write this:

Yes, that's appropriate given how Obj-C works. Your delegates should (usually) be weak pointers, or else you'll get circular references that don't want to go away. >:(

Given that the language works the way that it does, it's silly to add nil checks. It's Obj-C, you might as well use it as such.

The reason I don't like it is that it becomes an invisible side effect and it is not immediately clear if nil is an expected behavior or not. In C++ if this crashes, you know (assuming the programmer is not a complete fool) that the bug is that foo should not be null:

this->foo(bar);

Whereas if you have this:

if (this->foo) {
  this->foo(bar);
}

then you know that foo is expected to sometimes be null.

Bruce Perry
Member #270
April 2000

...or false, if it were JavaScript or Lua or something. :)

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

bamccaig
Member #7,536
July 2006
avatar

JavaScript doesn't have a -> operator, but ignoring that also "" and the undefined value. :P Maybe also 0, but I forget (I generally don't mix types like that). VBScript is exceptionally special in this regard. You have False, 0, "", Empty, Null, Nothing (object concept of Null) (IIRC). Some of these values are considered equal to one another, and others are not. I don't even play that. I created a library of conversion functions that generally assert a specific type, or Null. The horrific On Error Resume Next is used to recover from type errors within. Then for variables that represent objects I always initialize them to Nothing so they are always either Nothing or an object. VBScript actually becomes kind of sane (albeit, still overly verbose and relatively ugly) once you do something like that. :P

Schyfis
Member #9,752
May 2008
avatar

The thing I didn't like about D when I tried it a few weeks back was that there is pretty much no support for it outside the D homepage and official D forums. If you have yourself a cryptic error, you're probably not going to be able to figure it out.

________________________________________________________________________________________________________
[freedwill.us]
[unTied Games]

furinkan
Member #10,271
October 2008
avatar

bamccaig said:

The brillant(tm) team leader started copying/pasting the class library project into every program "solution". So now we have 3 or 4 copies of the library and each of them has diverged.

Like I've probably explained before, at my place they've been literally copying and modifying similar projects since around 2006. Its to the point where none of the current developers have a good idea how stuff works, because there is no documentation and the guy who wrote most of our code got fired years ago. ;D

My boss just doesn't understand why it takes so long to do 'simple' modifications. Unfortunately, even simple modifications take a long time when you have three layers of code from three different coders using three different coding styles. :-/

Bruce Perry
Member #270
April 2000

Schyfis said:

If you have yourself a cryptic error, you're probably not going to be able to figure it out.

There's an element of that, I agree; and Google isn't very good at recognising searches for either 'D' or 'dlang'. On the other hand, the D.learn forum (or newsgroup if you prefer viewing it that way) is very good, full of people ready and willing to help newbies, and the community has a real culture of wanting people to use the language, so they (probably) won't drive anyone away! Also, you do find some D questions and answers on StackOverflow.

[EDIT]
furinkan, why was he fired? For bad code? For enjoying himself with the boss's daughter (who of course still has her job)?

Let's hope they're at least better at coding than the boss's new grandkid :) (No offence to the kid, it's just that he or she is young and probably can't write code yet.)

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

furinkan
Member #10,271
October 2008
avatar

@Bruce Perry:
He was fired for milking his hours. Surfing the net all day, wanking, I donno, but he's long gone and everything was just copied from him.

Funny thing is, boss actually thinks the guys coding is fine. Does this look fine to you? It took me several minutes to discern what he was doing; It never even occurred to me that somebody would solve a problem like that.

<?php
//$due_date is in the format YYYY-MM-DD, as is common in SQL DB's
$date = date('m', strtotime($due_date)).'/'.date('d', strtotime($due_date)).'/'.date('Y', strtotime($due_date));
?>

Bruce Perry
Member #270
April 2000

Took me about 30 seconds, but that's under the conditions of being challenged quiz-style with an isolated problem. I can imagine it taking longer when you're in the thick of it all day.

Look on the plus side: if he'd worked all those hours, you'd have even more of that code :)

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

Matthew Leverton
Supreme Loser
January 1999
avatar

furinkan said:

It took me several minutes to discern what he was doing;

It took me 0.00001 seconds. And then a few minutes of laughing.

$date = (new DateTime($date))->format('m/d/Y');

Besides the WTF of how he wrote the code, PHP programmers' love for strtotime() and 86400 is comical.

bamccaig
Member #7,536
July 2006
avatar

Didn't take me long either. At first it was like blah, but I verified the repeated strtotime expression, and once I did that it was easy to guess what it was doing. I happen to be faced with code like that on a regular basis though i.e., entire server-side pages duplicated to handle a little flag:

if(flag)
{
    /* 300 lines of code */
}
else
{
    /* same 300 lines of code with about 15 bytes difference */
}

I think that's a good measure of a programmer's quality. Show them a snippet of code with some obvious errors as well as redundancies and ask them to fix it. If they get it working without cleaning it up and eliminating the redundant code then thank them for their time and show them the door. >:(

Matthew Leverton
Supreme Loser
January 1999
avatar

I know this varies a lot depending on language and project, but any function with more than 10-15 lines is probably too big for a team project. A function should do only one thing, and do it well.

Bob Keane
Member #7,342
June 2006

Bamccaig said:

Show them a snippet of code with some obvious errors as well as redundancies and ask them to fix it. If they get it working without cleaning it up and eliminating the redundant code then thank them for their time and show them the door.

I'm probably missing the point due to a hard week's night but, what happened to the old adage "If it ain't broke, don't fix it."?

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
If we get apple juice from squeezing apples, and we get prunes from drying out plums, where does prune juice come from?
Hi Randall Monroe.

Arthur Kalliokoski
Second in Command
February 2005
avatar

Bob Keane said:

what happened to the old adage "If it ain't broke, don't fix it."?

Farmers used to plow a certain amount with an ox and small plow per day in medieval times, today we call this amount of land an "acre". They've "fixed" it for one man to be able to plow several hundred acres a day now, so most of us are something besides farmers.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Thomas Fjellstrom
Member #476
June 2000
avatar

Farmers used to plow a certain amount with an ox and small plow per day in medieval times, today we call this amount of land an "acre". They've "fixed" it for one man to be able to plow several hundred acres a day now, so most of us are something besides farmers.

Ah but something was broken. there wasn't enough food. or money. can never have enough money.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Arthur Kalliokoski
Second in Command
February 2005
avatar

Scarcity is a fact of life. Nobody ever has "enough", except in the eyes of those who have even less. Why wasn't BillyGates satisfied with his first billion of ill-gotten gains?

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Thomas Fjellstrom
Member #476
June 2000
avatar

Why wasn't BillyGates satisfied with his first billion of ill-gotten gains?

Why is he and Warren Buffet giving away most of their money?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Arthur Kalliokoski
Second in Command
February 2005
avatar

Ah, but Gates has already "won" the game, seemingly proving he's not the nerd he really is. And those billions aren't really doing that much good after all, there's a lot of crooks in the world.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

furinkan
Member #10,271
October 2008
avatar

bamccaig said:

I happen to be faced with code like that on a regular basis though i.e., entire server-side pages duplicated to handle a little flag

Yea. Lots of that too. And my favorite: nondescript includes that execute like three lines of code. I wonder sometimes if he even knew how to declare a function. :-X

It took me 0.00001 seconds. And then a few minutes of laughing.

Keep in mind I've spent a whole day muddling through jewels like that. I thought assuredly, it was doing something majestic! I'm obviously just too new at programming to understand its intricacies. ::) But no, I checked it many times over, and it's just an obfuscated (read: stupid) way to change the date format.

Imagine my surprise. >:(

Anyways, I'm going to veer back on topic, as we have a discussion about greed budding that can take my place. ;D

SDL is not the enemy.

No, its not. But its fun to peg an enemy. If I had internet other than on my phone, I'd be programming constantly.

 1   2   3   4 


Go to: