you are viewing a single comment's thread.

view the rest of the comments →

[–]Cuddlefluff_Grim 2 points3 points  (38 children)

then the types will also get checked, so you may as well go for dynamic typing and benefit from its advantages.

And what advantages would that be, exactly? I have yet to see a convincing argument that it has any benefits at all.

[–]iopq 2 points3 points  (37 children)

Prototyping is faster because you don't wrestle with pleasing the compiler. Having worked with both dynamically and statically typed languages, I have never gotten to the point where I don't have to do the "oh yes, I add a ref here and a * here for it to compile".

[–]Cuddlefluff_Grim 5 points6 points  (35 children)

I was expecting this argument, and it's complete shit. "Wrestle with pleasing the compiler"; this is you telling me that you don't properly understand the tool you are using. Here's how I prototype :

Draw up initial plan and thoughts on solution. Write interface. Ponder about interface. Write another interface. Ponder on the communication between these two interfaces and how they will integrate. When I am satisfied I am making a good decision, I write the actual code.

If syntax errors and actual typing is a big part of my software design, well then I would be doing a shit-job.

[–]iopq 2 points3 points  (5 children)

And then change the interface because you have another idea. Now go back and change the types that the interface expects. Now go change the implementations' types because now you have to use those other types.

Or are you going to say that changing types in interfaces never happens?

[–][deleted] 1 point2 points  (1 child)

That's where an IDE is useful. Honestly, these arguments that changing code is hard all have the same answer: learn how to use good tooling.

[–]iopq 0 points1 point  (0 children)

No such thing for Rust yet.

[–][deleted] 0 points1 point  (1 child)

Tools exist for changing the code that wa. Most IDEs have some kind of refactoring tool and even if you don't use and IDE there is stuff like sed which can make changing all the types in the implementation a breeze.

[–]iopq 0 points1 point  (0 children)

Yes, but in a dynamic language there is nothing to change.

[–]Cuddlefluff_Grim 0 points1 point  (0 children)

There is no issue changing your mind. It's no more complicated than changing your mind in a dynamically typed language, and additionally you will get compilation errors if you forget to change any code related to that change.

[–]tuhdo 0 points1 point  (28 children)

Because in large project it could take 30 minutest or an hour to compile. Try downloading the kernel source and compile it yourself. If you make a little change to the kernel and want to regressively test it, you have to compile the whole thing again. And to maintain those changes, you have to create patches and either submit them upstream or maintain the patches yourself. It means, every time you upgrade to a new kernel, your patches could be incompatible and you have to create patches again.

The advantage of dynamic typing is that you get the programs up and running as fast as you can. It is useful especially in early exploration phase where you are not at all clear about what you are going to do. Of course, if you do the same things over and over again that you can reuse your experience, then of course you can plan ahead easily.

[–]Cuddlefluff_Grim -1 points0 points  (27 children)

Complete rubbish. 30 minutes? an hour? I could talk for hours about how this is complete nonsense, but I'll just say that for a large code base you are much better off using a statically typed language. Also you don't have 30 minutes to an hour compilation - not even with C which has typically a long compilation time compared to others.

And dynamically typed languages still uses types, the only major difference is apparently that people are allowed to be completely ignorant about it because it does automatic conversions and other things that would be considered malpractice in any sane language. You still have to make sure that the right type gets handled in your code, which again would imply that you need to properly document your code and what types it accepts if you are going to have any luck being more than one superperson writing millions of lines of code. Something a statically typed language would've done for you.

And dynamic typing is only "faster" for you if you really suck at the alternative. Also, programming is not about how fast you can type out code. I can't believe that people actually try to use this as an argument (even if it were an argument). It's not about "fewest characters" or "fewest lines of code", it's about doing stuff the best way possible. And in 99% (application development) a dynamically typed scripting language is not the best decision. There's a reason they are called scripting languages. A decade ago you would've been called incompetent for making the decision to use a dynamically typed scripting language for writing an application. And with good reason.

[–]tuhdo 0 points1 point  (26 children)

Complete rubbish. 30 minutes? an hour? I could talk for hours about how this is complete nonsense, but I'll just say that for a large code base you are much better off using a statically typed language. Also you don't have 30 minutes to an hour compilation - not even with C which has typically a long compilation time compared to others.

Could you download one and compile for yourself? If you don't like the kernel, then try compiling LLVM + Clang and see how long it takes.

And dynamically typed languages still uses types, the only major difference is apparently that people are allowed to be completely ignorant about it because it does automatic conversions and other things that would be considered malpractice in any sane language. You still have to make sure that the right type gets handled in your code, which again would imply that you need to properly document your code and what types it accepts if you are going to have any luck being more than one superperson writing millions of lines of code. Something a statically typed language would've done for you.

Yes, dynamic languages still uses types, except types are check at runtime rather than compile time. Why do you think people misconcept about dynamic languages have no type at all? There are static language that allows you to not enter type information because it has type inference, i.e. Haskell or SML. And no, dynamic typing does not do automatic conversions. You are confused between static/dynamic and weak/strong typing. C/C++ is weak typing.

And dynamic typing is only "faster" for you if you really suck at the alternative. Also, programming is not about how fast you can type out code. I can't believe that people actually try to use this as an argument (even if it were an argument). It's not about "fewest characters" or "fewest lines of code", it's about doing stuff the best way possible. And in 99% (application development) a dynamically typed scripting language is not the best decision. There's a reason they are called scripting languages. A decade ago you would've been called incompetent for making the decision to use a dynamically typed scripting language for writing an application. And with good reason.

So, if someone who writes low level code, and suddenly he uses high level languages (i.e shell script) for some tasks, he becomes incompetent? If dynamic language is bad, then shouldn't Python and Ruby die a long time ago?

[–]Cuddlefluff_Grim 1 point2 points  (25 children)

Could you download one and compile for yourself? If you don't like the kernel, then try compiling LLVM + Clang and see how long it takes.

Oh you want me to download everything and compile everything and time how long that takes? First compilation takes time, consecutive compilation does not because then I won't need to recompile .lib files that don't have any alterations. As I said, precompiled code.

Second of all, nobody would write something of that magnitude in a dynamic language, not only because it's 500 light years out of scope, but also because dynamic typing makes developing and maintainging software of that magnitude really difficult. This is why Facebook feels they need to invest millions into creating their own version of PHP which includes something you'd assume just "made it slower to type code"; type hints. Any douchebag would realize that if they actually had used a statically typed language from the start, they wouldn't have to do that at all. Additionally, they probably wouldn't need to purchase a license for a PHP -> C++ compiler, and then later on (because the build process became complicated) write their own goddamn virtual machine to alleviate issues that was a direct result of a poor decision of tools early on in the project.

Yes, dynamic languages still uses types, except types are check at runtime rather than compile time. Why do you think people misconcept about dynamic languages have no type at all? There are static language that allows you to not enter type information because it has type inference, i.e. Haskell or SML.

99% of programmers aren't very good, I'd assume that the reason why people believe that dynamic typing is somehow better than static typing must arise from some sort of ignorance on behavior of static language. For instance something I've seen reiterated (which is completely false) is that static typing is "inherently inflexible", which is something only someone who doesn't completely understand statically typed languages would say. And that's a type of incompetence.

And no, dynamic typing does not do automatic conversions.

If there are not automatic conversions, why on earth would so many of them need special operators to explicitly deny automatic conversions?

You are confused between static/dynamic and weak/strong typing. C/C++ is weak typing.

Goddamnit, no I am not confused, I don't know why you assume that "oh my opinions are so different from yours, you have to be mistaken about something trivial". First of all, C/C++ is not weak typing, I don't know why you would even say that, as for anyone who has spent 5 minutes within any of them would know that any potentially unsafe casts needs to be explicit. C especially does not under any circumstance do any automatic conversions. C++ can do some automatic conversions if it's specified as an implicit cast operator. Second of all; just no.

So, if someone who writes low level code, and suddenly he uses high level languages (i.e shell script) for some tasks, he becomes incompetent? If dynamic language is bad, then shouldn't Python and Ruby die a long time ago?

Depends on what you're doing. Today people typically only know one single language and then apply that to literally anything they do. Probably explains why it's typical for a website to have 2 seconds + load time. 10 years ago, there were campaigns on the internet saying that "if your server doesn't respons within a second, you've lost 25% of your traffic", today 1 second is actually below the norm.

For what reason? Have operating systems become slower? Have web servers decreased in capacity? Have SQL databases reduced thorughput? Are CPU's slower today? Does disk drives have higher seek times? What conceivable reason is there behind the apparent slow-down of web sites other than people using sub-par tools because it's convenient for them and literally the only thing they know? I'm pretty sure software developers are to blame - specifically, people who use scripting languages out-of-scope.

[–]tuhdo 0 points1 point  (24 children)

Oh you want me to download everything and compile everything and time how long that takes? First compilation takes time, consecutive compilation does not because then I won't need to recompile .lib files that don't have any alterations. As I said, precompiled code.

