Advertisement

what lang. is the best to start programming?

Started by January 01, 2003 05:09 PM
195 comments, last by caandom 21 years, 10 months ago
quote: Original post by NotAnAnonymousPoster
I was wondering whether I''d just misunderstood it. The only way it made sense to me is if Coplien''s definition of ''typed'' meant, ''strongly typed'', as opposed to what had previously been available as ''weakly typed''.

You''re getting confused between strong and weak typing and static and dynamic typing. C++ uses fairly weak static typing. Lisp, for example, uses strong dynamic typing.
quote:
Perhaps the claim is false and that wasn''t the case. Either way, my argument was that strong typing was not necessarily an idiotic concept.

It''s static typing that I''m saying is a problem. In particular, explicit static typing.
quote:
lol. Yes. It''s totally idiotic.

Phew!
Hello caandom, Im also 16 and just picked up a copy of C++ for dummies, LOL, thats a little wierd.
Wish ya good luck
This stuff looks a He** of alot harder than i had first thought.
Advertisement
Learn to write basic algorithms first.

THEN start looking at programming languages. This way, you can learn the logic of programming first. Then when it comes to learning a language (whichever you decide to use), all you have to worry about is picking up the syntax. (For now anyway...)

As for which language to use, let''s just not get into that argument because everyone has a completely different opinion. LEARN THEM ALL!!!
quote: Original post by tuita
Learn to write basic algorithms first.

THEN start looking at programming languages. This way, you can learn the logic of programming first. Then when it comes to learning a language (whichever you decide to use), all you have to worry about is picking up the syntax.

In principle this seems like a sound idea. In practice I suspect this would make learning to program a much more tedious task, devoid of its practical results.

quote:
In principle this seems like a sound idea. In practice I suspect this would make learning to program a much more tedious task, devoid of its practical results.

Yeah, your probably right. But if someone REALLY wants to learn then they have to be willing to do this kind of stuff. I mean if the kid wants to start game programming later, there are gonna be much more tedious things to cover (i.e. maths, and maths and damnit! I still need MORE MATHS! I HATE MATHS!!!)
Ahem. Sorry.
quote: Original post by tuita
Yeah, your probably right. But if someone REALLY wants to learn then they have to be willing to do this kind of stuff. I mean if the kid wants to start game programming later, there are gonna be much more tedious things to cover (i.e. maths, and maths and damnit! I still need MORE MATHS! I HATE MATHS!!!)
Ahem. Sorry.

Sure, but if you''re working on something interesting, there''s a fair chance that you can do this gradually, or at the very least get a clear idea of how it''s useful for something interesting. Studying theory without any apparent practical application can be very tedious.

Advertisement
quote: Original post by SabreMan
You''re getting confused between strong and weak typing and static and dynamic typing.

Yep, thought strong typing and static typing were the same thing.

"C combines all the power of assembly language with all the ease of use of assembly language"
quote: Original post by tuita
Learn to write basic algorithms first.

It is likely to be much easier to learn algorithms if you are able to actually try them out. Obviously you need to learn some programming basics to do that.
quote: Original post by NotAnAnonymousPoster
Yep, thought strong typing and static typing were the same thing.

Not at all. From the Tunes glossary...

quote:
Types
Typing in general means that the choice of possible data structures manipulated by a program can be conceptually divided into groups of objects with some homogeneity (e.g. integers, floating-point numbers, lists, arrays, hash-tables, etc.), which groups are called "types". Depending on the type of an object, different interfaces will be available to interact with it (numbers are subject to arithmetic operations; lists can be deconstructed into head and tail; functions can be applied; etc.), and different algorithms will be used to implement common interfaces (adding two integers is not same as adding two floating-point numbers).

Type systems
Programming language usually come with a type-system, some algebraic structure whose elements are the types of data that can be manipulated in the language, together with a mapping from the set of objects involved in defining the semantics of the language into the typesystem.

Static vs Dynamic Typing
When the types are known in advance and decisions about them are made at compile-time, the typing is said to be static; when the types can be known only when code is executed at run-time, the typing is said to be dynamic. [Some people from the Scheme community talk about "latent" vs "manifest" types rather than static vs dynamic types, but this vocabulary is not widely recognized.]

Strong vs Weak Typing
When the types detected or declared are strictly enforced by the language''s semantics, the language is strongly typed; when the semantics of the language allows for inconsistencies between the compile-time type and the run-time type, the language is weakly typed. Sometimes, languages are weakly typed at one level, but strongly typed at another one. Weak typing means that the invariants (program properties) expressible in the type system are (sometimes much) weaker.

Type Declaration vs Type Inference
Some typed language such as Pascal or Java require that types be explicitly declared for all functions and variables in a program. Other typed languages, such as ML or Haskell, will infer the type of an expression depending on its structure and context, without the need for programmer declaration, except maybe in difficult or ambiguous cases.

Orthogonal vs Interdependent Typing
In some languages (notably CAML, or Cecil), the semantics and the typesystem can be given independently, the typesystem serving as a restriction of the set of valid programs, that allows to eliminate bugs and/or enable various compiler optimizations; the typesystem could then be called "orthogonal" to the dynamic semantics. In other languages (notably LISP, C or Java), it is impossible to define the dynamic semantics of the language without involving its typesystem; the typesystem could thus be called "interdependent" with the dynamic semantics of the language. These terms are not very common, as far as I know.

Discussion
Strong type systems allow to catch a lot of common programming mistakes (typos, thinkos, lack of propagation of program modifications) that usually require a lot of debugging time to catch. Static type systems particularly allow to catch them quickly, as early as compile-time, without having to even worry about them. Type inference allows for such bug-catching to have no associated development costs, as long as the typesystem is powerful enough to express the considered program without the need for abuse or contorsions.

Some argue that you can always determine static or dynamic information about a program, and call it is type. For them, the distinction is between trivial static typing and rich static typing, between trivial dynamic typing and rich dynamic typing. Trivial here means that the compiler (resp. the runtime system) cannot use static (resp. dynamic) information about an expressions'' type so as to avoid checks and make early decisions about program behaviour, whereas rich means that it can.

Often, otherwise strongly typed languages have escapes allowing for weak typing (pointer/array dereference in C or C++, typecasting in C, C++ or Java; magic in OCAML). Such languages can usually still be neatly divided into weakly typed and strongly typed. Indeed, in the case of C and C++, the weak typing features are essential to any reasonably sized project, and their implicit rather than explicit character prevents any easy syntactic distinction between programs that abuse or don''t abuse the type-system; hence C and C++ are definitely weakly-typed languages. In the case of OCAML, such abuse is not an essential feature to normal user programs, and made explicit through the use of the keyword "magic" (or of special linking to routines written in C or other languages) that can be easily detected and avoided, - so OCAML is definitely a strongly-typed language. In the case of Java, the "weaknesses" in the type-system are explicit typecasts (but a runtime check ensures that an object can only be cast to a superclass of its class, of which it is a member, and for which there can be no static method discrepancy), and by the special NULL pointer (but the semantics again is well defined, although different for "static" and other methods); Java is thus strongly typed, although the invariants attached to its types may be less obvious and less nicely explained than in other strongly typed languages.

On a different note, otherwise statically typed languages sometimes have escapes that allow for dynamic typing. For instance the MOP in CLOS, or RTTI in C++, Java or Mercury, allow programs to inspect and modify objects whose type is not statically known. This enables the development of some generic software infrastructure, but at the same time forces the implementation to keep at runtime information that might otherwise have been thrown away at compile-time (as it is in OCAML for instance), with all the associated space and time overhead. Dynamically typed languages have this overhead, anyway.

Inferred Static Strong Types, such as exist in ML, Haskell, Clean or Mercury, are those that bring the most information on programs out of the least programmer efforts, allowing to express the stronger and richer invariants. Because they do not usually require any type declaration, they remove the burden that people used to dynamic programming languages usually feel about rich typing. However, because of language design and implementation issues (notably the simplicity of the typesystem and the guarantee that the process of typing will terminate promptly), most languages with strong static inferred types also restrict the expressiveness of their typesystem in such ways that advanced users of dynamically typed language will find them impossible to use (notably those who like dynamic interactive systems and/or LISP macros). A notable exception, Cayenne, is an extension Haskell with dependent types (types that depend on values), that allows to express arbitrary computations within the type system at compile-time; unhappily, it is more designed as a proof of concept than as a really usable programming language.

Compilers for languages without a rich static type system can nevertheless infer types from programs that follow common programming styles, and use these types to produce more efficient code, or emit warnings that help catch bugs. A case in point is CMUCL (a Common LISP compiler). Common LISP, a strongly dynamically typed language, allows the programmer to declare static types for expressions, so as to help the compiler. CMUCL takes advantage of these declarations as well as of information it can infer from the language''s semantics so as to construct precise types for expressions and produce efficient code that avoids runtime type dispatch. The situation of CMU Lisp is rather peculiar, since, depending on its the programmer-accessible safety settings, the declarations can be used either to tighten the type-safety of the language, or on the contrary to make it weakly-typed and provide an escape for low-level optimizations. Because this escape requires explicit and easily toggled safety settings, and is not essential to normal programs, CMU Lisp, like Common LISP in general, is still a strongly dynamically typed language.

quote: Original post by SabreMan
It is likely to be much easier to learn algorithms if you are able to actually try them out. Obviously you need to learn some programming basics to do that.


Absolutely correct. Which brings us back to the question at hand: -what lang. is the best to start programming?

I have read through the posts here and some recommend Python, others C/C++ etc...

Personally, I don't think it really matters which language you start with as you will be presented with similar logical difficulties in any of them. Try some out and see which one you seem to have the easiest grip of and start with that one. Then you can move on to whatever language you want to learn with much less difficulty. If you want to move on that is.


____________________________________________________________
Treat others the way you want them to treat you!!

[edited by - MichaelT on January 6, 2003 6:15:13 AM]

[edited by - MichaelT on January 6, 2003 6:15:58 AM]
No no no no! :)

This topic is closed to new replies.

Advertisement