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
JawnV6
Jul 4, 2004

So hot ...

Dren posted:

Poor Pollyanna just wants to unleash poorly founded vitriol about Java is that so wrong?

It was fine when I was a young whippersnapper, but now it's not and nobody else can have that fun. :colbert:

Adbot
ADBOT LOVES YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

shrughes posted:

Things would just be so much better if we got rid of Java and made an intuitive visual programming language.

I mean really we should just have a common business oriented language, then we don't need programmers at all anymore. We could call it COMBUORLA or something.

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

ratbert90 posted:

Ran across this in the kernel today (Freescale):


Yup, that's my #1 complaint about private vendor kernel trees: absolute dogshit like that is in them that would rightly get blasted when they try to submit it mainline.

That and never bothering to update. Have you tried to backport embedded infrastructure from 3.10 to 3.0.35? Ugh.

Zombywuf
Mar 29, 2008

We should just write everything in Agda, then there would be no bugs.

Because it is impossible to write anything in Agda.

QuarkJets
Sep 8, 2008

I, too, did not base my "gently caress Java" statement on a hello world example. Java has plenty of important things to be concerned about without using "ease of writing hello world apps" as a metric

tef
May 30, 2004

-> some l-system crap ->

Dren posted:

Poor Pollyanna just wants to unleash poorly founded vitriol about Java is that so wrong?

It's fine to hate on things, but we encourage nuanced hatred, over the "we just started using it and there is a lot of text" hated. For example, whining about python is fine, once you get past the "eww whitespace" stage.

Especially when the hating is coming from someone looking for any excuse to avoid writing code, meanwhile pleading for help. Code: It's going to suck.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

tef posted:

whining about python is fine, once you get past the "eww whitespace" stage.
However, once you are past this stage, if you're looking to troll python developers, "eww whitespace" is a fantastic way to do it.

quote:

Code: It's going to suck.

This really needs to be at the beginning of every intro to programming ever. Every design you ever come up with is going to be perfect and elegant and beautiful. And then you're going to have to actually write it and it's going to be impossibly ugly.

EAT THE EGGS RICOLA
May 29, 2008

tef posted:

It's fine to hate on things, but we encourage nuanced hatred, over the "we just started using it and there is a lot of text" hated. For example, whining about python is fine, once you get past the "eww whitespace" stage.

Especially when the hating is coming from someone looking for any excuse to avoid writing code, meanwhile pleading for help. Code: It's going to suck.

I hate the way that haml nesting is done through whitespace. It doesn't bug me in any other language, but for some reason it drives me insane in haml.

There, I said it.

Thern
Aug 12, 2006

Say Hello To My Little Friend
I once had to maintain a C# program that dynamically generated VBA macros and then called Excel to execute them. I no longer have the capacity to hate any Programming Languages after that, because I can no longer feel.

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

Dessert Rose posted:

However, once you are past this stage, if you're looking to troll python developers, "eww whitespace" is a fantastic way to do it.

Can we hate on untyped languages? Because coding in python/php/js/<insert interpreted language here> just feels like coding in C89 and having every variable be a void *.

The whitespace bugs me for a bit when I switch to python work, but it's not something that you actually feel after a while. The nagging "Am I sure this is actually what I think it is?" when anything can be anything gets me every time. How do you deal with it, especially when working on inherited code?

When trolling about python, I usually point at the Global Interpreter Lock because that's a coding horror all on it's own. If it were just the GIL, it'd be something fixable. The problem is like the BKL on linux, a bunch of cruft was written without re-entrancy in mind that's protected behind the global lock and god only knows what will break if you get rid of it.

Harik fucked around with this message at 02:29 on Dec 17, 2013

Posting Principle
Dec 10, 2011

by Ralp
python is strongly typed though.

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

Posting Principle posted:

python is strongly typed though.

Maybe I'm using the wrong term, but

Python code:
def delete(mylist, item):
    if isinstance(item, int):
       del mylist[item]
    else:
       mylist.remove(item)
