Javagony!

Поділитися
Вставка
  • Опубліковано 25 січ 2025

КОМЕНТАРІ • 184

  • @Truttle1
    @Truttle1  6 років тому +119

    UPDATE: I just noticed that Flawr was indeed the creator of Javagony. The creator of the language was mentioned at the bottom of the article rather than the top.

  • @NStripleseven
    @NStripleseven 3 роки тому +40

    “That weird little question mark operator that nobody uses”
    Excuse me, the ternary operator is an incredibly useful tool in compacting code while still leaving it (mostly) perfectly legible

  • @thekilla1234
    @thekilla1234 3 роки тому +67

    This will run forever:
    private static void runOne() {
    System.out.print(1);
    try {
    runOne();
    } catch(StackOverflowError e) {
    runOne();
    }
    }
    Eventually you will hit a StackOverflowError which is caught and replaced with a new call. Since you just had a stack overflow, the print() will cause a stack overflow but this time it is in the catch block and not the try block, which means the stack continues unwinding removing a runOne() from the stack. Eventually there will be enough stack space to run a full runOne() call, which will repeat forever.

    • @SimonClarkstone
      @SimonClarkstone 3 роки тому +17

      AFAICT, that doesn't run forever, but does run for an extremely long time. It prints O(2^n) ones, where n is roughly how deep the stack can get.

    • @whamer100
      @whamer100 3 роки тому +1

      sim1R sim1L

    • @branthebrave
      @branthebrave 3 роки тому +4

      Good idea. Until your computer simply runs out of memory. I think there might be a way to increase the amount of memory to use up before stack overflow? Or, write a native method that manually deletes a all those method calls from the stack (won't work with backwards recursion then). Well, unless java has its own special call stack, which it probably does.

    • @MichaelDarrow-tr1mn
      @MichaelDarrow-tr1mn 2 роки тому

      @@SimonClarkstone so what does it do on the last 1 huh?

  • @mobeushealer3336
    @mobeushealer3336 3 роки тому +73

    This channel basically confirms my ability to learn about random things rather than important ones.
    Keep it uppp

  • @WilliametcCook
    @WilliametcCook 2 роки тому +3

    "I curse you to, when you use Java you experience a ton of agony!"
    Don't need a curse for that

  • @seanrooney2230
    @seanrooney2230 4 роки тому +58

    These videos bring me joy. You're really smart, kid, and you manage to make these videos interesting as well.

  • @icif1234
    @icif1234 5 років тому +97

    The truth machine doesn't crash if you implement thread-able objects.
    If you call start() on a thread it behaves on its own and you can dispose of the current thread, which means no overflow!
    class Recursive implements Runnable {
    @Override
    public void run() {
    System.out.println("1");
    new Thread(new Recursive()).start();
    try {
    Thread.currentThread().join();
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    }
    }

    • @AntonioNoack
      @AntonioNoack 3 роки тому +1

      I am late, yes, but why do you execute "Thread.currentThread().join();"?
      It does nothing. It joins thread x with thread x.
      It's like a nop instruction, just way more complicated xD.

    • @koalakid3609
      @koalakid3609 3 роки тому

      Shut up nerd

    • @elzearcontelly2651
      @elzearcontelly2651 3 роки тому +3

      Because of the `join`, you're not freeing the calling thread, so it doesn't get discarded. You'll probably run out of RAM or your system will crash because there are too many threads quite fast.
      One solution would be to have the new thread join the previous one (currently it's doing the opposite)

    • @icif1234
      @icif1234 3 роки тому

      @@elzearcontelly2651 I appreciate the input, at the time of writing that comment it seems i didn't fully understand .join()

    • @branthebrave
      @branthebrave 3 роки тому

      could do a Thread Sleep to really slow it down until you run out of memory while still making the app seem responsive to a human

  • @thatotherandrew_
    @thatotherandrew_ 3 роки тому +38

    "Standard Java IDE like Eclipse or NetBeans"
    _Angry IntelliJ noises_

  • @sneeznoodle
    @sneeznoodle 3 роки тому +8

    "That question-mark operator I never use"
    **Sad ternary operator sound**

  • @nekoill
    @nekoill 3 роки тому +11

    Wait a minute, on a second look, Javagony is basically just a way to program in functional style in Java, given the recursion and all that, which is awesome.

  • @kryptoid2568
    @kryptoid2568 3 роки тому +44

    "That "l" is a lowercase L"
    reminds me of OiI

  • @lunarmagpie4305
    @lunarmagpie4305 3 роки тому +52

    Whats the point of Javagony? Its already agony without any changes.

    • @angelcaru
      @angelcaru 3 роки тому +2

      Agreed.

    • @lotsoflambdas
      @lotsoflambdas 6 місяців тому

      java is already bad.bunch of oop nonsense where the suffixes make as much sense as the ones in kayfbopt.stupid ppl talking about "clean code" and "cooperation" and "readability".real programmers use c++.
      (/priveleged static register intern unique_ptr*(std::heap,[=]template(T IRandomlyFoundThisSortaStuffInTheStandardLibraryItIsGood){return (unsigned long long long long)"Yes,this type is made up,and no,you shouldn't be converting const char* to a big number using builtin conversions";} sortaSerious)

  • @tux1468
    @tux1468 5 років тому +149

    The real Javagony is you putting the starting brace on the next line.

    • @_zelatrix
      @_zelatrix 3 роки тому +6

      No, it's that he's catching the general Exception rather than (in this case) an ArithmeticException

  • @GuyMichaely
    @GuyMichaely 4 роки тому +4

    Java is already javagony

  • @smashpik
    @smashpik 2 роки тому +2

    You sir are a great content creator I love your humor and your paper Mario gags, i have just 6 months learning programming mainly in java and i'm happy that i can enjoy so much this piece of art.

  • @hx9d674
    @hx9d674 3 роки тому +6

    Developer of that made java even pore painful to write. he's a true wizard.

  • @trolololo720
    @trolololo720 3 роки тому +7

    Are streams allowed though? Because if so, the challenge is pretty easy.
    3:13 The answer to that is tail recursion btw

    • @susulpone
      @susulpone 3 роки тому +4

      finally someone said it! I, as a functional programmer, got so exited at the idea of a tail recursive 99 bottles of beer that I completely forgot about decrements

    • @branthebrave
      @branthebrave 3 роки тому

      Or make your own stream library out of try catches :)

    • @trolololo720
      @trolololo720 3 роки тому +1

      @@branthebrave Seems like attacking a fly with a cannon, but you could in fact do that

  • @berndeckenfels
    @berndeckenfels 3 роки тому +5

    You can also use a new blacklimit[21] to get an ArrayIndexOutOfBounds for larger index.

  • @Roxor128
    @Roxor128 10 місяців тому

    This was well-named. There's something about the whole try-catch system that just makes my head hurt.

  • @NStripleseven
    @NStripleseven 3 роки тому +5

    Javagony: Surprisingly usable!

  • @Maximxls
    @Maximxls 3 роки тому +9

    In the blackjack example you also may have used Math.sqrt(b-21), which is imo more clear. If b is 22 or more, then the expression would evaluate to a negative number and sqrt would throw an exception.

    • @Maximxls
      @Maximxls 3 роки тому +4

      I just realized that this is slooooooow, sorry.

    • @Alexi_Blue
      @Alexi_Blue 3 роки тому

      It gives NaN for me and doesnt throw an exception for some reason

    • @Alexi_Blue
      @Alexi_Blue 3 роки тому +1

      Like, you can convert nan to 0 and divide by it no problem, but still

  • @photophone5574
    @photophone5574 2 роки тому +1

    You can also check if an integer is greater than a number through recursion:
    How to check if a number is negative or positive through incursion:
    Create two variables that are copies of the integer you want to check. Subtract 1 from the first copy and add 1 to the other. Use a try catch to check if one of the copies has reached zero.
    A < B
    A - B = C
    Therefore
    C < 0

  • @kamalamks7368
    @kamalamks7368 4 роки тому +9

    Can't wait for cgony
    It will be harder and more anniying

  • @focat
    @focat 3 роки тому +1

    You are so underrated! People need to see your content, it's amazing!

  • @Magnogen
    @Magnogen 3 роки тому +1

    4:24 OH NO HE'S SELF AWARE

  • @CyborusYT
    @CyborusYT 3 роки тому

    "When you use java, you experience a ton of agony!"
    Yeah?

  • @pa3ckp7
    @pa3ckp7 3 роки тому +1

    Ah yes java with double the agony, since java is agony by itself

  • @kazii_the_avali
    @kazii_the_avali Рік тому

    i love how i know enough about java to read the code but not enough to write it.

  • @whamer100
    @whamer100 3 роки тому +1

    i hear a Waterflame fan, electroman adventures is a banger

  • @arjix8738
    @arjix8738 Рік тому +1

    ==, >=,

  • @vicr123
    @vicr123 6 років тому +6

    If only goto statements existed :(

    • @Truttle1
      @Truttle1  6 років тому +10

      Victor Tran random fact (even though you probably already know this): Java has "goto" as a reserved keyword, but it has no purpose. The same applies to "const".

    • @vicr123
      @vicr123 6 років тому +1

      Well I didn't know about the const keyword ;)

    • @quack3891
      @quack3891 3 роки тому

      @@Truttle1 wait so you can't even #define it or anything like that to make it do stuff?

    • @Daniikk1012
      @Daniikk1012 3 роки тому

      @@quack3891 there is no preprocessor in Java, so macros, includes, #if do not work and there is no alternative to them. In Java you can imitate constants using static final variables. They probably will be used at compile time thanks to compiler optimizations, but that is not 100% true.

    • @quack3891
      @quack3891 3 роки тому

      @@Daniikk1012 huh, interesting, never knew that

  • @jj-ed1wz
    @jj-ed1wz 3 роки тому +1

    the question mark operator you never use is the ternary operator and condenses a 5 line else if statement into one line

    • @Truttle1
      @Truttle1  3 роки тому +1

      Since this video came out I started using it way more.

  • @Slade0120
    @Slade0120 3 роки тому

    weirdly enough, this has helped me understand try catch better.

  • @A1rPun
    @A1rPun 3 роки тому +4

    You can parse Integers without the need of try catch? Awesome.

  • @Astronomy487
    @Astronomy487 6 років тому +2

    tbh the name is the best part

    • @Truttle1
      @Truttle1  6 років тому +1

      Astronomy487 Java with a twist of agony!

  • @matthewrichardson4435
    @matthewrichardson4435 2 роки тому +1

    I don't know java so I dont know if this would work but for the blackjack program couldnt you just cast the expression a > b (inverse of a

  • @Alexi_Blue
    @Alexi_Blue 3 роки тому

    For the more/less check, i think you could do it like this:
    Check if a > b. a=7 b=16
    Int a = 1/ (int) Math.sqrt(a - b);
    That should also trigger the exception.
    If a is < than b, the answer is negative.
    If you sqrt a negative number, it gives a NaN
    (Int) converts NaN to 0
    1/0 triggers exception
    Cool vids you got m8, keep it up!

    • @cmyk8964
      @cmyk8964 Рік тому

      Or, since √x has no real answer for x

  • @DylanMatthewTurner
    @DylanMatthewTurner 4 роки тому +1

    Regular Java IS agony

  • @AlvinBalvin321
    @AlvinBalvin321 3 роки тому +3

    2:24 nextInt(); exists

  • @Camper_Samu
    @Camper_Samu 3 роки тому +1

    Wow this is really Javagony, he's using Eclipse and mentioned NetBeans

  • @branthebrave
    @branthebrave 3 роки тому

    You could create a Timer to emulate the while loop, but what fun is that

  • @NonTwinBrothers
    @NonTwinBrothers 3 роки тому +1

    5:36
    My first thought would be to try 1/max(27-21, 0)
    which works lol
    edit: My solution is better than the one in the video, lolololol

    • @mojacodes
      @mojacodes 2 роки тому +1

      did you mean "x"?

  • @EnderCrypt
    @EnderCrypt 3 роки тому +2

    okay but what about streams?

  • @algotkristoffersson15
    @algotkristoffersson15 2 роки тому

    3:17 just pop the top value from the stack and discard it within the loop, then you can go forever

  • @АнтонГусев-н5ю
    @АнтонГусев-н5ю 3 роки тому

    You could also use asserts as a more conventional if statement

  • @zvxcvxcz
    @zvxcvxcz Рік тому

    And I thought Javagony was just Java...

  • @bogger_
    @bogger_ 3 роки тому

    3:55 Electroman adventure music starts. Where are all geometry dash players?

  • @quack3891
    @quack3891 3 роки тому +1

    was half expecting labels but I assume desperation != heresy

    • @branthebrave
      @branthebrave 3 роки тому

      You'd need some more conditional control, like if, for them to be useful here, otherwise it's basically a method call. I think.

    • @quack3891
      @quack3891 3 роки тому

      @@branthebrave maybe but I figured it might be useful since we have try catch, the labels can be the try or catch. It couldn't be a method call since it just moves it back up I believe.
      I have no idea though, never used labels with try-catch

  • @Veptis
    @Veptis 2 роки тому

    Only doing recursion is also a style of programming language. If you are a fan, look at prolog

  • @theowillis6870
    @theowillis6870 3 роки тому +1

    What if the AP college board Gets there hands on this

  • @Periiapsis
    @Periiapsis 3 роки тому +1

    Can you use Boolean expressions, then use or cast it as an int? So if an expression is false then dividing 1 by it would throw an exception

    • @Astervista
      @Astervista 3 роки тому +1

      By the definition of Javagony, yes. In fact, ifs can be replaced with:
      try {
      assert (expression);
      {true block}
      } catch (AssertionError e) {
      {false block}
      }

  • @wcodelyoko
    @wcodelyoko 4 роки тому +2

    I'm pretty sure Math.addExact() uses an if statement tho. Perhaps another way of checking would be with recursion

    • @official-obama
      @official-obama 2 роки тому

      I'm pretty sure dividing uses an if statement too.

    • @arjix8738
      @arjix8738 Рік тому

      @@official-obama dividing does not use an if statement, it is a jvm instruction

    • @official-obama
      @official-obama Рік тому

      @@arjix8738 yeah, but i'm pretty sure jvm uses an if statement

    • @arjix8738
      @arjix8738 Рік тому

      @@official-obama I don't know about that, but real assembly has an instruction for division.
      I can't see why an if statement is necessary.

    • @official-obama
      @official-obama Рік тому

      @@arjix8738
      if(b != 0) {
      return a/b;
      } else {
      freak_out();
      }

  • @kbhasi
    @kbhasi 6 років тому

    I couldn't find the Pastebin link in the description, but if you did, you'll most likely paste there as a guest user.

    • @Truttle1
      @Truttle1  6 років тому

      Kevin Bhasi just added it

  • @jocabulous
    @jocabulous 3 роки тому

    couldnt you also use a logarithm to check if a number is greater/less than another

  • @ThePixelPolygon
    @ThePixelPolygon 6 років тому

    Why does it exist? Because why not!

  • @loukafortin6225
    @loukafortin6225 3 роки тому

    Is there a "goto" functionality in java like in c/c++? That would've fixed the stack overflow error right?

    • @Truttle1
      @Truttle1  3 роки тому +1

      There isn't

    • @swordofstabbingold
      @swordofstabbingold 2 роки тому

      goto is a thing in procedural languages mostly. C++ is a superset of C so it supports it even though it is technically not procedural.

  • @imaginartist2139
    @imaginartist2139 3 роки тому

    Math.addExsct is in java? Made?

  • @mekalcovic3973
    @mekalcovic3973 3 роки тому +1

    How to abuse streams api to get past the restrictions:
    T o; // object to test of type T, T extends Object
    try {
    Arrays.asList(o).stream().filter(/* condition goes here */).collect(Collectors.toList()).get(0);
    // if block
    } catch (IndexOutOfBoundsException e) {
    // else block
    }

  • @AlvinBalvin321
    @AlvinBalvin321 4 роки тому +2

    I literally learned about try earlier today

    • @AlvinBalvin321
      @AlvinBalvin321 3 роки тому +2

      yea u did, i remember that

    • @quack3891
      @quack3891 3 роки тому +1

      was half-expecting it to be only labels instead of try catch

  • @salmon4402
    @salmon4402 3 роки тому

    This is just normal Java.

  • @mattpharois9719
    @mattpharois9719 3 роки тому +1

    Is short-circuit banned as well?

  • @bujitself
    @bujitself 3 роки тому

    technically x > y is still allowed...

  • @theowillis6870
    @theowillis6870 3 роки тому

    is compareTo allowed

    • @theowillis6870
      @theowillis6870 3 роки тому

      like this
      String str1 = "Test";
      String str2 = "test";
      int compare = str1.compareTo(str2);
      try{
      int x = 1/compare;
      System.out.println("not equal");
      }catch(Exception e){
      System.out.println("eqaul");
      }

  • @neverdie0001
    @neverdie0001 2 роки тому

    5:03 *1 B O T T L E S*

  • @TroubleMakery
    @TroubleMakery 3 роки тому

    Hate to be that guy but Arithmetic is spelled incorrectly at 1:50

  • @imagineeelego
    @imagineeelego 3 роки тому

    I understand this without knowing java

  • @wesleymays1931
    @wesleymays1931 3 роки тому

    Doesn't Java have goto? And isn't that *not* banned?

  • @王建平-f2b
    @王建平-f2b 4 роки тому

    is there a pythagony?

    • @redpepper74
      @redpepper74 3 роки тому

      python but the only operators are square and sqrt

  • @Mrcake0103
    @Mrcake0103 2 роки тому

    I have my (hopefully) very last compsci final in 8 hours.
    Anyway, the name is pretty clever, but there are *far* better ways to torture yourself in Java.

  • @jameslawson1
    @jameslawson1 6 років тому +3

    Using Eclipse? Good man.

  • @Mr8lacklp
    @Mr8lacklp 3 роки тому

    Why not loop infinitely by consuming an infinite stream?

    • @ConcerninglyWiseAlligator
      @ConcerninglyWiseAlligator 3 роки тому

      That would be cheating since it's implemented with banned statements.

    • @official-obama
      @official-obama 2 роки тому

      @@ConcerninglyWiseAlligator and Math too
      and 1/(value)

  • @Pseudoplasmagore
    @Pseudoplasmagore 5 років тому

    Is Java like C#, empty spaces don't matter?

  • @avocadopeel7536
    @avocadopeel7536 3 роки тому

    new if statement:
    class Function {
    abstract void function();
    }
    class Func1 extends Function {
    @Override
    void function() {
    // do something
    }
    }
    class Func2 extends Function {
    @Override
    void function() {
    // do something else
    }
    }
    static void main() {
    Function[] functions = new Function[]{new Function1(), new Function2()};
    bool statement = true;
    functions[(int)statement].function();
    }

  • @therandomprogrammer041
    @therandomprogrammer041 3 роки тому

    Yeah you definitely forgot about goto statement you literally forgot it in the pre text of javagony and since it wasn't in the pre text so i cn use it and make a bit more efficient..

  • @hilligans1
    @hilligans1 2 роки тому

    The real agony comes from the fact that you arent using IntelliJ

  • @Blue-Maned_Hawk
    @Blue-Maned_Hawk 5 років тому +1

    1:00 What do you mean, switch case is useless?

  • @paulcosma2823
    @paulcosma2823 3 роки тому

    I might be a bit late but here's my take:
    public class Main
    {
    public static void main(String[] args) {
    xIf(1 == 2, () -> {
    System.out.println("True");
    }, () -> {
    System.out.println("False");
    });
    }
    public static void xIf(boolean condition, Action ifTrue, Action ifFalse) {
    int divideBy = Boolean.valueOf(condition).compareTo(Boolean.FALSE);
    try {
    int x = 1 / divideBy;
    ifTrue.run();
    } catch(Exception e) {
    ifFalse.run();
    }
    }
    static interface Action {
    void run();
    }
    }

  • @neverdie0001
    @neverdie0001 2 роки тому +1

    make a video about JSF***, which is simply JavaScript, but you are only allowd six different characters: []()!+

  • @nekoill
    @nekoill 3 роки тому +1

    If-else statements and switch cases are considered harmful and should not be used ever, anywhere. They're SLOW as all hell.
    Ternary operator, however, is fairly fine somehow, and it's a shame that you don't use it, because you should if possible instead of if-elses. Ternary operator, however, by definition only takes three arguments, so if you have a more complex case to deal with, you should check out a video here on UA-cam called something to the tune of "Branchless programming" or something like that. Branching logic loads CPU with frequently useless computations the results of which it has to ultimately flush. Getting rid of if-elses is one of the reasons pure functional languages are so damn fast, but by far not the only one of course.

  • @OatmealTheCrazy
    @OatmealTheCrazy 3 роки тому

    Obviously the real way to print 1 infinitely is to delay so it never overflows before the heat death of the universe....or the next likely power outage.

  • @thatguynamedmorgoth8951
    @thatguynamedmorgoth8951 5 років тому

    bro what about goto

    • @Mrqwertar
      @Mrqwertar 4 роки тому

      it exists in the language, but it's usage is explicitly prohibited

  • @jordanweir7187
    @jordanweir7187 3 роки тому +1

    This challenge to me is ruined by the fact you can call functions like Math. .... which have loops in them already, it should be only functions you've written and maybe system.out.println
    also doing it without trycatches would be more interestin too imo

    • @branthebrave
      @branthebrave 3 роки тому

      How would you do it "without try-catches"?

    • @jordanweir7187
      @jordanweir7187 3 роки тому

      @@branthebrave wat problem would u like me to try out without trycatches?

    • @branthebrave
      @branthebrave 3 роки тому

      @@jordanweir7187 The halting problem I suppose. I just don't know how you'd do it. Like with labels, finally, Threading, streams, or class structure abuse?

    • @jordanweir7187
      @jordanweir7187 3 роки тому

      @@branthebrave thats kind of a big problem, i meant like one of these examples he gives in the video like the truth machine or something

    • @branthebrave
      @branthebrave 3 роки тому +1

      @@jordanweir7187 Lol. Try the truth machine one 1 infinitely or 0

  • @michaellin4553
    @michaellin4553 3 роки тому

    pain

  • @Yadobler
    @Yadobler 3 роки тому

    i was expecting javascript and agony. slightly disappointed

  • @orangegaming9562
    @orangegaming9562 4 роки тому +1

    Now do a javagonyScript lol

  • @AntonioNoack
    @AntonioNoack 3 роки тому

    You can get conditions with || and && as well. (am at 1:23 at the moment)
    boolean notUsed001 = condition && doStuffIfConditionIsTrue();
    doStuffIfConditionIsTrue just must return a boolean

  • @stephendouglas684
    @stephendouglas684 3 роки тому

    Shouldn't you comment your code to explain what you're doing-ya know best practices and all...

    • @branthebrave
      @branthebrave 3 роки тому

      No. If you need comments then your code is hard to understand, but this may be.

  • @marqylemmonds4919
    @marqylemmonds4919 3 роки тому

    Why not just use while(){}?

  • @kodylowery7811
    @kodylowery7811 6 років тому +2

    You have informative, well produced, interesting videos; I just wish you would stop with the horrid cartoon characters. Lol keep up the good work.

    • @Truttle1
      @Truttle1  6 років тому +5

      I've been trying to limit how much I use the cartoon characters, but I probably won't completely get rid of them.

    • @kodylowery7811
      @kodylowery7811 6 років тому +2

      @@Truttle1 Stick to your guns brother. Love the Channel, just subscribed. I think it is really a volume problem. I end up turning my volume up and down throughout the video. Lol

  • @pavelvigilev9584
    @pavelvigilev9584 3 роки тому

    On 1:08
    >Java is basically unusable now
    Well.. you know... Java is completely unusable even with these operators. It is not a programming language, it's just a bunch of restrictions and limitations for a programmer. It's a castrated C++ or C#, because it doesn't allow you to do basic things like operator overloading. You can not even write a small program that will not eat all your memory.

  • @rue04
    @rue04 4 роки тому

    1st read java-gony instead of jav-agony

  • @infrakazos
    @infrakazos 3 роки тому +1

    Reply to me

  • @girlswithgames
    @girlswithgames 5 місяців тому

    is there no tail call optimization?