« first day (2296 days earlier)      last day (2530 days later) » 

12:27 AM
@HyperNeutrino do you have any quotes from OP regarding those edits you made?
you changed the challenge significantly
 
boop
so has anybody tried to make a catalogue of the shortest hello world, quine, cat, 99 bottles of beer?
other than the questions here ofc
 
@ais523 your quine post is quite fantastic.
 
0
Q: Compute the Discrete Cosine Transform

xakepp35Implement the Discrete Cosine Transform (DCT) for a sequence of any length. This may implemented as either a function or a program and the sequence can be given as either an argument or using standard input. There was previous challenge for DFT, now lets compute DCT! ;-) Rules This is code-go...

 
user165474
@Riker You mean the DCT challenge?
 
yes
ah, I see
I did'nt notice the "we can assume the same challenge rules"
sorry
 
user165474
12:38 AM
Ah, it's fine. Should have added an edit note or a comment :P
 
12:48 AM
hehe
bytes = len(code.encode(encoding))
 
1:04 AM
Uhhh @ATaco I think your userscript is borked, everyone is red in the chat
 
@Downgoat that poll's missing my option, which would be "values can sanely be implicitly cast if, and only if, operators are strongly typed"
all four possible combinations are seen in some language or other
 
@ais523 so operators must explicitly specify their operand types and if your attempted usage does not conform to any, then error?
 
JS has implicit casting and overloaded operators; Python has explicit casting only, but overloaded operators; Perl has implicit casting but monotyped operators; OCaml has explicit casting only and monotyped operators
@Downgoat that's how it works in OCaml
in Perl, effectively, all operators have a built-in cast
e.g. + always casts both arguments to number
if you want to concatenate strings, there's a different operator for that, and it will always cast both arguments to string
that said, OCaml is really extreme
it has a different operator for floating-point addition than it does for integer addition: Try it online! (see the debug view)
 
I like overloading, like julia
but implicit casting might be nice
 
1:15 AM
I think implicit casting and overloading at the same time is asking for trouble
 
maybe use overloading, and then default to the first definition (in the code) if the arg types don't match?
 
Perl's way of doing things are really different
the language can't distinguish between the integer 2 and the string "2" (at least, unless you really try hard to tell them apart)
and in fact, it's quite possible to look at the representation of a value in memory and discover that it's both at the same time
I think more languages should use that approach; IIRC, it's sometimes called a "unityped language"
 
how is it different than C?
 
@ais523 ... it would take way too much memory
@NathanMerrill it's both 2 and "2" at the same time
 
@ais523 wouldn't "2" be the integer 50 in memory?
 
1:19 AM
@ASCII-only Perl does take way too much memory :-)
@Downgoat actually Perl strings are both length-prefixed and NUL-terminated, so it'd be [1, 50, 0]
but inside several layers of wrappers
 
do you guys approve of this
 
there's a joke saying that to figure out how much memory a Perl program takes, start with the highest plausible estimate you can come up with, multiply by 10, and then you'll be more mentally prepared for the shock when you see what it actually is
it took me many rounds of optimization to get my build system (written in Perl) below 1GB of memory usage for a typical build
 
@totallyhuman There is literally no reason for it to exist, seing as how TIO already generates these automatically.
 
right but otherwise :P
i'm lazy and when i'm doing something off TIO...
like challenges that require internet access
 
I just write my submissions in TIO, and copy paste my code into my terminal if needed.
TIO needs Vim keybindings tho
 
1:23 AM
@Phoenix hehe
but like i said, i'm too lazy to do that
 
@Phoenix What about a vim plugin that sends your code to TIO?
Ooooh, now I'm excited I wanna try that
 
@DJMcMayhem That would require a stable TIO api
 
Stable APIs are for wimps.
 
@Phoenix ... The TIO API has been stable for like forever
 
1:30 AM
Yeah, if something doesn't change for a week it's OK to assume it's stable.
 
