THESE FORUMS NOW CLOSED (read only)

  • 12 Nov 2024, 18:46
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 4   Go Down

Author Topic: A programming thread!  (Read 48879 times)

ankhtahr

  • GET ON THE NIGHT TRAIN
  • *****
  • Offline Offline
  • Posts: 2,700
  • A hacker spathe night owl
A programming thread!
« on: 13 Mar 2014, 11:43 »

So I'm surprised to see that we don't really have a programming thread. We do have one, but it's from 2006.

I've just started to read "Learn you some Erlang for great good", a Erlang-guide based on the relatively well known "Learn you a Haskell for great good". It's good!

So what obscure programming languages do you enjoy, what anecdotes do you have to tell?
Logged
Quote from: Terry Pratchett
He had the look of a lawn mower just after the grass had organised a workers' collective.

hedgie

  • Methuselah's mentor
  • *****
  • Offline Offline
  • Posts: 5,382
  • No Pasarán!
Re: A programming thread!
« Reply #1 on: 13 Mar 2014, 12:23 »

So I'm surprised to see that we don't really have a programming thread. We do have one, but it's from 2006.

I've just started to read "Learn you some Erlang for great good", a Erlang-guide based on the relatively well known "Learn you a Haskell for great good". It's good!

So what obscure programming languages do you enjoy, what anecdotes do you have to tell?
Alas, I don't seem to have much aptitude for programming aside from just enough Perl to keep my systems running properly.   Haskell certainly looks interesting, though.  I do remember taking a programming class (which I had to drop due to my aforementioned lack of skill in that area) in which another student actually took it upon himself to complete one assignment in brainfuck.  I left before I found out as to whether or not he was successful.
Logged
"The highest treason in the USA is to say Americans are not loved, no matter where they are, no matter what they are doing there." -- Vonnegut

Pilchard123

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,131
  • I always name them Bitey.
Re: A programming thread!
« Reply #2 on: 13 Mar 2014, 15:58 »

Oh no, this is going to turn into another pun war. It's going to SNOBOL out of control!
Logged
Piglet wondered how it was that every conversation with Eeyore seemed to go wrong.

cesium133

  • Preventing third impact
  • *****
  • Offline Offline
  • Posts: 6,148
  • Has a fucked-up browser history
    • Cesium Comics
Re: A programming thread!
« Reply #3 on: 13 Mar 2014, 16:08 »

I use Fortran pretty regularly, though I'm not sure if that counts as obscure. It's still used a lot in physics.

As for esoteric languages, I think I've mentioned previously on the forum that I've written a subroutine call setup in Shakespeare. I went looking on my hard disk, though, and couldn't find it.
Logged
The nerdy comic I update sometimes: Cesium Comics

Unofficial character tag thingy for QC

ChaoSera

  • Scrabble hacker
  • *****
  • Offline Offline
  • Posts: 1,405
Re: A programming thread!
« Reply #4 on: 14 Mar 2014, 03:44 »

The only language that might count as obscure and that I've used so far is mIRC Script.
At work i use almost exclusively Java, apart from the occasional bash or XSLT Script. Right now I have to debug a shitload of Tests, because it's QA Phase now. I hate QA. My own stuff that I developed for this version is already tested and functional, so now I have to spend my time gonig through all the general tests, which are partly old and use principles we have since abandoned, so I now have to partly rewrite them.
Logged

pwhodges

  • Admin emeritus
  • Awakened
  • *
  • Offline Offline
  • Posts: 17,241
  • I'll only say this once...
    • My home page
Re: A programming thread!
« Reply #5 on: 14 Mar 2014, 04:15 »

It's years since I did any real programming, though I did loads back in the day.  And my best anecdotes are already somewhere in the forum.

Starting at uni in 1967, I was writing Algol-60 and K-autocode; out of uni I had a temporary job doing image processing in assembler for the English Electric Leo Marconi KDF-9.  I also played with Algol-68.  My first proper programming job at a software house had me writing in Coral-66; then doing embedded programming with no assembler - just writing the instructions in hex (non-standard hex using B-G instead of A-F).  And even some Cobol.

In the late 1970s and early 1980s I was selling an entire OS and medical image processing suite that I had written - to the Japanese, even - that was written in a mix of Assembler (for a Varian mini), BCPL and Fortran (both compilers ported and heavily modified by me), with some microcode for efficiency (subroutine entry and exit instructions for the BCPL and Fortran; backprojection code for tomographic image reconstruction).

