There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

jendrik , in After all, Why shouldn't i use Excel as my database?

Shows up as Untitled 1 to Untitled 25 for me on spotify

ChaoticNeutralCzech , in Exam Answer

<span style="color:#323232;">86400000
</span>
tatterdemalion , in Programming languages personified - leftoversalad
@tatterdemalion@programming.dev avatar

Erlang really is the necromancer’s language.

Why is Swift… like that?

vvvvv , in Exam Answer

print(“x”) is you want to screw your students.

smokeybeef ,

screw your students

ಠ_ಠ

treechicken ,
@treechicken@lemmy.world avatar

“Dr. Prof. Mann, I really didn’t understand anything about UNIX on that last midterm. Can we go over how to touch and finger after class?”

treechicken , in Exam Answer
@treechicken@lemmy.world avatar

It’s obviously:

Traceback (most recent call last): File “./main.py”, line 2, in <module> AttributeError: ‘str’ object has no attribute ‘length’

theFibonacciEffect ,

Ah yes, all pseudocode is python

SkyeHarith ,

Ah yes, python is psuedocode

treechicken ,
@treechicken@lemmy.world avatar

I deduce these two sets must be the same then?

PhAzE , in Exam Answer

The answer is 6. It’s 6 characters long.

potustheplant ,

Not really, no. That would be the answer if x= len(day). The code in the image would just throw an error.

force , (edited )

no it wouldn’t, because this is OCR reference language

run this

Ephera ,

What the heck, did someone invent a programming language, so students wouldn’t have to learn any real ones?

mounderfod ,
@mounderfod@lemmy.sdf.org avatar

Having done OCR GCSE computing:
It’s just a pseudocode style language that they use in exam questions so that you can understand the question regardless of which language your school had you study (in my case it was VB6 💀). In questions where you are asked to write code, you can use the reference language but realistically you just use the one you learned (although I did it all in python instead)

56_ ,
@56_@lemmy.ml avatar

Huh interesting. In Scotland we had another one: en.wikipedia.org/…/Haggis_(programming_language)

PhAzE ,

Yea, it’s pseudo code.

flumph ,
@flumph@programming.dev avatar

“Monday”.length is working JavaScript and does equal 6. No print command afaik though.

AnAngryAlpaca ,

