I searched around the webs and found tools that can indent java,C,php,HTML etc.
Is there a tool, that can reliably indent mixed sourcecode and different languages?
-> one indent tool to rule them all?
I am looking for a standalone opensource program or even a NetBeans plugin (but there seems to be only jindent).
The indentation rules for different languages are different. If there were a "universal indenter", it would first determine in which language the text was written, and then invoke what is essentially a language-specific indentation subroutine.
There are packages for LaTeX and the like which can indent more than one language, but you tell them which language they're dealing with...
Do you have a particular task you wish to accomplish?
I ended up using NetBeans' own indention functionality ( [SHIFT]+[ctrl]+F - on MacOS ).
It works quite well, though I have to indent by hand sometimes.
For really bad structured code I use the common tools.
SourceFormat claims to be a multi-language pretty printer. But it isn't free and only runs on windows.
WebStorm and IDEA (both from Jetbrains) can reformat mixed source, but they aren't open source. (via T.J. Crowder)
Related
I'm looking for a way to have to write and maintain a certain algorithm (a graphics rendering sub-module of my code, actually) only once. I need the algorithm in C++, PHP and Javascript. Theoretically I could write it in C++ and wrap it into a PHP extension; but that has many issues of itself and doesn't solve the Javascript link.
What I'm looking for, I think, is a tool that converts from a language (doesn't matter which one) into the three (or two, if the source language is one of the three) output languages I'm targetting. I've found MetaL (http://www.meta-language.net/) which seems to do what I want but also looks dead (no updates since 2007) and only targets one of the three languages I need. It needs to be quite flexible and allow me to update the results - for example, I use Cairo in my C++ and PHP rendering, and HTML Canvas on the Javascript side. So I need to customize to the API for certain effects.
Alternatively, I'd settle for a PHP parser and lexer that would give me an AST with enough information for me to write generators for C++ and Javascript as an alternative backend.
Any ideas? Thanks.
You could take a look at Haxe. Haxe is an open source programming language. It can be compiled to JavaScript, Flash/ActionScript, PHP, C++, Java, C#, Python and Lua.
The Emscripten project (which I only spotted last week) might interest you: http://syntensity.blogspot.com/2011/04/emscripten-10.html
This guy has basically written a compiler for C/C++ that compiles to Javascript code.
That should solve the Javascript side of your problem.
Hope that helps.
Another product along the same lines, and a bit more well known is Google Web Toolkit (GWT). It's based on Java, but the end result is similar -- you write your web application in Java code and it compiles the front-end parts into Javascript and the back-end parts into regular Java bytecode. I know you're not asking for Java, but if it interest you, the link is here: http://code.google.com/webtoolkit/
Slightly less useful, but possibly more relevant to your question is PHPJS. This is a project to implement as much of the PHP language in Javascript as possible. They're doing it on a function-by-function basis, so it's only ever going to be an approximation, but given that the language syntaxes are similar, it may be possible to use it to write code that works unchanged in native PHP and also in Javascript on the client side.
Of course the one big down-side of compiling one language into another is that the resulting code is always going to be sub-optimal. There's not much you can do about that, but it's worth bearing in mind before you start down the path of writing a shared code-base in a single language.
Maybe look into 'coding' your original algorithm in xml and using various xslt templates to output to your target languages ? Or possibly antlr (http://www.antlr.org/ http://www.amazon.com/Definitive-Antlr-Reference-Domain-Specific-Programmers/dp/0978739256/ref=sr_1_1?s=books&ie=UTF8&qid=1303114884&sr=1-1).
Maybe you can just Write it in javascript and then use a C++ and PHP javascript interpreter.
A completely different approach would be to use assembly code. Write the algorithm in a language of your choice, compile it to ASM source. Then provide the interface wrappers in the deployment languages.
Of course this is all so much 'air pie'. It depends upon so many variables, number of target platforms, importance of optimization, frequency of interface change related to implementation change etc etc
I want to develop an application with c#.net(winforms) to be a parser and editor for php.
I have many experiences in .net, but I am confused.
In fact I need to write an editor in which I can implement syntax coloring,
line numbers, gutters, expandable/collapsable regions, ...
I can write it with RichTextBox, but it has many difficulties.
Is there an easier way to do it, or is there a component to do this (free and source available of course), or ...
I want to know what various ways of doing this are.
Thanks for your replies
I guess that ScintillaNET will do the trick. (Tho I've never used it my self)
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am an applications developer for a for-profit college in Virginia. At this point I could code all of what I do in notepad if I wanted to, or had to, but I prefer to use an IDE for speed and organization. As a Mac user, I've used such IDEs as NotePad++, Coda, TextMate, TextEdit, NetBeans, and of course Dreamweaver.
At work my company owns licenses for the Adobe Suite that includes Dreamweaver and I enjoy the code hinting, the grouping of related files, the built-in FTP, the code snippets and custom keyboard actions. I get flack from other developers when I mention that I use Dreamweaver.
Is there a reason why I should NOT be using it...or is it just a case similar to people who think only black and white tattoos are cool and anything else isn't?
The people who object to you using Dreamweaver probably mean the WYSIWYG part which is known to produce tag soup.
By the way, NotePad++, Coda, TextMate and TextEdit are just editors, not IDEs, because they don't integrate build automation or debugging tools out of the box.
The issue most people have with Dreamweaver is that it's a code generator, and code generators are renowned for producing poor-quality HTML. (the main issue with that - other than pride in one one's word - being that it causes cross-browser compatibility issues)
if you take away the code generation aspect, it's a straight fight between any other IDE, and other IDEs are just as good or better.
That said, I haven't used Dreamweaver in a long time so I can't really comment on its current version. Maybe the code generation has improved massively (but I doubt it). Maybe it really is a better IDE than all the rest. In the end, the choice of IDE is a personal one; if you're comfortable in Dreamweaver, then it's a good choice for you.
Any person who gives you flack for your choice of editor is not a true developer. Certain IDEs have certain benefits based on the languages/frameworks they are targeting to speed or ease development pains. If your company bought Adobe, and you like Dreamweaver and code comfortably in it... then keep doing it. Dreamweaver is an outstanding product, and if it does what you need it to do then use it.
None of these developers who give you flack are responsible for your paycheck, so screw them. Use the tool that gets it done. If someone shows you a better one, have no shame in switching. If they don't, keep on keepin' on.
If you like it then use it. It's only up to you which editor to use and to decide is it worth that money.
Obviously we could all do 99% of our coding in notepad, but we choose IDEs for their productivity boosting, code-writing abbilities.
It depends what you are developing in. If you're coding C# and .NET using Dreamweaver would be an odd choice, though you could make it work.
If you're developing client side web stuff in XHTML, JavaScript, and CSS Dreamweaver is a fine choice.
I do like Dreamweaver when I'm building front ends and I want to see what I'm building. When it comes to coding I'd pick another tool. I think NetBeans is great for PHP and I love it how it raises code problems, and HTML issues (especially in regards to accessibility, standards, doctypes). Notepad++ is a godsend! I couldn't develop without it.
One think I always hated with Dreamweaver was the auto JavaScript features (and later SPRY framework) as these appealed to non coders as they provide functionality. What they don't realise is that Dreamweaver will produced bloated, horrible scripts. I once produced a JS/CSS dynamic menu using 2 CSS classes and 11 lines of unobtrusive JS. When getting Dreamweaver to produce something similar using a wizard it produced JS code in my page and a 1200 line JS file.
When I'm writing C# I have to use Visual Studio...
Just something I wanted to get off my chest.
I personally use Eclipse [currently 3.6 Helios], but have worked once on DW and I must say that it is extremely handy when it comes to write HTML or CSS. It is not that useful when it comes to write PHP or other programming languages, but for frontend it is VERY nice.
Funny, I remember a time in pre-Adobe acquisition days when Dreamweaver was considered the serious developer's tool and tools like Front Page were for novices. I agree with others that it may be the code generation aspects that the detractors have in mind. I used them once when I was learning PHP. After seeing the generated code, once was enough. Like you I now use it for it's other features.
If it forces nothing on you (if it lets you edit HTML without adding all kinds of nonsense you're not interested in), and you like using it, I see no reason not to. Especially since you mentioned some interesting features it has that you like to use.
Those "other developers" are probably thinking in black and white, unless Dreamweaver cannot be used as simply a code editor, but I believe it can.
I wouldn't care much about what those other developers think, unless they have compelling arguments. I think you would've mentioned those, if they had any. They're probably also the kind of developer that thinks anything Microsoft or Apple or whatever makes is automatically crap.
I've used it, a few, and quite time ago.
IMHO, the worst feature of Dreamweaver was that the basic layout of almost all HTML web pages was controlled using tables.
If you wanted to write an accesible HTML page (wich was requirement for a bunch of customers) you had to fight against it, and code the divs against its natural tendence to build tables.
Experienced web developers often use plain text editors (with syntax-highlighting) because the richer tools can get in the way as much as they help. However, any tool that lets you control every last character of the code will generally keep any developer happy, and I believe Dreamweaver does allow this via its bidirectional WYSIWYG-code editing mechanism.
Anyone who knows enough about coding to complain about "tag soup" or the spaghetti Javascript Dreamweaver produces should also know how to close the "snippets" toolbox and just use the program for what it's good at.
I personally find Dreamweaver's Live Code to be an excellent tool for debugging jQuery.
I'm working with websites written in PHP, along with many other programmers, and sometimes I have to deal with really awful code.
Indentation totally messed up, curly braces in the wrong places, terrible whitespace use, it really hurts my eyes and actually makes my work harder and take longer.
Is there a tool where you can specify your coding style and then it applies it to files?
I'm sure there must be such functions in different IDEs, but I need an independent tool as I code with simple notepads like Notepad++ or the like. ( if it's such a function in Notepad++, I didn't see it )
Try PHP Code Sniffer.
That should be exactly what you are looking for(at least that's what I thought afert reading the heading, see the update).
UPDATE:
Actually what Code Sniffer does is go through your code and detect coding style violations, it does not however fix the problems.
But by telling you what's wrong it enforces you to adhere to a certain coding style. So that might be an option for you in the future.
While I have never used any, as I (luckly?) don't use anyone else code much, google found this, PHP Beautifier.
EDIT
See this question which recommends PHP Code Beautifier which is free (but requires an account creation)
Eclipse PDT also can format your code. Not sure how configurable it is. Just hit CTRL-Shift-F.
Well for a quick solution Aptana IDE does support a code format option
See the SD PHP Formatter for a tool that prettyprints source files, one at a time, or in large batches, according to your preferred style.
From what I can find Notepad++ doesn't even do basic linting (syntax checking) so it won't be able to do code sniffing: http://sourceforge.net/p/notepad-plus/discussion/482781/thread/b802c218:
Can anyone write a PHP syntax checker plugin?
...
What's wrong with PHP itself? If you run PHP as a command line utility with -l (letter L), it will run as PHP lint and check for syntax errors. e.g.
php -l broken.php
Hook it up as an external tool, perhaps through a batch file.
But you can get Code Sniffers for other text editors e.g. Sublime Text, Atom.io.
What text to HTML converter for PHP would you recommend?
One of the examples would be Markdown, which is used here at SO. User just types some text into the text-box with some natural formatting: enters at the end of line, empty line at the end of paragraph, asterisk delimited bold text, etc. And this syntax is converted to HTML tags.
The simplicity is the main feature we are looking for, there does not need to be a lot of possibilities but those basic that are there should be very intuitive (automatic URL conversion to link, emoticons, paragraphs).
A big plus would be if there is WYSIWYG editor for it. Half-wysiwig just like here at SO would be even better.
Extra points would be if it would fit with Zend Framework well.
Take your pick at http://en.wikipedia.org/wiki/Lightweight_markup_language.
As for Markdown, there's one PHP parser that I've been using called PHP Markdown, and I especially like the Extra extension.
I have actually taken a stab at extending it with my own (undocumented) features. It's available at GitHub (remember that it's the extra branch I've fixed, not the masteR), if you're interested. I've intended on making it a 'proper fork' for a while, but that's another, largely offtopic, story.
The Zend Framework has a WYSIWYG editor bundled with it's Dojo integration.
http://framework.zend.com/manual/en/zend.dojo.form.html#zend.dojo.form.elements.editor
... Bring on the extra points!
There's always textile. It is widely implemented, and has a few basic similarities with Markdown. However, I have never seen a WYSIWYG editor for Textile.
You might find upflow useful.
If you want WYSIWYG, I'm a big fan of FCKeditor. It converts user input to HTML before submitting the form, not after, but has a nice PHP library for using it, and a PHP connector for handling file uploading/browsing (along with several other languages).
If you want something that can be read as plain-text but output as HTML, I vote for Markdown.
I will stick with my original idea of adopting Texy.
None of the products mentioned here actually beats it. I had problem with Texys syntax but it seems to be quite standard and is present in other products too.
It is very lightweith, supports very natural syntax and has great "half" wysiwyg editor Texyla (wiki is in Czech only)