Then I did a lot of system programming for Norsk Data machines, both in their machine code and in their own language, Planc (this work included a comms package for use with ICL mainframes which became one of Norsk Data's products).  I also ported my BCPL and used it for some utilities that the service department used (image storage and writing for our software library, which came from head office on floppies; a binary editor, which I used to rebuild messed up file systems on corrupted floppies).

The last part of my full-time programming career was in embedded systems (though I'd done some similar work right back in the early 1970s).  These systems were all for use in pharmaceutical manufacturing.  The main control programs were written in Modula-2.  At this time I started to make heavy use of OS/2 (starting with v1.3, and going on right through to the non-IBM successor product eComStation).

For the last fifteen or so years I have been a systems administrator, so comparatively little programming, but quite a lot of hacking of existing scripts (Rexx on OS/2, Perl especially, largely for spam detection in email servers).  Also web stuff (HTML & CSS of course, with JSP, Python and PHP scripting).  Mostly Windows systems these days; but I also run an OpenBSD firewall, and have an outdated RedHat Linux support qualification.

The main thing I've not had any practical involvement with is object-oriented stuff - C++, Euclid, etc.  I know the principles, of course (in fact the seeds of it are visible in Algol-68), but my mind just doesn't go that way.
Logged
"Being human, having your health; that's what's important."  (from: Magical Shopping Arcade Abenobashi )
"As long as we're all living, and as long as we're all having fun, that should do it, right?"  (from: The Eccentric Family )

ankhtahr

  • GET ON THE NIGHT TRAIN
  • *****
  • Offline Offline
  • Posts: 2,700
  • A hacker spathe night owl
Re: A programming thread!
« Reply #6 on: 15 Mar 2014, 03:04 »

I'm not sure whether it was Fortran or Cobol, but my grandfather told me of a problem he encountered at university. One program of his caused an error. The operators told him that the error was trying to calculate the square root of a negative number. He was very sure that there couldn't be any negative numbers at that point of the program. He had to manually calculate what the program did in every step to finally find out that the problem was that there was a difference between a positive and a negative zero. The error occured because of a negative zero. Once he transformed negative zeroes to positive zeroes at that moment it worked flawlessly.
Logged
Quote from: Terry Pratchett
He had the look of a lawn mower just after the grass had organised a workers' collective.

pwhodges

  • Admin emeritus
  • Awakened
  • *
  • Offline Offline
  • Posts: 17,241
  • I'll only say this once...
    • My home page
Re: A programming thread!
« Reply #7 on: 15 Mar 2014, 03:58 »

Zero being signed was a characteristic of certain hardware, not the languages.  Specifically, machines that didn't use twos-complement but used a signed magnitude format - typically these would be machines that worked directly in decimal, to avoid issues with binary-decimal conversion.  A decent compiler would have dealt with this problem, but many compilers were (are, I guess) not decent.
Logged
"Being human, having your health; that's what's important."  (from: Magical Shopping Arcade Abenobashi )
"As long as we're all living, and as long as we're all having fun, that should do it, right?"  (from: The Eccentric Family )

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #8 on: 19 Mar 2014, 18:26 »

So I've got a compulsory exercise set in my "Modelling of Computing" course. It's about turing machines and state machines and logic circuits and computability and that sort of stuff. The book used is this one

Now, one of the problems is this:
"Design in detail a TM that (bubble-)sorts any input word "

So, sort any string consisting of a's, b's and c's alphabetically; "cba" to "abc". Pretty simple stuff.

Now, the thing is, writing Turing machines in the form of state transitions gets kinda... messy. I hit 30 transition functions and lost completely track of where I was at. So, I figured I'd do this the good old fashioned way: test driven development! Yeah!

Now, to actually test a Turing machine, I need to have an actual Turing machine implementation. So I did that. Because to solve a simple problem, first solve a harder problem. This is the mantra! So now I can write Turing machines through TDD by testing against the expected output tape state. Aw yeah. The machines I can build don't actually have explicit accepting halting states - ALL halting states are accepting. So if they're used for language recognition, they can give positive answers ("the input string is in the language") by halting, but not negative ones.

If you want to see the Java project for whatever reason, I put it up on github: https://github.com/BBuanes/TM. Not sure why, but hey!

If you'd rather just see the setup of the machine:
(click to show/hide)

TL;DR: Programming at a university miiiight just have driven me insane.
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

ankhtahr

  • GET ON THE NIGHT TRAIN
  • *****
  • Offline Offline
  • Posts: 2,700
  • A hacker spathe night owl
Re: A programming thread!
« Reply #9 on: 22 Apr 2014, 17:18 »

Ok, so during this semester I'll have to do exercise sheets both in programming and in "software technology", which is basically software engineering classes. I'll have to pass the programming one, otherwise I won't be allowed to study computer science in Germany anymore. I should pass the SWT one too, because it would slow me down a lot if I wouldn't. So yeah, I'll have to do basic and advanced sheets at the same time, with my knowledge being stuck at about the half of the basic ones…

I'm still not too comfortable with object oriented programming. I enjoyed the small bit of C and the bigger bit of AVR assembler, so I probably have a slightly different viewpoint than most of my classmates. While they look down at the programming language from an abstract algorithm, I look up at the programming language from a system architecture point of view. Object oriented programming feels counterintuitive to me.

Anyway, I probably need to pick up an IDE now. I'd prefer just using vim, but that isn't much of an option with the SWT class. I'm going to need Maven, Checkstyle and Code Coverage using JaCoCo. The recommended IDE is Eclipse, with EclEMMA and a Maven and a Checkstyle plugin, but that crashed on me a few times. I've managed to reduce the crashes to a tolerable level, but it's still annoying. I've looked at Netbeans and promptly discarded it, and I looked at IntelliJ IDEA Community Edition and liked what I saw. It lacks the code coverage tools though, those are only available in the paid version. I could probably try to usi it anyway, trying to use JaCoCo manually through Maven or something, but would that really be a good idea? Any comments?
Logged
Quote from: Terry Pratchett
He had the look of a lawn mower just after the grass had organised a workers' collective.

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #10 on: 23 Apr 2014, 00:58 »

I've been using Eclipse for so long that IntelliJ throws my keybinds of completely. Other than that, they're pretty much the same - from what I've heard from people who work, IntelliJ paid edition is a big upgrade over Eclipse, while the free version is a sidegrade with far less cool (and uncool) available plugins. Eclipse is... a memory hog for sure, it can crash (though I haven't been through that recently), but it has that brilliant marketplace for free plugins right there in the editor. IntelliJ comes with built in support for some extra languages (like Groovy, which is really fucking groovy), but in my experience, adding additional languages to Eclipse works like a charm. I had Python with autocomplete, debugging and in-editor console running in minutes.

By the way, stay the away from Eclipse classic, as it's just bullshit. It's no faster, but has a ton of less features.

If you're using Eclipse with the Maven plugin (m2e), you'll want to know that you don't have to use the bogus maven gui they include, you just have to right click and open as text file. On the other hand, whenever you want to add something from a Maven repo to your project, there's a right click menu that allows you to search and add from all of the publicly available Maven stuff. Saves you a ton of trouble. Generally, whenever there's a problem with the interface, there's a setting. I'd seriously recommend looking into changing the theme for Eclipse too - I've got colored text on a black background, and it's the best.

No matter which one of them you use, you'll definitely want to get familiar with all of the re-factoring and code helping tools available. The university here doesn't really teach them, or their value. While the value of being able to rename a class, and have the class be renamed over all of your hirearchy has obvious value, there's things I see people just not using which they should be using, so here's a selection:

- autocomplete (shift+space on both Eclipse and IntelliJ) is the best thing in the world - remember when you had to look up APIs somewhere else? Not anymore! Also you'll be writing code ten times faster.
- Autocomplete also has built-in shortcuts for some common statements. If you write "syso", and click autocomplete, it'll automatically expand to System.out.println();, with your cursor in the parenthesis. For and simplified for loops are available through "for" and "foreach" respectively, and expand with the closest array or indexable object in yr loop. It's great.
- If you have a variable a of class A, and write a. before you go autocomplete, you'll get a list of all available methods and variables you can use with a - it'll even filter out the ones you can use where you are, so private members will only be shown if you're in A.
- autoformat is also super useful. It's highly configurable, and your code will always look great. It also helps you spot dangling if's and that kind of stuff immediately.
- Jump to last/next error (compilation problem) with ctrl+, and ctrl+. in Eclipse. Added or removed something from the signature of a method? Just jump around to the problems.
- Auto-fix problem is just, wow, much help, so best. Whenever your cursor is over a warning or error, ctrl+1 (Eclipse) gives you a menu that you can select fixes from. So, say you write MyClass implements MyInterface, where MyInterface defines some methods. You'll immediately get a compilation error, as MyClass needs to implement those methods. You ctrl+, to jump to the error on MyClass, ctrl+1 to get the menu, enter to select "add unimplemented methods", and BAM, you have each of the methods filled out.
- Further Eclipse - ctrl+shift+r is "open resource", which allows you to write in the name of any file in the hierarchy to jump to it. Ctrl+o is "go to method", which is the same, but for the class you're in.
- Generate getters, setters and constructors from variables are great tools. Generally, too many getters and setters is a sign that you're not quite into the OO way of thinking, but you'll want some. The constructor tool is amazing. Three button presses (alt+s, a, enter) gives you a constructor that sets all of the privates.
- Alt+arrow up or down moves a line of text up or down. If you do it with multiple lines selected, it moves all of those lines. Did you suddenly realize that this one line needs to be outside the if block? Well, you're in luck! Want to move this entire method higher up the document? You betcha.


Basically, get to know your IDE. Spend time getting those keybinds and features into your fingers. If you at any point think "this is a thing I do all the time that it should be possible to do automatically", the
feature probably already exists, somewhere. Hell, you can sort your methods alphabetically, if you want to.

With the OO stuff - if there's one thing I know in this world, it's OO programming. I'm not a straight up guru, but I'm still pretty decent at it, and I have some experience TAing both introductory and advanced programming courses in Java. If you want help with some exercise sheets, seriously send me a PM, and we can talk over Skype or something.
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

smack that isaiah

  • Beyond Thunderdome
  • ****
  • Offline Offline
  • Posts: 564
  • Tell me again what a monster is
    • Igor and the Whale
Re: A programming thread!
« Reply #11 on: 23 Apr 2014, 02:56 »

Most IDEs that I've come across have plugins to add vim keybindings for text editing.  I use the vim plugin in Visual Studio at work and in PyCharm for my personal python projects.  I would bet Eclipse has some sort of vim plugin, if you want to keep to your normal text editing feel in whichever IDE you choose.

It's been a while since I did Java work, but I remember BlueJ being a good introductory IDE for Java, if you want to look into that one, too.
Logged
Luminous beings are we, not this crude matter

Dimmukane

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,683
  • juicer
Re: A programming thread!
« Reply #12 on: 23 Apr 2014, 07:29 »

Ending my long period of lurking to chime in and say that JetBrains has some seriously useful IDEs if you're willing to pay for them.  I use both PyCharm and Rubymine (both 199$) and they're so much more useful than what I could do with Eclipse.  If you have the scratch to get them, they're definitely worth the purchase (and they come with I think a year's worth of software updates, with the option to extend the maintenance license for another 99$ a year).
Logged
Quote from: Johnny C
all clothes reflect identity constructs, destroy these constructs by shedding your clothes and sending pictures of the process to the e-mail address linked under my avatar

