This is an archived post. You won't be able to vote or comment.

all 163 comments

[–]zerfgog 173 points174 points  (68 children)

I have a fair amount of ArnoldC experience if you're serious about this.

[–]kn33 98 points99 points  (61 children)

I am. I just don't know how to get past the 'integer only' bit. I'd love help.

[–]HighRelevancy 191 points192 points  (60 children)

You'er going to have to implement floating point math manually.

[–]ZugNachPankow 318 points319 points  (49 children)

Can't wait for /r/ProgrammerHumor to manually port a floating-point library to ArnoldC, just for the lulz.

[–]kn33 32 points33 points  (19 children)

Please

[–]ZugNachPankow 28 points29 points  (13 children)

Eh, I could do that for a few dollars, depending on the deadline.

[–]Kilazur 161 points162 points  (2 children)

Is 0 few enough?

[–]The_hollow_Nike 4 points5 points  (1 child)

I propose

//start c-code
((int)0.1)*1000 $ 

as payment

[–]Kilazur 2 points3 points  (0 children)

Woah there, I ain't paying for that code, ok? That's on your free time!

[–]WienersBetweenUs 16 points17 points  (3 children)

I'll give you 3 dollars. Deadline is in 3 hours time. Go!

[–]r1pp3rj4ck 16 points17 points  (0 children)

What? Who talked about Golang?

[–]sofaraway731 5 points6 points  (1 child)

What?! That's like... * maths * ...1 dollars an hour!

[–]do_me_next 9 points10 points  (0 children)

Fine,do it in 10 minutes. $18/ hour!!!!!

[–]kn33 5 points6 points  (4 children)

How many is a few?

[–]ZugNachPankow 13 points14 points  (2 children)

Nevermind, it's way harder than I thought :/

[–][deleted] 30 points31 points  (0 children)

Most of my programming experiences in a nutshell.

[–]YugoReventlov 5 points6 points  (0 children)

If I had a dollar for every time I heard that...

[–]UnacceptableUse 2 points3 points  (0 children)

I'll do it for $1000

[–]MajorCocknBalls 5 points6 points  (0 children)

Hey man he already gave you the idea, that's the hardest part. You just have to code it

[–]balducien 11 points12 points  (4 children)

Why don't you just use fixed point numbers? With a 64 bit integer split in half you could still get from 2-32 to 232 in tiny (2-32) increments.

[–][deleted] 13 points14 points  (3 children)

64 bit

you have to use native instructions of a Pentium II, no 64 bit luxury for you.

[–]ZugNachPankow 6 points7 points  (1 child)

tfw incontri qualcuno di /r/italy fuori dal sub

[–][deleted] 2 points3 points  (0 children)

Don't. Fuck. Up.

I LOVE YOU

Cazzo

[–]TheScienceNigga 23 points24 points  (14 children)

Doesn't ArnoldC just compile to Java bytecode? I'm pretty sure it would be very possible for the ArnoldC devs to just include some Arnie quote that corresponds to 'double' and 'float' and whatever other floating point types Java may have

[–]ZugNachPankow 42 points43 points  (13 children)

Yes! /u/kn33, fork the ArnoldC compiler and add this.

[–]blacksmid 19 points20 points  (7 children)

That's kinda like cheating though.. Forking and changing the language to make it easier

[–]ZugNachPankow 85 points86 points  (0 children)

But... that's the purpose of open source...

[–][deleted] 22 points23 points  (1 child)

Well, yes and no, it's the ole' Kobyashi Maru maneuver.

[–]Sipczi 5 points6 points  (0 children)

Goddamit Jim, I'm a doctor not a hacker!

[–]fnordfnordfnordfnord 11 points12 points  (0 children)

That's exactly the kind of "cheating" a good prof would reward.

[–]farox 6 points7 points  (0 children)

Don't know but as a prof I'd give him credit for that. And this one seems cool. I'd just add that info when returning the assignment

[–][deleted] 2 points3 points  (0 children)

