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.
 
  • Locked thread
JewKiller 3000
Nov 28, 2006

by Lowtax

fritz posted:

optimize it to what?

i assume he's wondering if a programmer can declare new variables whenever they like, rather than reusing already declared ones that are no longer needed in order to save memory or registers. the answer is yes: the compiler is better at that than you are, unless you purposely confuse it (i.e., program in C)

Adbot
ADBOT LOVES YOU

VikingofRock
Aug 24, 2008




fritz posted:

optimize it to what?

Already answered, but what I was asking was this: if you don't reuse a variable when you could have done so, could LLVM optimize your two variable to have the same address in order to save space?

e: ^ yeah that

e2: page :420: code terribly everyday :350:

VikingofRock fucked around with this message at 05:09 on Jun 10, 2015

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

for a very long time gcc wouldn't reuse stack slots within large functions, which tend to be where you end up with a lot of locals. pre-dwarf2 CFI I don't know that gdb could handle that sanely, because stabs didn't include liveness or something.

gonadic io
Feb 16, 2011

>>=

comedyblissoption posted:

if you search online more about this F# limitation, youll find a bunch of stockholmed programmers defending it as making your code better because this is obviously the only way to prevent cycles in your definitions

Turns out that the VS extension f# power tools will do this (although the feature is not turned on by default??) . It's a VS limitation, not a f# one.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

VikingofRock posted:

Already answered, but what I was asking was this: if you don't reuse a variable when you could have done so, could LLVM optimize your two variable to have the same address in order to save space?

decent compilers have been doing that for decades

even lovely ones have mostly been doing that for decades

VikingofRock
Aug 24, 2008




eschaton posted:

decent compilers have been doing that for decades

even lovely ones have mostly been doing that for decades

I figured, although I could see some issues with determining what is and is not used again. For example, you could have an int a which you use for the first half of the function only, and an int b which you use for the second half only. Except you have an int& c which is a reference to a and an int* d which points to God knows what, and I could see things getting very complicated very quickly (which is why I think JewKiller 3000 had his C disclaimer).

Also I didn't know what that optimization is called so I couldn't really google it.

gonadic io
Feb 16, 2011

>>=
When the user does it's called 'premature optimisation'

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
honestly unless you're talking about enormous stack-allocated arrays i'm not sure it really matters if you have an empty stack slot or two in your function. register allocation is the important part of lifetime tracking.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Soricidus posted:

I like the way java does file structure. one public class per file, one package per directory, names must match. it has downsides too and the visibility rules could be better but whenever I read about poo poo like f# I realise how good I have it

say what you will about php but psr-0 and psr-4 have been great for making the language decent

actually pretty much everything the php-fig have put out has made the language and its use much better

i can't believe i'm saying this but modern php isn't half bad

qntm
Jun 17, 2009
nope, it's all bad! :stat:

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Blinkz0rz posted:

say what you will about php but psr-0 and psr-4 have been great for making the language decent

actually pretty much everything the php-fig have put out has made the language and its use much better

i can't believe i'm saying this but modern php isn't half bad

I didn't think it would be possible to have a post to terrible for this thread, but I'm going to need to ask you to leave.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS
dont get me wrong, i'd never choose php over c# or java willingly but i do a lot of work with inherited code and the last codebase i worked on was a laravel app and it wasn't an entirely unpleasant experience

Brain Candy
May 18, 2006

Blinkz0rz posted:

dont get me wrong, i'd never choose php over c# or java willingly but i do a lot of work with inherited code and the last codebase i worked on was a laravel app and it wasn't an entirely unpleasant experience

you can write a serviceable thing in any language when you are starting fresh with good people. whether it's still nice two years later...

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

VikingofRock posted:

I also think that in math/physics code, it's perfectly legitimate to give a variable a name like 'phi', 'theta', or 'rho' in a context where those have widely accepted meanings. For example if you have a function in some physics code which takes a point in spherical coordinates, it's totally cool to call the parameters 'r' (for the radial distance), 'theta' (for the polar angle), and 'phi' (for the azimuthal angle).
i'm absolutely fine with code full of greek letter names, and sometimes i wish unicode variables were acceptable in mainstream languages.

what pisses me right off though is hundred-line functions, and especially hundred-line functions that store state in the global namespace. gently caress yoooooou. encapsulate your garbage so i can work out which bit stinks

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

there must be some straightforward global liveness analysis that could localize variables for you. right?

Brain Candy
May 18, 2006

coffeetable posted:

i'm absolutely fine with code full of greek letter names, and sometimes i wish unicode variables were acceptable in mainstream languages.

put the greek in the comments/derivation, almost as good and you don't have to worry about idiot hell fuckers adding Cyrillic Ye's to variable names

Jerry Bindle
May 16, 2003

Karl Marx posted:

The history of all previous societies has been the history of class struggles.

and that struggle continues today. thanks for the MVC wisdom from yesterday.

comedyblissoption
Mar 15, 2006

gonadic io posted:

Turns out that the VS extension f# power tools will do this (although the feature is not turned on by default??) . It's a VS limitation, not a f# one.
Having folders doesn't matter. F# still forces you to strictly janitor the order of your module executions so that definitions precede use across the entire project. This is to the point that you have to ensure your main function is the last thing declared.

leftist heap
Feb 28, 2013

Fun Shoe

comedyblissoption posted:

Having folders doesn't matter. F# still forces you to strictly janitor the order of your module executions so that definitions precede use across the entire project. This is to the point that you have to ensure your main function is the last thing declared.

lol

gonadic io
Feb 16, 2011

>>=

comedyblissoption posted:

Having folders doesn't matter. F# still forces you to strictly janitor the order of your module executions so that definitions precede use across the entire project. This is to the point that you have to ensure your main function is the last thing declared.

Oh yeah, I have complained about this before in this very thread more than once.

brap
Aug 23, 2004

Grimey Drawer
F# is a couple of cool ideas in a batshit package. All the good parts will come to C# soon so gently caress it.

gonadic io
Feb 16, 2011

>>=
only the good parts that don't break backwards compatibility, like not allowing null references would. i like it. it's not as good as haskell imo but it has way better tooling and infrastructure

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Subjunctive posted:

there must be some straightforward global liveness analysis that could localize variables for you. right?
if such a thing exists in python, i would be v keen to learn about it

(i know absolutely gently caress all about compilers and parsing and all of that stuff)

gonadic io
Feb 16, 2011

>>=

coffeetable posted:

if such a thing exists in python, i would be v keen to learn about it

(i know absolutely gently caress all about compilers and parsing and all of that stuff)

guido literally took tco OUT of python because he didn't like it

besides, python is interpreted so there's gently caress all optimisations you can do except maybe in ironpython or the other less common compilers for it

e: also, even if you wanted to most optimisations would break the direct line-by-line error reporting that is the only reason to use interpreted langs in the first place

gonadic io fucked around with this message at 17:56 on Jun 10, 2015

Shaggar
Apr 26, 2006
is anyone still using python? I thought it was abandoned like ruby.

gonadic io
Feb 16, 2011

>>=

Shaggar posted:

is anyone still using python? I thought it was abandoned like ruby.

lol

Bloody
Mar 3, 2013

python is pretty okay except for its hosed up type system. once that pep that statically types python is implemented or whatever python will be solidly tolerable as a matlab-replacement

Shaggar
Apr 26, 2006

math majors don't count

fritz
Jul 26, 2003

gonadic io posted:

guido literally took tco OUT of python because he didn't like it

you sort of have to marvel at how python succeeded despite van rossum being in charge

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

gonadic io posted:

besides, python is interpreted so there's gently caress all optimisations you can do except maybe in ironpython or the other less common compilers for it

i was under the impression that it was compiled to bytecode and then that was executed. does that not count as compilation?

VikingofRock
Aug 24, 2008




Physicists (especially astrophysicists) also love python, and have been known to write huge, complex simulations in it.

Honestly it's probably not the worst choice of language, because it's cargo-cult-y nature makes for more readable code and its huge standard library means that physicists write less code (and therefore gently caress up less code).

Valeyard
Mar 30, 2012


Grimey Drawer
i like python

in fact, im looking into https://pypi.python.org/pypi/pyquery right now, a library which adds jquery like selectors to python

jesus WEP
Oct 17, 2004


Valeyard posted:

i like python

in fact, im looking into https://pypi.python.org/pypi/pyquery right now, a library which adds jquery like selectors to python
gross

VikingofRock
Aug 24, 2008




My biggest problem with python is that "fail fast" is not one of their design goals. You don't have a compiler to catch anything but the most basic syntax errors, you don't have a type system which keeps you from doing stupid stuff, and a bunch of stuff that should throw an exception doesn't.

For example, recently I was doing a thing where I was reading some data from a file, and then cutting out all the entries with some_field < 20. Except I forgot to cast some_field to numerical type. So later in some unrelated function, when I cut out everything where (some_field < 20), I ended up keeping everything because strings are always greater than numbers. So later in some unrelated function, things failed because I was passing it a bunch of junk data (because the things with some_field < 20 were junk).

If I had been coding this in a language with a stronger type system, it wouldn't have compiled because the return type of my parsing function would have been wrong. If I had been coding this in a language which threw exceptions for things like comparing '21' with 20, I would have been able to figure things out quickly there. But instead my small mistake in my parsing function broke things way, way later and I wasted a bunch of time trying to figure out why the hell nothing was working.

Apparently they've made ('21' > 20) throw an exception in python 3, but everyone still uses python 2 so that doesn't really help.

gonadic io
Feb 16, 2011

>>=
i didn't say that i didn't like python, i just would never program in it myself again. however, i would sooner choose it than any other p-lang.

GameCube
Nov 21, 2006

i use python 3.

VikingofRock
Aug 24, 2008




I don't think Python is a bad language, and there are some very nice things about it. I just think it is sometimes very frustrating to work with / maintain.

qntm
Jun 17, 2009
So your biggest problem with Python is something that has been fixed?

gonadic io
Feb 16, 2011

>>=
i had a friend who spend days debugging matlab code, because nan's were getting into his code somehow despite a whole load of isnan

turns out that when the library said that it returns 'nan' it meant the characters lmao

Adbot
ADBOT LOVES YOU

The Leck
Feb 27, 2001

coffeetable posted:

i'm absolutely fine with code full of greek letter names, and sometimes i wish unicode variables were acceptable in mainstream languages.

what pisses me right off though is hundred-line functions, and especially hundred-line functions that store state in the global namespace. gently caress yoooooou. encapsulate your garbage so i can work out which bit stinks
what about 500 line functions with tons of state stored in global namespace and reuse of variables for unrelated activities? :smithicide:

  • Locked thread