IDK, Dennis says it shouldn't be used.
 
@Phoenix He said it shouldn't be used, not that it isn't stable
 
does this java code look right?:
public class Tokenizer {
    private Class<? extends Token>[] tokens;
    private Tokenizer(Class<? extends Token>[] tokens) {
        this.tokens = tokens;
    }

    public Tokenizer() {
        this(new Class<? extends Token>[]{
            AsteriskToken,
            LParenToken,
            MinusToken,
            NumberToken,
            PlusToken,
            RParenToken,
            SlashToken,
            Token
        });
    }
}
 
@Downgoat ? extends Token is redundant, should just be Token
 
@Downgoat yeah
 
1:37 AM
@Phoenix huh ok thanks
 
@Phoenix How is it redundant
 
Anything that extends a Token is itself a Token.
 
@Phoenix ... You do know there's a reason why the wildcard syntax exists right?
 
When is the ? extends ... syntax useful?
 
I don't know.
Well, I kinda do.
If something takes a List<Rectangle> as a parameter, you can't pass it a List<Square>, you'd want List<? extends Rectangle> as the paramter to type so that works. But it doesn't seem to matter in this context.
 
1:40 AM
@feersum Wait i'm an idiot it's for when you want to be able to use a subclass
 
@feersum I make really heavy use of that in my day job; basically it's almost impossible to write typesafe generic code without it
but it takes quite a while to explain how it works
the basic idea is that you can store a value of type A in a variable of type B if A is a class that extends B
 
apparently, you can't do def f(x, y = x): ... in python :c
 
and Java wants to verify that values are only stored in correctly typed variables across your whole source code
 
@ais523 That happens automatically.
Rectangle foo = new Square(); is perfectly valid.
 
the variance annotations ? extends A and ? super A allow types to be expressed sufficiently accurately that Java can deduce that variables have values of the right types, even across function boundaries
 
1:42 AM
@Phoenix ... It's a list of classes, they're all subtypes
 
@ASCII-only OH I GET IT NOW
I didn't realize what the code was doing >_>
 
@Phoenix right, when there's information available on the sorts of values that the variables can actually have; the purpose of variance annotations is to make that information available "long-range" in a program
 
@Phoenix if I have a Class<Token> and Token has static property foo. How would I access it?
 
@Downgoat I think Class has a method to read a static property
let me check the API
 
Very tediously with reflection methods.
 
1:45 AM
@Downgoat tokenClass.getDeclaredField("foo").get(null)
 
I don't like Java reflection.
 
alternatively, I believe Token.foo (and just disregard the Class<Token> that you happen to have) fits your requirements
 
Can't do that unfortunetly, because I am also passing subclasses of Token
 
@Downgoat I think in general you have to use reflection at this point, because IIRC there's no way that a class can force all its subclasses to have a particular static field with a particular visibility; the issue is that the subclass could be package-private to a different package
 
You can pass objects of subclasses of Token
Probably not better tho
 
1:47 AM
you might not be doing that, but the compiler doesn't know that
 
@Downgoat Then pass a Token instance instead of subclass
 
can't doing like VSL
 
@Downgoat ?
 
where there are a lot of Token classes
and each token class has info on how to parse it
and then the output is a new Token(parsedTokenStringValue)
 
if you can change your architecture, I strongly recommend giving Token an instance method to get the value in question; or if this is needed for some sort of factory, having a TokenProperties object that you pass around instead of Class<? extends Token> objects
(note that there is only one Class<Token> object, Token.class itself)
 
1:49 AM
@Downgoat but even node-vsl doesn't need a list of tokens
 
that is what I would do
I didn't think subclassing Token was good idea
 
I thought you were doing that part of VSL is node
 
@Downgoat make a TokenParser class
 
but guy in CS class only knows one parsing algorithm and needs subclasses for that
 
@Downgoat Well it is
 
