[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
List 5 advantages your favourite language has over Python 3
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 113
Thread images: 7
File: fizzbuzz of the christ.png (402 KB, 1024x768) Image search: [Google]
fizzbuzz of the christ.png
402 KB, 1024x768
List 5 advantages your favourite language has over Python 3
>>
Go:
- statically typed
- more regular syntax
- more performant for the same "real-world" applications that both get uses for (web services etc)
- better concurrency model
- universal One True FormatĀ® (no tab-space wars etc)

Python's literal single, indefeasible niche is scientific computing, and usage by non-programmer scientists.
>>
>>54081016
2.7 > 3
>>
>>54081211
George Boole would be ashamed.
>>
>>54081016
Java
Large projects are not inherently a mess
It's a typed language
Not all libraries break when using a newer version
More efficient resource usage
Huge performance gains
https://benchmarksgame.alioth.debian.org/u64q/python.html
>>
File: 1452043388505.jpg (132 KB, 391x311) Image search: [Google]
1452043388505.jpg
132 KB, 391x311
>>54081016
I don't understand why this works please explain

"FizzBuzz"[i*i%3*4:8--i**4%5] or i


the
"string"[a:b]
syntax will print the substring from a to b, e.g.
"string"[4:5] == "n"


the or is short-circuiting so if and only if the string is empty, i.e.
""
will i be printed instead

i*i%3*4
is equivalent to
(i**2%3)*4
and may be written without parenthesis and always evaluates to either 0 or 4, meaning we start in the string
"FizzBuzz"
at either
"F"
or
"B"
.

8--i**4%5
is equivalent to
8 - ((-1 * (i**4))%5)
and always evaluates to either 4 or 8, therefore if and only if the first and second statements both evaluate to 4 will i by itself be printed.

So I understand all of that, what I'm asking is:

1) where did these magical terse formulas come from? and perhaps more pertinently

2) how does one become adept at coming up with solutions like this?
>>
>>54081085
>Python's literal single, indefeasible niche is scientific computing, and usage by non-programmer scientists.
What about web dev?

Also
>using Go for web development
I get that Go is new and fancy and all, but it's not some sort of one-size-fits-all shoo-in language.
>>
>>54081896
>2) how does one become adept at coming up with solutions like this?
Lurking /g/ too much. Link related

http://pastebin.com/GQPnUi7d
>>
>>54081016
Haskell
-immutability
-godly parallelism and threading
-better performance
-pattern matching
-algebraic datatypes
>>
>>54081896
>1) where did these magical terse formulas come from? and perhaps more pertinently
I believe it's Fermat's Little Theorem
>>
>>54081016
C:
-good type syntax
-performance
-structs
-pointer magic(both a pro and con)
-can be run on anything
>>
>>54081016
>150k starting
>lots and lots of documentation
>everything is possible with it
>light weight
>numerous IDEs to choose from

I can keep going, Python is nice language tho, its just not professional, but its fun to start with or do some small projects, I use it too.
>>
>>54082159
>not professional
How can a language be "professional"

Also
>listing non-technical reasons for liking a language
kek
>>
>>54081016
>Python 3
Meme. Use a real language like Python 2 instead.
>>
>>54082321
>legacy languages
seriously hope
>>
>>54081016
1. Strong static safety/correctness guarantees (high resilience against typos and mistakes)
2. Higher-order polymorphism (permits powerful abstractions, allowing you to save lots of code)
3. Type inferencing (ties in to #1 but removes the hassle)
4. Higher-order ad-hoc overloading resolved at compile time (allows zero-cost abstraction)
5. algebraic datatypes (allows you to embed a much richer topology of data structures in a native and compiler-checked way)

Guess what language
>>
>>54081598
But Boole couldn't count to 2.
>>
>>54082358
>correctness guarantees
Well, only a Haskell fag would believe this.
>>
>>54082358
>2. Higher-order polymorphism (permits powerful abstractions, allowing you to save lots of code)
Python has this

>3. Type inferencing (ties in to #1 but removes the hassle)
Python has this too

>5. algebraic datatypes (allows you to embed a much richer topology of data structures in a native and compiler-checked way)
Python has this too
>>
>>54082387
>Python has this
I'm just going to go ahead and assume you don't know what higher-order polymorphism, type inferencing or algebraic datatypes are.
>>
>>54082426
Not him, but you're a moron
>>
My favourite language actually has people using the latest version
>>
>>54082426
You can go ahead and assume that, and I'll go ahead and assume that you don't actually know any Python at all.
>>
>>54081085
>- universal One True FormatĀ® (no tab-space wars etc)

I really like this - more languages should do it.
>>
>>54081085
>>54082565
>FOIC is good
>>
C:
- more platforms
- more libraries
- much much quicker
- compiled
- doesnt require the crazy tabbing to get things working
>>
>>54082990
It has less books for noobs unlike Python.
>>
>>54081896
You start from an easy to understand form then iteratively make it more and more terse, and you learn a lot in the process since you have to go look up many details of the language.
>>
>>54083095
Is that a bad thing?
>>
>>54082990
All your lib functions are named shit. C is literally unreadable.
>>
C + Python is the best combination.

Provide counterexamples.
>>
File: 1425054841966.jpg (8 KB, 299x168) Image search: [Google]
1425054841966.jpg
8 KB, 299x168
/g/ please help. I always liked programming and think it would be a nice job for me. But only decided recently.

The problem is I wasted 3 years learning an IT job and now got an related job which is kind of exhaustive.

So what would be the best way to switch to a more programming related career? Just learn the needed skills in my free time?

How did you become a programmer, /g/, if you did so? (I guess some of us only see it as hobby)
>>
>>54081211
Fix your float rounding
>>
>>54081016
Elisp:
-it's built into Emacs
-Emacs is an IDE for it
-it's easy to code in it
-Emacs is a meme editor
-code is easy to read and write and looks (((((beautiful)))))
>>
File: pythonxd.png (101 KB, 1193x1147) Image search: [Google]
pythonxd.png
101 KB, 1193x1147
>>54081016
>>
>>54083410
C + Tcl is better combination.

Provide counterexamples.
>>
>>54083410
Counterexample one: Python is shit
>>
C++ is way more efficient
>>
/g/entoo people, i'm trying to learn C# and C++, i already know python, and i try to do and save a fibbonaci secuence, how can improve this code?
using System;
using System.Collections.Generic;
using System.Linq;

namespace fibonacci
{
public class Fibo
{
static void Main()
{
int number = 1;
List<int> list = new List<int>();
list.Add(0);
list.Add(1);
Console.WriteLine(number);
for (int i = 0; i <= 100; i++)
{
number = list.ElementAt(list.Count() - 1) + list.ElementAt(list.Count() - 2);
list.Add(number);
Console.WriteLine(number);
}
}
}
}
>>
>>54084880
Do you really need the whole sequence in memory? Or just the last results to calculate the next with?
>>
>>54084880
int n_0 = 1;
int n_1 = 0;
int n_2 = 0;
Console.WriteLine(n_0);

for (int i = 0; i <= 100; ++i)
{
n_2 = n_1;
n_1 = n_0;
n_0 = n_2 + n_1;
Console.WriteLine(n_0);
}
>>
>>54084953

pretty neat
>>
>>54084988
that's the bog standard iterative implementation

you could also do something more clever like the matrix squaring method or just the closed form version.
>>
C#
- Statically typed i.e. better suited for larger projects
- Much faster
- God tier tools (Visual Studio)
- Proper backwards compatibility instead of breaking changes every version
- no forced indentation

>>54084880
Maybe
var list = new List<int> { 0, 1 };

instead of
List<int> list = new List<int>();
list.Add(0);
list.Add(1);


Also don't declare that number variable at the beginning, do it just before its first use.
>>
>>54081016
It's compiled.
>>
>>54084895
I try to do both things, with diferent code.
>>54085037
Thx for the tips anon.
>>
I use python 3. Tasty
>>
>>54084819
>memegorithms
>>
>>54085037
>>54085066
I forgot, use list[n] instead of ElementAt(n).
>>
>>54083398
Maybe if youre a retarded pythonfag
>>
>>54085236
Not even him, but C libraries are notoriously shit-named, no matter which lang you compare it to
>>
>>54081016
x86 assembly
>easy to learn unless ur a fag
>fastest
>fastest
>most efficient
>fastest
>>
>>54086725
Sure, learning it is easy, but try and write anything big in less than a month with it on its own
>>
>>54086823
I implemented a JPEG encoder using SIMD in assembly in two weeks.
>>
>>54086823
I wrote 2 games in assembly in 2 weeks
>>
>>54086842
>>54086864
Sure maybe 2 weeks straight
>>
>>54087124
nope, 2 games 4 hours after work mon-fri, most of the day sats and suns
>>
>>54082367
Boole shouldn't be counting at all, He should literally just sit there and say either true or false.
>>
>>54087124
>Sure maybe 2 weeks straight
Nah, 2-5 hours after work and a 8 hour session on the first Saturday. Even taught myself x86 assembly in the process, which is why I think you could do it in shorter time if you already know assembly.
>>
>>54081930
>What about web dev?
>I get that Go is new and fancy and all, but it's not some sort of one-size-fits-all shoo-in language.

It literally originated as a language expressly designed for writing webshit.
>>
>>54087807
Then why does /g/ tout it to be a language specially good at systems programming?
>>
>>54087837
Literally nobody does that
>>
>>54087866
Literally everyone on this silly imageboard argue that it is a C replacement.
>>
JavaScript:
- I can run it in my browser

/thread
>>
>>54087888
Literally nobody does. People say that the 2 work fantastically with each other, and I can attest to that. I made a CHIP-8 emulator in C, and Python was very useful for external tools, like a chip8 sokoban map generator, sprite to binary converter, assembler, compiler, etc. Plus, while I haven't tried it, you can extend Python's fluid capabilities with C code
>>
>>54087922
>Python
We were talking about Go.
>>
>>54087942
Oh thank fuck, sorry I was an idiot. Yeah it's not a C replacement
>>
the worst aspect of Python is forced indenting I would never use it because of that
>>
>>54087955
But that's what's being touted on this board.

It even says so here:
https://golang.org/doc/faq#creating_a_new_language

>Go was born out of frustration with existing languages and environments for systems programming
>>
>>54088015
What I mean is that I agree with you, it's fascinating people are still trying to push it despite so many people's frustrations, including professionals
>>
>>54088030
>What I mean is that I agree with you
Ah, okay. I'm just confused.
>>
>>54081016

- better language design
- already better C embedding API, but not completed, so there is even room
- better sandboxing
- better startup times
- better overall performance than CPython
- overall better interpreter architecture than CPython
- better code quality

[spoiler]Wren, so you can see that even a basically one-man project can do things better than the CPython community.[/spoiler]
>>
>>54082387
>python3 has partial application and function composition

if (3 == ["faggot", (True, False), 8.2]):
print("dick")
else:
3+3

>good typing
what's the type of print?

>implying classes are the same as datatypes
>>
OCaml

typed
fast
tail call optimization
pattern matching
>>
>no OO cancer
>endline markers
>no pickyass stupid "whitespace is codeblocks" bullshit so I can actually search for the end of a block
>compiled
>direct control over memory (bawww, i suck at memory management, C has to be shit because of my failings)
>no horrible ass-backwards data structures
>no horrible completely broken compatibility between versions (lol, the living fuck, seriously)
Oh wait, that's more than 5. Ooops.

Python is shit.
>>
>>54081016
Python is for the programmer who want to make apps fast and not have to spend a long time maintaining code.

Looking at other languages gives me a headache in comparison.
>>
>>54086864
Care to show us these games anon? a repo or something. This is quite interesting.
>>
>>54089477
>>python3 has partial application and function composition
It does, you flaming homo. Go home, you obviously don't know Python.
>>
>>54090477
>it does
>let me ad hominem and not provide examples as proof that it does
>>
>>54086842
>>54086842

You guys are my idols now.

Care to share more info, tools, backstory, tips, what motivated you, the actual repo?
>>
>>54089576
I keep reading about this language. Used by Mark Zukerfag.

What are the use cases? What is it doing for you that other langs can't achieve?
>>
>>54090516
https://docs.python.org/2/library/functools.html

http://blog.thedigitalcatonline.com/blog/2014/08/20/python-3-oop-part-3-delegation-composition-and-inheritance/#.VxQLJZN96EI

Here you go you illiterate piece of shit.
>>
C with OpenMP is fater than Python 3.
>>
>>54090543
Had a 1st generation digital camera which I only could extract raw YUV frames from. Decided it would be a fun project to do, and since I just had received my Intel manuals (this was in 2008 I think) I picked them up and started reading about SIMD instructions which is when I figured I'd try to do it in assembly.
>>
File: 1451421666857.png (131 KB, 600x500) Image search: [Google]
1451421666857.png
131 KB, 600x500
>>54090607
>everything's unreadable and requires shitty encapsulation just to try to provide a functionality
>everything's an object
>>
>>54090649
Fucking top fucking kek... Step aside python fags. This is the real deal here.

I highly admire this type of thinking anon.
>Need to do transformation on data? >Undocumented routine?
>An idea, important for a project, that nobody implemented before?
>LET'S FUCK THIS SHIT UP IN 2 WEEKS

I hope
>>54086864
would share the story behind the 2 games, as well as for some keywords and hopefully the repo.
>>
>>54090686
>everything's an object
Yes, everything is a first class citizen you dumb frog poster.
>>
>>54090818
>functions are first class citizens
>implying that's a frog
>>
>>54090853
>functions are first class citizens
They are in Python. Do you even know Python? Do you even know functional programming?
>>
>>54081896
>So I understand all of that, what I'm asking is:
>1) where did these magical terse formulas come from? and perhaps more pertinently
>2) how does one become adept at coming up with solutions like this?
You don't ever want to write that kind of code though. If someone seriously proposed this for FizzBuzz during an interview I'd reject him.
>>
>>54090881
>python is fp
it just gets better and better
i wonder how you're gonna top yourself
>>
>>54089477
>what's the type of print?
A function that takes one required arg and a number of optional args.