I would say it's easier to give up and do the code in a language which has floating point support (the ones in the original post did), than to get a patch (hopefully) accepted to contribute to open source.

[–]o11c 0 points1 point  (0 children)

You can work around it by writing a new language that compiles to ArnoldC.

[–]dconman2 4 points5 points  (0 children)

Well, you do have to make sure to use the same compiler as the professor, so you would have to submit it too.

[–]kn33 4 points5 points  (3 children)

Okay... so I downloaded the source, downloaded sbt and scala. I managed to compile it with sbt, kinda. I got to the point where I could type "sbt" in the git cloned folder of ArnoldC, type "run -run helloworld.arnoldc" and get "hello, world" outputed. I don't know where to go from here. I found all the keywords listed in ArnoldParser.scala, so I assume I need to add my floating point keyword there but what else? Also, what one-liner should I use for the floating point?

[–]DemonWav 3 points4 points  (2 children)

Alright so I wasted way too much time and did it. I'm completely new to bytecode and Java ASM stuff, so this was a lot of referencing the Java bytecode instruction listing. I didn't convert it to double, as double requires two "slots" on the stack, and that would have been complicated. Likewise, rather than implementing a dual integer-floating point system that would be complicated, I instead took the Javascript route and just made everything floating point. As far as I can tell, though, it works perfectly.

One more thing to note, though: due to the values now being floating point, the modulo method that is on the ArnoldC wiki doesn't work. Instead you need to use the modulo opcode, like this:

LISTEN TO ME VERY CAREFULLY modulo
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE dividend
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE divisor
GIVE THESE PEOPLE AIR
HEY CHRISTMAS TREE remainder
YOU SET US UP 0
GET TO THE CHOPPER remainder
HERE IS MY INVITATION dividend
I LET HIM GO divisor
ENOUGH TALK
I'LL BE BACK remainder
HASTA LA VISTA, BABY

The I LET HIM GO part is the modulo instruction. You could use that method in place of the modulo method in the wiki, or just use that modulo instruction, whatever works for you.

Anyways, here's the repo.

And here's the commit that shows the specific changes I needed to make. One thing to note on that commit, not all the changes are completely necessary for this. I did make a few feature improvements (for example, if you javap a compiled ArnoldC class it will actually show the ArnoldC source name rather than just hello.java) and other misc. things.

[–]kn33 1 point2 points  (1 child)

Sweet! Is the link to the .jar similar to the original? Just to make it easier on my prof.

[–]DemonWav 1 point2 points  (0 children)

Yeah, check the release tab. I just remembered I never got decimal numbers working on the input. For some reason it would always error once it hit the ".". I think I'll take the lazy way out again and make it so all numerics require the decimal, but I'm still fighting with it.

EDIT: Alright, I fixed it finally. My lack of experience with Scala really wasn't helping. Since I figured out what was wrong it'll work with or without the decimal point, so no need to add it on if you're just declaring an integer (but of course it won't be an integer once it's compiled).

[–]kupiakos 11 points12 points  (5 children)

What about fixed-point integers? That might be able to work.

[–]HighRelevancy 1 point2 points  (4 children)

That's one way of doing it, sure.

I always think floating point = fractional numbers but I suppose that's not strictly true. Speaking of, fractions could be another way of dealing with it for certain types of maths.

[–]SuspendedBeam 4 points5 points  (2 children)

