的编程语言学习数据结构和算法的选择 [英] Choice of programming language for learning data structures and algorithms

查看:148
本文介绍了的编程语言学习数据结构和算法的选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的编程语言您会推荐学习关于数据结构和算法吗?

考虑以下内容:

  • 个人体验
  • 语言功能(指针,面向对象等)
  • 在适宜学习DS&放大器;一个概念

我问,因为有一些书,在那里,是编程语言无关的(从数学角度来写的,并且使用伪code)。如果我从其中的一个学习,我想选一门编程语言,以code和在运行的算法。

I ask because there are some books out there that are programming language-agnostic (written from a Mathematical perspective, and use pseudocode). If I learn from one of these, I would like to choose a programming language to code and run the algorithms in.

那么,有哪些引进DS和放大器等书;一个概念写在一个特定的编程350.00例子 - 我想$ C C这些算法$以及 - 因此,在一定程度上,语言拿起这本书太

Then, there are other books which introduce DS & A concepts with examples written in a particular programming laguage - and I would like to code these algorithms as well - thus, to a certain extent, the language picks the book too.

无论哪种方式,我必须选择一种语言,我想preFER坚持一个贯穿始终。撇开个人的语言preferences,哪一个是最适合这个目的?

Either way, I have to pick a language, and I would prefer to stick to one throughout. Setting aside personal language preferences, which one is best for this purpose?

推荐答案

你想学什么的这个问题的答案取决于

The answer to this question depends on exactly what you want to learn.

高层如Python和Ruby语言经常建议,因为它们是高层次的语法是相当的可读性。然而,这些语言都抽象为常见的数据结构。没有什么能阻止你实现自己的版本,作为一个学习的过程,但你会发现你正在构建高层次的数据结构之上的其他高层次的数据结构,这并不一定有用。

High level languages like Python and Ruby are often suggested because they are high level and the syntax is quite readable. However these languages all have abstractions for the common data structures. There's nothing stopping you implementing your own versions as a learning exercise but you may find that you're building high level data structures on top of other high level data structures, which isn't necessarily useful.

此外,Ruby和Python是动态类型语言。这可能是好的,但它也可能会造成混淆的初学者,也可以是更难(最初)捕获错误,因为他们通常并不明显,直到运行时。

Also, Ruby and Python are dynamically typed languages. This can be good but it can also be confusing for the beginner and it can be harder (initially) to catch errors since they typically won't be apparent until runtime.

C是另一个极端。这是很好的,如果你想了解真正的低级别的细节,如内存管理方式,但内存管理突然一个重要的考虑因素,如malloc的正确使用()/ free()的。这可以分散注意力。此外,C是不是面向对象的。这不是一件坏事,而只是值得注意的。

C is at the other extreme. It's good if you want to learn really low-level details like how the memory is managed but memory management is suddenly an important consideration, as in correct usage of malloc()/free(). That can be distracting. Also, C isn't object-oriented. That's not a bad thing but simply worth noting.

C ++已经提到。正如我在注释中说,我认为这是一个的可怕的选择。 C ++是即使在简单的用法可怕复杂,有陷阱荒谬的数额。此外,C ++有没有共同的基类。这很重要,因为数据结构,如哈希表依赖于那里是一个共同的基类。你可以实现一个版本为名义的基类,但它是一个有点不太有用。

C++ has been mentioned. As I said in the comment, I think this is a terrible choice. C++ is hideously complicated even in simple usage and has a ridiculous amount of "gotchas". Also, C++ has no common base class. This is important because data structures like hash tables rely on there being a common base class. You could implement a version for a nominal base class but it's a little less useful.

爪哇也被提及。很多人喜欢讨厌Java和它的真实的语言是非常冗长,缺乏一些更现代的语言特性(比如闭包),​​但没有真正重要的。 Java是静态类型的,具有垃圾收集。这意味着Java编译器将赶上许多错误,动态类型语言不会(直到运行时),并有一个与段故障无交易(这并不是说你不能在Java的内存泄漏;明明可以)。我认为Java是一个不错的选择。

Java has also been mentioned. Many people like to hate Java and it's true that the language is extremely verbose and lacking in some of the more modern language features (eg closures) but none of that really matters. Java is statically typed and has garbage collection. This means the Java compiler will catch many errors that dynamically typed languages won't (until runtime) and there's no dealing with segmentation faults (which isn't to say you can't leak memory in Java; obviously you can). I think Java is a fine choice.

C#中的语言的就像是一个更现代的Java版本。与Java它是一个管理(垃圾回收)的中间汇编语言,一个虚拟机上运行。这里列出的所有其他语言形式除了C / C ++还运行在虚拟机上,但是Python和Ruby等都是PTED直接而除$ P $不是编译成字节code。

C# the language is like a more modern version of Java. Like Java it is a managed (garbage collected) intermediate compiled language that runs on a virtual machine. Every other language listed here apart form C/C++ also run on a virtual machine but Python, Ruby, etc are interpreted directly rather than compiled to bytecode.

C#有相同的优点和缺点如Java,基本上是这样。

C# has the same pros and cons as Java, basically.

最后,你有函数式语言:哈斯克尔,OCaml中,计划/ Lisp语言,Clojure中,F#等这些想在一个非常不同的方式对所有的问题,都值得我们学习,在某些时候,但是这又归结到你想要什么学习:函数式编程或数据结构?我会坚持学习的时间的一件事,而不是混乱的问题。如果你学会在某些时候一个函数式语言(我建议),Haskell是一种安全和很好的选择。

Lastly you have the functional languages: Haskell, OCaml, Scheme/Lisp, Clojure, F#, etc. These think about all problems in a very different way and are worth learning at some point but again it comes down to what you want to learn: functional programming or data structures? I'd stick to learning one thing at a time rather than confusing the issue. If you do learn a functional language at some point (which I would recommend), Haskell is a safe and fine choice.

选择Java或C#。两者都有免费的,优秀的IDE(Eclipse中,Netbeans的和IntelliJ社区版的Java,Visual Studio的前preSS的C#,Visual Studio的社区版),使编写和运行codea的管理单元。如果你不使用本地数据结构不是一个数组更复杂,任何对象,你自己写,你会学到基本相同的事情,你会在C / C ++,但无需实际管理内存。

Pick Java or C#. Both have free, excellent IDEs (Eclipse, Netbeans and IntelliJ Community Edition for Java, Visual Studio Express for C#, Visual studio community edition) that make writing and running code a snap. If you use no native data structure more complex than an array and any object you yourself write you'll learn basically the same thing as you would in C/C++ but without having to actually manage memory.

让我来解释一下:一个可扩展的哈希表需要是否有足够的元素添加到被调整。在将意味着做类似的背衬的数据结构中的现有元素的大小(通常的阵列)和复制倍增任何实现。实施基本上是所有的命令式语言,但在C / C相同++,你必须处理分割fauls当你不分配或释放一​​些正确的。

Let me explain: an extensible hash table needs to be resized if sufficient elements are added. In any implementation that will mean doing something like doubling the size of the backing data structure (typically an array) and copying in the existing elements. The implementation is basically the same in all imperative languages but in C/C++ you have to deal with segmentation fauls when you don't allocate or deallocate something correctly.

Python或Ruby(它并没有真正事项)将是我的下一个选择(非常接近其他两个)就因为动态类型可以在第一次是有问题的。

Python or Ruby (it doesn't really matter which) would be my next choice (and very close to the other two) just because the dynamic typing could be problematic at first.

这篇关于的编程语言学习数据结构和算法的选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