deleted_by_author

  • Loading...
  • kia ,

    You don’t need terminating semicolons in JavaScript. They’re added in if missing. It can actually cause a few bugs around returns.

    dvlsg ,
    @dvlsg@lemmy.world avatar

    There technically is!

    developer.mozilla.org/en-US/docs/Web/API/…/print

    Well. In browsers, anyways.

    Scrollone ,

    Yes, but it prints the page, so in this case it wouldn’t print anything

    PrettyFlyForAFatGuy , (edited )
    
    <span style="color:#323232;">function print(str) {
    </span><span style="color:#323232;">  console.log(str)
    </span><span style="color:#323232;">}
    </span>
    

    FTFY

    fidodo ,

    How do you know what language this is?

    ChickenLadyLovesLife , in traslation: i made that bug 15 years ago and have been waiting for it to matter.

    Not a bug exactly, but about ten years ago I was working as an iOS developer and to get around a major problem introduced by the app designer, I made use of a “private method”, which is something an app supposedly gets rejected for by Apple. I came up with a way of hiding it and had to sweat out the approval period before it went live. Ten years later that shit is still there; I’m sure the developers currently responsible for the app don’t even know it’s there. I normally comment my code with an eye to helping future programmers understand what’s going on and why, but this hack was one where I even obscured the comments.

    AVincentInSpace ,

    What does “private method” mean in this context? Did you make use of an undocumented endpoint of the iOS API?

    ChickenLadyLovesLife ,

    Yeah, same thing.

    firelizzard ,
    @firelizzard@programming.dev avatar

    Objective-C does not enforce method access (e.g. private methods) at the runtime level. If you are sufficiently determined, there are no restrictions on what methods you can call, unlike Java or C# (AFAIK).

    AVincentInSpace ,

    Java absolutely lets you do that with Reflections. You’re not supposed to, and it’s painfully slow, but the JVM is only marginally smarter than javac (and that’s saying something) so there’s nothing actually stopping you.

    humbletightband ,

    If you are determined enough, it’s not that slow 😉

    firelizzard ,
    @firelizzard@programming.dev avatar

    I thought there was security code to stop that kind of thing. Granted, it’s been over 10 years since I’ve done anything with Java more than tinkering with Minecraft mods.

    homura1650 ,

    Java did have a Security Manager that can be used to prevent this sort of thing. The original thinking was that the Java runtime would essentially be an OS, and you could have different applets running within the runtime. This required a permission system where you could confine the permissions of parts of a Java program without confining the entire thing; which led to the Java security manager.

    Having said that, the Java Security Manager, while an interesting idea, has never been good. The only place it has ever seen significant use was in webapps, where it earned Java the reputation for being insecure. Nowadays, Java webapps are ancient history due to the success of Javascript.

    The security manager was depreciated in Java 17, and I believe removed entirely in Java 21.

    jlow , in Exam Answer

    Are they using a red pen to write the checkmarks for correct answers to make it confusing but logical at least?

    autokludge ,
    @autokludge@programming.dev avatar

    Nah, just using one of those handy pens with blue, black & 2 red ink. ;)

    blindsight ,

    Grading in red is generally avoided, nowadays. Red is closely associated with failure/danger/bad, and feedback should generally be constructive to help students learn and grow.

    I usually like to grade in a bright colour that students are unlikely to pick: purple, green, pink, orange, or maybe light blue (if most students are working in pencil). Brown is poo. Black and dark blue are too common. Yellow is illegible. Red is aggressive.

    Anyway, I’m guessing they just graded everything in green. The only time I’ve ever graded in more than one colour was when I needed to subgrade different categories of grades, like thinking/communication/knowledge/application. In that case, choosing a consistent colour for each category makes it easier to score.

    SquishyPandaDev , (edited ) in Exam Answer
    @SquishyPandaDev@yiffit.net avatar

    Good thing this only uses ASCii characters, else you get into some fun discussions about UTF encoding

    qaz ,

    But does it count the null byte or not?

    SquishyPandaDev ,
    @SquishyPandaDev@yiffit.net avatar

    In most languages, length method doesn’t count the null terminator. Might result in some fun memory errors

    YoorWeb ,
    CanadaPlus , (edited ) in Programming languages personified - leftoversalad

    This is epic.

    Can anyone explain Java, PHP and Perl to me?

    xmunk ,

    Java is extremely widespread in corporate companies - hence the suit and tie. Perl is fair to liken to spelunking deep into a dark cave with only your wits to save you.

    PHP seems to be a reference to the fact that it’s extremely common on servers… but it also might be a lazy phpbad joke - it’s pretty weak either way (if you wanted to play into the server characteristic give it a dozen arms serving the entire restaurant in the background).

    frezik ,

    As a Perl dev, I dunno if that’s how I’d characterize the language, but I’ll take it over yet another “Perl is unreadable line noise lol and what’s the deal with airline food” reference.

    xmunk ,

    Yeah, to be honest you can write good code in any language and it’ll usually look pretty similar… all the perl stereotypes come from having to maintain shell scripts from someone kludging their way through learning to code… it’s the same reason why phpbad, amateurs could get into webdev with php so there’s an impression that all php is the php written by amateurs.

    Also, bear in mind that over time these languages have converged through feature additions “LISP has functional programming - why can’t PHP have first class functions… oh traits look neat, let’s add that… you know those statically typed languages sure seem nice…”

    maniel ,

    Guess PHP is a server…

    CanadaPlus ,

    That seems to be the consensus. That’s pretty weak, salad people, you know you could have done better.

    silasmariner , in Exam Answer

    They missed out the context code:

    
    <span style="color:#323232;">trait DoW { def length: FiniteDuration }
    </span><span style="color:#323232;">object Monday extends DoW { override def length = 24.hours }
    </span><span style="color:#323232;">...
    </span><span style="color:#323232;">implicit def toDoW(s: String): DoW = s match {
    </span><span style="color:#323232;"> case "Monday" => Monday
    </span><span style="color:#323232;">...
    </span><span style="color:#323232;">}
    </span><span style="color:#323232;">var day: DoW = _
    </span>
    

    (Duration formatting and language identification are left as an exercise for the reader)

    Magnetar ,

    Upvote for using Scala.

    silasmariner ,

    Implicit was too much of a give away wasn’t it?

    Magnetar ,

    I’ve literally seen code that does something awfully similar. But you could have used an Enumeration.

    Fuck, I think you just gave me an idea for an issue in my code that has bugged me for days.

    silasmariner , (edited )

    I could’ve used a lot of things, but I’m on my phone and I wanted fewer characters to render it, whilst being sure it would work without having to run it.

    Also, I am pleased to have maybe helped. Perhaps we can be friends, you and I. Perhaps not. Idk, maybe you punch dogs, why would you do that? Seems mean.

    Have you ever just, like, edited a comment? How do people know when you did it? I guess if I were writing a thing to check it I’d use a registry of timestamps and checksums… So, like, ok, you can track, but why, how does it look?

    Anyway sorry I had some drinks between now and first post, goodnight

    paholg ,

    Works even better in Ruby, as the code as given is valid, you just need to monkey patch length:

    
    <span style="color:#323232;">#!/usr/bin/env ruby
    </span><span style="color:#323232;">
    </span><span style="color:#323232;">module DayLength
    </span><span style="color:#323232;">  def length
    </span><span style="color:#323232;">    if ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"].include? self
    </span><span style="color:#323232;">      "24 hours"
    </span><span style="color:#323232;">    else
    </span><span style="color:#323232;">      super
    </span><span style="color:#323232;">    end
    </span><span style="color:#323232;">  end
    </span><span style="color:#323232;">end
    </span><span style="color:#323232;">
    </span><span style="color:#323232;">class String
    </span><span style="color:#323232;">  prepend DayLength
    </span><span style="color:#323232;">end
    </span><span style="color:#323232;">
    </span><span style="color:#323232;">day = "Monday"
    </span><span style="color:#323232;">
    </span><span style="color:#323232;">x = day.length
    </span><span style="color:#323232;">
    </span><span style="color:#323232;">print(x)
    </span>
    
    silasmariner , (edited )

    Code as given can be made valid in scala I believe. My starter was based on that assumption. I think raku can do it too, but you would probably have to x = $ to make it work…

    Edit: misread your comment slightly, CBA to change mine now. It is what it is

    kubica , in Exam Answer
    @kubica@kbin.social avatar

    The future is not yet young man.

    cows_are_underrated , in Exam Answer

    It is indeed wrong. The correct answer would be 24.

    takeda , (edited ) in Exam Answer

    For 1 hour = 4^(-1) characters

    mox , in Exam Answer

    hours = 0.25

    There. I fixed it! :)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines