Why define variables in other languages

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Why define variables in other languages

Re: Why define variables in other languages

Post by guest3456 » 07 Nov 2016, 21:33

boiler wrote:Then you basically tell him he shouldn't be posting that here; go google it.
no, that's not what i "basically told him".

what i basically told him was, 1. enlightened him that there are many other programming languages that are loosely typed besides AHK, and 2. showed him how he can find the answer himself, and probably get a better answer than anyone here will give, since most AHK users probably don't even know the difference.

give a man a fish, feed him for a day. teach him to fish, feed him for life.
boiler wrote: And you think your response helped enlighten him?
based on his reply, i'm sure my response didn't do a damn thing. and since im in the mood for quotes today, its apropos: no good deed goes unpunished

Re: Why define variables in other languages

Post by tank » 06 Nov 2016, 12:14

I suppose i can get behind that boiler. i would add that while the posted link was a bit on the "intentional irritant" side, it did deliver a result on point of the ask. The problem is that this is not an answer to be discovered on a forum post. this is one of those questions that can only really be answered by an in depth exploration in the the subject of how languages allocate memory. While Capn Odin did an admirable job attempting a synopsis, i felt like it suffers from the same problem as the question. It can only take you to the looking glass and into wonderland. There is no short answer that can adequately explain it because in addition to the complexities of the subject and implementation differences, there is also the reasoning used by the individual language developer(s).
Let me give you an example
PHP is often and incorrectly considered a loosely typed or dynamically typed language. that's not the case. what it does instead is for any variable it allocates for each character into character arrays. it then takes the value assigned and applies ever reasonable variant type into its data type. when you ask for a cast of a string "15 this is a fabulous string" as int and get 15 the system performs a type juggling act to the int value in memory to get 15. it juggled out the first integers it found and ended its juggle when it encountered a non int. Its a bit psychotic and there are endless debates and questions on every php forum over the confusions that arise with php type juggling. It is one of the reasons that PHP ends up so hack-able in my opinion. Finally as of PHP 7 you can finally approach having the option to lock a variable into a type.

I probably confused someone with that poor explanation. but in understanding that you get some very implementation specific advantages and disadvantages. for one implementation the disadvantages of this from another implementation could be advantages

Re: Why define variables in other languages

Post by boiler » 06 Nov 2016, 06:24

He was asking here because, as he said, AHK is one of the only languages he knows of that doesn't require variable type declarations. So he thought he could get some good insight from AHK users. Then you basically tell him he shouldn't be posting that here; go google it. And you think your response helped enlighten him? I think he would be happy if you didn't respond next time.

Re: Why define variables in other languages

Post by guest3456 » 31 Oct 2016, 17:30

gilliduck wrote: dickwad
ok next time i wont respond and you'll stay in the dark

Re: Why define variables in other languages

Post by gilliduck » 31 Oct 2016, 14:14

guest3456 wrote:
gilliduck wrote: In basically every other language I've seen I would have to set var1 as either some sort of text or integer or floating point or whatever have you.
you must not have seen very many programming languages then :)

gilliduck wrote:What's the advantage/disadvantages of that?
http://lmgtfy.com/?q=type+system
dickwad

Re: Why define variables in other languages

Post by tank » 30 Oct 2016, 20:42

each language has a different way of allocating memory,
there is a whole science to understanding the differences. everything in ahk is basically declared as a string.

Re: Why define variables in other languages

Post by guest3456 » 30 Oct 2016, 20:33

gilliduck wrote: In basically every other language I've seen I would have to set var1 as either some sort of text or integer or floating point or whatever have you.
you must not have seen very many programming languages then :)

gilliduck wrote:What's the advantage/disadvantages of that?
http://lmgtfy.com/?q=type+system

Re: Why define variables in other languages

Post by Capn Odin » 30 Oct 2016, 19:17

This way of handling types is mostly seen in scripting languages (not precompiled).

Advantages:
  • Allows the programer greater freedom, especially in regards to return values.
  • This freedom makes prototyping faster.
Disadvantages:
  • Requires overhead either computational or storage.
  • In funcions, if you require some specific data type you have to test the variable, Since you don't know what type of data it contains.
  • It is prone to cause errors in large projects with many contributors, due to the uncertain nature of the content of a variable.
It is a little late right now, so I have probably forgotten a lot of dis/advantages.

I personally don't like to work in big teams on projects with no static type checking.

Why define variables in other languages

Post by gilliduck » 30 Oct 2016, 16:50

Why is it that the bulk of other languages require you to define the type of data going into a variable instead of just letting it take whatever you put in? In AHK I can simply say var1 := "Text" or var1 := 2. In basically every other language I've seen I would have to set var1 as either some sort of text or integer or floating point or whatever have you.

What's the advantage/disadvantages of that? I prefer the simplicity of AHKs freeform variables, make life a lot easier for me.

Top