ev4n

  • Scrabble hacker
  • *****
  • Offline Offline
  • Posts: 1,328
  • Shameless Shamy Shipper
Re: A programming thread!
« Reply #13 on: 23 Apr 2014, 12:26 »

I hate eclipse.  It's so big and slow.

Most people here use notepad++.  Not an IDE, but fast.
Logged

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #14 on: 23 Apr 2014, 13:45 »

It's fast at not doing anything else useful than writing text. You're shooting yourself in the foot, and slowing your progress considerably if you stick with a text editor.

Seriously, if I was hiring a Java developer, and asked them "what's your IDE of choice", and got a text editor as a reply, I'd show them the door. The amount of speed and utility you get from any IDE is just incredible when compared to plain text, and I'd know I would be getting a lot more and better work from somebody who knew how to use proper tools. Maybe I'd accepts a pretty heavily pimped Vim, but that's a stretch.

As far as I'm aware, most places you learn programming does not teach proper tool usage, and does not teach how to write good unit tests. Both of those are sorely lacking here in Norway, and from what you guys have written about your education in various places, it's not stuff that's being taught there. Those two are essential skills, and if you don't know them, you can be as good as you want at understanding and writing in your language of choice and still not be able to write good software.
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

ankhtahr

  • GET ON THE NIGHT TRAIN
  • *****
  • Offline Offline
  • Posts: 2,700
  • A hacker spathe night owl