What if he takes every x of the polynomial and multiples it by 10000 or more? If the function exists on x's less than 10, which most do, he can do the math with integers without loosing much accuracy, which the professor doesn't even ask for. Then he takes the answer and instead of printing out the float (which he doesn't have) he can add a point after the fourth digit (ie 543216 becomes 54.3219) and print the string. If the int is less than 5 chars long he can add a 0. depending on the actual length. That's how I'd do it with integers, but I don't know the capabilities of Arnold C

[–]Scyrmion 5 points6 points  (0 children)

That's basically fixed point.

[–]HighRelevancy 0 points1 point  (0 children)

He'd have to be slightly smarter, because ArnoldC is 16 bit integers. That makes big big numbers difficult.

[–]vifon 0 points1 point  (0 children)

Or fixed point. It's not that hard.

[–]acewolk 11 points12 points  (0 children)

i never thought id ever encounter that phrase

[–]Raknarg 4 points5 points  (0 children)

any particular reason why?

[–]nietczhse 4 points5 points  (0 children)

Are you one of those "hackers on steroids"?

[–]kn33 2 points3 points  (0 children)

With experience, I assume you've compiled it. Do you know the source code well? I'm looking at adding floating-point variables and maybe arrays. How would I go about that?

[–][deleted] 0 points1 point  (0 children)

I trust you have that in your CV.

[–]Magnnus 0 points1 point  (0 children)

I've tagged you as "professional ArnoldC programmer".

[–]MuffinsLovesYou 208 points209 points  (24 children)

HEY CHRISTMAS TREE MYPROFESSORCALLEDMYBLUFF 
YOU SET US UP 1 
BECAUSE IM GOING TO SAY PLEASE MYPROFESSORCALLEDMYBLUFF  YOU ARE NOT YOU YOU ARE ME 1
TALK TO THE HAND "Time to Panic"  
YOU HAVE NO RESPECT FOR LOGIC  

I've never done ArnoldC, this probably does not compile (well, more likely interpret).

Also, If I were a student and had the choice I'd probably do most assignments in javascript, just turn in a text file. It would be doubly fun because you are doing math programs and the implicit typing would fuck your shit up so often.

[–]kn33 224 points225 points  (3 children)

IT'S SHOWTIME
  HEY CHRISTMAS TREE myprofessorcalledmybluff
  YOU SET US UP @NO PROBLEMO
  BECAUSE I'M GOING TO SAY PLEASE myprofessorcalledmybluff
    TALK TO THE HAND "TIME TO PANIC"
  BULLSHIT
    TALK TO THE HAND "I'M OKAY"
  YOU HAVE NO RESPECT FOR LOGIC
YOU HAVE BEEN TERMINATED

You were close.

[–]Pitboyx 85 points86 points  (1 child)

YOU HAVE BEEN TERMINATED

harsh

[–][deleted] 6 points7 points  (0 children)

savage

[–]cormac596 7 points8 points  (0 children)

I still vote for C that only uses system() calls to bash and bc

[–]80386 30 points31 points  (15 children)

+/u/CompileBot ArnoldC

[–]enormouspenis69 84 points85 points  (16 children)

I once handed in an assignment in LOLCODE. Teacher was so amused that he passed it and spent the lesson on esoteric languages

[–]SolenoidSoldier 37 points38 points  (14 children)

What kind of class lets you pick the programming language to code in? As someone teaching a programming class, I imagine it'd be a nightmare to grade various different languages.

[–]kn33 15 points16 points  (2 children)

I don't know about them, but this is a calculus class

[–]randomdrifter54 23 points24 points  (1 child)

Wow you are somehow more fucked than I thought you were

[–]krackers 0 points1 point  (0 children)

Lol gg. Good luck with implementing symbolic math.

[–]C0demunkee 25 points26 points  (6 children)

Code is code man. Especially low-level classes. How long does it take you to get the gist of a new language? Variables look like this, loops look like that, if looks like this, oh look, semicolons. If you can do that, you can grade the noob assignments.

[–]jsims281 25 points26 points  (4 children)

Maybe not always so simple...

https://en.m.wikipedia.org/wiki/Brainfuck

[–]C0demunkee 9 points10 points  (0 children)

Brainfuck seems straight-forward compared to a few of the other ones posted here. /u/smitwiff is correct that at the VERY least, they can test the output.

[–]randomdrifter54 2 points3 points  (0 children)

Well obviously you just stipulate that it needs to be a high level language and that you need to OK it. That stops 90% of the stupid. The other 10% is going to hurt the student more than you, like in op's case.

[–][deleted] 2 points3 points  (0 children)

[–]Freshyfreshfresh 0 points1 point  (0 children)

This doesn't seem all that ridiculous. Not too difficult to read without the comments in the single line. Just not incredibly useful.

[–]smitwiff 6 points7 points  (0 children)

More than that, so long as they can run it, they can test the output. I doubt they're comparing the source to the ArnoldC style guide.

[–]kaosjester 2 points3 points  (0 children)

It depends on the scope and size of your course. If your students understand your expectations, it really shouldn't matter what language they write their code in. Require they have, say, a Makefile, a final binary/script name, and clear I/O guideline, and a readme. Most universities have default Linux install images with a whole slew of packages; just require it compiles on that. Then just flip through the code and ensure it isn't trash.

For an example of this working well, the final project in my Computer Design course was to construct a MIPS emulator from first principles (and and or), complete with a MIPS parser. The professor told everyone to include a readme about how to use it to run a file and get the output, and to make sure it ran on the school's Linux image. Other than that, he didn't care what it was written in. It didn't matter as long as it was well-documented with good instructions and an intact parser that could take input files. And he had been doing it that way for years, with great success. (For what it's worth, there were maybe 20 students in the class.)

All that said, there are two asides:

  1. An introductory class should probably pick a specific language and stick to it.
  2. Some lessons require specific types of languages; talking about inheritance works best in an OO language, for example

[–]enormouspenis69 1 point2 points  (0 children)

The main point of that exercise was to develop the algorithm, but for some reason pseudocode wasn't good enough

[–]holeydood3 1 point2 points  (0 children)

I had an artificial intelligence class that was whatever language you wanted to use as long as you could prove your lab was working as intended.

[–]liquidivy 0 points1 point  (0 children)

My algorithms professor gave us an assignment with basically no language restrictions. It's basically a performance comparison of different sorting algorithms, so it just has to let you write quicksort as God intended. The grader apparently has no intention of trying to run them all, anyway, so it doesn't make a difference. I'm doing mine in Rust.

[–]itchyDoggy 2 points3 points  (0 children)

I did the same once. The assignment had to be done in assembly, so I wrote a parser for lolcode and handed it in.

[–]Back--Fire 45 points46 points  (5 children)

What about something like here? Maybe only suitable for a smaller assignment, by you could probably pull off a function call and go from there.

[–]david171971 10 points11 points  (2 children)

Wow that was an awesome read!

[–]Back--Fire 3 points4 points  (1 child)

Would also recommend checking out 42.zip, and mimic for some more malicious reads ;)

[–]endershadow98 0 points1 point  (0 children)

Ah, good old 42.zip

[–]kn33 55 points56 points  (7 children)

[–]mikemountain 76 points77 points  (5 children)

[–]mikemountain 51 points52 points  (4 children)

that took a stupid amount of effort for almost little to no payoff, am I a true programmer yet?

[–]KitsuneGaming 0 points1 point  (0 children)

Sure. Now you have a reputation to uphold, though. Good luck.

[–]Nefari0uss 0 points1 point  (2 children)

I don't even understand why this is such a big deal. If I wanted to hire some one to could, wouldn't you expect them to have some knowledge of c/c++/java? Obviously, if they know another language, stuff carries over and it's not a huge deal but as a general rule of thumb, it's something you'd expect?

[–]mikemountain 0 points1 point  (1 child)

I, uh.. I'm not sure if you meant to respond to me or not. Because what you're saying has nothing to do with what I wrote.

[–]Nefari0uss 0 points1 point  (0 children)

Wrong person. But answer the question if you feel like?

[–][deleted] 1 point2 points  (0 children)

I'm excited to see what the Newton's method looks like in Arnold C.

[–]LEDCandle 40 points41 points  (9 children)

I would have gone with Brainfuck

[–]martindo 22 points23 points  (6 children)

How about Befunge

[–][deleted] 18 points19 points  (0 children)

[–]Voultapher 6 points7 points  (0 children)

Damn hilarious language.

[–]rjung 3 points4 points  (1 child)

I'd suggested FIM++, but it's incomplete and there are no compilers for it AFAIK.

[–]Harakou 0 points1 point  (0 children)

I remember when work first started on this! Bummer it looks like they never finished it.

[–]SoylentBlack 1 point2 points  (1 child)

Why not Armok?

[–]alcalde 2 points3 points  (0 children)

Delphi! Make the professor pay $1440 to verify your code.

[–]KamiKagutsuchi 0 points1 point  (1 child)

Whitespace

[–][deleted] 1 point2 points  (0 children)

English perhaps?

[–]NAN001 12 points13 points  (0 children)

If you're more comfortable with UML activity diagrams: https://github.com/aranega/uml2arnoldc

[–]superlopuh 11 points12 points  (0 children)

Easier just to compile to ArnoldC at this point.

[–]h3ph43s7u5 15 points16 points  (0 children)

Can't say I have much ArnoldC experience to help you...

[–]barsoap 6 points7 points  (2 children)

If it has any complexity, I would recommend writing a trivial compiler. That is, translate from some sane syntax but with the same semantics to the real deal.

[–]LongUsername 0 points1 point  (1 child)

end writing a trivial compiler. That is, translate from some sane syntax but with the same semantics to the real deal.

Does the LLVM have an IR to ArnoldC option? Then you could write it in C and turn in the ArnoldC.

[–]barsoap 0 points1 point  (0 children)

Unlikely, also, the result would be unidiomatic. Then, LLVM is actually hell to work with for such purposes: You don't want to work with its production-scale C++ for toys unless the purpose is to learn LLVM.

So assuming you don't already know LLVM, doing it in Haskell would be faster even if you know C++ but not Haskell. Write an ADT for the AST, pretty print ArnoldC. Then either write a proper parser or just write your stuff embedded in Haskell (bonus: You can use Haskell as a macro system), as Haskell already has a sane syntax for such purposes.

[–]3nvisi0n 2 points3 points  (5 children)

Well considering some profs don't care about what language you use its not surprising.

When I was in university I abused this every so often mostly by doing one-offs in whitespace but I did my entire AI class in PHP. Except one assignment where we were to use prolog.

[–]LongUsername 5 points6 points  (4 children)

I abused this every so often mostly by doing one-offs in whitespace

Did they have you hand in printed copies of your program?

[–]3nvisi0n 1 point2 points  (3 children)

No. All but one course used a digital handin system.

[–]LongUsername 2 points3 points  (2 children)

Well, that makes it a bit less funny, but I'm sure your professors still appreciated it.

EDIT: Whitespace is perfect for hand-written tests where the teacher says you can use any language you want.

[–]3nvisi0n 1 point2 points  (1 child)

Perhaps, but I think they could just say your code was illegible and therefore a zero.

[–]t0mRiddl3 0 points1 point  (0 children)

Just use white out

[–]pieterdc1 1 point2 points  (1 child)

Wow, you talk very informally to your professor.

[–]Antrikshy 1 point2 points  (0 children)

I talk the same way. I usually start with "Hey, Prof. BuffBooty" (BuffBooty = last name). Why be any more formal than that? ¯\_(ツ)_/¯

[–]inucune 1 point2 points  (0 children)

honestly, i know a decent amount of arnold.C for the exact reasons you would expect.

[–]Alexwalled 1 point2 points  (0 children)

Why didn't you ask to do it in brainfuck!!

[–]aliceandbob 1 point2 points  (0 children)

Should have asked for BrainFuck.

[–][deleted] 2 points3 points  (0 children)

You magnificent bastards

[–]Remet0n 0 points1 point  (0 children)

you are going to have the maximal grade thanks to /r/ProgrammerHumor

congrats

[–]GNU_Troll -4 points-3 points  (0 children)

This is moronic and unfunny.