1:49 AM
you could even make it TokenParser<TokenType extends Token> if you want to make it type-safe relative to your token hierarchy
this is the thing with Java; the entire language is designed such that working around its problems can normally only be done by adding more and more levels of abstraction
 
You guys are making this way too hard.
 
which is why you end up with AbstractFactoryFactoryImpls
 
yeah factory classes would fix this
but goddammit java
 
@Downgoat O_o
@Downgoat what kind of algorithm would that be
 
When do you actually need Factory classes
 
1:51 AM
In computer science, a Pratt parser is an improved recursive descent parser that associates semantics with tokens instead of grammar rules. It was first described by Vaughan Pratt in the 1973 paper "Top down operator precedence", and was treated in much more depth in a Masters Thesis under his supervision. Pratt designed the parser originally to implement the CGOL programming language. Douglas Crockford used the technique to build JSLint. == Notes == == See also == Operator Precedence Parser == External links == Pratt Parsers: Expression Parsing Made Easy A Pratt Parser implementation in Python...
 
@Downgoat can't you implement earley/recursive descent/shift-reduce yourself
 
apparently reading that paper made think the word "CFG" describes derivative of BNF :P
 
I've never come across one ever.
 
@feersum haha +1
 
@ASCII-only I mean we really only need to implement shunting yard
@Phoenix understandable
 
1:52 AM
The basic problem with Java is that not everything abstracts correctly; constructors are a good example of something that doesn't.
The normal workaround is to wrap the thing that you're having trouble with in an extra layer of abstraction; a Factory is just the general name for any abstraction that works like a constructor.
 
My idea is to not bother figuring out what the tokens mean at tokenization time.
I just inspect them again later.
 
@Downgoat just pass the tokenizer a list of regexes
 
Actually, no, I've used a Factory class once. I just called .newDefaultInstance() and wondered why it wasn't a constructor.
 
@ASCII-only well how does it know which token class to construct
 
@Downgoat have you seen lex? it's basically a compiler from a list of regexes (each of which is associated with code to construct the appropriate token) to a program
also, for anyone confused about the use of regexes here; regexes were pretty much invented for tokenisation, it's just parsing they can't do
 
1:54 AM
the lex that is like GNU flex?
 
GNU didn't invent it (also their version of it isn't even called lex) :-P
 
>_>
 
@Downgoat 0/10 seperate classes is bad idea, just use token type enum like vsl does
 
it's fairy easy to do much the same thing manually, anyway, if you want to
 
@ais523 yes, we used flex for c++ vsl
 
1:55 AM
This is yet another thing besides VSL?
 
@ASCII-only exactly
@feersum nah, just a dumb CS project
 