Or a function, more generally.

Or an object, even more generally.

>>> type(print)
<class 'builtin_function_or_method'>
>>
>>54090909
strawmanning much?

Where did I say that Python is FP?

It's clearly multi-paradigm, and draws heavily from functional programming.
>>
>ITT: Multiparadigm languages can't be FP because they have objects

I wish this meme would stop.
>>
>>54090909
>my little anon can't be this desperate for replies on the Internet
>>
>>54090853
>>54089477
Wait, are you seriously unaware that Python has higher-order functions?
>>
>>54090929
it's not a real type though, it's just a classification

what's the type of the list?
at least in haskell, types make sense because it's ingrained into its type system, and one is encouraged to care about typing
one barely uses type info in lagthon
>>
>>54090938
given the context, it's pretty understandable to infer you meant python is fp, dummy
>>
>>54090972
YOU CANT HAVE THEM IF YOU DONT HAVE A GOD-TIER TYPE SYSTEM
IMPLEMENTING THEM ANY OTHER WAY IS JUST A HACK
>>
>>54091023
>given the context, it's pretty understandable to infer you meant python is fp, dummy
Except it wasn't.

>>54091010
>it's not a real type though, it's just a classification
It's a real type, idiot. func is a builtin.

>what's the type of the list?
list

>at least in haskell, types make sense because it's ingrained into its type system, and one is encouraged to care about typing
IT IS IN PYTHON TOO YOU DUMB SHIT

How about you actually try to program or at least read up on Python before making retarded statements that aren't even true.

Python is strongly typed and has higher-order functions.
>>
>>54091046
>YOU CANT HAVE THEM IF YOU DONT HAVE A GOD-TIER TYPE SYSTEM
Python is *****strongly***** typed dipshit.

The fact that you don't know anything about Python is not a valid argument against Python.
>>
>>54091010
Python is fundamentally duck typed. You can optionally assert strong typing via isinstance() and ABCs (abstract base classes) and even static typing via type hints.

But Python is fundamentally duck typed so you're comparing apples and oranges with Haskell.

Basically you're just whining that you don't like Python because you love enforced type systems.
>>
>>54091010
>what's the type of the list?
>>54091062

The type of a list instance is list.
The type of the list type is type.

>>> type([])
<class 'list'>
>>> type(type([]))
<class 'type'>

Python has metaclasses, too, which are about as fun as Lisp macros.
>>
File: K1450984594203.png (57 KB, 800x334) Image search: [Google]
K1450984594203.png
57 KB, 800x334
>>54081016
Get wrecked python fags
>>
>>54081016
1. - 5. It's not Python.
>>
>>54091062
you said, " dou you know python, do you you know fp?", and that implies they go hand in hand

it's not a real type, it's a classification
>type of list is list
and faggots like u r faggots, amrigth?
>strongly typed
see >>54089477
>>
>>54091145
>types are not types because I don't know Python
>i don't know the difference between dynamically vs statically and weakly vs strongly typed

See >>54091115

They are not "le hurr durr classifications xDDD ebin meme" they are ****types****

Just because everything not False and not None is evaluated to True, does not mean that Python isn't strongly typed.
>>
>>54091189
I don't know what those meme terms mean
strongly typed suggests, to me, a system that encourages a specific type for evry expression, that's why ever if else clause should have a specific type
>>
>>54091189
>Just because everything not False and not None is evaluated to True
That's not true. They evaluate to whatever their __bool__ method returns, and __bool__ CANNOT return a non-bool value.

So the default implementation of __bool__ for user classes returns True, so by default all user types bool-eval to True, but this is NOT type coercion.

The if keyword implicitly calls bool() on its argument so it may seem like type coercion but it's not. If you try to return a non-bool from __bool__() you WILL get a type error.
>>
>>54090637
Well I would hope so since the fast Python code is just a fucking wrapper to C or Fortran code.
>>
>>54091137
Go?
>>
>>54081939
>dat huge fucking shellcode
not compiling this family
>>
>>54081085
Yeah your favorite OS gentoo uses python
Thread replies: 113
Thread images: 7

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.