Originally posted by erendorn
View Post
Announcement
Collapse
No announcement yet.
HOPE: The Ease Of Python With The Speed Of C++
Collapse
X
-
-
Originally posted by kigurai View PostLet's just say I am not impressed with syntax if it confuses someone with the level of C++ knowledge I have.
There might be numerous reasons why you can't use anything not in the standard lib. Regardless of which, standard functionality is what was discussed, not third party libraries, e.g. boost.
There might be parts of the standard library that is only available in CPython. As far as I know, those exceptions are extremly rare for all relevant implementations.
For all practical purposes, CPython is the standard, and thus the entire standard library is available everywhere Python is installed.
(Also, in the example used, no module was used, so in this specific case the argument is moot)
Comment
-
Why even bother with C++ or Python when you have Julia which is much faster/easier than both and is heavily optimized for this kind of task? Julia was created for this type of problem so it doesn't make sense to not use it. If you are using C++/Python for this kind of thing then you are using a hammer to drive a screw. Julia even features an interactive mode where you can write your program interactively like programming a calculator, then output the results in a fancy graph/plot/chart.
Code:# Implements squared for integers. squared(x::Int) = x^2 # Implements squared for Array{Int,1}, aka [1,2,3]. function squared(numbers::Array{Int,1}) squaredNums = Int[] for x in numbers push!(squaredNums, squared(x)) end return squaredNums end # Implements squared for UnitRange{Int}, aka 1:10. function squared(numbers::UnitRange{Int}) squaredNums = Int[] for x in numbers push!(squaredNums, squared(x)) end return squaredNums end # average returns the average of an Int array. average(x::Array{Int,1}) = sum(x) / length(x) # returns the value of the Golden Ratio. goldenRatio() = (1 + 5^0.5) / 2
Code:julia> squared(10) 100 julia> squared([1,2,3,4,5]) 5-element Array{Int64,1}: 1 4 9 16 25 julia> squared(1:10) 10-element Array{Int64,1}: 1 4 9 16 25 36 49 64 81 100 julia> average(squared(1:100)) 3383.5 julia> sum(squared(1:1000)) 333833500 julia> goldenRatio() 1.618033988749895
Comment
-
Originally posted by mmstick View PostWhy even bother with C++ or Python when you have Julia which is much faster/easier than both and is heavily optimized for this kind of task?
2. c++ is general purpose language, you can do any task in it.
3. c++ features backward compatibility. nobody is going to rewrite all of their code just because some random language of the day spawned. compatibility all the way back to plain c is the main reason for c++ syntax issues.
4. i know nothing about julia, no doubt there are many more downsides to it.
Comment
-
Originally posted by mmstick View PostWhy even bother with C++ or Python when you have Julia which is much faster/easier than both and is heavily optimized for this kind of task? Julia was created for this type of problem so it doesn't make sense to not use it. If you are using C++/Python for this kind of thing then you are using a hammer to drive a screw.
- (most important) Python has a much larger software community, with a much larger software ecosystem, and a lot more tools available. Further, those tools tend to be more mature, more tested, and have more help and documentation available. Its future is also a lot more certain due to the much larger community and much larger commercial stake in the language.
- Being a general-purpose language, it has a lot of tools for dealing with things besides just data analysis. Things like file and directory handling, interacting with online data, and accessing network resources are all much easier in python and are all very common when doing data analysis. When I am doing data analysis, I am almost never doing just data analysis. I need to find files, manipulate files, save files, often dozens if not thousands. So being a general-purpose language is actually a huge benefit.
- It seems that most of the new ideas are coming from python in terms of basic ways to work with data. Julia has some interesting ideas with performance, but in terms of data structures and graphics interfaces most of the development is happening in python and then, sometimes, is later ported to Julia (while the python version continues to advance).
- Generally the slow code paths are already in C++ (which is still far faster than Julia), so Python performance is not usually a major bottleneck for me.
- (much less important) I very much prefer python syntax. Julia is primarily a Matlab clone in terms of syntax. It fixes a few bone-headed Mathworks decisions and has a few Python features tacked on, but overall it is pretty much the same as Matlab in almost all areas.
So I am keeping my eye on Julia, just as I am keeping my eye on efforts to improve python performance. But at the present time the performance improvement isn't worth all the other downsides.
Originally posted by mmstick View PostJulia even features an interactive mode where you can write your program interactively like programming a calculator, then output the results in a fancy graph/plot/chart.Last edited by TheBlackCat; 21 October 2014, 11:19 AM.
Comment
-
Originally posted by pal666 View Post1. you can't be much faster than c++, that is bullshit
2. c++ is general purpose language, you can do any task in it.
3. c++ features backward compatibility. nobody is going to rewrite all of their code just because some random language of the day spawned. compatibility all the way back to plain c is the main reason for c++ syntax issues.
4. i know nothing about julia, no doubt there are many more downsides to it.
2) That's not the point. C++ is an ugly bloated mess of inconsistency that only someone with years of experience can properly understand. In the real world, people prefer simplification over complification. C++ needs to die sooner rather than later. C++ certainly isn't made for scientific computing either, which Julia is.
3) Again, irrelevant. There's no need to rewrite the bulk of code when you can import an existing Fortran/C library which you are probably already using in another language. Not to mention, because writing your code in Julia is easier to read and write you have more time to work on optimizing your algorithms.
4) Then don't be a dumbass and learn about it.
Comment
-
Originally posted by mmstick View Post1) You're really naive. Fortran is faster than C which is faster than C++. Julia makes heavy use of the best of C and Fortran math libraries so it is close to Fortran performance.
Comment
-
Originally posted by TheBlackCat View PostSo does Python and C++ (and matlab). The libraries are pretty much standard. Julia's advantage isn't the libraries, it is that it uses multiple dispatch to allow optimized code paths for different data types. That gives it speed slower than C or C++, but usually faster than cpython (and to a lesser extent Pypy).
Comment
-
Originally posted by mmstick View PostIf you want to claim that it is slower then explain the benchmark results which demonstrate otherwise.
Comment
Comment