Re: A programming thread!
« Reply #15 on: 23 Apr 2014, 15:09 »

That's one of the basic parts of this lecture. Stuff like "How to and why version control", unit tests, tools like Maven and methods like XP and the waterfall model.

Admittedly, I frickin love my text editor. For smaller things, I prefer it over a bloated IDE, but Java is completely insane without one. The stuff I have to do in "Computer Organisation / Technical computer science II) I'll probably do using vim. Mostly assembler and basic C. But trying to do all the things I need in Software Technology with it would probably end with me going insane. I'm still not sure what to use, but I guess I'll try and use Eclipse, as all the guides from the lecture are abed on it, and I don't understand enough to use of the inner workings to use a different IDE, even though IntelliJ seems more to my liking than Eclipse. Also I can't afford the Ultimate edition, and I need Code Coverage for this lecture. It's 89€+VAT with a student license for something that might be more comfortable, but takes a lot of getting used to (to learn how to transfer the Eclipse processes to IntelliJ), while I don't earn money from it, and am not even sure if I want to. I'd rather do some work in C or another lower level language. Or maybe Erlang, but who the fuck uses Erlang in a business.

But still I'm tempted by it, because IntelliJ made such a great impression on me.
Logged
Quote from: Terry Pratchett
He had the look of a lawn mower just after the grass had organised a workers' collective.

smack that isaiah

  • Beyond Thunderdome
  • ****
  • Offline Offline
  • Posts: 564
  • Tell me again what a monster is
    • Igor and the Whale
Re: A programming thread!
« Reply #16 on: 23 Apr 2014, 15:19 »