isn't strongly typed to me. This is actually example code right off the python documentation, and guess what happens if mylist is a sparse list of integers?

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
I'm a huge fan of Nick Coghlan's Python 3 Q & A, especially the But, but, surely fixing the GIL is more important than fixing Unicode... section.

EDIT:

Harik posted:

Maybe I'm using the wrong term

Correct. You are talking about static vs. dynamic typing. Python is strongly and dynamically typed. I've always liked this diagram and hopefully have reproduced it well enough:

code:
                    Strong
                       |
                       |
           Java        |    Python
                       |
                       |
Static ----------------+--------------- Dynamic
                       |
                       |    Javascript
             C         |    Perl
                       |
                       |
                      Weak
I didn't intend the distance along each axis to mean anything and arbitrarily picked a few languages that occurred to me at the time.

Lysidas fucked around with this message at 03:28 on Dec 17, 2013

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

Lysidas posted:

Correct. You are talking about static vs. dynamic typing. Python is strongly and dynamically typed.

Whoops, you're right, that's what I meant. Since so many interpreted languages play fast-and-loose with types I mixed up dynamic typing with weak typing.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
It's basically a given that any conversation about strong/weak typing will involve people using completely different definitions for the terms.

tef
May 30, 2004

-> some l-system crap ->
Yep, python has really strong typing

code:
>>> True * 3
3
code:
>>> a = [1,2,3]
>>> a.extend("abc")
>>> a
[1, 2, 3, 'a', 'b', 'c']
:v:

tef
May 30, 2004

-> some l-system crap ->
Back on track, this is a masterpiece

quote:

> The core functions which follow neither rule include C-style
> abbreviations like "strptime" which couldn't be automatically swapped to
> either format, and complete anomalies like "nl2br". If you named those
> functions as part of a consistent style, you would probably also follow
> stronger naming conventions than Rasmus did when he named
> "htmlspecialchars".

Well, there were other factors in play there. htmlspecialchars was a
very early function. Back when PHP had less than 100 functions and the
function hashing mechanism was strlen(). In order to get a nice hash
distribution of function names across the various function name lengths
names were picked specifically to make them fit into a specific length
bucket. This was circa late 1994 when PHP was a tool just for my own
personal use and I wasn't too worried about not being able to remember
the few function names.

-Rasmus

Opinion Haver
Apr 9, 2007

PHP is a piece of performance art. That's the only explanation.

Lurchington
Jan 2, 2003

Forums Dragoon

tef posted:

Yep, python has really strong typing

code:
>>> True * 3
3
code:
>>> a = [1,2,3]
>>> a.extend("abc")
>>> a
[1, 2, 3, 'a', 'b', 'c']
:v:


I'm definitely con on string types counting as an iterable for most things, but given that, it still makes consistent
code:
>>> isinstance('butts', collections.Sequence)
True
and True on 2.x are instances of int:
code:
>>> isinstance(True, int)
True
>>> issubclass(bool, int)
True

Lurchington fucked around with this message at 07:28 on Dec 17, 2013

NFX
Jun 2, 2008

Fun Shoe

tef posted:

Yep, python has really strong typing

code:
>>> True * 3
3
code:
>>> a = [1,2,3]
>>> a.extend("abc")
>>> a
[1, 2, 3, 'a', 'b', 'c']
:v:

code:
>>> a.extend(4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
>>> a.append("abc")
>>> a
[1, 2, 3, 'a', 'b', 'c', 'abc']
What did you expect when using extend?

QuarkJets
Sep 8, 2008

tef posted:

Yep, python has really strong typing

code:
>>> True * 3
3
:v:

Yeah, there's simply no way that True could be inheriting from int, seeing as how no language has ever allowed True and False to represent 1 and 0

QuarkJets fucked around with this message at 08:46 on Dec 17, 2013

het
Nov 14, 2002

A dark black past
is my most valued
possession

QuarkJets posted:

Yeah, no other language allows True and False to be represented as the integers 1 and 0
Well he wasn't necessarily saying it was absurd on the whole, just that it didn't represent what you would call strong typing. Also, coercing 1/0 to true/false seems more reasonable than the converse to me.

edit: oh, you edited. whatever, I still think that's sort of silly even if it's one of those things that doesn't often impact real world coding

QuarkJets
Sep 8, 2008

het posted:

Well he wasn't necessarily saying it was absurd on the whole, just that it didn't represent what you would call strong typing. Also, coercing 1/0 to true/false seems more reasonable than the converse to me.

edit: oh, you edited. whatever, I still think that's sort of silly even if it's one of those things that doesn't often impact real world coding

I think that having False and True be represented by integers has become so ingrained in so many languages that if it suddenly wasn't the case then people would just be making GBS threads on Python for that instead, even though it's largely irrelevant trivia at this point

e: Although I guess in Java false and true aren't representable by integers, so there's that

QuarkJets fucked around with this message at 09:25 on Dec 17, 2013

Jewel
May 2, 2009

QuarkJets posted:

I think that the 0=False, 1=True thing has become so ingrained that if it suddenly wasn't the case then people would just be making GBS threads on Python for that instead, even though it's largely irrelevant trivia at this point

I wouldn't call the physical state of a switch to be "on" and "off" signified by 1 and 0, much like the power that flows through them, and the relevance that has to stuff like logic/boolean gates, to be "largely irrelevant trivia", though :v:

Edit: Also coersion to 1 and 0 is super nice because I get really annoyed in languages like C# where I can't just write

code:
int someInt = someBool * 100;
or in a more practical case, something like this:

code:
int offset = (i % 3 == 0) * 100;
or, for something like XNA in a loop of items or something:

code:
int offset = (i == currentSelected) * 100;

Jewel fucked around with this message at 09:31 on Dec 17, 2013

Nippashish
Nov 2, 2005

Let me see you dance!

Jewel posted:

I wouldn't call the physical state of a switch to be "on" and "off" signified by 1 and 0, much like the power that flows through them, and the relevance that has to stuff like logic/boolean gates, to be "largely irrelevant trivia", though :v:

What do the numbers 1 and 0 have to do with "on" and "off"?

Jewel
May 2, 2009

Nippashish posted:

What do the numbers 1 and 0 have to do with "on" and "off"?

0 signifies nothing (no power in this case) and 1 signifies something being completely on (power in this case). As if 0 is 0% and 1 is 100%. Which is 0-1 ratios that we use a lot in programming regardless (lerp(a, b, percentFrom0To1))

When you think about circuitry as a bunch of logic gates 1 and 0 make a lot more sense. This thing only activates when it gets Something (Power) from here and Nothing from here. That mindset transfers pretty easily and natively to programming imo.

Edit: vvv That's what I have to resort to, but it can feel cluttered and gross.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Jewel posted:

or in a more practical case, something like this:

code:
int offset = (i % 3 == 0) * 100;

Just write
code:
int offset = (i % 3 == 0) ? 100 : 0;
Much easier for everybody.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Jewel posted:

0 signifies nothing (no power in this case) and 1 signifies something (power in this case).

You're saying the correlation is there because you're used to it.

You could be talking about voltages, but then you need to learn about the static discipline, and VOL and VIH. The gist of it is that the world is full of noise and margin-of-error things that will gently caress up your signals if you're not careful, so you need to pick an arbitrary limit for what's logically zero and what's logically one that are well-suited for your environment and use case.

It's quite rare that you ever see zero voltage across a wire, even if it's treated as a logical zero. Real-world physics is dope, yo.

Jewel
May 2, 2009

Suspicious Dish posted:

You're saying the correlation is there because you're used to it.

You could be talking about voltages, but then you need to learn about the static discipline, and VOL and VIH. The gist of it is that the world is full of noise and margin-of-error things that will gently caress up your signals if you're not careful, so you need to pick an arbitrary limit for what's logically zero and what's logically one that are well-suited for your environment and use case.

It's quite rare that you ever see zero voltage across a wire, even if it's treated as a logical zero. Real-world physics is dope, yo.

Well yeah but I didn't expect other people to know (or care) about nuances like that. We still say that "okay that's basically nothing so let's treat it as nothing" and 0 is "nothing" almost universally.

Zombywuf
Mar 29, 2008

Any language where you can't do:
C++ code:
struct dicks {
  int farts;
};
struct butts {
  char *poop;
  dicks boner;
};
dicks a;
butts *b = (butts *)(&a);
has no claim to being weakly typed.

Ornedan
Nov 4, 2009


Cybernetic Crumb
code:
import Unsafe.Coerce

data Foo = Foo String
         deriving Show
data Bar = Bar Int
         deriving Show

foo :: Foo
foo = Foo "---"

bar :: Bar
bar = unsafeCoerce foo

main = do
  print foo
  print bar
I'm not sure that Haskell should be called weakly typed, though.

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!
At the same time, Haskell's not perfectly strongly-typed, either (bottom is a single value that inhabits all types, which technically allows coercion between any two types); you have to go with Agda if you want that.

Sockser
Jun 28, 2007

This world only remembers the results!




Hey thread, I got a lovely bachelor's in computer science and at work I develop internal tools where nobody else will ever look at my code until I leave the company so I never really get feedback other than "it does/n't work"

How do I learn to be a better programmer and avoid doing dumb poo poo that crops up in this thread?

EAT THE EGGS RICOLA
May 29, 2008

Sockser posted:

Hey thread, I got a lovely bachelor's in computer science and at work I develop internal tools where nobody else will ever look at my code until I leave the company so I never really get feedback other than "it does/n't work"

How do I learn to be a better programmer and avoid doing dumb poo poo that crops up in this thread?

Make something cool and put it on github? Then use that to get a neat job?

astr0man
Feb 21, 2007

hollyeo deuroga

Sockser posted:

How do I learn to be a better programmer and avoid doing dumb poo poo that crops up in this thread?

Program more and then when someone tells you something you did is dumb don't do it any more.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Never make any mistakes. Easy.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
[edit] wrong thread

:downs:

New Yorp New Yorp fucked around with this message at 20:00 on Dec 17, 2013

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

Jewel posted:

I wouldn't call the physical state of a switch to be "on" and "off" signified by 1 and 0, much like the power that flows through them, and the relevance that has to stuff like logic/boolean gates, to be "largely irrelevant trivia", though :v:

Edit: Also coersion to 1 and 0 is super nice because I get really annoyed in languages like C# where I can't just write

code:
int someInt = someBool * 100;
or in a more practical case, something like this:

code:
int offset = (i % 3 == 0) * 100;
or, for something like XNA in a loop of items or something:

code:
int offset = (i == currentSelected) * 100;

This is all really terrible code, though, and more languages should discourage you from writing it!

Most people don't expect bools to be multiplying anything, and it'll cause double-takes and misunderstandings of code.

As Suspicious Dish said, just use the ternary. Don't try to write 'clever code'.

McGlockenshire
Dec 16, 2005

GOLLOCKS!

EAT THE EGGS RICOLA posted:

Make something cool and put it on github? Then use that to get a neat job?

astr0man posted:

Program more and then when someone tells you something you did is dumb don't do it any more.

These, only do it in languages that aren't the ones you use at work.

Adbot
ADBOT LOVES YOU

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

PleasingFungus posted:

This is all really terrible code, though, and more languages should discourage you from writing it!

Most people don't expect bools to be multiplying anything, and it'll cause double-takes and misunderstandings of code.

As Suspicious Dish said, just use the ternary. Don't try to write 'clever code'.

In the same vein, I've seen a bug that manifested with (a && b) * 100. Don't write clever code.

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