the reason you use lex/flex in practice is just because they have really good optimizers special-cased to tokenisation, and that tokenisation is the second-slowest part of parsing (and the slowest at low optimisation levels)
but writing a lexer manually is easy too (unless you're working with, say, Incident), and doesn't normally need the same number of levels of abstraction that you'd need for a parser
 
@Downgoat actually i think you can keep it this way
 
Question: what is java/OO way to do:
[
     ['[0-9]', TokenType.Number],
     ['\+|-', TokenType.Operator],
]
 
almost every lexing framework I've seen outputs a tagged union (which in Java can be implemented most easily using an enum)
because the parser wants a uniform interface
 
1:57 AM
have a root node, then according to wikipedia root node will have data on valid next tokens so just call rootNode.tokenize() i think?
 
I would do a tuple but java doesn't support tuple
@ais523 :O does java have attributed enums
 
But a tagged union's elements can hold data; an enum can't.
 
@Downgoat yes
 
omg 10/10
nevermin
 
@feersum right, I was wondering about that
apparently a Java enum can have values statically associated with the enum constants, but not read-write values
so maybe you would need a whole inheritance hierarchy :-(
 
1:59 AM
Right.
 
@Anyone: If you were forced to only program in either Java or JavaScript for the rest of your life what would you choose?
 
Java.
 
@HelkaHomba JavaScript because Node is the best
 
Java, but I wouldn't be happy
JS's library support is too bad for me
 
I'd say Java too
 
2:00 AM
@HelkaHomba JavaScript all the way
Java is too painful
 
enum Token {
    NUMBER('\d'),
    OPERATOR('[-+]');

    private String regex;

    Token (String regex) { this.regex = regex; }

    string getRegex () { return regex; }
}
 
It's also super easy to make language in JS that would be great. cough vsl cough
 
@Downgoat "JavaScript is too painful" ftfy
 
@HelkaHomba sorry, but i actually lol'd on this
 
Java doesn't give me the willies
 
2:04 AM
@HelkaHomba If Java it better than JS you're using JS wrong
 
@ASCII-only btw in java stirng is "" you're using char :P
 
@Downgoat oh whoops
Also I used string instead of String the last time because I thought I was writing C#
 
O_o can enum not have public constructor
 
@HelkaHomba Java
 
oh wait nevermind
 
2:09 AM
That's Java 4, JS 1 and 1 goat
 
C# master race
 
@HelkaHomba 0/10 discrimination
 
I count goats as 100.7% of people if it helps
 
idk if that is good thing bad thing
Question: how do I effectly explain that using a Class: Pattern HashMap in java is really bad idea and reflection is also bad
 
@Downgoat Explain that reflection requires the vm to look through all its symbols and stuff
so super slow
 
2:21 AM
I did
 
@Downgoat wat whoever you're explaining to doesn't think slow = bad?
 
no they just don't seem to understand how java work
 
It makes your code far, far harder to maintain.
 
They said to use x -> x instanceof Foo because doing if (condition) x instanceof Foo is slow for some reason?
 
@Phoenix No it doesn't
 
2:24 AM
not sure I understand
 
One does not maintain a CS assignment, so that argument doesn't help.
 
@Downgoat if looks faster, it doesn't create a lambda
 
@ASCII-only Reflection makes code less readable 99% of the time.
 
@Phoenix Of course, but it doesn't make it any harder to maintain
 
0
Q: Is this sort of "language" allowed?

MD XFI wrote a "language" called shortC. Basically, it reads shortened C code and turns it into actual C, from which it can be compiled by whatever C compiler the programmer wishes. For example, in the language, I transforms to int and C transformed to char when "compiled" (translated). Is this sort ...

 
2:26 AM
Yeah, I misspoke a bit.
 
Question: I shouldn't need to import classes that are in the same package right?
 
@Downgoat correct
 
Question: can anyone who has made language in java please link me
 
CC @ATaco
 
@Downgoat is cs assignment not just shunting yard
 
2:28 AM
@ASCII-only We literally only have to do shunting yard
 
you can do parser + tokenizer + interpreter in about 200 lines of java max
ok brb trying to write shunting yard
@Downgoat what does it need to support
 
it's a calculator
that simple
 
@Downgoat just +/-? or other operators as well
 
Question: when you get job are co-workers like this >_<
@ASCII-only plus, minus, times, divide, exponentiation, and functions
 
If you need to implement a calculator, you can use the builtin JS evaluator.
 
2:32 AM
Unsanitary
 
@Downgoat wait do you even need shunting yard
@Phoenix 0/10 too slow
@Downgoat functions? pls provide syntax
 
Question: how do I make Matcher start at a certain index
@ASCII-only foo(123)
example function would be sqrt(123)
 
@Downgoat matcher.find(index)
 
@ASCII-only that returns boolean though
I want to get matched string
 
@Downgoat then use matcher.group(0) to get string after calling find
 
2:41 AM
thanks
 
Would a language totally with pragmas okay
 
@SIGSEGV totally with pragmas?
 
Like uhh C macros
I could call it PRAGramming
nvm its bad
 
Poll: is doge pronounced with a soft or hard g?
 
@Riker soft
 
2:46 AM
@Riker dojh or doujh
soft
It sounds like dodge
 
@Downgoat Ay yo I have.
 
to the same people: is gif pronounced with a hard or soft g?
@SIGSEGV what no
dojh != dodge
the g sound is the same yes tho
 
@Riker soft
 
Hmm
kden
 
@ASCII-only I wonder if there's a correlation
 
2:48 AM
So you ask if its dojh or doggy?
 
dog-eh but yes
doh-je or dog-eh
 
@Downgoat question: is power ** or ^
 
power should always be ^ imho
 
I like ** for power because it's unambiguous
 
@ASCII-only caret
 
2:50 AM
^ is easily interpreted as xor instead (and is also used for other operations, like concat in OCaml)
 
Math.pow(a,b).
Obviously.
 
@Downgoat do you have to use shunting yard
 
at least one golflang just uses *
 
Nah use to the power of
 
@SIGSEGV ...
 
2:52 AM
use superscript notation; we don't have enough rich text languages yet
come to think of it, the only one I can think of offhand is colorforth
 
I pushed an update that fixes TeamSpirit...
 
Mathematica lets you have exponents in superscript
 
?
how?
 
@Downgoat Checkout this and this which is two languages I've written in Java.
 
ctrl-6
 
2:54 AM
there's also 90, but that was mostly a joke
 
func power(int x, int y) -> int:
  int temp = 1

  for int n -> range(y):
    temp *= x

  return temp
 
I specified things like "comments must be in italics" without specifying how the source code is represented at all
 
Wood send screenshot but playing Rainbow Six Siege
 
it's a fun language, though
maybe I should write an interpreter so that it can be used on code-golf challenges
 
I'm using -> in two different contexts, I want to change one of them into something else
What do I change it into?
 
2:55 AM
that said, it's also almost completely unreproducible
@Qwerp-Derp
 
@ais523 Only ASCII pls
 
what are the contexts? the change is likely going to be based on context
although => is common as a "second arrow"
 
-> in the func means the return type must be int
-> in the for loop basically assigns n to an item in range(y), and iterates over that - basically a foreach
 
@Qwerp-Derp ><>
 
@ASCII-only i mean shunting yard is easiest right
 
2:57 AM
=>
 
-> and => look really similar though
 
@Downgoat yeah but boring, plus doesn't work for function
 
@Qwerp-Derp range constructors are normally ..
 
I'm thinking I should replace the -> in the for loop, but to something else other than a keyword (no in)
 
for n (1 .. 10)
 
2:58 AM
@Qwerp-Derp ~>, :>, |>, paren/brace/bracket/angle bracket + >
 
for n -> [1..10]?
 
@Qwerp-Derp for n:1..10
 
(Perl's actual syntax for this is for my $x (1 .. 10), and you don't technically need the my; that's just to scope the variable to the loop)
 
for n |> [1..10] looks nice
 
use : because java
 
2:59 AM
But then there's a : on the end of the for loop
And it looks weird
for (int n: [1..10]):
 
@ASCII-only i thought Wikipedia show special shunting yard for function
 
That looks odd
 
> weird
> java
I see no difference /s
 
@Riker Aaaaaaand then there's PHP
 
good point
that SO trends thing said php was going down
 
3:01 AM
Does anyone here watch Extra Credits?
You know the episode on accretion? I honestly believe that's the design philosophy of PHP
Because mysql_real_escape_string
 
3:13 AM
CMC: given a pair of rectangular coordinates, calculate the equivalent polar coordinates (r, θ) where θ is in degrees.
 
Question: how do I get a string that starts at a specific index w/ Matcher? in java
.find(n) with an anchored (^foo) regex does not work for n > 0
 
@Downgoat oh no that's what i was doing
 
@Downgoat solution: use string.subSequence(index, string.length)
 
You mean substring?
 
3:28 AM
@Downgoat no because subsequence does not alloc new string
 
oh
 
3:46 AM
0
Q: First question about overflow?

Dj DacMay I ask a question about overflow? I was thinking an example of overflow calculation would be the number of googolplexes a number is because the computer can't count with that large numbers. AFAIK no computer language has a library for 512-bit numbers so I wanted to create a question where the ...

 
@NewMetaPosts ^^
 
@ASCII-only can you verify that this is correct:
import tokenizer.*;
import java.util.Stack;

public class Parser {
    public Stack<Token> parse(Stack<Token> tokens) {
        Stack<Token> output = new Stack<Token>();
        Stack<Token> operatorStack = new Stack<Token>();

        while (!tokens.empty()) {
            Token token = tokens.pop();

            if (token.getType() == TokenType.NUMBER) output.push(token);
            if (token.getType() == TokenType.OPERATOR) {
                int precedence = TokenType.getPrecedence(token.getValue());
It seem to infinite loop
 
@Downgoat solution: debug the JS way with System.out.println(output.join('')) or whatever
 
I think it's the subsequence
oh my god nullpointerexeptions are the bane of my existence
 
@Downgoat where is subsequence
 
4:00 AM
tokenizer is seperate
Looks like subsequence was causing infinite bork
 
@Mego The first "etiquette" in raw.githubusercontent.com/TheNineteenthByte/The-Nineteenth-Byte/… is not bolded properly
And whatever happened to
3
Q: Should administrative content hosted on external sites ever be binding?

Helka HombaShould PPCG rules or guidelines or other administrative content be considered "official" when it is not hosted on meta or main? (Note that "PPCG" refers to the entirety of the Programming Puzzles & Code Golf Stack Exchange site microcosm, including main, meta, and chat.) Currently, most of our...

Like, what happens when all the room owners and mods stop frequenting PPCG? Who can edit that github document?
 
@Downgoat did you remember to increment index
 
wait i have to do what
I thought subsequence did that
 
@HelkaHomba That's intentional, but since a lot of people have been remarking about this maybe it should be changed
@Downgoat string.subSequence(index, string.length) <- index is an int, you need to increment yourself
 
Oh, I see
 
4:05 AM
@ASCII-only D: oh
 
4:17 AM
@ASCII-only wait how to unary op in shunting yard
 
if you have a parsing algorithm that handles binary operators, you can generalise it to unary operators via assuming an operand before or after it (depending on whether it's prefix or postfix)
normally the resulting generalisation will "cancel out" into something that makes sense within the algorithm
 
0
Q: Unshorten Google Links

Hyper NeutrinoChallenge Given a valid goo.gl shortened link, output the original URL. Example goo.gl/qIwi3N would give something like https://codegolf.stackexchange.com/. For input, you can choose to have the https?:// at the beginning, you can choose to have www. before the goo.gl, and you can also choose ...

 
4:34 AM
0
A: We've written a new Chatiquette, and we want your feedback!

Helka HombaWhy Host It Externally? Should administrative content hosted on external sites ever be binding? Current top answer says no. Why put the chatiquette on github rather than in a meta post all privileged PPCG users can maintain? Who maintains the github chatiquette when the users with permissions ...

 
@Downgoat if unary use < instead of <=, pls see cheddar shunting yard if it still exists
 
@ASCII-only :O i could copy paste cheddar shunting yard
 
@Downgoat yeah you probably could
@Downgoat does it have to be in java
if not i'd have said use haskell or perl for parsers pretty much builtin to the language
 
5:27 AM
I found this post on imgur, wonder who made it :P
 
@Phoenix "A Jelly Programmer", 3 minutes ago
0 days old
very suspicious
 
Why suspicious?
 
@Phoenix Someone created an account just to post that
also how did you find it less than 3 minutes after it was posted
 
I was browsing newest user submitted
 

« first day (2296 days earlier)      last day (2530 days later) »