Live data from Hacker News

Anyprint: use any language's print statements in Python

github.com

61–70 of 76 posts

Re: Anyprint: use any language's print statements in Python

#61
post #23

Earlier quoted context omitted.

Perhaps you'd enjoy Nim which supports both. echo "hello world" echo("hello world") and as a bonus, also the following: "hello world".echo

I'm a primarily Python dev, have been for a long time. Lately I've been working in Javascript/typescript and there is no worse antifeature than having 3 different ways of doing the same thing. You try to figure out how to do something, you see 3 different solutions and you ask yourself, what's the difference? What's more correct? Will I need one over the other? Are they compatible? Is one way better supported than th…

>You try to figure out how to do something, you see 3 different solutions and you ask yourself, what's the difference? What's more correct?

Maybe I'm just bad programmer, but I whole heartedly embrace languages that let me express myself in a way I want to. Big part of my day is dealing/writing/converting stuff to Python and part of me wishes there wasn't "the Zen way" to do things, but instead I could express myself, but this kind a goes beyond Python in a sense that it doesn't have the syntax I would like to use.

I'm by no means saying that JavaScript is any better. So far my personal favorite language has been Ruby (and not the Rails way), for some reasons it feel like with Ruby I can just tell the code what to do instead of having to explicitly command it to do what I want step by step.

Re: Anyprint: use any language's print statements in Python

#62
post #27
post #23

Earlier quoted context omitted.

Perhaps you'd enjoy Nim which supports both. echo "hello world" echo("hello world") and as a bonus, also the following: "hello world".echo

Lua does too, for literal tables and strings being sole argument you can omit parentheses. But to call method on a literal you need to add them. > print("OK") > print "OK" > ("OK %d"):format(1) I've seen some funky (ab)use of these, people using literal strings and tables and functions named class and similar to do: > class "Something" { > -- ... > }

This is one of the reasons I love Lua. I'm constantly pleasantly surprised by Lua. It defines a few simple primitives, and allows you to do whatever you want with them, even to the absurd.

Hell, it even allows you to do this:

> somefunc "1string" "2string" "3string" > somefunc {} {} {}

Re: Anyprint: use any language's print statements in Python

#63
post #39

Earlier quoted context omitted.

print chevron in python2 is super awesome print 'hello' f = open(file, 'w') print>>f, 'world' It just feels more "powerful" than Py3k's print(somestring, file=someopenfile)

> More powerful But less obvious and readable, which is anti pythonic. If you want "power" over readability, there is ruby/perl.

I'm not going to discuss perl readability, but the fact is that I cannot simply 0%% to beginning of the block in "readable" python. ?:$ does its job though.

Re: Anyprint: use any language's print statements in Python

#64
post #4

Makes all these valid in Python: printf("printf %d\n", 10); fmt.Println("hello") cout Really funny, including the testimonials: > Anyprint has many glowing reviews from its many satisfied users: > > * "omg pls" > * "what is wrong with you" > * "That's stupid and not useful." > * "Please add my testimonial: "very accurate testimonials"." > * "kragniz, please stop writing questionable python metamodules :v"

> cout For the love of god, please stop using endl. It performs a flush when "\n" is both valid and all that you ever want.

Also what happened to the std:: prefix?

Re: Anyprint: use any language's print statements in Python

#65
post #39

Ironically, what I miss most from Python is Python2's print, which for a language proud of getting rid of parenthesis, that is very contradictory....

print chevron in python2 is super awesome print 'hello' f = open(file, 'w') print>>f, 'world' It just feels more "powerful" than Py3k's print(somestring, file=someopenfile)

You'd like Perl:

  open my $file, '>', 'hello';
  print{$file} "Hello";

Re: Anyprint: use any language's print statements in Python

#66
post #49
post #48

Earlier quoted context omitted.

UFCS. Also found in D. And, frustratingly, did not get past the C++ committee.

Name resolution is already so insanely complicated in C++ it's hard for me to lament this too much.

Well, the works already been done so I don't care that much about language at this point.

Re: Anyprint: use any language's print statements in Python

#67
post #23

Earlier quoted context omitted.

Perhaps you'd enjoy Nim which supports both. echo "hello world" echo("hello world") and as a bonus, also the following: "hello world".echo

I'm a primarily Python dev, have been for a long time. Lately I've been working in Javascript/typescript and there is no worse antifeature than having 3 different ways of doing the same thing. You try to figure out how to do something, you see 3 different solutions and you ask yourself, what's the difference? What's more correct? Will I need one over the other? Are they compatible? Is one way better supported than th…

I also think we should write our programs as concise and simple as we can. There should really be one obvious way to do it.

I recently read the statement that "If you can solve parsing Perl, you solve the Halting Problem "(http://www.perlmonks.org/?node_id=663393). This is not a joke, it's serious.

Python and Go keep their promise to stay simple. However I believe, metaclasses, asynchronous programming and constructs like "yield from" and the whole itertools library could be better engineered. And lastly with new approved PEPs like concerning string interpolation etc., I believe Python is making compromises in its core ideology. In contrast, in go if you want to allocate something you just use make(), if you want your code to run concurrently you just use "go", if you want to send messages between threads, you just use channels. The complexity is well hidden in the language itself.

What I don't like in Java for example is that, as a general purpose language, in each version new features are added. And these new features add complexity, and complexity leads to mistakes.

Perl I understand, it was designed as the first postmodern programming language. Javascript was written in a very short time and intended to be a browser scripting language. But Typescript?, with Typescript there is no excuse. I guess, this is Microsoft's policy: Worse is better, make everyone (or at least revenue sources) happy. You want feature x, they add it, you want lambdas, they add it etc.

Maybe I'm a bit tired of hassling through chaos, but I want my codebase to be structured. If I don't like an API, I take my time and write a simpler abstraction. One programming advice stuck in my mind from the Art of Linux Programming: you should focus on data structures (a.k.a structuring).

I think this advice is true for all aspects of life. You need to set aside a place for your things, if you want to live/work in a tidy environment. You need to plan your day, if you don't want to fall apart. You need folders to organize your e-mail/documents. You need to structure your programs in meaningful abstractions into seperate modules/subroutines.

Re: Anyprint: use any language's print statements in Python

#68

Earlier quoted context omitted.

To say nothing of vitally important format expressions like (format t "~{~a~^, ~}" list)

And of course the stuff necessary for word-wrap-in-`format`: (format t "~{~ ~}" '("these" "words" "will" "be" "wrapped" "to" "40" "characters")) and the other `format` insanity in: http://cybertiggyr.com/fmt/fmt.pdf

Behold the mighty power of CL format!! I wonder if the format string language, aka "line noise", is turing complete...

Re: Anyprint: use any language's print statements in Python

#69

Earlier quoted context omitted.

I'm a primarily Python dev, have been for a long time. Lately I've been working in Javascript/typescript and there is no worse antifeature than having 3 different ways of doing the same thing. You try to figure out how to do something, you see 3 different solutions and you ask yourself, what's the difference? What's more correct? Will I need one over the other? Are they compatible? Is one way better supported than th…

I also think we should write our programs as concise and simple as we can. There should really be one obvious way to do it. I recently read the statement that "If you can solve parsing Perl, you solve the Halting Problem "( http://www.perlmonks.org/?node_id=663393 ). This is not a joke, it's serious. Python and Go keep their promise to stay simple. However I believe, metaclasses, asynchronous programming and construc…

To be fair on typescript, I think it's inheriting most of these issues from wanting to give a better way to do things, but keeping (near-)full backwards compatibility with JS.

It's ES5, ES6 etc that is adding to it.

Post reply on HN