Snalin is definitely right that an IDE is a must in modern programming with larger projects.  In college I did all my C++ programming with vim, a command line, and makefiles (I only took two comp sci courses in college; my major was really busy and I couldn't fit in too many intensive extra courses.  The majority of my comp sci experience came from high school and personal projects).   I had used an IDE in high school, but that was on Windows and on my school's computers; I didn't know of any Linux IDEs and didn't bother getting any or looking into it much--I could do what I wanted with just these tools; all my projects tended to be small.

Then I got a job doing lots of computer science and started using Visual Studio.  Having an IDE is fantastic.  All the knowledge of functions, interfaces, and other libraries just at your fingertips is unimaginably helpful.  No more constantly having to Google for APIs or keep headers, tlbs, or dll exports open next to my main terminal.  I have since then investigated IDEs for Linux when I wanted to start doing Python work on my own at home, and PyCharm is truly amazing, as Dimmukane mentioned.  When I get around to sitting down and devoting more than just a few hours a week towards my personal projects I'll probably upgrade from the free version.

I do still love vim and do do text editing work in it, and I do look for vim key bindings in almost any program I use, but I wouldn't want to go back to programming in it alone.
Logged
Luminous beings are we, not this crude matter

Dimmukane

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,683
  • juicer
Re: A programming thread!
« Reply #17 on: 24 Apr 2014, 08:00 »

Or maybe Erlang, but who the fuck uses Erlang in a business.

Heh. Heheheheh.
Logged
Quote from: Johnny C
all clothes reflect identity constructs, destroy these constructs by shedding your clothes and sending pictures of the process to the e-mail address linked under my avatar

jwhouk

  • Awakened
  • *****
  • Offline Offline
  • Posts: 11,022
  • The Valley of the Sun
Re: A programming thread!
« Reply #18 on: 24 Apr 2014, 08:48 »

A funny thing: while I was trying to conjure up a new keyboard for the wife's new laptop, I found my copy of the SMART Software System Mini-Manual. 400 pages (letter-size) in a binder of information about a database system that doesn't exist anymore.

EDIT: I take that back. SmartWare still exists.
Logged
"Character is what you are in the Dark." - D.L. Moody
There is no joke that can be made online without someone being offended by it.
Life's too short to be ashamed of how you were born.
Just another Joe like 46

ev4n

  • Scrabble hacker
  • *****
  • Offline Offline
  • Posts: 1,328
  • Shameless Shamy Shipper
Re: A programming thread!
« Reply #19 on: 24 Apr 2014, 09:28 »

It's fast at not doing anything else useful than writing text. You're shooting yourself in the foot, and slowing your progress considerably if you stick with a text editor.

Seriously, if I was hiring a Java developer, and asked them "what's your IDE of choice", and got a text editor as a reply, I'd show them the door. The amount of speed and utility you get from any IDE is just incredible when compared to plain text, and I'd know I would be getting a lot more and better work from somebody who knew how to use proper tools

Good thing I'm about 10,000 miles from being a Java developer, eh?

There are plenty of embedded software environments where debugging is not available from an IDE (assuming inline debugging is even available at all), where makefiles are maintained manually, and where the speed and usability of your text editor is more important than its general purpose usefulness.

Different strokes for different folks.
Logged

Masterpiece

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,364
  • No time for Claireification
Re: A programming thread!
« Reply #20 on: 25 Apr 2014, 08:12 »

Today I'm being taught Python! And pygame, and this is the result of the first ten minutes:

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #21 on: 25 Apr 2014, 11:47 »

Quickly, make a 2048 clone in PyGame with just your own selfies.
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

Pilchard123

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,131
  • I always name them Bitey.
Re: A programming thread!
« Reply #22 on: 25 Apr 2014, 13:24 »

Dooooo eeeeeeeet!
Logged
Piglet wondered how it was that every conversation with Eeyore seemed to go wrong.

Schmee

  • Pneumatic ratchet pants
  • ***
  • Offline Offline
  • Posts: 349
  • ( ͡° ͜ʖ ͡°)
Re: A programming thread!
« Reply #23 on: 25 Apr 2014, 20:12 »

No! Only use one selfie. Make each tile a slightly more zoomed-in version of the previous tile. 2048 is just your eye, 4096 is your pupil.
Logged
work it ᕙ༼ຈل͜ຈ༽ᕗ harder 
make it (ง •̀_•́)ง better 
do it ᕦ༼ຈل͜ຈ༽ᕤ faster 
raise your ヽ༼ຈل͜ຈ༽ノ donger

Masterpiece

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,364
  • No time for Claireification
Re: A programming thread!
« Reply #24 on: 26 Apr 2014, 18:43 »

I really wanna do that now.

ankhtahr

  • GET ON THE NIGHT TRAIN
  • *****
  • Offline Offline
  • Posts: 2,700
  • A hacker spathe night owl
Re: A programming thread!
« Reply #25 on: 27 Apr 2014, 18:10 »

Yeah, this is great already. I'm working on the first exercise sheet of SWT. They've got relatively detailed instructions (which are specific to Eclipse…), but I'm stuck at one point. This subtask is:
Quote
Make sure that calling "mvn package" puts the correct main class in the resulting Java manifest. Also set the two settings of the maven-jar-plugin "addDefaultImplementationEntries" and "addDefaultSpecificationEntries" to "true". (This causes the jar which is produced by maven to be executable)

I think I've got the first part covered (even though it was never explained what a manifest is…), but I can't manage to do the second. I'm trying to do it using Eclipse, but can't figure out how. The provided pom.xml doesn't contain anything about maven-jar-plugin, and I don't know how to change the default settings (there is an entry in the tab "effective POM" for this plugin).
Logged
Quote from: Terry Pratchett
He had the look of a lawn mower just after the grass had organised a workers' collective.

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #26 on: 28 Apr 2014, 02:39 »

First of all, the manifest is a setting for the maven packaging plugin, if you hadn't googl'd your way to that yet. So in the POM, there should be something like this:

Code: [Select]
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.1</version>
        ...
        <configuration>
          <archive>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
              <addClasspath>true</addClasspath>
              <mainClass>mainPackage.MainClass</mainClass>
            </manifest>
          </archive>
        </configuration>
        ...
      </plugin>

If you don't have that, you can just cut and paste it in your POM, under the <plugins></plugins> section. If that's not there, just add it wherever under the top level (<project>). As I might have mentioned earlier, you'll want to right-click the POM and select "open with -> text editor", because the eclipse pom editor is confusing.

I'll admit that my knowledge of maven is based on trial and error in addition to some copy-pasting and intuition. But, I got it working, using the above settings, where mainclass points to the fully qualified path to your main class. Try it - cd to the root of your directory, and run mvn package. If you get "build successfull" after it's downloaded everything, go to the newly made target folder, and try to execute the jar in there.

The idea with the plugins is that they each follow their own xml schema for what keywords and stuff they use - I think. The quote you have from the subtask is full of bullshit, by the way - addDefaultImplementationEntries and addDefaultSpecificationEntries does NOT make the jar executable. What they do is that they add a bunch of extra information to the MANIFEST.MF file inside the jar, this link explains it. All you need to do to make the thing executable is to add a main class. If you haven't already, I recommend that you go dig around in the jar files maven generates, and look at all of the files in there.


If you can't get it to work, send me a PM and I can mail you an example project with a simple hello world.
« Last Edit: 28 Apr 2014, 02:49 by snalin »
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

ankhtahr

  • GET ON THE NIGHT TRAIN
  • *****
  • Offline Offline
  • Posts: 2,700
  • A hacker spathe night owl
Re: A programming thread!
« Reply #27 on: 28 Apr 2014, 13:00 »

okay, so now I've been screaming at my notebook for half an hour. Fucking Eclipse.

Running mvn package on the console works great. Running it from Eclipse, with the .launch file we're supposed to use (I have no idea what they do, or what they are for) fails, with this error. This launch file (which seems to be the only way I can somehow launch mvn package) only runs with the embedded maven, and I can't seem to convince it to run with the external maven.

I already remember, why I can't stand Eclipse. It's a complete mess. The user interface is extremely far from consistent.
Logged
Quote from: Terry Pratchett
He had the look of a lawn mower just after the grass had organised a workers' collective.

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #28 on: 28 Apr 2014, 15:34 »

Why are you running it from within Eclipse? Is that a requirement?

When I right click the POM and go "run as -> maven build" and select "package" as my goal, I get the same error as you (probably a m2e problem), but the jar packs just fine (BUILD SUCCESS, as maven puts it). I'm using the  1.4.1.something version of m2e, which is the standard you pick up from their install site, so if you just installed it, you should have the same thing.

Btw, the .launch file is apparently a launch configuration that's been packaged to a file. So it basically does the right click, run as, whatever for you. Why your uni thinks it's a good idea to give that to you instead of just having you package the thing on your own is beyond me. The problem seems to be more that your uni is trying to hold your hand and just help you do stuff, and in the process makes a huge mess of everything. "You need to deploy your project with maven" would have been a good way to give the assignment.

It's also really silly that running maven goals is done from right clicking the pom instead of say right clicking the project and selecting something from the "maven" menu.
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

Masterpiece

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,364
  • No time for Claireification
Re: A programming thread!
« Reply #29 on: 28 Apr 2014, 17:31 »

I'm teaching myself Haskell.



I could be better.

Masterpiece

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,364
  • No time for Claireification
Re: A programming thread!
« Reply #30 on: 28 Apr 2014, 17:32 »

Oh wait, I know what I did wrong!

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #31 on: 28 Apr 2014, 18:12 »

Uuuuhrghr Haskell.

Apparently it's not that bad when you learn to write it properly, but I saw one to many "couldn't match the expected type '[[Bool]]' with actual type '[[[[Bool]]]]'" in my half-semester of being taught it. I might try it again. They've got a really great book (Learn You A Haskell For Great Good), and at least it's not fucking Lisp.
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

ankhtahr

  • GET ON THE NIGHT TRAIN
  • *****
  • Offline Offline
  • Posts: 2,700
  • A hacker spathe night owl
Re: A programming thread!
« Reply #32 on: 28 Apr 2014, 21:16 »

snalin: try Erlang, to me it feels like Haskell with more real world usecases, and also I feel more comfortable with Erlang than with Haskell.

In other news, I somehow finished the tasks, and am now working on the other programming task (which is due on May 12th, but I wanted to start early).

It starts so fucking easy (It's the new iteration of the "basic programming" course of last semester for the people who didn't manage to get enough points on the exercise sheets), but it gets difficult so fast, that I almost assume they worded the exercise wrong:

Quote
Write the classes "Point", "Line", and "Triangle". A point is a two-dimensional "double" Vector, a line segment consists of two, a triangle of three points.

For the class "Point" a constructor, that creates a Point out of two "double" values. Also write constructors for the classes "Line" and "Triangle", which create a line segment or a Triangle out of two or three points respectively.

Write a method for the class "Line", which returns the point of intersection between itself and another given line segment, if it exists.

Write a constructor for "Triangle", which creates a triangle out of three line segments.

What do you need to change, if you transfer this into a three dimensional space? Which advantages do you now see in object oriented programming?

Classes: Check.
Constructors: Check.
Intersection between two line segments? Argh. The simplest solution I've found was this C++ code. Converting this to object oriented Java doesn't seem like such an easy task, if only because I need to write so much. Also I don't see how that should be easy to convert into three dimensions.
Logged
Quote from: Terry Pratchett
He had the look of a lawn mower just after the grass had organised a workers' collective.

Pilchard123

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,131
  • I always name them Bitey.
Re: A programming thread!
« Reply #33 on: 29 Apr 2014, 00:06 »

Uuuuhrghr Haskell.

Apparently it's not that bad when you learn to write it properly, but I saw one to many "couldn't match the expected type '[[Bool]]' with actual type '[[[[Bool]]]]'" in my half-semester of being taught it. I might try it again. They've got a really great book (Learn You A Haskell For Great Good), and at least it's not fucking Lisp.

A Russian spy is returning with information. "I was only able to copy the final part of the new American missile guidance  system, but I can tell you that it's written in Lisp."

"How do you know?" asks his handler.

"Well..."

Code: [Select]
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))()())))))))))))))))))))()))))))
)))))))))))))))))))))))))))))))))))))))))))))))())))))))))))))))))))))))))))))))))
)())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))()))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
Logged
Piglet wondered how it was that every conversation with Eeyore seemed to go wrong.

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #34 on: 29 Apr 2014, 04:46 »

Intersection between two line segments? Argh. The simplest solution I've found was this C++ code.

The person who wrote that needs to die in programmer hell. Seriously, don't write variable names like s, s1, s1_x. Also, you're allowed to use objects (or structs) and return objects in C++, there is no reason for not having that method read:

Code: [Select]
Point get_line_intersection(Line line1, Line line2)
instead of

Code: [Select]
char get_line_intersection(float p0_x, float p0_y, float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float *i_x, float *i_y)

EDIT6: Okay, that took a lot of tries, but the method pointed out in this article actually works. You have to check that the point of intersection is on the line, but otherwise it's golden. I really need to start doing more geometry again!


EDITEDIT: REMEMBER! Eclipse has a generate hashCode/Equals function from "source -> generate hashCode() and equals()", in addition to a bunch of other generators. You should use the equals one - Eclipse will generate a better equals method than you ever could. The correct one for the triangle class is:

Code: [Select]
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Triangle other = (Triangle) obj;
if (p1 == null) {
if (other.p1 != null)
return false;
} else if (!p1.equals(other.p1))
return false;
if (p2 == null) {
if (other.p2 != null)
return false;
} else if (!p2.equals(other.p2))
return false;
if (p3 == null) {
if (other.p3 != null)
return false;
} else if (!p3.equals(other.p3))
return false;
return true;
}