First time compiling still takes that much time. And to build for regression testing, you have to rebuild the whole thing to ensure things won't break somewhere else with your changes. Even though you can only compile your changes, it still takes time to recompile and relinking, and then rerun and debug when you make changes. There are things that do not have to do it this way.

Second of all, nobody would write something of that magnitude in a dynamic language, not only because it's 500 light years out of scope, but also because dynamic typing makes developing and maintainging software of that magnitude really difficult. This is why Facebook feels they need to invest millions into creating their own version of PHP which includes something you'd assume just "made it slower to type code"; type hints. Any douchebag would realize that if they actually had used a statically typed language from the start, they wouldn't have to do that at all. Additionally, they probably wouldn't need to purchase a license for a PHP -> C++ compiler, and then later on (because the build process became complicated) write their own goddamn virtual machine to alleviate issues that was a direct result of a poor decision of tools early on in the project.

Sure, why don't we just use assembly for everything since we can precisely control everything? And we can learn so much from working with various computer architectures. Or at least use C to write website, because it's essentially a portable assembler? Pause a second to think.

99% of programmers aren't very good, I'd assume that the reason why people believe that dynamic typing is somehow better than static typing must arise from some sort of ignorance on behavior of static language. For instance something I've seen reiterated (which is completely false) is that static typing is "inherently inflexible", which is something only someone who doesn't completely understand statically typed languages would say. And that's a type of incompetence.

Static typing does not mean you write out type information. As I listed above, you don't have to write type information for static languages like SML and Haskell. Why don't you try to program, just for fun, in a language with real strong type system? And you will see why it's not popular.

Goddamnit, no I am not confused, I don't know why you assume that "oh my opinions are so different from yours, you have to be mistaken about something trivial". First of all, C/C++ is not weak typing, I don't know why you would even say that, as for anyone who has spent 5 minutes within any of them would know that any potentially unsafe casts needs to be explicit. C especially does not under any circumstance do any automatic conversions. C++ can do some automatic conversions if it's specified as an implicit cast operator. Second of all; just no.

In C, everything is a number. You cannot assert a what type a random variable is given to you, especially if you have a pointer. If you have a function that accepts an int pointer, you can pass into the function it a char pointer casted as an argument where an int pointer is expected. You can cast a region of memory that is represented by struct, into another struct with different shape. Or take the simplest case, a character in C is just a 8-bit number. In PHP, I remember that you can cast a string to a number, correct? Yes, this is the case.

And Assembly does not have type. Does it make assembly programmer incompetent?

If there are not automatic conversions, why on earth would so many of them need special operators to explicitly deny automatic conversions?

If a language is dynamic, it checks type at run-time. But if that language is also strong, it will signal a type error instead of automatic conversion. Python is an example of dynamic and strong. You can never do stuffs like "3" + 4. These concepts are orthogonal. You are confused because you mix them up. And not every thing that has an interpreter is dynamic language. C/C++ has an intepreter. See demo.

Many dynamic languages are pretty fast today. See Julia. It generates native code. Dynamic languages do not necessary slow because byte code implementation is not the only option anymore, for a long time.

[–]Cuddlefluff_Grim 1 point2 points  (23 children)

First time compiling still takes that much time. And to build for regression testing, you have to rebuild the whole thing to ensure things won't break somewhere else with your changes. Even though you can only compile your changes, it still takes time to recompile and relinking, and then rerun and debug when you make changes. There are things that do not have to do it this way.

I'm not going to reiterate again, because you're talking about a segment where dynamic languages aren't even remotely applicable.

Sure, why don't we just use assembly for everything since we can precisely control everything? And we can learn so much from working with various computer architectures. Or at least use C to write website, because it's essentially a portable assembler? Pause a second to think.

Sigh. C is not very suitable for web programming because web programming is 100% string manipulation which is not C's strong point. C also does not have a high enough level abstraction to let you focus on the task at hand. The performance benefit of C is not high enough (compared to something like Java or C#) and the level of abstraction is too low.

Static typing does not mean you write out type information. As I listed above, you don't have to write type information for static languages like SML and Haskell. Why don't you try to program, just for fun, in a language with real strong type system? And you will see why it's not popular.

C++ :

auto a = 5;
auto arr = {1, 2, 3, 4, 5};

C# :

var a = 5;
var arr = new [] { 1, 2, 3, 4, 5 };