Did you remember all of your null-checks? You didn't. I wouldn't have remembered them, that's for sure. Have them generated for you!
« Last Edit: 29 Apr 2014, 06:10 by snalin »
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

Masterpiece

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,364
  • No time for Claireification
Re: A programming thread!
« Reply #35 on: 29 Apr 2014, 05:22 »

Code: [Select]
char get_line_intersection(float p0_x, float p0_y, float p1_x, float p1_y, float p2_x, float p2_y, float p3_x, float p3_y, float *i_x, float *i_y)
Return char? Whut?

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #36 on: 29 Apr 2014, 05:42 »

The person uses 0 for "they did not intersect" and 1 for "they did intersect". It's C code, basically. If whomever wrote it was actually writing C, it's fine, if they were writing C++, again, it's bullshit.

EDIT: to make it clear, C doesn't have built-in boolean values. It's low level, what-you-see-is-what-you-get, remember, so instead of wrapping 0 and 1 in a thing and calling it "boolean" or "bool", they just let you do that yourself.
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #37 on: 29 Apr 2014, 05:50 »

No, it does find the intersection point, and puts it in the variables *i_x and *i_y. Sending in primitive variables for storage is something you kinda have to do in C, and can do but really, really shouldn't in C++, C# (out keyword) and some other languages. Java does the correct thing and disallows that completely.

By the way, accepting arbitrary sized variables for output storage was how the Heartbleed bug happened, as far as I can remember.

EDIT: Oh you sneaky Masterpiece, removing your post so it looks like I'm insane, talking to shadows.
« Last Edit: 30 Apr 2014, 09:58 by snalin »
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

Masterpiece

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,364
  • No time for Claireification
Re: A programming thread!
« Reply #38 on: 01 May 2014, 12:16 »

Sorry I just realized I was speaking nonsense, my mistake.

ev4n

  • Scrabble hacker
  • *****
  • Offline Offline
  • Posts: 1,328
  • Shameless Shamy Shipper
Re: A programming thread!
« Reply #39 on: 01 May 2014, 13:13 »

My kid is asking to learn some programming again.  Really not sure where to steer them.
Logged

Pilchard123

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,131
  • I always name them Bitey.
Re: A programming thread!
« Reply #40 on: 01 May 2014, 13:35 »

I like codeacademy, though I haven't been there for a while.
Logged
Piglet wondered how it was that every conversation with Eeyore seemed to go wrong.

ankhtahr

  • GET ON THE NIGHT TRAIN
  • *****
  • Offline Offline
  • Posts: 2,700
  • A hacker spathe night owl
Re: A programming thread!
« Reply #41 on: 01 May 2014, 16:23 »

Depends. I enjoy low level stuff, but I also really enjoy abstract stuff like Erlang. But somehow I can't seem to get the hang of the stuff in between.
Logged
Quote from: Terry Pratchett
He had the look of a lawn mower just after the grass had organised a workers' collective.

snalin

  • Vulcan 3-D Chess Master
  • *****
  • Offline Offline
  • Posts: 3,540
  • You may Baste me
Re: A programming thread!
« Reply #42 on: 01 May 2014, 17:33 »

My kid is asking to learn some programming again.  Really not sure where to steer them.

codeacademy is pretty cool. If your kid is kinda young, I'd rather go with what Khan Academy has on programming, which is very visual and instant-feedback. Check it out here
Logged
I am a cowboy / on a steel horse I ride
I am wanted / Dead or alive

ankhtahr

  • GET ON THE NIGHT TRAIN
  • *****
  • Offline Offline
  • Posts: 2,700
  • A hacker spathe night owl
Re: A programming thread!
« Reply #43 on: 01 May 2014, 18:10 »

Uh, I kinda forgot to make a recommendation there. I would look into Arduino. There's loads of things that can be done with it, some projects being aimed at children, and there's something really cool about typing code, flashing it into an arduino, and seeing an LED blink because of it.
Logged
Quote from: Terry Pratchett
He had the look of a lawn mower just after the grass had organised a workers' collective.

ankhtahr

  • GET ON THE NIGHT TRAIN
  • *****
  • Offline Offline
  • Posts: 2,700
  • A hacker spathe night owl
Re: A programming thread!
« Reply #44 on: 03 May 2014, 05:09 »

I was considering putting this into the pointless thread, but it's only relevant for programmers, so I'll throw it in here:

Wat

Anyone who doesn't know this talk, watch it. It's great!
Logged
Quote from: Terry Pratchett
He had the look of a lawn mower just after the grass had organised a workers' collective.

Pilchard123

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,131
  • I always name them Bitey.
Re: A programming thread!
« Reply #45 on: 03 May 2014, 11:35 »

I'm sure I've seen that before, but I don't remember the content.
Logged
Piglet wondered how it was that every conversation with Eeyore seemed to go wrong.

hedgie

  • Methuselah's mentor
  • *****
  • Offline Offline
  • Posts: 5,382
  • No Pasarán!
Re: A programming thread!
« Reply #46 on: 04 May 2014, 09:11 »


Seriously, if I was hiring a Java developer, and asked them "what's your IDE of choice", and got a text editor as a reply, I'd show them the door. The amount of speed and utility you get from any IDE is just incredible when compared to plain text, and I'd know I would be getting a lot more and better work from somebody who knew how to use proper tools. Maybe I'd accepts a pretty heavily pimped Vim, but that's a stretch.
There's probably an emacs command for that.
Logged
"The highest treason in the USA is to say Americans are not loved, no matter where they are, no matter what they are doing there." -- Vonnegut

Masterpiece

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,364
  • No time for Claireification
Re: A programming thread!
« Reply #47 on: 05 May 2014, 04:44 »

I'm still struggling with Haskell. We're supposed to write a recursive function called "proceed", which should increment the amount of days you specified on the day you gave the function. The code I wrote so far looks like this:

Code: [Select]
data Day = Mon | Tue | Wed | Thu | Fri | Sat | Sun
deriving (Enum, Eq, Show)

next :: Day -> Day
next Sun = Mon
next d = succ d


proceed :: Day -> Int -> Day
proceed x y | y == 1     = next x
            | otherwise  = proceed x (y-1)

The problem I'm having is that no matter what Int I give the proceed function, it will still give the 'next' value of the day entered. So, what I'm expecting to happen is this:
Code: [Select]
*Main> proceed Mon 9
Wed
and what's happening is this:
Code: [Select]
*Main> proceed Mon 9
Tue

This frustrates me.

Masterpiece

  • Older than Moses
  • *****
  • Offline Offline
  • Posts: 4,364
  • No time for Claireification
Re: A programming thread!
« Reply #48 on: 05 May 2014, 05:33 »

Fixed it. It made no sense to only call 'next' once. That was my mistake.

Code: [Select]
proceed :: Day -> Int -> Day
proceed x y | y > 0 = proceed (next x) (y-1)
            | y <= 0 = x

dr. nervioso

  • Beyond Thunderdome
  • ****
  • Offline Offline
  • Posts: 555
  • No more Mr. Nice Bitch
Re: A programming thread!
« Reply #49 on: 08 May 2014, 17:30 »

The only code i have extensive experience with is Python. I really like using it to do graphic design like stuff. It's a lot more fun than Photoshop.

Also, can anyone suggest a good way to learn Java? I have to learn at least some of the language in the next month so I will know what's going on in my next CS class
Logged
Quote
this forum is slowly decomposing into butts and kitties
Pages: [1] 2 3 4   Go Up