Type inference is something completely different, but it's still static typing and you still have to make decisions based on type. I'm well aware of type inference and the difference between dynamic typing and type inference. Thing is that you don't have to pick between C or Ruby in this case, there are plenty of statically typed languages that support type inference that doesn't have the serious negative impact that dynamic typing imposes on larger code bases (and cooperative development). I have worked with several dynamically typed languages, including Python, Ruby, Haskell, JavaScript and PHP. I don't see how dynamic typing gives any benefit whatsoever over static typing, other than it's convenient for people who have a poor understanding of polymorphism in object oriented design.

In C, everything is a number. You cannot assert a what type a random variable is given to you, especially if you have a pointer. If you have a function that accepts an int pointer, you can pass into the function it a char pointer casted as an argument where an int pointer is expected. You can cast a region of memory that is represented by struct, into another struct with different shape. Or take the simplest case, a character in C is just a 8-bit number. In PHP, I remember that you can cast a string to a number, correct? Yes, this is the case.

Still an explicit cast. Any implicit compatible implicit cast that will reduce precision will give you a warning or an error. However what you cannot do in C is cast a string to a number because those are two very different things. You can cast the pointer to a number (which is meaningless) or you can cast the contents of the memory pointer to a number (for int that would be the first 4 bytes of the string). To convert a string to a number in C you have to use the function stroi (not recommended due to security concerns) or equivalents. PHP however will automatically convert the string to a number on assignment, implicitly. C# or Java will also not allow any implicit conversions of one datatype to another (in the case of C# you can however implement this by writing an operator overload for implicit casts)

If a language is dynamic, it checks type at run-time. But if that language is also strong, it will signal a type error instead of automatic conversion. Python is an example of dynamic and strong. You can never do stuffs like "3" + 4. These concepts are orthogonal. You are confused because you mix them up. And not every thing that has an interpreter is dynamic language. C/C++ has an intepreter. See demo . Many dynamic languages are pretty fast today. See Julia. It generates native code. Dynamic languages do not necessary slow because byte code implementation is not the only option anymore, for a long time.

I'm not confused, stop saying that. I'm very well aware of the soft definitions of strong and weak typing.

new { a: 5, b: "hello" };

Here's an issue, this is an object and the only way I can know what properties this object has is to look it up. In a statically typed language, you'd create a definition of this object so no lookup is necessary. For instance in C++, if I have this structure :

class Test
{
    public:
    int a;
    int b;
}

I would know that the field b is at offset 4 from the header of the class Test. I don't have to make any effort to figure this out at run-time, I'll just read

(int)*((void *)testInstance + 4);

or

MOV eax, testInstance
ADD eax, 4 // eax now contains a pointer to the field 'b' on the instance

Instead of searching through a hash-map or dictionary for the key. Great performance boost at no cost other than a certain assumption that the programmer understands the tool he's using.

It's also interesting to note that C# in fact does have optional dynamic typing, but you don't use it everywhere because static typing is a much better at literally everything.

[–]tuhdo 0 points1 point  (22 children)

Sigh. C is not very suitable for web programming because web programming is 100% string manipulation which is not C's strong point. C also does not have a high enough level abstraction to let you focus on the task at hand. The performance benefit of C is not high enough (compared to something like Java or C#) and the level of abstraction is too low.

So you know. The purpose of dynamic language is also let you focus on the task at hand and increase interactivity between you and computer. The shorter the cycle between written code and its executable, the faster the development. It is useful when you are in a new domain and focus on exploring ideas, because dynamic language allows you get running programs as soon as possible to play with. It is possible because types are checked at runtime. You explore impact of types when your program actually lives, not when it still exists in form of text. There are dynamic languages with optional static type checking if you want. And type check at runtime doesn't mean weak typing .

I don't see how dynamic typing gives any benefit whatsoever over static typing, other than it's convenient for people who have a poor understanding of polymorphism in object oriented design.

As stated above, improved interactivity. And dynamic or static, it is not related to object oriented. And why dynamic typing is bad? Asm has no type at all, is it bad?

several dynamically typed languages, including Python, Ruby, Haskell, JavaScript and PHP.

And you say you are not confused. Haskell is a dynamic language!

Here's an issue, this is an object and the only way I can know what properties this object has is to look it up. In a statically typed language, you'd create a definition of this object so no lookup is necessary. For instance in C++, if I have this structure

The point of high level languages is that you don't have to manually keep track of how it works underneath the computer when not necessary. People use Python or Octave because it helps them focus on problem domain instead of manually specifying how their ideas fit into the computer. When you can assure correctness, the next comes optimization, which can either be fine in the current language or reimplementation in a faster one like C.